fix: save route's
This commit is contained in:
@@ -34,7 +34,10 @@ class RolePage extends GetView<RoleLogic> {
|
|||||||
title: role.keys.first,
|
title: role.keys.first,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
String route = role.values.first;
|
String route = role.values.first;
|
||||||
await controller.gService.saveSelectedRole(route);
|
await controller.gService.saveSelectedRole(
|
||||||
|
Module.chicken,
|
||||||
|
route,
|
||||||
|
);
|
||||||
Get.offAllNamed(route);
|
Get.offAllNamed(route);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -106,7 +109,10 @@ class RolePage extends GetView<RoleLogic> {
|
|||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(title, style: AppFonts.yekan12Bold.copyWith(color: AppColor.blueNormal)),
|
child: Text(
|
||||||
|
title,
|
||||||
|
style: AppFonts.yekan12Bold.copyWith(color: AppColor.blueNormal),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -16,21 +16,12 @@ class AppModel extends HiveObject {
|
|||||||
@HiveField(3)
|
@HiveField(3)
|
||||||
List<TargetPage>? targetPages;
|
List<TargetPage>? targetPages;
|
||||||
|
|
||||||
AppModel({this.isFirstRun, this.isDarkMode, this.selectedModule, this.targetPages});
|
AppModel({
|
||||||
|
this.isFirstRun,
|
||||||
AppModel copyWith({
|
this.isDarkMode,
|
||||||
bool? isFirstRun,
|
this.selectedModule,
|
||||||
bool? isDarkMode,
|
this.targetPages,
|
||||||
Module? selectedModule,
|
});
|
||||||
List<TargetPage>? targetPages,
|
|
||||||
}) {
|
|
||||||
return AppModel(
|
|
||||||
isFirstRun: isFirstRun ?? this.isFirstRun,
|
|
||||||
isDarkMode: isDarkMode ?? this.isDarkMode,
|
|
||||||
selectedModule: selectedModule ?? this.selectedModule,
|
|
||||||
targetPages: targetPages ?? this.targetPages,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@@ -51,11 +42,8 @@ class TargetPage extends HiveObject {
|
|||||||
|
|
||||||
TargetPage({required this.route, this.functions, this.module});
|
TargetPage({required this.route, this.functions, this.module});
|
||||||
|
|
||||||
TargetPage copyWith({String? route, List<String>? functions, Module? module}) {
|
@override
|
||||||
return TargetPage(
|
String toString() {
|
||||||
route: route ?? this.route,
|
return 'TargetPage{route: $route, functions: $functions, module: $module}';
|
||||||
functions: functions ?? this.functions,
|
|
||||||
module: module ?? this.module,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,14 +40,13 @@ class GService extends GetxService {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> saveSelectedRole(String route) async {
|
Future<void> saveSelectedRole(Module module,String route) async {
|
||||||
AppModel model = box.values.first;
|
AppModel model = box.values.first;
|
||||||
model.targetPages?.first.route = route;
|
TargetPage? targetPage = model.targetPages?.firstWhere((element) => element.module == module);
|
||||||
|
if(targetPage!=null){
|
||||||
await model.save();
|
targetPage.route =route;
|
||||||
AppModel model2 = box.values.first;
|
model.save();
|
||||||
|
}
|
||||||
iLog("Saved route: $model2");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> setIsNotFirstTime() async {
|
Future<void> setIsNotFirstTime() async {
|
||||||
|
|||||||
Reference in New Issue
Block a user