chore : home page separation

This commit is contained in:
2025-06-15 09:48:52 +03:30
parent c8c6002d79
commit a893545403
7 changed files with 896 additions and 511 deletions

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart' show Text, EdgeInsets, Colors;
import 'package:flutter/widgets.dart';
import 'package:rasadyar_auth/data/models/local/user_local/user_local_model.dart';
import 'package:rasadyar_auth/data/services/token_storage_service.dart';
import 'package:rasadyar_auth/data/utils/safe_call.dart';
@@ -7,11 +8,22 @@ import 'package:rasadyar_chicken/data/models/response/inventory/inventory_model.
import 'package:rasadyar_chicken/data/models/response/kill_house_distribution_info/kill_house_distribution_info.dart';
import 'package:rasadyar_chicken/data/repositories/chicken_repository.dart';
import 'package:rasadyar_chicken/data/repositories/chicken_repository_imp.dart';
import 'package:rasadyar_chicken/presentation/pages/home/view.dart';
import 'package:rasadyar_chicken/presentation/pages/sales_out_of_province/view.dart';
import 'package:rasadyar_core/core.dart';
enum ErrorLocationType { serviceDisabled, permissionDenied, none }
class RootLogic extends GetxController {
RxInt currentPage = 2.obs;
List<Widget> pages = [
Container(color: Colors.red),
SalesOutOfProvincePage(),
HomePage(),
Container(color: Colors.blue),
Container(color: Colors.amber),
];
RxList<ErrorLocationType> errorLocationType = RxList();
RxMap<int, dynamic> inventoryExpandedList = RxMap();
var tokenService = Get.find<TokenStorageService>();
@@ -20,8 +32,7 @@ class RootLogic extends GetxController {
RxInt count = 5.obs;
RxList<InventoryModel> inventoryList = RxList();
Rxn<KillHouseDistributionInfo> killHouseDistributionInfo =
Rxn<KillHouseDistributionInfo>();
Rxn<KillHouseDistributionInfo> killHouseDistributionInfo = Rxn<KillHouseDistributionInfo>();
@override
void onInit() {
@@ -43,9 +54,7 @@ class RootLogic extends GetxController {
Future<void> getInventory() async {
await safeCall<List<InventoryModel>?>(
call: () async => await chickenRepository.getInventory(
token: tokenService.accessToken.value!,
),
call: () async => await chickenRepository.getInventory(token: tokenService.accessToken.value!),
onSuccess: (result) {
if (result != null) {
iLog(result);
@@ -71,9 +80,7 @@ class RootLogic extends GetxController {
Future<void> getKillHouseDistributionInfo() async {
await safeCall<KillHouseDistributionInfo?>(
call: () async => await chickenRepository.getIKillHouseDistributionInfo(
token: tokenService.accessToken.value!,
),
call: () async => await chickenRepository.getIKillHouseDistributionInfo(token: tokenService.accessToken.value!),
onSuccess: (result) {
if (result != null) {
iLog(result);
@@ -86,23 +93,15 @@ class RootLogic extends GetxController {
}
void _handleGeneric(DioException error) {
Get.showSnackbar(
_errorSnackBar('اعتبار توکن شما منقضی شده است لطفا دوباره وارد شوید'),
);
Get.showSnackbar(_errorSnackBar('اعتبار توکن شما منقضی شده است لطفا دوباره وارد شوید'));
tokenService.deleteTokens();
Get.offAllNamed(AuthPaths.auth, arguments: Module.chicken);
}
GetSnackBar _errorSnackBar(String message) {
return GetSnackBar(
titleText: Text(
'خطا',
style: AppFonts.yekan14.copyWith(color: Colors.white),
),
messageText: Text(
message,
style: AppFonts.yekan12.copyWith(color: Colors.white),
),
titleText: Text('خطا', style: AppFonts.yekan14.copyWith(color: Colors.white)),
messageText: Text(message, style: AppFonts.yekan12.copyWith(color: Colors.white)),
backgroundColor: AppColor.error,
margin: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
borderRadius: 12,
@@ -110,4 +109,8 @@ class RootLogic extends GetxController {
snackPosition: SnackPosition.TOP,
);
}
void changePage(int index) {
currentPage.value = index;
}
}