setting_page.dart 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import 'package:cpt_profile/modules/setting/setting_view_model.dart';
  2. import 'package:cpt_profile/router/page/profile_page_router.dart';
  3. import 'package:cs_resources/generated/l10n.dart';
  4. import 'package:cs_resources/theme/app_colors_theme.dart';
  5. import 'package:flutter/cupertino.dart';
  6. import 'package:flutter/material.dart';
  7. import 'package:auto_route/auto_route.dart';
  8. import 'package:hooks_riverpod/hooks_riverpod.dart';
  9. import 'package:plugin_basic/provider/app_config/app_config_service.dart';
  10. import 'package:router/ext/auto_router_extensions.dart';
  11. import 'package:widgets/ext/ex_widget.dart';
  12. import 'package:widgets/my_appbar.dart';
  13. import 'package:widgets/my_button.dart';
  14. import 'package:widgets/my_text_view.dart';
  15. import 'package:widgets/shatter/setting_item_container.dart';
  16. @RoutePage()
  17. class SettingPage extends HookConsumerWidget {
  18. const SettingPage({Key? key}) : super(key: key);
  19. //启动当前页面
  20. static void startInstance({BuildContext? context}) {
  21. if (context != null) {
  22. context.router.navigate(const SettingPageRoute());
  23. } else {
  24. appRouter.navigate(const SettingPageRoute());
  25. }
  26. }
  27. @override
  28. Widget build(BuildContext context, WidgetRef ref) {
  29. final viewModel = ref.watch(settingViewModelProvider.notifier);
  30. final state = ref.watch(settingViewModelProvider);
  31. return Scaffold(
  32. appBar: MyAppBar.appBar(context, S.current.settings, backgroundColor: context.appColors.whiteBG),
  33. backgroundColor: context.appColors.backgroundDark,
  34. body: SingleChildScrollView(
  35. scrollDirection: Axis.vertical,
  36. physics: const BouncingScrollPhysics(),
  37. child: Column(
  38. mainAxisSize: MainAxisSize.max,
  39. crossAxisAlignment: CrossAxisAlignment.center,
  40. children: [
  41. const SizedBox(height: 10),
  42. //允许通知
  43. SettingItemContainer(
  44. title: S.current.enable_notification,
  45. rightWidget: CupertinoSwitch(
  46. activeColor: context.appColors.textPrimary,
  47. value: state.enbaleNofitication,
  48. onChanged: (value) {
  49. viewModel.changeEnableNotification(value);
  50. },
  51. ),
  52. isShowMoreIcon: false,
  53. ),
  54. //修改手机号码
  55. SettingItemContainer(title: S.current.change_mobile_phone).onTap(viewModel.gotoChangeMobilePage),
  56. //重置密码
  57. SettingItemContainer(title: S.current.reset_password).onTap(viewModel.gotoResetPasswordPage),
  58. //隐私协议
  59. SettingItemContainer(title: S.current.privacy_policy),
  60. //服务条款
  61. SettingItemContainer(title: S.current.terms_conditions),
  62. //删除账号
  63. SettingItemContainer(title: S.current.account_deactivation).onTap(viewModel.doDeleteAccount),
  64. //评价我们
  65. SettingItemContainer(title: S.current.rate_us),
  66. //版本号
  67. SettingItemContainer(
  68. title: S.current.version_no,
  69. rightWidget: MyTextView(
  70. AppConfigService.getState().version,
  71. textColor: context.appColors.textPrimary,
  72. fontSize: 15,
  73. isFontMedium: true,
  74. ),
  75. isShowMoreIcon: false,
  76. ),
  77. //提交按钮
  78. MyButton(
  79. onPressed: viewModel.doLogout,
  80. text: S.current.logout,
  81. textColor: Colors.white,
  82. backgroundColor: context.appColors.btnBgDefault,
  83. fontWeight: FontWeight.w500,
  84. type: ClickType.throttle,
  85. fontSize: 16,
  86. minHeight: 50,
  87. radius: 5,
  88. ).marginOnly(top: 22, bottom: 25, left: 15, right: 15),
  89. ],
  90. ),
  91. ),
  92. );
  93. }
  94. }