123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- import 'package:cpt_profile/modules/setting/setting_view_model.dart';
- import 'package:cpt_profile/router/page/profile_page_router.dart';
- import 'package:cs_resources/generated/l10n.dart';
- import 'package:cs_resources/theme/app_colors_theme.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:auto_route/auto_route.dart';
- import 'package:hooks_riverpod/hooks_riverpod.dart';
- import 'package:plugin_basic/provider/app_config/app_config_service.dart';
- import 'package:router/ext/auto_router_extensions.dart';
- import 'package:widgets/ext/ex_widget.dart';
- import 'package:widgets/my_appbar.dart';
- import 'package:widgets/my_button.dart';
- import 'package:widgets/my_text_view.dart';
- import 'package:widgets/shatter/setting_item_container.dart';
- @RoutePage()
- class SettingPage extends HookConsumerWidget {
- const SettingPage({Key? key}) : super(key: key);
- //启动当前页面
- static void startInstance({BuildContext? context}) {
- if (context != null) {
- context.router.navigate(const SettingPageRoute());
- } else {
- appRouter.navigate(const SettingPageRoute());
- }
- }
- @override
- Widget build(BuildContext context, WidgetRef ref) {
- final viewModel = ref.watch(settingViewModelProvider.notifier);
- final state = ref.watch(settingViewModelProvider);
- return Scaffold(
- appBar: MyAppBar.appBar(context, S.current.settings, backgroundColor: context.appColors.whiteBG),
- backgroundColor: context.appColors.backgroundDark,
- body: SingleChildScrollView(
- scrollDirection: Axis.vertical,
- physics: const BouncingScrollPhysics(),
- child: Column(
- mainAxisSize: MainAxisSize.max,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- const SizedBox(height: 10),
- //允许通知
- SettingItemContainer(
- title: S.current.enable_notification,
- rightWidget: CupertinoSwitch(
- activeColor: context.appColors.textPrimary,
- value: state.enbaleNofitication,
- onChanged: (value) {
- viewModel.changeEnableNotification(value);
- },
- ),
- ),
- //修改手机号码
- SettingItemContainer(title: S.current.change_mobile_phone).onTap(viewModel.gotoChangeMobilePage),
- //重置密码
- SettingItemContainer(title: S.current.reset_password).onTap(viewModel.gotoResetPasswordPage),
- //隐私协议
- SettingItemContainer(title: S.current.privacy_policy),
- //服务条款
- SettingItemContainer(title: S.current.terms_conditions),
- //删除账号
- SettingItemContainer(title: S.current.account_deactivation).onTap(viewModel.doDeleteAccount),
- //评价我们
- SettingItemContainer(title: S.current.rate_us),
- //版本号
- SettingItemContainer(
- title: S.current.version_no,
- rightWidget: MyTextView(
- AppConfigService.getState().version,
- textColor: context.appColors.textPrimary,
- fontSize: 15,
- isFontMedium: true,
- ),
- ),
- //提交按钮
- MyButton(
- onPressed: viewModel.doLogout,
- text: S.current.logout,
- textColor: Colors.white,
- backgroundColor: context.appColors.btnBgDefault,
- fontWeight: FontWeight.w500,
- type: ClickType.throttle,
- fontSize: 16,
- minHeight: 50,
- radius: 5,
- ).marginOnly(top: 22, bottom: 25, left: 15, right: 15),
- ],
- ),
- ),
- );
- }
- }
|