my_router.dart 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. import 'package:lszlgl/base/base_lifecycle_state.dart';
  2. import 'package:lszlgl/page/home/store_house_page.dart';
  3. import 'package:lszlgl/page/login/forget_password_page.dart';
  4. import 'package:lszlgl/page/login/login_page.dart';
  5. import 'package:lszlgl/page/main_tab_page.dart';
  6. import 'package:lszlgl/page/print/connect_print_page.dart';
  7. import 'package:lszlgl/page/print/print_page.dart';
  8. import 'package:lszlgl/page/sample_task/reap_sample_detail/reap_sample_task_page.dart';
  9. import 'package:lszlgl/page/sample_task/sample_task_list_tab_page.dart';
  10. import 'package:lszlgl/page/user_center/account_manage_page.dart';
  11. import 'package:lszlgl/page/user_center/change_pwd_page.dart';
  12. import 'package:lszlgl/page/user_center/setting_page.dart';
  13. import 'package:lszlgl/router/my_navigator.dart';
  14. import '../page/qrcode_scan/qrcode_scan_page.dart';
  15. import '../page/sample_task/stock_sample_detail/stock_sample_task_page.dart';
  16. import '../page/signature/signature_page.dart';
  17. // 根页面
  18. const rLoginPage = '/';
  19. // 主页
  20. const rMainTabPage = '/MainTabPage';
  21. // 账号管理
  22. const rAccountManagePage = '/AccountManagePage';
  23. // 设置
  24. const rSettingPage = '/SettingPage';
  25. // 修改密码
  26. const rChangePwdPage = '/ChangePwdPage';
  27. // 收获流程列表
  28. const rSampleTaskListTabPage = '/SampleTaskListTabPage';
  29. // 收获扦样任务
  30. const rReapSampleTaskPage = '/ReapSampleTaskPage';
  31. // 库存扦样任务
  32. const rStockSampleTaskPage = '/StockSampleTaskPage';
  33. // 电子签名
  34. const rSignaturePage = '/SignaturePage';
  35. // 打印
  36. const rPrintPage = '/PrintPage';
  37. // 连接
  38. const rConnectPrintPage = '/ConnectPrintPage';
  39. // 扫一扫
  40. const rQrCodeScanPage = '/QrCodeScanPage';
  41. // 忘记密码
  42. const rForgetPasswordPage = '/ForgetPasswordPage';
  43. // 仓库信息
  44. const rStoreHousePage = '/StoreHousePage';
  45. final Map<String, MyNavigatorBuilder> rRouteMap = {
  46. // 根页面
  47. rLoginPage: (context, args) => const LoginPage(),
  48. rMainTabPage: (context, args) => const MainTabPage(),
  49. rAccountManagePage: (context, args) => const AccountManagePage(),
  50. rSettingPage: (context, args) => const SettingPage(),
  51. rChangePwdPage: (context, args) => ChangePwdPage(startHome: args as bool?),
  52. rSampleTaskListTabPage: (context, args) => SampleTaskListTabPage(args: args as SampleTaskListTabPageArgs?),
  53. rReapSampleTaskPage: (context, args) => ReapSampleTaskPage(args: args as ReapSampleTaskPageArgs),
  54. rStockSampleTaskPage: (context, args) => StockSampleTaskPage(args: args as StockSampleTaskPageArgs),
  55. rSignaturePage: (context, args) => SignaturePage(args: args as SignaturePageArgs),
  56. rPrintPage: (context, args) => PrintPage(args: args as PrintPageArgs),
  57. rConnectPrintPage: (context, args) => ConnectPrintPage(args: args as ConnectPrintPageArgs),
  58. rQrCodeScanPage: (context, args) => QrCodeScanPage(isKC: args as bool),
  59. rForgetPasswordPage:(context,args) => const ForgetPasswordPage(),
  60. rStoreHousePage:(context,args) => StoreHousePage(houseNum: args as String),
  61. };
  62. class MyRouter {
  63. MyRouter._();
  64. /// 登录
  65. static void startLogin({bool popAll = false}) {
  66. if (popAll) {
  67. MyNavigator.pushRemoveUntil(rLoginPage, (route) => false);
  68. } else {
  69. MyNavigator.push(rLoginPage);
  70. }
  71. }
  72. /// 主页
  73. static void startMain({bool popAll = false}) {
  74. if (popAll) {
  75. MyNavigator.pushRemoveUntil(rMainTabPage, (route) => false);
  76. } else {
  77. MyNavigator.push(rMainTabPage);
  78. }
  79. }
  80. /// 账号管理
  81. static void startAccountManage() {
  82. MyNavigator.push(rAccountManagePage);
  83. }
  84. /// 设置
  85. static void startSetting() {
  86. MyNavigator.push(rSettingPage);
  87. }
  88. /// 修改密码
  89. static void startChangePwd({bool? startHome}) {
  90. MyNavigator.push(rChangePwdPage, args: startHome);
  91. }
  92. /// 忘记密码
  93. static void forgetPwd(){
  94. MyNavigator.push(rForgetPasswordPage);
  95. }
  96. /// 收获环节列表
  97. static Future<dynamic> startSampleTaskList(SampleTaskListTabPageArgs args) {
  98. return MyNavigator.push(rSampleTaskListTabPage, args: args);
  99. }
  100. /// 收获扦样任务
  101. static Future<dynamic> startReapSampleTask({ReapSampleTaskPageArgs? args, bool replace = false}) async {
  102. args ??= ReapSampleTaskPageArgs();
  103. if (replace) {
  104. return MyNavigator.pushReplace(rReapSampleTaskPage, args: args);
  105. } else {
  106. return MyNavigator.push(rReapSampleTaskPage, args: args);
  107. }
  108. }
  109. /// 仓库详情
  110. static void startStoreHouse(String num) {
  111. MyNavigator.pushReplace(rStoreHousePage, args: num);
  112. }
  113. /// 库存扦样任务
  114. static Future<dynamic> startStockSampleTask({StockSampleTaskPageArgs? args}) {
  115. return MyNavigator.push(rStockSampleTaskPage, args: args ?? StockSampleTaskPageArgs());
  116. }
  117. /// 电子签名
  118. static Future<dynamic> startSignature({SignaturePageArgs? args}) {
  119. return MyNavigator.push(rSignaturePage, args: args ?? SignaturePageArgs());
  120. }
  121. /// 打印任务
  122. static Future<dynamic> startPrint(PrintPageArgs args) {
  123. return MyNavigator.push(rPrintPage, args: args);
  124. }
  125. /// 打印任务
  126. static Future<dynamic> startConnectPrint({ConnectPrintPageArgs? args}) {
  127. return MyNavigator.push(rConnectPrintPage, args: args ?? ConnectPrintPageArgs());
  128. }
  129. /// 扫一扫
  130. static Future<dynamic> startQrCodeScan({bool? isKC = false}) {
  131. return MyNavigator.push(rQrCodeScanPage, args: isKC);
  132. }
  133. }