setting_page.dart 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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_text_view.dart';
  14. import 'package:widgets/shatter/setting_item_container.dart';
  15. @RoutePage()
  16. class SettingPage extends HookConsumerWidget {
  17. const SettingPage({Key? key}) : super(key: key);
  18. //启动当前页面
  19. static void startInstance({BuildContext? context}) {
  20. if (context != null) {
  21. context.router.navigate(const SettingPageRoute());
  22. } else {
  23. appRouter.navigate(const SettingPageRoute());
  24. }
  25. }
  26. @override
  27. Widget build(BuildContext context, WidgetRef ref) {
  28. final viewModel = ref.watch(settingViewModelProvider.notifier);
  29. final state = ref.watch(settingViewModelProvider);
  30. return Scaffold(
  31. appBar: MyAppBar.appBar(context, S.current.settings, backgroundColor: context.appColors.whiteBG),
  32. backgroundColor: context.appColors.backgroundDark,
  33. body: SingleChildScrollView(
  34. scrollDirection: Axis.vertical,
  35. physics: const BouncingScrollPhysics(),
  36. child: Column(
  37. mainAxisSize: MainAxisSize.max,
  38. crossAxisAlignment: CrossAxisAlignment.center,
  39. children: [
  40. const SizedBox(height: 10),
  41. //允许通知
  42. SettingItemContainer(
  43. title: S.current.enable_notification,
  44. rightWidget: CupertinoSwitch(
  45. activeColor: context.appColors.textPrimary,
  46. value: state.enbaleNofitication,
  47. onChanged: (value) {
  48. viewModel.changeEnableNotification(value);
  49. },
  50. ),
  51. ),
  52. //修改手机号码
  53. SettingItemContainer(title: S.current.change_mobile_phone).onTap(viewModel.gotoChangeMobilePage),
  54. //重置密码
  55. SettingItemContainer(title: S.current.reset_password),
  56. //隐私协议
  57. SettingItemContainer(title: S.current.privacy_policy),
  58. //服务条款
  59. SettingItemContainer(title: S.current.terms_conditions),
  60. //删除账号
  61. SettingItemContainer(title: S.current.account_deactivation),
  62. //评价我们
  63. SettingItemContainer(title: S.current.rate_us),
  64. //版本号
  65. SettingItemContainer(
  66. title: S.current.version_no,
  67. rightWidget: MyTextView(
  68. AppConfigService.getState().version,
  69. textColor: context.appColors.textPrimary,
  70. fontSize: 15,
  71. isFontMedium: true,
  72. ),
  73. ),
  74. ],
  75. ),
  76. ),
  77. );
  78. }
  79. }