feat : dynamic form navigation

This commit is contained in:
2025-04-26 16:50:19 +03:30
parent 6e6d2b22f6
commit c10ddaf0d5
11 changed files with 568 additions and 369 deletions

View File

@@ -26,96 +26,100 @@ class AddMobileInspectorPage extends GetView<AddMobileInspectorLogic> {
RFab.smallAdd(onPressed: () => controller.countInspector.value++),
],
),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
child: Column(
children: [
Expanded(
child: ObxValue((data) {
return ListView.separated(
itemBuilder:
(context, index) => Container(
padding: EdgeInsets.symmetric(
horizontal: 12,
vertical: 16,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
border: Border.all(width: 1, color: AppColor.bgDark),
),
child: Column(
spacing: 16,
children: [
RTextField(
label: 'نام و نام خانوادگی',
filled: true,
filledColor: AppColor.whiteLight,
padding: EdgeInsets.zero,
),
RTextField(
label: 'شماره مجوز',
filled: true,
filledColor: AppColor.whiteLight,
padding: EdgeInsets.zero,
),
RTextField(
label: 'شماره ثبت',
filled: true,
filledColor: AppColor.whiteLight,
padding: EdgeInsets.zero,
),
RTextField(
label: 'کد اقتصادی',
filled: true,
filledColor: AppColor.whiteLight,
padding: EdgeInsets.zero,
),
body: Column(
children: [
Expanded(
child: ObxValue((data) {
return ListView.separated(
padding: const EdgeInsets.fromLTRB(25, 10, 25, 0),
itemBuilder:
(context, index) =>
Container(
padding: EdgeInsets.symmetric(
horizontal: 12,
vertical: 16,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
border: Border.all(width: 0.7, color: AppColor.bgDark),
),
child: Column(
spacing: 16,
children: [
RTextField(
label: 'نام و نام خانوادگی',
filled: true,
filledColor: AppColor.whiteLight,
padding: EdgeInsets.zero,
),
RTextField(
label: 'شماره مجوز',
filled: true,
filledColor: AppColor.whiteLight,
padding: EdgeInsets.zero,
),
RTextField(
label: 'شماره ثبت',
filled: true,
filledColor: AppColor.whiteLight,
padding: EdgeInsets.zero,
),
RTextField(
label: 'کد اقتصادی',
filled: true,
filledColor: AppColor.whiteLight,
padding: EdgeInsets.zero,
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: SizedBox(
height: 40,
child: Row(
spacing: 16,
children: [
Expanded(
child: RElevated(
text: 'ثبت',
onPressed: () {},
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: SizedBox(
height: 40,
child: Row(
spacing: 16,
children: [
Expanded(
child: RElevated(
text: 'ثبت',
textStyle:AppFonts.yekan16.copyWith(color: Colors.white),
onPressed: () {},
),
Expanded(
child: ROutlinedElevated(
text: 'انصراف',
onPressed: () {},
),
),
Expanded(
child: ROutlinedElevated(
text: 'انصراف',
textStyle:AppFonts.yekan16,
onPressed: () {},
),
],
),
),
],
),
),
],
),
),
],
),
separatorBuilder: (context, index) => SizedBox(height: 15),
itemCount: data.value,
);
}, controller.countInspector),
),
),
separatorBuilder: (context, index) => SizedBox(height: 15),
itemCount: data.value,
);
}, controller.countInspector),
),
RElevated(
Padding(
padding: const EdgeInsets.fromLTRB(20, 4, 20, 20),
child: RElevated(
text: 'مرحله بعد',
onPressed: () {
Get.toNamed(InspectionRoutes.inspectionRegistrationOfViolation);
},
height: 50,
isFullWidth: true,
height: 40,
backgroundColor: AppColor.greenNormal,
textStyle: AppFonts.yekan16.copyWith(color: Colors.white),
),
SizedBox(height: 25),
],
),
),
],
),
);
}

View File

@@ -1,11 +1,19 @@
import 'package:flutter/material.dart';
import 'package:inspection/presentation/routes/app_routes.dart';
import 'package:rasadyar_core/core.dart';
class AddSupervisionLogic extends GetxController {
RxInt selectedSegment = 0.obs;
RxInt violationSegmentsSelected = 0.obs;
RxInt selectedTypeOfOwnership = 0.obs;
RxInt selectedUnitType = 0.obs;
RxInt selectedAccompanyingInspectors = 0.obs;
RxList<int> selectedAccompanyingInspectors = RxList<int>([0]);
Map<String,List<String>> tmpData = {
'نوع مالکیت': ['دولتی', 'غیر دولتی', 'استیجاری', 'شخصی', 'سایر'],
'نوع واحد': ['دولتی', 'غیر دولتی', 'استیجاری', 'شخصی', 'سایر'],
'بازرسان همراه': ['ندارد','دولتی', 'غیر دولتی', 'استیجاری', 'شخصی', 'سایر'],
};
List<String> tmpLs = ['دولتی', 'غیر دولتی', 'استیجاری', 'شخصی', 'سایر'];
@@ -23,10 +31,34 @@ class AddSupervisionLogic extends GetxController {
),
};
// The data for the segments
final Map<int, Widget> violationSegments = {
0: Container(
padding: EdgeInsets.all(10),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(50)),
child: Text('دارد', style: AppFonts.yekan13),
),
1: Container(
padding: EdgeInsets.all(10),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(50)),
child: Text('ندارد', style: AppFonts.yekan13),
),
};
List<String> routes = [
InspectionRoutes.inspectionRegistrationOfViolation,
InspectionRoutes.inspectionDisplayInformation
];
@override
void onReady() {
// TODO: implement onReady
super.onReady();
}
@override

View File

@@ -1,9 +1,6 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_core/presentation/widget/buttons/elevated.dart';
import 'package:rasadyar_core/presentation/widget/inputs/r_input.dart';
import 'package:rasadyar_core/presentation/widget/tabs/new_tab.dart';
import 'package:inspection/inspection.dart';
import 'package:rasadyar_core/core.dart';
import 'logic.dart';
@@ -23,111 +20,221 @@ class AddSupervisionPage extends GetView<AddSupervisionLogic> {
height: 16,
),
),
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 16,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 12,
children: [
Text(
'نوع پروانه کسب',
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(
color: AppColor.blueNormal,
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 10,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'نوع پروانه کسب',
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(
color: AppColor.blueNormal,
),
),
SizedBox(height: 16),
ObxValue((data) {
return NewCupertinoSegmentedControl<int>(
padding: EdgeInsets.zero,
children: controller.segments,
groupValue: data.value,
selectedColor: AppColor.blueNormal,
unselectedColor: Colors.white,
borderColor: Colors.grey.shade300,
onValueChanged: (int value) {
data.value = value;
},
);
}, controller.selectedSegment),
SizedBox(height: 16),
Text(
'تخلف',
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(
color: AppColor.blueNormal,
),
),
SizedBox(height: 16),
ObxValue((data) {
return NewCupertinoSegmentedControl<int>(
padding: EdgeInsets.zero,
children: controller.violationSegments,
groupValue: data.value,
selectedColor: AppColor.blueNormal,
unselectedColor: Colors.white,
borderColor: Colors.grey.shade300,
onValueChanged: (int value) {
if(value == 0) {
controller.routes.ensureContainsAtStart(InspectionRoutes.inspectionRegistrationOfViolation);
} else {
controller.routes.remove(InspectionRoutes.inspectionRegistrationOfViolation);
}
data.value = value;
},
);
}, controller.violationSegmentsSelected),
SizedBox(height: 8),
RTextField(label: 'صادر کننده پروانه'),
SizedBox(height: 8),
RTextField(label: 'شماره مجوز'),
SizedBox(height: 8),
RTextField(label: 'شماره ثبت'),
SizedBox(height: 8),
RTextField(label: 'کد اقتصادی'),
],
),
),
SizedBox(height: 10),
optionWidget(
selected: controller.selectedTypeOfOwnership,
options: controller.tmpData.entries.elementAt(0),
onSelected:
(index) =>
controller.selectedTypeOfOwnership.value = index,
),
SizedBox(height: 18),
optionWidget(
selected: controller.selectedUnitType,
options: controller.tmpData.entries.elementAt(1),
onSelected:
(index) => controller.selectedUnitType.value = index,
),
SizedBox(height: 18),
optionWidget(
selectedList: controller.selectedAccompanyingInspectors,
options: controller.tmpData.entries.elementAt(2),
onSelected: (data) {
final selected = controller.selectedAccompanyingInspectors;
final route = InspectionRoutes.inspectionAddMobileInspector;
ObxValue((data) {
return NewCupertinoSegmentedControl<int>(
padding: EdgeInsets.zero,
children: controller.segments,
groupValue: data.value,
selectedColor: AppColor.blueNormal,
unselectedColor: Colors.white,
borderColor: Colors.grey.shade300,
onValueChanged: (int value) {
data.value = value;
},
);
}, controller.selectedSegment),
if (data == 0) {
selected.resetWith(0);
controller.routes.remove(route);
return;
}
RTextField(label: 'صادر کننده پروانه'),
RTextField(label: 'شماره مجوز'),
RTextField(label: 'شماره ثبت'),
RTextField(label: 'کد اقتصادی'),
controller.routes.ensureContainsAtStart(route);
selected.removeIfPresent(0);
selected.toggle(data);
},
),
],
),
),
optionWidget(controller.selectedTypeOfOwnership),
optionWidget(controller.selectedAccompanyingInspectors),
optionWidget(controller.selectedUnitType),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: RElevated(
text: 'مرحله بعد',
onPressed: () {
Get.toNamed(InspectionRoutes.inspectionAddMobileInspector);
},
height: 40,
isFullWidth: true,
backgroundColor: AppColor.greenNormal,
textStyle: AppFonts.yekan16.copyWith(color: Colors.white),
),
Padding(
padding: const EdgeInsets.fromLTRB(20, 0, 20, 20),
child: RElevated(
text: 'مرحله بعد',
onPressed: () {
Get.toNamed(controller.routes.first);
},
height: 50,
isFullWidth: true,
backgroundColor: AppColor.greenNormal,
textStyle: AppFonts.yekan16.copyWith(color: Colors.white),
),
],
),
),
],
),
);
}
Column optionWidget(RxInt selected) {
Column optionWidget({
RxInt? selected,
RxList<int>? selectedList,
required MapEntry<String, List<String>> options,
required void Function(int index) onSelected,
}) {
assert(
(selected != null) != (selectedList != null),
'Exactly one of selected or selectedList must be provided',
);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Text(
'نوع پروانه کسب',
options.key,
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
),
),
SizedBox(
height: 75,
height: 50,
child: ListView.separated(
shrinkWrap: true,
padding: EdgeInsets.all(20),
padding: EdgeInsets.symmetric(horizontal: 20),
scrollDirection: Axis.horizontal,
itemBuilder:
(context, index) => ObxValue((data) {
return ChoiceChip(
onSelected: (value) {
selected.value = index;
},
selectedColor: AppColor.blueNormal,
labelStyle:
data.value == index
? AppFonts.yekan13.copyWith(
color: AppColor.whiteLight,
)
: AppFonts.yekan12.copyWith(
color: AppColor.darkGreyNormalActive,
),
checkmarkColor: Colors.white,
label: Text(controller.tmpLs[index]),
selected: index == data.value,
);
}, selected),
(context, index) =>
selected != null
? ObxValue((data) {
return ChoiceChip(
onSelected: (_) => onSelected(index),
color: WidgetStateProperty.resolveWith<Color?>((data,) {
if (selected.value == index) {
return AppColor.blueNormal;
} else {
return Colors.white;
}
}),
labelStyle:
data.value == index
? AppFonts.yekan13.copyWith(
color: AppColor.whiteLight,
)
: AppFonts.yekan12.copyWith(
color: AppColor.darkGreyNormalActive,
),
checkmarkColor: Colors.white,
label: Text(options.value[index]),
selected: index == data.value,
);
}, selected)
: ObxValue((data) {
return ChoiceChip(
onSelected: (value) => onSelected.call(index),
color: WidgetStateProperty.resolveWith<Color?>((states,) {
if (data.contains(index)) {
return AppColor.blueNormal;
} else {
return Colors.white;
}
}),
labelStyle:
data.contains(index)
? AppFonts.yekan13.copyWith(
color: AppColor.whiteLight,
)
: AppFonts.yekan12.copyWith(
color: AppColor.darkGreyNormalActive,
),
checkmarkColor: Colors.white,
label: Text(options.value[index]),
selected: data.contains(index),
);
}, selectedList!),
separatorBuilder: (context, index) => SizedBox(width: 8),
itemCount: controller.tmpLs.length,
itemCount: options.value.length,
),
),
],

