feat : init statics

This commit is contained in:
2025-07-26 15:47:22 +03:30
parent ad456d5855
commit bafa24543d
54 changed files with 1853 additions and 1421 deletions

View File

@@ -0,0 +1,69 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_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;
RxList<int> selectedAccompanyingInspectors = RxList<int>([0]);
Map<String,List<String>> tmpData = {
'نوع مالکیت': ['دولتی', 'غیر دولتی', 'استیجاری', 'شخصی', 'سایر'],
'نوع واحد': ['دولتی', 'غیر دولتی', 'استیجاری', 'شخصی', 'سایر'],
'بازرسان همراه': ['ندارد','دولتی', 'غیر دولتی', 'استیجاری', 'شخصی', 'سایر'],
};
List<String> tmpLs = ['دولتی', 'غیر دولتی', 'استیجاری', 'شخصی', 'سایر'];
// The data for the segments
final Map<int, Widget> segments = {
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),
),
};
// 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() {
super.onReady();
}
@override
void onClose() {
// TODO: implement onClose
super.onClose();
}
}

View File

@@ -0,0 +1,249 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_inspection/presentation/routes/app_routes.dart';
import 'logic.dart';
class AddSupervisionPage extends GetView<AddSupervisionLogic> {
const AddSupervisionPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColor.lightGreyLight,
appBar: RAppBar(
title: 'ایجاد بازرسی',
leading: Assets.vec.messageAddSvg.svg(
width: 16,
height: 16,
colorFilter: ColorFilter.mode(
Colors.white,
BlendMode.srcIn,
),
),
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
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(
controller: TextEditingController(),label: 'صادر کننده پروانه'),
SizedBox(height: 8),
RTextField(
controller: TextEditingController(),label: 'شماره مجوز'),
SizedBox(height: 8),
RTextField(
controller: TextEditingController(),label: 'شماره ثبت'),
SizedBox(height: 8),
RTextField(
controller: TextEditingController(),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;
if (data == 0) {
selected.resetWith(0);
controller.routes.remove(route);
return;
}
controller.routes.ensureContainsAtStart(route);
selected.removeIfPresent(0);
selected.toggle(data);
},
),
],
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(20, 0, 20, 25),
child: RElevated(
text: 'مرحله بعد',
onPressed: () {
Get.toNamed(controller.routes.first);
},
height: 40,
isFullWidth: true,
backgroundColor: AppColor.greenNormal,
textStyle: AppFonts.yekan16.copyWith(color: Colors.white),
),
),
],
),
);
}
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: 50,
child: ListView.separated(
shrinkWrap: true,
padding: EdgeInsets.symmetric(horizontal: 20),
scrollDirection: Axis.horizontal,
itemBuilder:
(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: options.value.length,
),
),
],
);
}
}