feat:切换flutter版本
This commit is contained in:
1 parent
ee761ccc48
commit
72443f7abf
32 files changed
+536
-375
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:common_utils/common_utils.dart';
|
||||
import 'package:ducafe_ui_core/ducafe_ui_core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -15,31 +16,11 @@ Widget appNetworkImg(
|
||||
double imgHeight = 60,
|
||||
BoxFit fit = BoxFit.cover,
|
||||
}) {
|
||||
return Image.network(
|
||||
src,
|
||||
width: imgWidth,
|
||||
height: imgHeight,
|
||||
fit: fit,
|
||||
loadingBuilder:
|
||||
(BuildContext context, Widget child, ImageChunkEvent? loadingProgress) {
|
||||
if (loadingProgress == null) {
|
||||
return child;
|
||||
} else {
|
||||
return Center(
|
||||
child: SizedBox(
|
||||
width: imgHeight,
|
||||
height: imgHeight,
|
||||
child: CircularProgressIndicator(
|
||||
value: loadingProgress.expectedTotalBytes != null
|
||||
? loadingProgress.cumulativeBytesLoaded /
|
||||
(loadingProgress.expectedTotalBytes ?? 1)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
errorBuilder: (BuildContext context, Object error, StackTrace? stackTrace) {
|
||||
return CachedNetworkImage(
|
||||
imageUrl: AppNetworkTool.ossImage(src),
|
||||
placeholder: (context, url) =>
|
||||
CircularProgressIndicator().width(50.w).height(50.w),
|
||||
errorWidget: (context, url, error) {
|
||||
final theme = FTheme.of(context);
|
||||
return FIcon(
|
||||
FAssets.icons.globeLock,
|
||||
@@ -48,19 +29,6 @@ Widget appNetworkImg(
|
||||
).width(imgWidth * 0.5).height(imgHeight * 0.5);
|
||||
},
|
||||
);
|
||||
// return CachedNetworkImage(
|
||||
// imageUrl: AppNetworkTool.ossImage(src),
|
||||
// placeholder: (context, url) =>
|
||||
// CircularProgressIndicator().width(50.w).height(50.w),
|
||||
// errorWidget: (context, url, error) {
|
||||
// final theme = FTheme.of(context);
|
||||
// return FIcon(
|
||||
// FAssets.icons.globeLock,
|
||||
// color: theme.colorScheme.error,
|
||||
// size: theme.typography.base.fontSize,
|
||||
// ).width(imgWidth * 0.5).height(imgHeight * 0.5);
|
||||
// },
|
||||
// );
|
||||
}
|
||||
|
||||
Widget appFileImg(
|
||||
|
||||
@@ -14,9 +14,6 @@ mixin OrderMixin {
|
||||
|
||||
final appController = Get.find<AppControl>();
|
||||
|
||||
// 路由变化
|
||||
StreamSubscription<GlobalRouter>? routerBus;
|
||||
|
||||
/// **************** start 需要重制 start ****************
|
||||
|
||||
// 时间类型
|
||||
@@ -57,7 +54,7 @@ mixin OrderMixin {
|
||||
);
|
||||
|
||||
// 当前的tab
|
||||
RxInt currentTabIndex = RxInt(0);
|
||||
int currentTabIndex = 0;
|
||||
|
||||
// 购买用户
|
||||
Rxn<ServiceUser?> payUser = Rxn<ServiceUser>(null);
|
||||
@@ -80,11 +77,12 @@ mixin OrderMixin {
|
||||
|
||||
// 点击分类tab
|
||||
Future<void> doTab(int i) async {
|
||||
if (currentTabIndex == i) return;
|
||||
EasyLoading.show(
|
||||
status: '切换中...',
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
);
|
||||
currentTabIndex.value = i;
|
||||
currentTabIndex = i;
|
||||
if (i <= classifyList.length - 1) {
|
||||
final current = classifyList[i];
|
||||
await getProduct(classifyCode: current.serviceUniqueCode);
|
||||
@@ -113,12 +111,11 @@ mixin OrderMixin {
|
||||
),
|
||||
);
|
||||
classifyList.value = list;
|
||||
classifyList.refresh();
|
||||
}
|
||||
|
||||
// 获取商品
|
||||
Future<void> getProduct({
|
||||
String classifyCode = "-1",
|
||||
}) async {
|
||||
Future<void> getProduct({String classifyCode = "-1"}) async {
|
||||
final list = await appController.dataBase.getProductDao.getAll(
|
||||
classifyCode,
|
||||
hourType.value.code,
|
||||
@@ -401,9 +398,7 @@ mixin OrderMixin {
|
||||
|
||||
/// **************** start 副屏幕相关 start ****************
|
||||
|
||||
void putOffSendSubScreen({
|
||||
int seconds = 5,
|
||||
}) {
|
||||
void putOffSendSubScreen({int seconds = 5}) {
|
||||
if (putOffSendSubScreenDelayed != null) {
|
||||
sendSubScreen();
|
||||
putOffSendSubScreenDelayed = null;
|
||||
@@ -432,18 +427,6 @@ mixin OrderMixin {
|
||||
|
||||
/// **************** end 副屏幕相关 end ****************
|
||||
|
||||
/// **************** start 路由变化相关 start ****************
|
||||
listenRouter() {
|
||||
routerBus = GlobalRouteObserver.globalRouteObserverBus
|
||||
.on<GlobalRouter>()
|
||||
.listen((event) {
|
||||
if (event.action == RouterActionType.didPop &&
|
||||
event.name == RouteNames.faceDiscern) {}
|
||||
});
|
||||
}
|
||||
|
||||
/// **************** end 路由变化相关 end ****************
|
||||
|
||||
// 生成安卓唯一的code
|
||||
Future<String> _getUniqueCode() async {
|
||||
String code = "";
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:ducafe_ui_core/ducafe_ui_core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:forui/forui.dart';
|
||||
@@ -148,3 +150,37 @@ Widget orderSelectPanel(
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget orderRowClassify(
|
||||
BuildContext context, {
|
||||
required List<ClassifyEntity> classifyList,
|
||||
required Function(int) onChange,
|
||||
int currentTabIndex = 0,
|
||||
}) {
|
||||
final theme = FTheme.of(context);
|
||||
return classifyList
|
||||
.map((v) {
|
||||
final target = classifyList[currentTabIndex];
|
||||
final active = target.id == v.id;
|
||||
return FButton(
|
||||
style: active ? FButtonStyle.primary : FButtonStyle.secondary,
|
||||
label: Text(
|
||||
v.name,
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: theme.typography.xl.copyWith(
|
||||
color: active
|
||||
? theme.colorScheme.secondary
|
||||
: theme.colorScheme.primary,
|
||||
),
|
||||
).center().width(120.w),
|
||||
onPress: () {
|
||||
final index = classifyList.indexWhere((i) => i.id == v.id);
|
||||
onChange(index);
|
||||
},
|
||||
);
|
||||
})
|
||||
.toList()
|
||||
.toRowSpace(space: 20.w);
|
||||
}
|
||||
@@ -12,6 +12,8 @@ import 'package:get/get.dart';
|
||||
import 'package:pj_supermarket_cloud/common/index.dart';
|
||||
|
||||
class SelectPayTypeDialogController extends GetxController {
|
||||
SelectPayTypeDialogController();
|
||||
|
||||
/// **************** start 回调函数 start ****************
|
||||
|
||||
// |开始识别|的回调
|
||||
@@ -114,16 +116,16 @@ class SelectPayTypeDialogController extends GetxController {
|
||||
}
|
||||
|
||||
// |开始识别|点击
|
||||
doRecognition() {
|
||||
Future<void> doRecognition() async {
|
||||
switch (orderPayDisplayType.value) {
|
||||
case OrderPayDisplayType.qrCode:
|
||||
_dispatchQrCode();
|
||||
await _dispatchQrCode();
|
||||
break;
|
||||
case OrderPayDisplayType.walletCard:
|
||||
_dispatchWalletCard();
|
||||
await _dispatchWalletCard();
|
||||
break;
|
||||
case OrderPayDisplayType.face:
|
||||
_dispatchFace();
|
||||
await _dispatchFace();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
@@ -143,7 +145,7 @@ class SelectPayTypeDialogController extends GetxController {
|
||||
globalQrCode,
|
||||
);
|
||||
_closeStatus();
|
||||
Navigator.of(Get.context!, rootNavigator: true).pop();
|
||||
Navigator.of(Get.context!).pop();
|
||||
}
|
||||
|
||||
// |取消|点击
|
||||
@@ -151,18 +153,18 @@ class SelectPayTypeDialogController extends GetxController {
|
||||
if (isRecognition.value) {
|
||||
final flag = await appMessageDialog(Get.context!, "是否取消识别");
|
||||
if (!flag) return;
|
||||
Navigator.of(Get.context!, rootNavigator: true).pop();
|
||||
Navigator.of(Get.context!).pop();
|
||||
return;
|
||||
}
|
||||
_closeStatus();
|
||||
onCancel?.call();
|
||||
Navigator.of(Get.context!, rootNavigator: true).pop();
|
||||
Navigator.of(Get.context!).pop();
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// 二维码识别 start
|
||||
// **************************************************************************
|
||||
void _dispatchQrCode() async {
|
||||
Future<void> _dispatchQrCode() async {
|
||||
try {
|
||||
if (isRecognition.value) {
|
||||
Toast.error(msg: "正在识别中,请勿重复点击");
|
||||
@@ -229,7 +231,7 @@ class SelectPayTypeDialogController extends GetxController {
|
||||
// **************************************************************************
|
||||
// 饭卡识别 start
|
||||
// **************************************************************************
|
||||
void _dispatchWalletCard() async {
|
||||
Future<void> _dispatchWalletCard() async {
|
||||
if (isRecognition.value) {
|
||||
Toast.error(msg: "正在识别中,请勿重复点击");
|
||||
return;
|
||||
@@ -302,9 +304,8 @@ class SelectPayTypeDialogController extends GetxController {
|
||||
// **************************************************************************
|
||||
// 人脸支付 start
|
||||
// **************************************************************************
|
||||
void _dispatchFace() async {
|
||||
Future<void> _dispatchFace() async {
|
||||
try {
|
||||
EasyLoading.dismiss();
|
||||
EasyLoading.show(
|
||||
status: '人脸识别准备中...',
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
@@ -312,13 +313,15 @@ class SelectPayTypeDialogController extends GetxController {
|
||||
final faceDao = app.dataBase.getFaceDao;
|
||||
final databaseFaceCount = await faceDao.findCount("-1");
|
||||
if (databaseFaceCount == null || databaseFaceCount == 0) {
|
||||
Toast.error(msg: "人脸数据库为空,请前往'设置'->'人脸管理'点击同步人脸");
|
||||
throw Error();
|
||||
String msg = "人脸数据库为空,请前往'设置'->'人脸管理'点击同步人脸";
|
||||
Toast.error(msg: msg);
|
||||
throw Exception(msg);
|
||||
}
|
||||
final isActive = await AppFaceTool.isActiveSdk();
|
||||
if (!isActive) {
|
||||
Toast.error(msg: "请检查激人脸sdk激活码");
|
||||
throw Error();
|
||||
String msg = "请检查激人脸sdk激活码";
|
||||
Toast.error(msg: msg);
|
||||
throw Exception(msg);
|
||||
}
|
||||
final faceCount = await FaceDiscernPlugs.getFaceCount();
|
||||
if (faceCount == 0) {
|
||||
@@ -326,8 +329,9 @@ class SelectPayTypeDialogController extends GetxController {
|
||||
}
|
||||
final isJump = await AppFaceTool.jumpFacePage();
|
||||
if (!isJump) {
|
||||
Toast.error(msg: "跳转到人脸检测页面失败");
|
||||
throw Error();
|
||||
String msg = "跳转到人脸检测页面失败";
|
||||
Toast.error(msg: msg);
|
||||
throw Exception(msg);
|
||||
}
|
||||
faceDiscernListen = FaceDiscernPlugs.faceStream.listen((event) {
|
||||
if (event == null) return;
|
||||
@@ -342,6 +346,7 @@ class SelectPayTypeDialogController extends GetxController {
|
||||
SubScreenPlugin.doubleScreenShow();
|
||||
});
|
||||
} catch (e) {
|
||||
logger.e("|$_tag|跳转人脸识别页面,意外的错误error:|$e|");
|
||||
EasyLoading.dismiss();
|
||||
}
|
||||
}
|
||||
@@ -418,12 +423,11 @@ class SelectPayTypeDialogController extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> selectPayTypeDialog() async {
|
||||
final context = Get.context!;
|
||||
final payTypeC = Get.find<SelectPayTypeDialogController>();
|
||||
payTypeC.initPayType();
|
||||
final theme = FTheme.of(context);
|
||||
final width = context.width;
|
||||
final height = context.height;
|
||||
final theme = FTheme.of(Get.context!);
|
||||
final width = Get.context!.width;
|
||||
final height = Get.context!.height;
|
||||
return showDialog(
|
||||
context: Get.context!,
|
||||
barrierDismissible: false,
|
||||
@@ -467,14 +471,8 @@ Future<void> selectPayTypeDialog() async {
|
||||
Obx(
|
||||
() => Visibility(
|
||||
visible: payTypeC.payUser.value == null,
|
||||
replacement: selectPayTypeUser(
|
||||
context,
|
||||
payTypeC.payUser.value,
|
||||
),
|
||||
child: selectPayTypeHint(
|
||||
context,
|
||||
payTypeC.orderPayDisplayType.value,
|
||||
),
|
||||
replacement: selectPayTypeUser(payTypeC.payUser.value),
|
||||
child: selectPayTypeHint(payTypeC.orderPayDisplayType.value),
|
||||
),
|
||||
).center().expanded(),
|
||||
].toColumn().width(width * 0.5).height(height * 0.6),
|
||||
@@ -518,8 +516,8 @@ Future<void> selectPayTypeDialog() async {
|
||||
);
|
||||
}
|
||||
|
||||
Widget selectPayTypeUser(BuildContext context, ServiceUser? user) {
|
||||
final theme = FTheme.of(context);
|
||||
Widget selectPayTypeUser(ServiceUser? user) {
|
||||
final theme = FTheme.of(Get.context!);
|
||||
if (user == null) return const SizedBox.shrink();
|
||||
final isFree = user.walletIsFreeze ?? true;
|
||||
final textStyle = theme.typography.xl;
|
||||
@@ -545,7 +543,7 @@ Widget selectPayTypeUser(BuildContext context, ServiceUser? user) {
|
||||
style: titleTheme,
|
||||
prefixIcon: FIcon(FAssets.icons.badgeDollarSign),
|
||||
title: Text('余额', style: textStyle),
|
||||
details: appPrice(context, user.walletBalance),
|
||||
details: appPrice(Get.context!, user.walletBalance),
|
||||
),
|
||||
FTile(
|
||||
style: titleTheme,
|
||||
@@ -564,8 +562,8 @@ Widget selectPayTypeUser(BuildContext context, ServiceUser? user) {
|
||||
.height(double.infinity);
|
||||
}
|
||||
|
||||
Widget selectPayTypeHint(BuildContext context, OrderPayDisplayType? type) {
|
||||
final theme = FTheme.of(context);
|
||||
Widget selectPayTypeHint(OrderPayDisplayType? type) {
|
||||
final theme = FTheme.of(Get.context!);
|
||||
if (type == null) return const SizedBox.shrink();
|
||||
const baseMsg = "请点击开始识别按钮";
|
||||
String msg = "";
|
||||
|
||||
Reference in new issue
Block a user