完整实现收银终端的Android专用Kiosk模式支持,包括: - 添加原生设备管理与Kiosk模式核心逻辑 - 新增Flutter设置页的Kiosk相关配置与控制UI - 更新README添加部署命令 - 补充Android权限与组件声明
295 lines
10 KiB
Dart
295 lines
10 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 'controller.dart';
|
|
|
|
class SettingPage extends GetView<SettingController> {
|
|
const SettingPage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return TerminalShell(
|
|
title: '设置',
|
|
activeNav: TerminalNavType.settings,
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
SizedBox(width: 240.w, child: _SettingMenu(controller: controller)),
|
|
SizedBox(width: XfjDesignTokens.cardGap.w),
|
|
Expanded(child: _SettingContent(controller: controller)),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _SettingMenu extends StatelessWidget {
|
|
const _SettingMenu({required this.controller});
|
|
|
|
final SettingController controller;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = FTheme.of(context);
|
|
return TerminalSurface(
|
|
padding: EdgeInsets.all(12.w),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Padding(
|
|
padding: EdgeInsets.fromLTRB(12.w, 4.h, 12.w, 12.h),
|
|
child: Text(
|
|
'终端设置',
|
|
style: theme.typography.sm.copyWith(
|
|
color: XfjDesignTokens.muted,
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
),
|
|
),
|
|
Obx(
|
|
() => Column(
|
|
children: SettingMenuType.values
|
|
.map(
|
|
(type) => _SettingMenuButton(
|
|
type: type,
|
|
selected: controller.cuurentMenuType.value == type,
|
|
onTap: () => controller.doMenu(type),
|
|
).marginOnly(bottom: 8.h),
|
|
)
|
|
.toList(),
|
|
),
|
|
),
|
|
const Spacer(),
|
|
Obx(() {
|
|
final bound = controller.isBound.value;
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Container(
|
|
padding: EdgeInsets.all(16.w),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFF7F8FA),
|
|
border: Border.all(color: XfjDesignTokens.line),
|
|
borderRadius: BorderRadius.circular(
|
|
XfjDesignTokens.controlRadius,
|
|
),
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Container(
|
|
width: 8.w,
|
|
height: 8.w,
|
|
decoration: BoxDecoration(
|
|
color: bound
|
|
? XfjDesignTokens.success
|
|
: XfjDesignTokens.warning,
|
|
shape: BoxShape.circle,
|
|
),
|
|
),
|
|
SizedBox(width: 8.w),
|
|
Text(
|
|
bound ? '设备已绑定' : '设备未绑定',
|
|
style: theme.typography.sm.copyWith(
|
|
color: bound
|
|
? XfjDesignTokens.success
|
|
: XfjDesignTokens.warning,
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 8.h),
|
|
Text(
|
|
bound ? '部分设置修改后会自动同步到本机服务。' : '请先在基本信息中绑定设备后使用业务设置。',
|
|
style: theme.typography.sm.copyWith(
|
|
color: XfjDesignTokens.muted,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
if (controller.kioskStatus.value.canExitToAndroidHome) ...[
|
|
SizedBox(height: 8.h),
|
|
const SettingKioskExitButton(),
|
|
],
|
|
],
|
|
);
|
|
}),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _SettingMenuButton extends StatelessWidget {
|
|
const _SettingMenuButton({
|
|
required this.type,
|
|
required this.selected,
|
|
required this.onTap,
|
|
});
|
|
|
|
final SettingMenuType type;
|
|
final bool selected;
|
|
final VoidCallback onTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = FTheme.of(context);
|
|
return InkWell(
|
|
onTap: onTap,
|
|
borderRadius: BorderRadius.circular(XfjDesignTokens.controlRadius),
|
|
child: Container(
|
|
constraints: BoxConstraints(minHeight: 56.h),
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 10.h),
|
|
decoration: BoxDecoration(
|
|
color: selected ? XfjDesignTokens.primary : Colors.transparent,
|
|
borderRadius: BorderRadius.circular(XfjDesignTokens.controlRadius),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
FIcon(
|
|
_menuIcon(type),
|
|
color: selected ? Colors.white : const Color(0xFF344054),
|
|
size: 23.sp,
|
|
),
|
|
SizedBox(width: 12.w),
|
|
Expanded(
|
|
child: Text(
|
|
type.title,
|
|
style: theme.typography.base.copyWith(
|
|
color: selected ? Colors.white : const Color(0xFF344054),
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
if (selected)
|
|
FIcon(FAssets.icons.check, color: Colors.white, size: 18.sp),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _SettingContent extends StatelessWidget {
|
|
const _SettingContent({required this.controller});
|
|
|
|
final SettingController controller;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = FTheme.of(context);
|
|
return TerminalSurface(
|
|
clipBehavior: Clip.antiAlias,
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
constraints: BoxConstraints(minHeight: 92.h),
|
|
padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 14.h),
|
|
decoration: const BoxDecoration(
|
|
border: Border(bottom: BorderSide(color: XfjDesignTokens.line)),
|
|
),
|
|
child: Obx(() {
|
|
final type = controller.cuurentMenuType.value;
|
|
return Row(
|
|
children: [
|
|
Expanded(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
type.title,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: theme.typography.xl2.copyWith(
|
|
color: XfjDesignTokens.ink,
|
|
fontWeight: FontWeight.w800,
|
|
),
|
|
),
|
|
SizedBox(height: 4.h),
|
|
Text(
|
|
_menuDescription(type),
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: theme.typography.sm.copyWith(
|
|
color: XfjDesignTokens.muted,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}),
|
|
),
|
|
Expanded(
|
|
child: Padding(
|
|
padding: EdgeInsets.all(20.w),
|
|
child: Obx(() {
|
|
if (controller.isLoading.value) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
final type = controller.cuurentMenuType.value;
|
|
if (!controller.isBound.value &&
|
|
type != SettingMenuType.baseInfo &&
|
|
type != SettingMenuType.backup) {
|
|
return const SettingEmpty(
|
|
message: '设备尚未绑定,请先在“基本信息”中完成绑定',
|
|
);
|
|
}
|
|
return _buildDetail(context, type);
|
|
}),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildDetail(BuildContext context, SettingMenuType type) {
|
|
return switch (type) {
|
|
SettingMenuType.baseInfo => settingBaseInfo(context),
|
|
SettingMenuType.backup => settingBackup(context),
|
|
SettingMenuType.syncSetting => settingSync(context),
|
|
SettingMenuType.paySetting => settingPay(context),
|
|
SettingMenuType.faceSetting => settingFace(context),
|
|
SettingMenuType.productSetting => settingProduct(context),
|
|
SettingMenuType.versionSetting => settingVersionSetting(context),
|
|
};
|
|
}
|
|
}
|
|
|
|
SvgAsset _menuIcon(SettingMenuType type) {
|
|
return switch (type) {
|
|
SettingMenuType.baseInfo => FAssets.icons.settings,
|
|
SettingMenuType.backup => FAssets.icons.databaseBackup,
|
|
SettingMenuType.syncSetting => FAssets.icons.refreshCw,
|
|
SettingMenuType.paySetting => FAssets.icons.creditCard,
|
|
SettingMenuType.faceSetting => FAssets.icons.scanFace,
|
|
SettingMenuType.productSetting => FAssets.icons.package,
|
|
SettingMenuType.versionSetting => FAssets.icons.rocket,
|
|
};
|
|
}
|
|
|
|
String _menuDescription(SettingMenuType type) {
|
|
return switch (type) {
|
|
SettingMenuType.baseInfo => '查看终端身份、绑定状态和字体显示设置',
|
|
SettingMenuType.backup => '查看备份路径并导出本地数据库和日志',
|
|
SettingMenuType.syncSetting => '手动刷新设备、长连接、分类、商品和离线订单',
|
|
SettingMenuType.paySetting => '配置允许使用的支付方式和默认支付方式',
|
|
SettingMenuType.faceSetting => '查询、同步和维护本地人脸样本',
|
|
SettingMenuType.productSetting => '查询本地商品、同步分类商品和维护默认菜品',
|
|
SettingMenuType.versionSetting => '查看可用终端版本、更新内容和下载状态',
|
|
};
|
|
}
|