From 148541bcb298434ab64ccb74f14d65e3781a3076 Mon Sep 17 00:00:00 2001 From: Liuyf Date: Wed, 19 Feb 2025 16:01:58 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E9=97=A8?= =?UTF-8?q?=E9=93=83=E7=A0=81=E4=BF=9D=E5=AD=98=E5=90=8E=E6=98=AF=E9=BB=91?= =?UTF-8?q?=E8=89=B2=E5=9B=BE=E7=89=87=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tools/showCupertinoAlertView.dart | 43 +++++++++++++++------------ 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/lib/tools/showCupertinoAlertView.dart b/lib/tools/showCupertinoAlertView.dart index 9b303167..d973cc78 100755 --- a/lib/tools/showCupertinoAlertView.dart +++ b/lib/tools/showCupertinoAlertView.dart @@ -2,6 +2,7 @@ import 'dart:typed_data'; import 'dart:ui'; import 'package:flutter/cupertino.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; @@ -54,7 +55,7 @@ class ShowCupertinoAlertView { child: Text( '${"开启微信接收报警消息需要先关注".tr}$qrCodeText${"微信公众号,请保存二维码并使用微信扫一扫设置".tr}', style: - TextStyle(fontSize: 24.sp, color: Colors.black), + TextStyle(fontSize: 24.sp, color: Colors.black), )), SizedBox( height: 60.h, @@ -159,8 +160,8 @@ class ShowCupertinoAlertView { //发送需要实名认证的电子钥匙时身份信息确认框 void realNameIDCardInfoComfirmAlert( {required String getNameStr, - required String getIDCardStr, - required VoidCallback onConfirm}) { + required String getIDCardStr, + required VoidCallback onConfirm}) { showCupertinoDialog( context: Get.context!, builder: (context) { @@ -340,7 +341,7 @@ class ShowCupertinoAlertView { ), CupertinoDialogAction( child: - Text('购买'.tr, style: TextStyle(color: AppColors.mainColor)), + Text('购买'.tr, style: TextStyle(color: AppColors.mainColor)), onPressed: () { Get.back(); sureClick(); @@ -391,7 +392,7 @@ class ShowCupertinoAlertView { ), CupertinoDialogAction( child: - Text('删除'.tr, style: TextStyle(color: AppColors.mainColor)), + Text('删除'.tr, style: TextStyle(color: AppColors.mainColor)), onPressed: () { Get.back(); clearClick(); @@ -406,8 +407,8 @@ class ShowCupertinoAlertView { //可视门铃二维码弹窗 void showVisualDoorbellCodeAlert( {required BuildContext widgetContext, - required String qrCodeUrl, - required String qrCodeText}) { + required String qrCodeUrl, + required String qrCodeText}) { showCupertinoModalPopup( context: widgetContext, builder: (BuildContext context) { @@ -447,7 +448,7 @@ class ShowCupertinoAlertView { child: Text( qrCodeText, style: - TextStyle(fontSize: 24.sp, color: Colors.black), + TextStyle(fontSize: 24.sp, color: Colors.black), )), Container( margin: EdgeInsets.only(left: 60.w, right: 60.w), @@ -456,29 +457,33 @@ class ShowCupertinoAlertView { onClick: () async { // 截图并保存到相册 try { + final Color qrcodeStyleColor = + defaultTargetPlatform == TargetPlatform.iOS + ? const Color(0xFF000000) + : Colors.white; final QrPainter painter = QrPainter( data: qrCodeUrl, version: QrVersions.auto, gapless: false, errorCorrectionLevel: QrErrorCorrectLevel.L, - eyeStyle: const QrEyeStyle( + eyeStyle: QrEyeStyle( eyeShape: QrEyeShape.square, - color: Colors.white, + color: qrcodeStyleColor, ), - dataModuleStyle: const QrDataModuleStyle( + dataModuleStyle: QrDataModuleStyle( dataModuleShape: QrDataModuleShape.square, - color: Colors.white, + color: qrcodeStyleColor, )); final ByteData? byteData = - await painter.toImageData(600.0, - format: ImageByteFormat.png); + await painter.toImageData(600.0, + format: ImageByteFormat.png); final Uint8List pngBytes = - byteData!.buffer.asUint8List(); + byteData!.buffer.asUint8List(); final result = - await ImageGallerySaver.saveImage( - Uint8List.fromList(pngBytes), - quality: 100, - name: 'qr_code'); + await ImageGallerySaver.saveImage( + Uint8List.fromList(pngBytes), + quality: 100, + name: 'qr_code'); if (result['isSuccess']) { EasyLoading.showToast('保存成功'.tr); } else {