import 'package:ducafe_ui_core/ducafe_ui_core.dart'; import 'package:flutter/material.dart'; import 'package:forui/forui.dart'; import 'package:get/get.dart'; import 'package:pj_supermarket_cloud/common/index.dart'; import 'package:pj_supermarket_cloud/pages/setting/widgets/index.dart'; import 'index.dart'; class SettingPage extends GetView { const SettingPage({super.key}); // 主视图 Widget _buildView() { final context = Get.context!; final width = Get.context!.sizes.width; final theme = FTheme.of(context); return [ _buildMenu().width(width * 0.2).height(double.infinity), FDivider( axis: Axis.vertical, style: theme.dividerStyles.verticalStyle.copyWith( color: theme.colorScheme.primary, ), ), Obx(() => _buildDetail(context, controller.cuurentMenuType.value)) .marginSymmetric(horizontal: 10.w) .expanded(), ].toRow().height(double.infinity); } Widget _buildMenu() { final theme = FTheme.of(Get.context!); return Obx( () => controller.menuList .map((v) { final isSelect = controller.cuurentMenuType.value == v.type; return [ FIcon( v.prefixIcon, color: isSelect ? theme.colorScheme.secondary : theme.colorScheme.primary, ), Text( v.title, style: theme.typography.xl.copyWith( color: isSelect ? theme.colorScheme.secondary : theme.colorScheme.primary, ), ).paddingHorizontal(20.w), isSelect ? FIcon( FAssets.icons.check, color: theme.colorScheme.secondary, ) : SizedBox.shrink(), ] .toRow( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, ) .decorated( color: isSelect ? theme.colorScheme.primary : theme.colorScheme.secondary, border: Border.all( color: theme.colorScheme.primary, width: 1, ), borderRadius: theme.style.borderRadius, ) .onTap(() => controller.doMenu(v)); }) .toList() .toColumnSpace( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, space: 10.h, ) .height(double.infinity), ); } Widget _buildDetail(BuildContext context, SettingMenuType type) { return FutureBuilder( future: controller.checkIsBind(), builder: (context, snapshot) { if (!snapshot.hasData) { return const SizedBox.shrink(); } final isBand = snapshot.data!; switch (type) { case SettingMenuType.baseInfo: return settingBaseInfo(context); case SettingMenuType.backup: return settingBackup(context); case SettingMenuType.syncSetting: if (!isBand) { return const SizedBox.shrink(); } return settingSync(context); case SettingMenuType.paySetting: if (!isBand) { return const SizedBox.shrink(); } return settingPay(context); case SettingMenuType.faceSetting: if (!isBand) { return const SizedBox.shrink(); } return settingFace(context); case SettingMenuType.productSetting: if (!isBand) { return const SizedBox.shrink(); } return settingProduct(context); default: return SizedBox.shrink(); } }, ); } @override Widget build(BuildContext context) { final theme = FTheme.of(context); final height = context.height; return GetBuilder( init: SettingController(), id: "setting", builder: (_) { return FScaffold( header: FHeader.nested( title: Text("设置"), prefixActions: [ FHeaderAction.back(onPress: Get.back), ], style: theme.headerStyle.nestedStyle.copyWith( titleTextStyle: theme.typography.lg, actionStyle: theme.headerStyle.nestedStyle.actionStyle.copyWith( size: theme.typography.xl2.fontSize, ), ), ).height(height * 0.1), content: _buildView(), contentPad: true, resizeToAvoidBottomInset: false, ); }, ); } }