feat: add Poultry Farm Inspection module with navigation and logic
This commit is contained in:
@@ -122,6 +122,15 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
var tmpRoles = result?.role
|
||||
?.where((element) => element == 'PoultryScience' || element == 'Steward')
|
||||
.toList();
|
||||
|
||||
/*var tmpRoles = result?.role?.where((element) {
|
||||
return element == 'PoultryScience' ||
|
||||
element == 'Steward' ||
|
||||
element == 'CityOperator' ||
|
||||
element == 'CityJahad' ||
|
||||
element.toLowerCase().contains("admin");
|
||||
}).toList();*/
|
||||
|
||||
await tokenStorageService.saveRoles(_module, tmpRoles ?? []);
|
||||
if (rememberMe.value) {
|
||||
await tokenStorageService.saveUserPass(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/common/fa_user_role.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/app_bar.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
@@ -15,11 +14,7 @@ class RolePage extends GetView<RoleLogic> {
|
||||
isBase: true,
|
||||
child: Column(
|
||||
children: [
|
||||
Assets.images.selectRole.image(
|
||||
height: 212.h,
|
||||
width: Get.width.w,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
Assets.images.selectRole.image(height: 212.h, width: Get.width.w, fit: BoxFit.cover),
|
||||
ObxValue((data) {
|
||||
return Expanded(
|
||||
child: GridView.builder(
|
||||
@@ -38,15 +33,9 @@ class RolePage extends GetView<RoleLogic> {
|
||||
title: role.keys.first,
|
||||
onTap: () async {
|
||||
String route = role.values.first;
|
||||
await controller.gService.saveRoute(
|
||||
Module.chicken,
|
||||
route,
|
||||
);
|
||||
await controller.gService.saveRoute(Module.chicken, route);
|
||||
|
||||
await controller.gService.saveRole(
|
||||
Module.chicken,
|
||||
data[index],
|
||||
);
|
||||
await controller.gService.saveRole(Module.chicken, data[index]);
|
||||
Get.offAllNamed(route);
|
||||
},
|
||||
);
|
||||
@@ -58,17 +47,9 @@ class RolePage extends GetView<RoleLogic> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Widget roleCard({
|
||||
required String title,
|
||||
Function()? onTap,
|
||||
int? width,
|
||||
int? height,
|
||||
}) {
|
||||
Widget roleCard({required String title, Function()? onTap, int? width, int? height}) {
|
||||
return Container(
|
||||
width: width?.w ?? 128.w,
|
||||
height: height?.h ?? 48.h,
|
||||
@@ -84,6 +65,7 @@ Widget roleCard({
|
||||
child: Text(
|
||||
title,
|
||||
style: AppFonts.yekan12Bold.copyWith(color: AppColor.blueNormal),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class PoultryFarmInspectionHomeLogic extends GetxController
|
||||
with GetTickerProviderStateMixin {
|
||||
RxInt selectedSegmentIndex = 0.obs;
|
||||
RxList<Resource<PaginationModel<String>>> inspectionList = RxList([
|
||||
Resource<PaginationModel<String>>.success(
|
||||
PaginationModel(results: ["s", "b", "c", "d"]),
|
||||
),
|
||||
]);
|
||||
RxList<Resource<PaginationModel<String>>> inactiveInspectionList = RxList([
|
||||
Resource<PaginationModel<String>>.success(
|
||||
PaginationModel(results: ["s", "b", "c", "d"]),
|
||||
),
|
||||
]);
|
||||
|
||||
RxInt expandedIndex = RxInt(-1);
|
||||
|
||||
late TabController tabController;
|
||||
|
||||
RxInt selectedTabIndex = 0.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
tabController = TabController(length: 4, vsync: this);
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
void toggleExpanded(int index) {
|
||||
expandedIndex.value = expandedIndex.value == index ? -1 : index;
|
||||
}
|
||||
|
||||
void changeSegmentIndex(int index) {
|
||||
if (index == selectedSegmentIndex.value) {
|
||||
return;
|
||||
}
|
||||
expandedIndex.value = -1;
|
||||
selectedSegmentIndex.value = index;
|
||||
}
|
||||
|
||||
void changeTab(int index) {
|
||||
if (index == selectedTabIndex.value) {
|
||||
return;
|
||||
}
|
||||
selectedTabIndex.value = index;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
export 'home/logic.dart';
|
||||
export 'home/view.dart';
|
||||
@@ -0,0 +1,44 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rasadyar_core/presentation/common/app_color.dart';
|
||||
|
||||
class PoultryFarmInspectionRootLogic extends GetxController {
|
||||
DateTime? _lastBackPressed;
|
||||
final pages = [
|
||||
Container(color: Colors.amber),
|
||||
Container(color: Colors.blue),
|
||||
Container(color: Colors.red),
|
||||
];
|
||||
|
||||
RxInt currentPage = 0.obs;
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
void changePage(int index) {
|
||||
currentPage.value = index;
|
||||
}
|
||||
|
||||
void popBackTaped() async {
|
||||
final now = DateTime.now();
|
||||
if (_lastBackPressed == null || now.difference(_lastBackPressed!) > Duration(seconds: 2)) {
|
||||
_lastBackPressed = now;
|
||||
Get.snackbar(
|
||||
'خروج از برنامه',
|
||||
'برای خروج دوباره بازگشت را بزنید',
|
||||
snackPosition: SnackPosition.TOP,
|
||||
duration: Duration(seconds: 2),
|
||||
backgroundColor: AppColor.warning,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
class PoultryFarmInspectionRootPage extends GetView<PoultryFarmInspectionRootLogic> {
|
||||
const PoultryFarmInspectionRootPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChickenBasePage(
|
||||
isFullScreen: true,
|
||||
onPopScopTaped: controller.popBackTaped,
|
||||
child: ObxValue((data) {
|
||||
return Stack(
|
||||
children: [
|
||||
IndexedStack(children: controller.pages, index: data.value),
|
||||
Positioned(
|
||||
right: 0,
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
child: RBottomNavigation(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
items: [
|
||||
RBottomNavigationItem(
|
||||
label: 'بازرسی فعال',
|
||||
icon: Assets.vec.settingSvg.path,
|
||||
isSelected: controller.currentPage.value == 0,
|
||||
onTap: () {
|
||||
controller.changePage(0);
|
||||
},
|
||||
),
|
||||
RBottomNavigationItem(
|
||||
label: 'خانه',
|
||||
icon: Assets.vec.homeSvg.path,
|
||||
isSelected: controller.currentPage.value == 1,
|
||||
onTap: () {
|
||||
controller.changePage(1);
|
||||
},
|
||||
),
|
||||
RBottomNavigationItem(
|
||||
label: 'پروفایل',
|
||||
icon: Assets.vec.profileCircleSvg.path,
|
||||
isSelected: controller.currentPage.value == 2,
|
||||
onTap: () {
|
||||
controller.changePage(3);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.currentPage),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -31,5 +31,11 @@ class PoultryActionLogic extends GetxController {
|
||||
route: ChickenRoutes.activeHatchingPoultryScience,
|
||||
icon: Assets.vec.activeFramSvg.path,
|
||||
),
|
||||
|
||||
PoultryActionItem(
|
||||
title: "بازرسی مزارع طیور",
|
||||
route: ChickenRoutes.poultryFarmInspectionHome,
|
||||
icon: Assets.vec.activeFramSvg.path,
|
||||
),
|
||||
].obs;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ class PoultryActionPage extends GetView<PoultryActionLogic> {
|
||||
title: item.title,
|
||||
vecIcon: item.icon,
|
||||
onTap: () async {
|
||||
|
||||
Get.toNamed(item.route, id: poultryFirstKey);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:rasadyar_chicken/presentation/pages/common/auth/logic.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/common/auth/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/common/role/logic.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/common/role/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/poultry_farm_inspection/poultry_farm_inspection.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/poultry_science/active_hatching/logic.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/poultry_science/active_hatching/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/poultry_science/farm/logic.dart';
|
||||
@@ -69,7 +70,6 @@ sealed class ChickenPages {
|
||||
page: () => HomePage(),
|
||||
middlewares: [AuthMiddleware()],
|
||||
binding: BindingsBuilder(() {
|
||||
|
||||
Get.put(HomeLogic());
|
||||
Get.lazyPut(() => BaseLogic());
|
||||
}),
|
||||
@@ -223,5 +223,16 @@ sealed class ChickenPages {
|
||||
}),
|
||||
),
|
||||
//endregion
|
||||
|
||||
//region Poultry Farm Inspection
|
||||
GetPage(
|
||||
name: ChickenRoutes.poultryFarmInspectionHome,
|
||||
page: () => PoultryFarmInspectionHomePage(),
|
||||
binding: BindingsBuilder(() {
|
||||
Get.lazyPut(() => PoultryFarmInspectionHomeLogic());
|
||||
Get.lazyPut(() => BaseLogic(), fenix: true);
|
||||
}),
|
||||
),
|
||||
//endregion
|
||||
];
|
||||
}
|
||||
|
||||
@@ -35,7 +35,11 @@ sealed class ChickenRoutes {
|
||||
static const genocidePoultryScience = '$_poultryScience/genocidePoultryScience';
|
||||
static const killingRegistrationPoultryScience = '$genocidePoultryScience/KillingRegistration';
|
||||
|
||||
//endregion
|
||||
|
||||
//region poultry Farm Inspection
|
||||
static const _poultryFarmInspection = '$_base/poultryFarmInspection';
|
||||
static const poultryFarmInspectionHome = '$_poultryFarmInspection/Home';
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
Widget cardInfo({
|
||||
required int value,
|
||||
required String description,
|
||||
required Color color,
|
||||
}) {
|
||||
return Container(
|
||||
width: 93.w,
|
||||
height: 53.h,
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
width: 0.50,
|
||||
color: const Color.fromARGB(54, 169, 169, 169),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
spacing: 4,
|
||||
children: [
|
||||
Text(
|
||||
value.separatedByCommaFa,
|
||||
style: AppFonts.yekan13Bold.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
Text(
|
||||
description,
|
||||
style: AppFonts.yekan10.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user