app-starlock/star_lock/lib/tools/showCupertinoAlertView.dart
Daisy cbae36bd97 1,封装身份证信息和真实姓名输入框及确认框
2,新增更新电子钥匙实名认证信息接口对接
3,电子钥匙详情修改实名认证状态/身份证号/真实姓名的逻辑处理
2024-05-09 11:01:38 +08:00

224 lines
6.7 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/appRouters.dart';
import 'package:star_lock/app_settings/app_colors.dart';
typedef AuthInfoCallback = void Function(String idCard, String name);
class ShowCupertinoAlertView {
//高级功能弹窗
void advancedFeatureAlert() {
showCupertinoDialog(
context: Get.context!,
builder: (context) {
return CupertinoAlertDialog(
title: Container(
margin: EdgeInsets.only(bottom: 20.h),
child: Image.asset(
'images/icon_gift.png',
width: 50.w,
height: 50.w,
),
),
content: Text('该功能是高级功能,请开通后再使用'.tr),
actions: [
CupertinoDialogAction(
child: Text(
'取消'.tr,
style: TextStyle(color: AppColors.mainColor),
),
onPressed: () {
Get.back();
},
),
CupertinoDialogAction(
child: Text(
'去开通'.tr,
style: TextStyle(color: AppColors.mainColor),
),
onPressed: () async {
Get.toNamed(Routers.advancedFeaturesWebPage,
arguments: {'isShop': true});
},
),
],
);
});
}
//高级功能顶部提示框
Widget topTipsAdvancedFeatures(String tipsText) {
return Container(
color: AppColors.vipFeatureBgColor,
padding: EdgeInsets.only(left: 20.w),
height: 80.h,
child: Row(
children: [
Text(tipsText,
style: TextStyle(
color: AppColors.vipFeatureBtnTextColor, fontSize: 22.sp)),
SizedBox(
width: 10.w,
),
SizedBox(
width: 146.w,
height: 46.h,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: AppColors.vipFeatureBtnBgColor,
),
onPressed: () {
Get.toNamed(Routers.advancedFeaturesWebPage, arguments: {
'isShop': true,
});
},
child: Text(
'去开通'.tr,
style: TextStyle(color: Colors.white, fontSize: 22.sp),
)),
),
Expanded(
child: SizedBox(
width: 2.w,
))
],
),
);
}
//发送需要实名认证的电子钥匙时身份信息确认框
void realNameIDCardInfoComfirmAlert(
{required String getNameStr,
required String getIDCardStr,
required VoidCallback onConfirm}) {
showCupertinoDialog(
context: Get.context!,
builder: (context) {
return CupertinoAlertDialog(
title: Text('请确认姓名全名和身份证号码是否正确'.tr),
content: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 10.h,
),
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
'姓名 ',
style: TextStyle(fontSize: 22.sp, color: Colors.black),
),
Text(
'身份证',
style: TextStyle(fontSize: 22.sp, color: Colors.black),
)
],
),
SizedBox(
width: 10.w,
),
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
getNameStr,
style: TextStyle(fontSize: 22.sp, color: Colors.black),
),
Text(
getIDCardStr,
style: TextStyle(fontSize: 22.sp, color: Colors.black),
)
],
)
],
),
actions: [
CupertinoDialogAction(
child: Text(
'取消'.tr,
style: TextStyle(color: AppColors.mainColor),
),
onPressed: () {
Get.back();
},
),
CupertinoDialogAction(
child: Text(
'确定'.tr,
style: TextStyle(color: AppColors.mainColor),
),
onPressed: () async {
// 执行回调函数
onConfirm();
Get.back();
},
),
],
);
});
}
//打开实名认证弹出输入身份证信息框
void showOpenAuthWithIDCardInfoAlert(AuthInfoCallback callback) {
showCupertinoDialog(
context: Get.context!,
builder: (BuildContext context) {
String idCard = '';
String name = '';
return CupertinoAlertDialog(
title: const Text('请输入身份证号和真实姓名'),
content: Column(
children: <Widget>[
SizedBox(
height: 10.h,
),
CupertinoTextField(
placeholder: '请输入身份证号',
onChanged: (value) {
idCard = value;
},
),
SizedBox(
height: 10.h,
),
CupertinoTextField(
placeholder: '请输入真实姓名',
onChanged: (value) {
name = value;
},
),
],
),
actions: <Widget>[
CupertinoDialogAction(
onPressed: () {
Get.back();
},
child: Text(
'取消'.tr,
style: TextStyle(color: AppColors.mainColor),
),
),
CupertinoDialogAction(
onPressed: () {
// 在这里处理确认按钮的逻辑
callback(idCard, name);
Get.back();
},
child: Text(
'确定'.tr,
style: TextStyle(color: AppColors.mainColor),
),
),
],
);
},
);
}
}