Files
rasadyar_application/features/inspection/lib/presentation/action/view.dart

724 lines
23 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_core/presentation/widget/buttons/elevated.dart';
import 'logic.dart';
class ActionPage extends GetView<ActionLogic> {
const ActionPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColor.bgLight,
body: SafeArea(
child: Column(
children: [
SizedBox(height: 20),
ObxValue((data) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: List.generate(4, (index) {
return headerWidget(
icon: controller.headersIcons[index],
title: controller.headersTitle[index],
onTap: () {
controller.updateSelectedIndex(index);
},
isSelected: controller.selectedIndex.value == index,
);
}),
);
}, controller.selectedIndex),
Expanded(
child: ObxValue((index) {
if (index.value == 3) {
WidgetsBinding.instance.addPostFrameCallback((_) {
showCupertinoDialog(
context: context,
barrierDismissible: true,
builder: (context) {
return CupertinoAlertDialog(
title: Text(
'از سامانه خارج می شوید؟',
style: AppFonts.yekan18.copyWith(
color: AppColor.lightGreyDarkActive,
),
),
actions: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
spacing: 16,
children: [
Expanded(
child: RElevated(
text: 'بله',
onPressed: () {
exit(0);
},
),
),
Expanded(
child: ROutlinedElevated(
text: 'خیر',
onPressed: () {
controller.updateSelectedIndex(
controller.previousIndex.value,
);
Get.back();
},
),
),
],
),
),
],
);
},
);
});
}
return switch (index.value) {
0 => profileWidget(),
1 => supervisionHistoryWidget(),
2 => statisticsWidget(),
int() => Container(),
};
}, controller.selectedIndex),
),
],
),
),
);
}
Container statisticsWidget() => Container(
margin: EdgeInsets.only(top: 50),
padding: EdgeInsets.symmetric(vertical: 50),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30),
),
),
child: Column(
children: [
Container(
height: 32,
margin: EdgeInsets.symmetric(horizontal: 22,vertical: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
spacing: 10,
children: [
Expanded(
child: ROutlinedElevatedIcon(
icon: FaIcon(FontAwesomeIcons.calendar),
onPressed: () {},
text: 'از تاریخ',
textStyle: AppFonts.yekan16.copyWith(
color: AppColor.blueNormal,
),
),
),
Expanded(
child: ROutlinedElevatedIcon(
icon: FaIcon(FontAwesomeIcons.calendar),
onPressed: () {},
text: 'تا تاریخ',
textStyle: AppFonts.yekan16.copyWith(
color: AppColor.blueNormal,
),
),
),
],
),
),
optionWidget(
selected: controller.filter1Index,
title: 'فیلترتراکنش ها',
options: controller.tmpLs,
),
optionWidget(
selected: controller.filter2Index,
title: 'فیلتر شهرستان',
options: controller.hamadanCities,
),
SizedBox(height: 10),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
vecWidgetWithOnTap(
assets: Assets.vecPdfDownloadSvg,
onTap: () {},
width: 64,
height: 64,
),
vecWidgetWithOnTap(
assets: Assets.vecExcelDownloadSvg,
onTap: () {},
width: 64,
height: 64,
),
],
),
),
SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 20,
children: [
headerInfo(title: 'تعداد تراکنش ها', description: '183 '),
headerInfo(
title: 'جمع تراکنش ها',
description: '183 ریال',
background: AppColor.green1Light,
),
],
),
],
),
);
Widget supervisionHistoryWidget() {
return ObxValue((data) {
return ListView.builder(
itemBuilder: (context, index) {
return historyItem(data[index], () {
data[index] = !data[index];
});
},
shrinkWrap: true,
physics: BouncingScrollPhysics(),
itemCount: data.length,
);
}, controller.supervisionHistoryList);
}
Column profileWidget() {
return Column(
children: [
slidableWidgetOne(),
slidableWidgetOne(),
slidableWidgetOne(),
slidableWidgetOne(),
slidableWidgetOne(),
],
);
}
Widget headerWidget({
required String icon,
required String title,
required VoidCallback onTap,
bool isSelected = false,
}) {
return GestureDetector(
onTap: onTap,
child: Column(
spacing: 8,
children: [
Container(
width: 48,
height: 48,
padding: EdgeInsets.all(8),
decoration: ShapeDecoration(
color: isSelected ? AppColor.blueLightActive : AppColor.blueLight,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: vecWidget(
icon,
width: 40,
height: 40,
color: AppColor.blueNormal,
),
),
Text(
title,
style: AppFonts.yekan12.copyWith(
color:
isSelected ? AppColor.blueNormalActive : AppColor.blueNormal,
),
),
],
),
);
}
Widget slidableWidgetOne() {
if (controller.showSlideHint) {
controller.triggerSlidableAnimation();
}
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 20),
child: Slidable(
key: Key('selectedLocationWidget'),
controller: controller.slidController.value,
endActionPane: ActionPane(
motion: StretchMotion(),
children: [
CustomSlidableAction(
onPressed: (context) {},
backgroundColor: AppColor.redNormal,
foregroundColor: Colors.white,
padding: EdgeInsets.all(16),
borderRadius: BorderRadius.circular(8),
autoClose: true,
child: vecWidget(Assets.vecTrashSvg, width: 24, height: 24),
),
],
),
child: GestureDetector(
onTap: () {},
child: Container(
height: 62,
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 15),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(width: 1, color: AppColor.blackLightHover),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
spacing: 4,
children: [
Text(
'داود خرم مهری پور',
style: AppFonts.yekan10.copyWith(
color: AppColor.blueNormal,
),
),
Text(
'03295224154',
style: AppFonts.yekan12.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
],
),
Column(
spacing: 4,
children: [
Text(
'افزودن کاربر',
style: AppFonts.yekan10.copyWith(
color: AppColor.blueNormal,
),
),
Text(
'ثبت بازرسی',
style: AppFonts.yekan12.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
],
),
Column(
spacing: 4,
children: [
Text(
'همدان',
style: AppFonts.yekan10.copyWith(
color: AppColor.blueNormal,
),
),
Text(
'همدان',
style: AppFonts.yekan12.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
],
),
],
),
),
),
),
);
}
Widget slidableWidgetTwo({required VoidCallback onTap}) {
return Slidable(
key: Key('selectedLocationWidget'),
controller: controller.slidController.value,
endActionPane: ActionPane(
motion: StretchMotion(),
children: [
CustomSlidableAction(
onPressed: (context) {},
backgroundColor: AppColor.blueNormal,
foregroundColor: Colors.white,
padding: EdgeInsets.all(16),
borderRadius: BorderRadius.only(
topRight: Radius.circular(8),
bottomRight: Radius.circular(8),
),
autoClose: true,
child: vecWidget(Assets.vecEditSvg, width: 24, height: 24),
),
CustomSlidableAction(
onPressed: (context) {},
backgroundColor: AppColor.redNormal,
foregroundColor: Colors.white,
padding: EdgeInsets.all(16),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
bottomLeft: Radius.circular(8),
),
autoClose: true,
child: vecWidget(Assets.vecTrashSvg, width: 24, height: 24),
),
],
),
child: GestureDetector(
onTap: onTap,
child: Container(
height: 62,
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 15),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(width: 1, color: AppColor.blackLightHover),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
spacing: 4,
children: [
Text(
'داود خرم مهری پور',
style: AppFonts.yekan10.copyWith(
color: AppColor.blueNormal,
),
),
Text(
'03295224154',
style: AppFonts.yekan12.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
],
),
Column(
spacing: 4,
children: [
Text(
'افزودن کاربر',
style: AppFonts.yekan10.copyWith(
color: AppColor.blueNormal,
),
),
Text(
'ثبت بازرسی',
style: AppFonts.yekan12.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
],
),
Column(
spacing: 4,
children: [
Text(
'همدان',
style: AppFonts.yekan10.copyWith(
color: AppColor.blueNormal,
),
),
Text(
'همدان',
style: AppFonts.yekan12.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
],
),
],
),
),
),
);
}
Widget historyItem(bool isExpanded, VoidCallback onTap) {
return AnimatedContainer(
margin: EdgeInsets.symmetric(horizontal: 30, vertical: 10),
curve: Curves.easeInOut,
duration: Duration(seconds: 1),
height: isExpanded ? 364 : 62,
child:
isExpanded
? markerDetailsWidget(ontap: onTap)
: slidableWidgetTwo(onTap: onTap),
);
}
Widget markerDetailsWidget({required VoidCallback ontap}) {
return GestureDetector(
onTap: ontap,
behavior: HitTestBehavior.opaque,
child: Container(
clipBehavior: Clip.antiAlias,
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
decoration: ShapeDecoration(
color: Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
),
child: Column(
spacing: 15,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
spacing: 12,
children: [
vecWidgetWithOnTap(
assets: Assets.vecEditSvg,
onTap: () {},
width: 24,
height: 24,
color: AppColor.blueNormal,
),
Text(
'سوابق بازرسی من',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
vecWidgetWithOnTap(
assets: Assets.vecTrashSvg,
width: 24,
height: 24,
color: AppColor.redNormal,
onTap: () {},
),
],
),
Container(
height: 32,
clipBehavior: Clip.antiAlias,
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 4),
decoration: ShapeDecoration(
color: AppColor.blueLight,
shape: RoundedRectangleBorder(
side: BorderSide(width: 1, color: AppColor.blueLightHover),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'تاریخ بازرسی',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
Text(
'1403/12/12',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
],
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'شماره همراه',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
Text(
'0326598653',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'آخرین فعالیت',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
Text(
'1409/12/12',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'موجودی',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
Text(
'5کیلوگرم',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
],
),
...List.generate(
5,
(index) => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'فروش رفته',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
Text(
'0 کیلوگرم',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
],
),
),
],
),
),
);
}
Column optionWidget({
required RxInt selected,
required String title,
required List<String> options,
}) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 22,vertical: 10),
child: Text(
title,
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 30),
child: Wrap(
runSpacing: 8,
spacing: 8,
children:
options
.map(
(e) => ObxValue((data) {
return ChoiceChip(
onSelected: (value) {
selected.value = options.indexOf(e);
},
selectedColor: AppColor.blueNormal,
labelStyle:
data.value == options.indexOf(e)
? AppFonts.yekan13.copyWith(
color: AppColor.whiteLight,
)
: AppFonts.yekan12.copyWith(
color: AppColor.darkGreyNormalActive,
),
checkmarkColor: Colors.white,
label: Text(e),
selected: options.indexOf(e) == data.value,
);
}, selected),
)
.toList(),
),
),
],
);
}
Container headerInfo({
required String title,
required String description,
Color? background,
}) {
return Container(
clipBehavior: Clip.antiAlias,
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: ShapeDecoration(
color: background ?? AppColor.blueLight,
shape: RoundedRectangleBorder(
side: BorderSide(width: 1, color: AppColor.blackLightHover),
borderRadius: BorderRadius.circular(8),
),
),
alignment: AlignmentDirectional.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
spacing: 10,
children: [
Text(title, style: AppFonts.yekan10),
Text(description, style: AppFonts.yekan12),
],
),
);
}
}