123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- import 'package:cpt_profile/modules/me/setting/setting_state.dart';
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:plugin_basic/base/base_state.dart';
- import 'package:plugin_basic/base/base_stateful_page.dart';
- import 'package:plugin_basic/service/app_config_service.dart';
- import 'package:plugin_basic/service/user_service.dart';
- import 'package:plugin_basic/utils/ext_get_nav.dart';
- import 'package:cs_resources/constants/color_constants.dart';
- import 'package:router/path/router_path.dart';
- import 'package:shared/utils/log_utils.dart';
- import 'package:widgets/ext/ex_widget.dart';
- import 'package:widgets/my_appbar.dart';
- import 'package:widgets/utils/dark_theme_util.dart';
- import '../dark_model/dark_model_page.dart';
- import '../notification_enable/notification_enable_page.dart';
- import '../reset_password/reset_password_page.dart';
- import 'setting_controller.dart';
- class SettingPage extends BaseStatefulPage<SettingController> {
- SettingPage({super.key});
- //启动当前页面
- static void startInstance() {
- return Get.start(RouterPath.SETTING);
- }
- @override
- State<SettingPage> createState() => _SettingPageState();
- @override
- SettingController createRawController() {
- return SettingController();
- }
- }
- class _SettingPageState extends BaseState<SettingPage, SettingController> {
- late SettingState state;
- @override
- void initState() {
- super.initState();
- state = controller.state;
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: MyAppBar.appBar(context, "设置".tr),
- body: SafeArea(
- bottom: true,
- top: false,
- //真正的 Content 布局
- child: Scrollbar(
- child: SingleChildScrollView(
- child: Container(
- margin: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
- decoration: BoxDecoration(
- color: DarkThemeUtil.multiColors(ColorConstants.white, darkColor: ColorConstants.darkBlackItem),
- borderRadius: BorderRadius.circular(10),
- boxShadow: [
- BoxShadow(color: hexToColor('#000000', opacity: 0.1), blurRadius: 7),
- ],
- ),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Obx(() {
- return _buildItem(
- '实名认证'.tr,
- state.getVerifyStatusText(UserService.to.getUserProfile.name),
- () async {
- Log.d("进入实名认证页面");
- },
- );
- }),
- Obx(() {
- return _buildItem(UserService.to.passwordType.value == 'change' ? '修改密码'.tr : '设置密码'.tr, '', () {
- ResetPasswordPage.startInstance(UserService.to.passwordType.value);
- });
- }),
- _buildItem('修改手机号'.tr, '', () {
- Get.toNamed(RouterPath.CHANGEMOBILE);
- }),
- _buildItem('深色模式'.tr, '', () {
- DarkModelPage.startInstance();
- }),
- _buildItem('消息推送'.tr, '', () {
- NotificationEnablePage.startInstance();
- }),
- autoCtlGetBuilder(builder: (controller) {
- return _buildItem('清除缓存'.tr, state.appSize, () {
- controller.clearCache();
- }, isShowNextIcon: false);
- }),
- _buildItem('版本号'.tr, 'v ${ConfigService.to.version}', () {}, isShowNextIcon: false),
- Container(
- height: 40,
- width: double.infinity,
- margin: const EdgeInsets.symmetric(horizontal: 20, vertical: 25),
- color: hexToColor('#0689FB'),
- child: Center(
- child: Text("退出".tr, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w500, color: Colors.white)),
- ),
- ).onTap(() {
- controller.showLogoutDialog();
- })
- ],
- ),
- ),
- ),
- ),
- ));
- }
- Widget _buildItem(String title, String des, VoidCallback action, {bool isShowNextIcon = true}) {
- return GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () {
- action();
- },
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 20),
- child: Column(
- children: [
- Container(
- padding: const EdgeInsets.symmetric(vertical: 15),
- child: Row(
- children: [
- Text(
- title.tr,
- style: TextStyle(
- fontSize: 14,
- fontWeight: FontWeight.w500,
- color: DarkThemeUtil.multiColors(ColorConstants.black, darkColor: ColorConstants.white)),
- ),
- const Spacer(),
- Visibility(
- visible: des.isNotEmpty,
- child: Text(
- des.tr,
- style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: hexToColor('#0689FB')),
- ),
- ),
- Visibility(
- visible: isShowNextIcon,
- child: Icon(Icons.navigate_next_sharp, size: 20, color: hexToColor('#CCCCCC')),
- ),
- ],
- ),
- ),
- Divider(
- color: DarkThemeUtil.multiColors(hexToColor('#EDEDED'), darkColor: ColorConstants.darkBlackItemDivider),
- height: 0.5,
- )
- ],
- ),
- ),
- );
- }
- }
|