select_role_page.dart 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import 'package:cpt_auth/modules/select_role/screen_owner.dart';
  2. import 'package:cpt_auth/modules/select_role/screen_tenant.dart';
  3. import 'package:cs_resources/generated/l10n.dart';
  4. import 'package:cs_resources/theme/app_colors_theme.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:auto_route/auto_route.dart';
  7. import 'package:hooks_riverpod/hooks_riverpod.dart';
  8. import 'package:router/ext/auto_router_extensions.dart';
  9. import 'package:widgets/ext/ex_widget.dart';
  10. import 'package:widgets/my_appbar.dart';
  11. import 'package:widgets/my_button.dart';
  12. import 'package:widgets/my_text_view.dart';
  13. import '../../router/page/auth_page_router.dart';
  14. import 'select_role_view_model.dart';
  15. @RoutePage()
  16. class SelectRolePage extends HookConsumerWidget {
  17. const SelectRolePage({Key? key}) : super(key: key);
  18. //启动当前页面
  19. static void startInstance({BuildContext? context}) {
  20. if (context != null) {
  21. context.router.push(const SelectRolePageRoute());
  22. } else {
  23. appRouter.push(const SelectRolePageRoute());
  24. }
  25. }
  26. @override
  27. Widget build(BuildContext context, WidgetRef ref) {
  28. final viewModel = ref.read(selectRoleViewModelProvider.notifier);
  29. final state = ref.watch(selectRoleViewModelProvider);
  30. return Scaffold(
  31. appBar: MyAppBar.appBar(context, ""),
  32. backgroundColor: context.appColors.backgroundDefault,
  33. body: Container(
  34. padding: const EdgeInsets.symmetric(horizontal: 15),
  35. width: double.infinity,
  36. child: Column(
  37. mainAxisSize: MainAxisSize.max,
  38. crossAxisAlignment: CrossAxisAlignment.center,
  39. children: [
  40. MyTextView(
  41. S.current.owner_or_tenant,
  42. fontSize: 23.5,
  43. marginTop: 25,
  44. marginBottom: 25,
  45. textAlign: TextAlign.center,
  46. isFontMedium: true,
  47. textColor: context.appColors.textBlack,
  48. ),
  49. //顶部的Tab切换
  50. Row(
  51. children: [
  52. MyTextView(
  53. S.current.owner,
  54. textColor: state.selectedIndex == 0 ? context.appColors.tabTextSelectedPrimary : context.appColors.tabTextUnSelectedPrimary,
  55. fontSize: 16,
  56. isFontMedium: true,
  57. paddingTop: 16,
  58. paddingBottom: 16,
  59. cornerRadius: 5,
  60. textAlign: TextAlign.center,
  61. onClick: () {
  62. viewModel.selectRole(0);
  63. },
  64. backgroundColor: state.selectedIndex == 0 ? context.appColors.tabBgSelectedPrimary : context.appColors.tabBgUnSelectedPrimary,
  65. ).expanded(),
  66. MyTextView(
  67. S.current.tenant,
  68. textColor: state.selectedIndex == 1 ? context.appColors.tabTextSelectedPrimary : context.appColors.tabTextUnSelectedPrimary,
  69. fontSize: 16,
  70. marginLeft: 15,
  71. paddingTop: 16,
  72. paddingBottom: 16,
  73. textAlign: TextAlign.center,
  74. isFontMedium: true,
  75. cornerRadius: 5,
  76. onClick: () {
  77. viewModel.selectRole(1);
  78. },
  79. backgroundColor: state.selectedIndex == 1 ? context.appColors.tabBgSelectedPrimary : context.appColors.tabBgUnSelectedPrimary,
  80. ).expanded(),
  81. ],
  82. ),
  83. IndexedStack(
  84. index: state.selectedIndex,
  85. children: const [
  86. ScreenOwner(),
  87. ScreenTenant(),
  88. ],
  89. ).expanded(),
  90. //底部的按钮
  91. MyButton(
  92. onPressed: viewModel.submitRole,
  93. text: S.current.next,
  94. textColor: Colors.white,
  95. backgroundColor: context.appColors.btnBgDefault,
  96. fontWeight: FontWeight.w500,
  97. type: ClickType.throttle,
  98. fontSize: 16,
  99. minHeight: 50,
  100. radius: 5,
  101. ).marginOnly(top: 30, bottom: 30, left: 18, right: 18),
  102. ],
  103. ),
  104. ),
  105. );
  106. }
  107. }