action
 profile
This commit is contained in:
2025-04-21 15:45:15 +03:30
parent d4ebefedba
commit 0c750e1c01
36 changed files with 1082 additions and 207 deletions

View File

@@ -1,10 +1,12 @@
import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_core/data/utils.dart';
class ActionLogic extends GetxController with GetTickerProviderStateMixin {
late Rx<SlidableController> slidController;
bool showSlideHint = true;
RxBool isExpanded = false.obs;
RxInt selectedIndex = 0.obs;
RxInt previousIndex = 0.obs;
List<String> headersTitle = [
'کاربران',
@@ -20,10 +22,31 @@ class ActionLogic extends GetxController with GetTickerProviderStateMixin {
Assets.vecLogoutSvg,
];
RxList<bool> supervisionHistoryList = [false, false, false, false].obs;
List<String> tmpLs = ['دولتی', 'غیر دولتی', 'استیجاری', 'شخصی', 'سایر'];
List<String> hamadanCities = [
'همدان',
'ملایر',
'نهاوند',
'تویسرکان',
'اسدآباد',
'بهار',
'رزن',
'کبودرآهنگ',
'فامنین',
'لالجین',
];
RxInt filter1Index = 0.obs;
RxInt filter2Index = 0.obs;
@override
void onInit() {
super.onInit();
slidController = SlidableController(this).obs;
}
@override
@@ -38,7 +61,6 @@ class ActionLogic extends GetxController with GetTickerProviderStateMixin {
super.onClose();
}
Future<void> triggerSlidableAnimation() async {
await Future.delayed(Duration(milliseconds: 200));
await slidController.value.openEndActionPane();
@@ -47,4 +69,12 @@ class ActionLogic extends GetxController with GetTickerProviderStateMixin {
showSlideHint = !showSlideHint;
}
void updateSelectedIndex(int index) {
if(index == selectedIndex.value) {
return;
}
previousIndex.value = selectedIndex.value;
selectedIndex.value = index;
}
}

View File

@@ -1,5 +1,9 @@
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';
@@ -22,7 +26,8 @@ class ActionPage extends GetView<ActionLogic> {
icon: controller.headersIcons[index],
title: controller.headersTitle[index],
onTap: () {
controller.selectedIndex.value = index;
controller.updateSelectedIndex(index);
},
isSelected: controller.selectedIndex.value == index,
);
@@ -30,16 +35,63 @@ class ActionPage extends GetView<ActionLogic> {
);
}, controller.selectedIndex),
Expanded(
child: ObxValue(
(index) => switch (index.value) {
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 => slidableWidgetTwo(),
2 => slidableWidgetOne(),
3 => slidableWidgetOne(),
int() => Placeholder(),
},
controller.selectedIndex,
),
1 => supervisionHistoryWidget(),
2 => statisticsWidget(),
int() => Container(),
};
}, controller.selectedIndex),
),
],
),
@@ -47,6 +99,112 @@ class ActionPage extends GetView<ActionLogic> {
);
}
Container statisticsWidget() => Container(
margin: EdgeInsets.only(top: 50),
padding: EdgeInsets.symmetric(horizontal: 35, 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.only(top: 10, left: 22, right: 22),
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),
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: 25,
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: [
@@ -195,138 +353,363 @@ class ActionPage extends GetView<ActionLogic> {
);
}
Widget slidableWidgetTwo() {
return ObxValue((data) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 20),
child: GestureDetector(
onTap: (){
controller.isExpanded.value = !controller.isExpanded.value;
},
child: AnimatedContainer(
duration: Duration(milliseconds: 2000),
height: data.value ? 370 : 62,
child:
data.value
? Container(color: Colors.yellow,height: 80,width: 180,)
: Slidable(
key: Key('selectedLocationWidget'),
controller: controller.slidController.value,
endActionPane: ActionPane(
motion: StretchMotion(),
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: [
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,
Text(
'داود خرم مهری پور',
style: AppFonts.yekan10.copyWith(
color: AppColor.blueNormal,
),
),
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,
Text(
'03295224154',
style: AppFonts.yekan12.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
],
),
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,
Column(
spacing: 4,
children: [
Text(
'افزودن کاربر',
style: AppFonts.yekan10.copyWith(
color: AppColor.blueNormal,
),
),
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,
),
),
],
),
],
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,
),
),
],
),
],
),
),
);
}, controller.isExpanded);
),
);
}
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: [
Text(
title,
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
),
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),
],
),
);
}
}