Files
pj_supermarket_cloud/lib/pages/setting/view.dart
T
2026-01-29 16:02:41 +08:00

147 lines
4.5 KiB
Dart

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<SettingController> {
const SettingPage({super.key});
// 主视图
Widget _buildView() {
final context = Get.context!;
final width = Get.context!.sizes.width;
final theme = FTheme.of(context);
return <Widget>[
_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 <Widget>[
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);
case SettingMenuType.versionSetting:
if (!isBand) {
return const SizedBox.shrink();
}
return settingVersionSetting(context);
}
},
);
}
@override
Widget build(BuildContext context) {
return GetBuilder<SettingController>(
init: SettingController(),
id: "setting",
builder: (_) {
return FScaffold(
header: appDefaultNav(context, title: "设置"),
content: _buildView().marginOnly(top: 20.h),
contentPad: true,
resizeToAvoidBottomInset: false,
);
},
);
}
}