my_router.dart 4.8 KB

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