feat : dynamic form navigation
This commit is contained in:
@@ -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),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
|
||||
@@ -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),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:device_preview/device_preview.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_app/domain/service/user/user_service.dart';
|
||||
import 'package:rasadyar_app/presentation/routes/app_pages.dart';
|
||||
@@ -12,11 +11,9 @@ void main() async {
|
||||
await setupAllProvider();
|
||||
|
||||
runApp(MyApp());
|
||||
// runApp(DevicePreview(builder: (context) => ForDevicePreview(),));
|
||||
// runApp(DevicePreview(builder: (context) => ForDevicePreview(),));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*class ForDevicePreview extends StatelessWidget {
|
||||
const ForDevicePreview({super.key});
|
||||
|
||||
@@ -51,6 +48,10 @@ class MyApp extends StatelessWidget {
|
||||
initialBinding: BindingsBuilder.put(() => UserService()),
|
||||
getPages: AppPages.pages,
|
||||
locale: Locale('fa'),
|
||||
localizationsDelegates: [
|
||||
PersianMaterialLocalizations.delegate,
|
||||
PersianCupertinoLocalizations.delegate,
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ export 'package:rasadyar_core/presentation/widget/widget.dart';
|
||||
export 'package:flutter_slidable/flutter_slidable.dart';
|
||||
export 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
export 'package:flutter_rating_bar/flutter_rating_bar.dart';
|
||||
|
||||
|
||||
export 'package:persian_datetime_picker/persian_datetime_picker.dart';
|
||||
import 'package:dartx/dartx.dart' as dartx;
|
||||
|
||||
26
packages/core/lib/presentation/utils/list_extensions.dart
Normal file
26
packages/core/lib/presentation/utils/list_extensions.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
extension ListExtensions<T> on List<T> {
|
||||
void toggle(T item) {
|
||||
if (contains(item)) {
|
||||
if (length > 1) {
|
||||
remove(item);
|
||||
}
|
||||
} else {
|
||||
add(item);
|
||||
}
|
||||
}
|
||||
|
||||
void ensureContainsAtStart(T item) {
|
||||
if (!contains(item)) {
|
||||
insert(0, item);
|
||||
}
|
||||
}
|
||||
|
||||
void removeIfPresent(T item) {
|
||||
remove(item);
|
||||
}
|
||||
|
||||
void resetWith(T item) {
|
||||
clear();
|
||||
add(item);
|
||||
}
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
export 'color_utils.dart';
|
||||
export 'list_extensions.dart';
|
||||
@@ -43,7 +43,7 @@ class _ROutlinedElevatedStateIcon extends State<ROutlinedElevatedIcon> {
|
||||
return OutlinedButton.icon(
|
||||
icon: widget.icon,
|
||||
label: Text(widget.text),
|
||||
onPressed: () {},
|
||||
onPressed: widget.onPressed,
|
||||
style: ButtonStyle(
|
||||
side: WidgetStateProperty.resolveWith<BorderSide?>((states) {
|
||||
if (states.contains(WidgetState.pressed)) {
|
||||
|
||||
@@ -1,110 +1,115 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
@immutable
|
||||
class RTextField extends StatefulWidget {
|
||||
RTextField(
|
||||
{super.key,
|
||||
this.maxLines,
|
||||
this.maxLength,
|
||||
this.hintText,
|
||||
this.padding,
|
||||
this.onChanged,
|
||||
this.onSubmitted,
|
||||
this.keyboardType,
|
||||
this.showCounter = false,
|
||||
this.isDense,
|
||||
this.initText,
|
||||
this.isForNumber = false,
|
||||
this.style,
|
||||
this.hintStyle,
|
||||
this.suffixIcon,
|
||||
this.prefixIcon,
|
||||
this.validator,
|
||||
this.readonly = false,
|
||||
this.boxConstraints,
|
||||
this.minLines,
|
||||
this.radius,
|
||||
this.filled,
|
||||
this.filledColor,
|
||||
this.enabled,
|
||||
this.errorStyle,
|
||||
this.labelStyle,
|
||||
this.label}) {
|
||||
RTextField({
|
||||
super.key,
|
||||
this.maxLines,
|
||||
this.maxLength,
|
||||
this.hintText,
|
||||
this.padding,
|
||||
this.onChanged,
|
||||
this.onSubmitted,
|
||||
this.keyboardType,
|
||||
this.showCounter = false,
|
||||
this.isDense,
|
||||
this.initText,
|
||||
this.isForNumber = false,
|
||||
this.style,
|
||||
this.hintStyle,
|
||||
this.suffixIcon,
|
||||
this.prefixIcon,
|
||||
this.validator,
|
||||
this.readonly = false,
|
||||
this.boxConstraints,
|
||||
this.minLines,
|
||||
this.radius,
|
||||
this.filled,
|
||||
this.filledColor,
|
||||
this.enabled,
|
||||
this.errorStyle,
|
||||
this.labelStyle,
|
||||
this.label,
|
||||
}) {
|
||||
filled = filled ?? false;
|
||||
obscure = false;
|
||||
_inputBorder = OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.grey.shade300),
|
||||
borderRadius: BorderRadius.circular(radius ?? 16));
|
||||
borderSide: BorderSide(color: Colors.grey.shade300),
|
||||
borderRadius: BorderRadius.circular(radius ?? 8),
|
||||
);
|
||||
}
|
||||
|
||||
RTextField.noBorder(
|
||||
{super.key,
|
||||
this.maxLines,
|
||||
this.maxLength,
|
||||
this.hintText,
|
||||
this.padding,
|
||||
this.onChanged,
|
||||
this.onSubmitted,
|
||||
this.keyboardType,
|
||||
this.showCounter = false,
|
||||
this.isDense,
|
||||
this.initText,
|
||||
this.style,
|
||||
this.hintStyle,
|
||||
this.suffixIcon,
|
||||
this.radius,
|
||||
this.validator,
|
||||
this.boxConstraints,
|
||||
this.minLines,
|
||||
this.isForNumber = false,
|
||||
this.readonly = false,
|
||||
this.label,
|
||||
this.filled,
|
||||
this.filledColor,
|
||||
this.errorStyle,
|
||||
this.labelStyle,
|
||||
this.enabled}) {
|
||||
RTextField.noBorder({
|
||||
super.key,
|
||||
this.maxLines,
|
||||
this.maxLength,
|
||||
this.hintText,
|
||||
this.padding,
|
||||
this.onChanged,
|
||||
this.onSubmitted,
|
||||
this.keyboardType,
|
||||
this.showCounter = false,
|
||||
this.isDense,
|
||||
this.initText,
|
||||
this.style,
|
||||
this.hintStyle,
|
||||
this.suffixIcon,
|
||||
this.radius,
|
||||
this.validator,
|
||||
this.boxConstraints,
|
||||
this.minLines,
|
||||
this.isForNumber = false,
|
||||
this.readonly = false,
|
||||
this.label,
|
||||
this.filled,
|
||||
this.filledColor,
|
||||
this.errorStyle,
|
||||
this.labelStyle,
|
||||
this.enabled,
|
||||
}) {
|
||||
_inputBorder = OutlineInputBorder(
|
||||
borderSide: BorderSide.none,
|
||||
borderRadius: BorderRadius.circular(radius ?? 16));
|
||||
borderSide: BorderSide.none,
|
||||
borderRadius: BorderRadius.circular(radius ?? 16),
|
||||
);
|
||||
obscure = false;
|
||||
filled = filled ?? true;
|
||||
}
|
||||
|
||||
RTextField.password(
|
||||
{super.key,
|
||||
this.maxLines = 1,
|
||||
this.maxLength,
|
||||
this.hintText,
|
||||
this.padding,
|
||||
this.onChanged,
|
||||
this.onSubmitted,
|
||||
this.keyboardType,
|
||||
this.showCounter = false,
|
||||
this.isDense,
|
||||
this.initText,
|
||||
this.style,
|
||||
this.hintStyle,
|
||||
this.suffixIcon,
|
||||
this.prefixIcon,
|
||||
this.radius,
|
||||
this.validator,
|
||||
this.boxConstraints,
|
||||
this.minLines,
|
||||
this.isForNumber = false,
|
||||
this.readonly = false,
|
||||
this.label,
|
||||
this.filled,
|
||||
this.filledColor,
|
||||
this.errorStyle,
|
||||
this.labelStyle,
|
||||
this.enabled}) {
|
||||
RTextField.password({
|
||||
super.key,
|
||||
this.maxLines = 1,
|
||||
this.maxLength,
|
||||
this.hintText,
|
||||
this.padding,
|
||||
this.onChanged,
|
||||
this.onSubmitted,
|
||||
this.keyboardType,
|
||||
this.showCounter = false,
|
||||
this.isDense,
|
||||
this.initText,
|
||||
this.style,
|
||||
this.hintStyle,
|
||||
this.suffixIcon,
|
||||
this.prefixIcon,
|
||||
this.radius,
|
||||
this.validator,
|
||||
this.boxConstraints,
|
||||
this.minLines,
|
||||
this.isForNumber = false,
|
||||
this.readonly = false,
|
||||
this.label,
|
||||
this.filled,
|
||||
this.filledColor,
|
||||
this.errorStyle,
|
||||
this.labelStyle,
|
||||
this.enabled,
|
||||
}) {
|
||||
_inputBorder = OutlineInputBorder(
|
||||
borderSide: BorderSide.none,
|
||||
borderRadius: BorderRadius.circular(radius ?? 16));
|
||||
borderSide: BorderSide.none,
|
||||
borderRadius: BorderRadius.circular(radius ?? 16),
|
||||
);
|
||||
filled = filled ?? true;
|
||||
obscure = true;
|
||||
_isPassword = true;
|
||||
@@ -170,53 +175,61 @@ class _RTextFieldState extends State<RTextField> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: widget.padding ?? const EdgeInsets.symmetric(vertical: 6.0),
|
||||
child: TextFormField(
|
||||
controller: _controller,
|
||||
readOnly: widget.readonly,
|
||||
minLines: widget.minLines,
|
||||
maxLines: widget.maxLines,
|
||||
onChanged: widget.onChanged,
|
||||
validator: widget.validator,
|
||||
enabled: widget.enabled,
|
||||
obscureText: obscure ?? false,
|
||||
onTapOutside: (event) {
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
onFieldSubmitted: widget.onSubmitted,
|
||||
maxLength: widget.maxLength,
|
||||
textDirection: TextDirection.rtl,
|
||||
style: widget.style ,
|
||||
keyboardType: widget.keyboardType,
|
||||
decoration: InputDecoration(
|
||||
errorStyle: widget.errorStyle,
|
||||
errorMaxLines: 1,
|
||||
isDense: widget.isDense,
|
||||
suffixIcon: widget.suffixIcon ??
|
||||
(widget._isPassword
|
||||
? IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
obscure = !obscure!;
|
||||
});
|
||||
},
|
||||
icon: Icon(!obscure!
|
||||
? CupertinoIcons.eye_slash
|
||||
: CupertinoIcons.eye))
|
||||
: null),
|
||||
suffixIconConstraints: widget.boxConstraints,
|
||||
prefixIcon: widget.prefixIcon,
|
||||
prefixIconConstraints: widget.boxConstraints,
|
||||
hintText: widget.hintText,
|
||||
labelText: widget.label,
|
||||
labelStyle: widget.labelStyle??AppFonts.yekan14.copyWith(color: AppColor.lightGreyDarkActive),
|
||||
filled: widget.filled,
|
||||
fillColor: widget.filledColor,
|
||||
counter: widget.showCounter ? null : const SizedBox(),
|
||||
hintStyle: widget.hintStyle,
|
||||
enabledBorder: widget._inputBorder,
|
||||
focusedBorder: widget._inputBorder,
|
||||
border: widget._inputBorder),
|
||||
));
|
||||
padding: widget.padding ?? EdgeInsets.zero,
|
||||
child: TextFormField(
|
||||
controller: _controller,
|
||||
readOnly: widget.readonly,
|
||||
minLines: widget.minLines,
|
||||
maxLines: widget.maxLines,
|
||||
onChanged: widget.onChanged,
|
||||
validator: widget.validator,
|
||||
enabled: widget.enabled,
|
||||
obscureText: obscure ?? false,
|
||||
onTapOutside: (event) {
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
onFieldSubmitted: widget.onSubmitted,
|
||||
maxLength: widget.maxLength,
|
||||
textDirection: TextDirection.rtl,
|
||||
style: widget.style,
|
||||
keyboardType: widget.keyboardType,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 16),
|
||||
errorStyle: widget.errorStyle,
|
||||
errorMaxLines: 1,
|
||||
isDense: widget.isDense,
|
||||
suffixIcon:
|
||||
widget.suffixIcon ??
|
||||
(widget._isPassword
|
||||
? IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
obscure = !obscure!;
|
||||
});
|
||||
},
|
||||
icon: Icon(
|
||||
!obscure! ? CupertinoIcons.eye_slash : CupertinoIcons.eye,
|
||||
),
|
||||
)
|
||||
: null),
|
||||
suffixIconConstraints: widget.boxConstraints,
|
||||
prefixIcon: widget.prefixIcon,
|
||||
prefixIconConstraints: widget.boxConstraints,
|
||||
hintText: widget.hintText,
|
||||
labelText: widget.label,
|
||||
alignLabelWithHint: true,
|
||||
labelStyle: AppFonts.yekan14
|
||||
.copyWith(color: AppColor.lightGreyDarkActive)
|
||||
.merge(widget.labelStyle),
|
||||
filled: widget.filled,
|
||||
fillColor: widget.filledColor,
|
||||
counter: widget.showCounter ? null : const SizedBox(),
|
||||
hintStyle: widget.hintStyle,
|
||||
enabledBorder: widget._inputBorder,
|
||||
focusedBorder: widget._inputBorder,
|
||||
border: widget._inputBorder,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user