my_router.dart 4.5 KB

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