setting_page.dart 3.0 KB

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