fix: save route's

This commit is contained in:
2025-09-06 21:18:18 +03:30
parent d2e74e6627
commit 1bc449c9be
3 changed files with 23 additions and 30 deletions

View File

@@ -34,7 +34,10 @@ class RolePage extends GetView<RoleLogic> {
title: role.keys.first,
onTap: () async {
String route = role.values.first;
await controller.gService.saveSelectedRole(route);
await controller.gService.saveSelectedRole(
Module.chicken,
route,
);
Get.offAllNamed(route);
},
);
@@ -106,7 +109,10 @@ class RolePage extends GetView<RoleLogic> {
child: InkWell(
onTap: onTap,
child: Center(
child: Text(title, style: AppFonts.yekan12Bold.copyWith(color: AppColor.blueNormal)),
child: Text(
title,
style: AppFonts.yekan12Bold.copyWith(color: AppColor.blueNormal),
),
),
),
);

View File

@@ -16,21 +16,12 @@ class AppModel extends HiveObject {
@HiveField(3)
List<TargetPage>? targetPages;
AppModel({this.isFirstRun, this.isDarkMode, this.selectedModule, this.targetPages});
AppModel copyWith({
bool? isFirstRun,
bool? isDarkMode,
Module? selectedModule,
List<TargetPage>? targetPages,
}) {
return AppModel(
isFirstRun: isFirstRun ?? this.isFirstRun,
isDarkMode: isDarkMode ?? this.isDarkMode,
selectedModule: selectedModule ?? this.selectedModule,
targetPages: targetPages ?? this.targetPages,
);
}
AppModel({
this.isFirstRun,
this.isDarkMode,
this.selectedModule,
this.targetPages,
});
@override
String toString() {
@@ -51,11 +42,8 @@ class TargetPage extends HiveObject {
TargetPage({required this.route, this.functions, this.module});
TargetPage copyWith({String? route, List<String>? functions, Module? module}) {
return TargetPage(
route: route ?? this.route,
functions: functions ?? this.functions,
module: module ?? this.module,
);
@override
String toString() {
return 'TargetPage{route: $route, functions: $functions, module: $module}';
}
}

View File

@@ -40,14 +40,13 @@ class GService extends GetxService {
return res;
}
Future<void> saveSelectedRole(String route) async {
Future<void> saveSelectedRole(Module module,String route) async {
AppModel model = box.values.first;
model.targetPages?.first.route = route;
await model.save();
AppModel model2 = box.values.first;
iLog("Saved route: $model2");
TargetPage? targetPage = model.targetPages?.firstWhere((element) => element.module == module);
if(targetPage!=null){
targetPage.route =route;
model.save();
}
}
Future<void> setIsNotFirstTime() async {