View File

@@ -80,7 +80,18 @@ class LocationDetailsPage extends GetView<LocationDetailsLogic> {
Expanded(
child: ROutlinedElevatedIcon(
icon: FaIcon(FontAwesomeIcons.calendar),
onPressed: () {},
onPressed: () async {
Jalali? picked = await showPersianDatePicker(
context: context,
initialDate: Jalali.now(),
firstDate: Jalali(1385, 8),
lastDate: Jalali(1450, 9),
initialEntryMode:
PersianDatePickerEntryMode.calendarOnly,
initialDatePickerMode: PersianDatePickerMode.day,
);
var label = picked?.formatFullDate();
},
text: 'تا تاریخ',
textStyle: AppFonts.yekan16.copyWith(
color: AppColor.blueNormal,
@@ -140,7 +151,7 @@ class LocationDetailsPage extends GetView<LocationDetailsLogic> {
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 22,
vertical: 25,
vertical: 21,
),
child: Column(
spacing: 6,
@@ -154,7 +165,7 @@ class LocationDetailsPage extends GetView<LocationDetailsLogic> {
),
SizedBox(height: 2),
Text(
'1043/12/12',
'1403/12/12',
textAlign: TextAlign.center,
style: AppFonts.yekan12,
),

View File

@@ -1,10 +1,8 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_core/presentation/widget/buttons/elevated.dart';
import 'package:rasadyar_core/presentation/widget/buttons/fab.dart';
import 'package:rasadyar_core/presentation/widget/inputs/r_input.dart';
import 'package:inspection/presentation/registration_of_violation/logic.dart';
import 'package:inspection/presentation/routes/app_routes.dart';
import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_core/presentation/widget/buttons/fab.dart';
class RegistrationOfViolationPage
extends GetView<RegistrationOfViolationLogic> {
@@ -13,7 +11,7 @@ class RegistrationOfViolationPage
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor:AppColor.bgLight,
backgroundColor: AppColor.bgLight,
appBar: RAppBar(
title: 'ثبت تخلف',
leading: vecWidget(
@@ -27,77 +25,83 @@ backgroundColor:AppColor.bgLight,
],
),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20,vertical: 10),
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
child: Column(
children: [
Expanded(
child: ObxValue((data) {
return ListView.separated(
itemBuilder: (context, index) =>Container(
padding:EdgeInsets.symmetric(horizontal: 8,vertical: 12),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
border: Border.all(width: 1,color: AppColor.bgDark),
),
child: Column(
spacing:16 ,
children: [
RTextField(
label: 'عنوان تخلف',
filled: true,
filledColor: AppColor.whiteLight,
itemBuilder:
(context, index) => Container(
padding: EdgeInsets.symmetric(
horizontal: 8,
vertical: 12,
),
RTextField(
label: 'توضیحات تخلف',
filled: true,
filledColor: AppColor.whiteLight,
maxLines: 5,
minLines: 5,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
border: Border.all(width: 0.75, color: AppColor.bgDark),
),
RTextField(
label: 'عنوان تخلف',
filled: true,
filledColor: AppColor.whiteLight,
child: Column(
spacing: 16,
children: [
RTextField(
label: 'عنوان تخلف',
filled: true,
filledColor: AppColor.whiteLight,
),
RTextField(
label: 'توضیحات تخلف',
filled: true,
filledColor: AppColor.whiteLight,
maxLines: 3,
minLines: 3,
),
RTextField(
label: 'عنوان تخلف',
filled: true,
filledColor: AppColor.whiteLight,
),
RTextField(
label: 'عنوان تخلف',
filled: true,
filledColor: AppColor.whiteLight,
),
RTextField(
label: 'توضیحات تخلف',
filled: true,
filledColor: AppColor.whiteLight,
maxLines: 3,
minLines: 3,
),
SizedBox(
height: 40,
child: Row(
spacing: 16,
children: [
Expanded(
child: RElevated(
text: 'ثبت',
onPressed: () {},
),
),
Expanded(
child: ROutlinedElevated(
text: 'انصراف',
onPressed: () {},
),
),
],
),
),
],
),
RTextField(
label: 'عنوان تخلف',
filled: true,
filledColor: AppColor.whiteLight,
),
RTextField(
label: 'توضیحات تخلف',
filled: true,
filledColor: AppColor.whiteLight,
maxLines: 5,
minLines: 5,
),
SizedBox(
height: 40,
child: Row(
spacing: 16,
children: [
Expanded(child: RElevated(text: 'ثبت', onPressed: (){})),
Expanded(child:ROutlinedElevated(text: 'انصراف',onPressed: (){},) ),
],
),
)
],
),
) ,
separatorBuilder: (context, index) => SizedBox(height: 15,),
),
separatorBuilder: (context, index) => SizedBox(height: 15),
itemCount: data.value,
);
},controller.countViolation),
}, controller.countViolation),
),
RElevated(
@@ -110,7 +114,7 @@ backgroundColor:AppColor.bgLight,
backgroundColor: AppColor.greenNormal,
textStyle: AppFonts.yekan16.copyWith(color: Colors.white),
),
SizedBox(height: 25,)
SizedBox(height: 25),
],
),
),