Quellcode durchsuchen

7.3 修改保存二维码样式 缺一张图

hudaqiang vor 4 Jahren
Ursprung
Commit
1a55a7d651

+ 80 - 43
lib/paegs/gang_page/qr_code_for_store_payment_page/qr_code_for_store_payment_page.dart

@@ -31,44 +31,7 @@ class _QRCodeForStorePaymentPageState extends State<QRCodeForStorePaymentPage> {
     return Scaffold(
       body: Stack(
         children: [
-          RepaintBoundary(
-            key: rootWidgetKey,
-            child: Container(
-              child: Column(children: [
-                Container(
-                  child: Image.asset(
-                    'images/logo.png',
-                    height: 86,
-                  ),
-                ),
-                Container(height: 80,),
-                Container(
-                  height: 240,
-                  width: 240,
-                  padding: EdgeInsets.all(10),
-                  decoration: BoxDecoration(
-                      borderRadius: BorderRadius.circular(9.6),
-                      color: Colors.white),
-                  child: QrImage(
-                    data:
-                    'http://www.banghuo.net/bby/pay/pay.html?shop_uid=${widget.data.shopUid}',
-                    gapless: false,
-                    version: QrVersions.auto,
-                    size: 216.0,
-                  ),
-                ),
-              ],mainAxisAlignment: MainAxisAlignment.center,),
-              decoration: BoxDecoration(
-                gradient: LinearGradient(
-                    colors: MyColors.lg2,
-                    begin: Alignment.topCenter,
-                    end: Alignment.bottomCenter),
-                // color: Colors.yellow
-              ),
-              height: MediaQuery.of(context).size.width * 1.5,
-              width: MediaQuery.of(context).size.width,
-            ),
-          ),
+          savePic(context),
           Container(
             decoration: BoxDecoration(
               gradient: LinearGradient(
@@ -125,7 +88,7 @@ class _QRCodeForStorePaymentPageState extends State<QRCodeForStorePaymentPage> {
                         Container(
                           height: 240,
                           width: 240,
-                          padding:EdgeInsets.all(10),
+                          padding: EdgeInsets.all(10),
                           decoration: BoxDecoration(
                               borderRadius: BorderRadius.circular(9.6),
                               color: Colors.white),
@@ -134,7 +97,7 @@ class _QRCodeForStorePaymentPageState extends State<QRCodeForStorePaymentPage> {
                                 'http://www.banghuo.net/bby/pay/pay.html?shop_uid=${widget.data.shopUid}',
                             gapless: false,
                             version: QrVersions.auto,
-                            size:  216,
+                            size: 216,
                           ),
                         ),
                       ],
@@ -166,6 +129,81 @@ class _QRCodeForStorePaymentPageState extends State<QRCodeForStorePaymentPage> {
     );
   }
 
+  RepaintBoundary savePic(BuildContext context) {
+    //970/1450
+    return RepaintBoundary(
+      key: rootWidgetKey,
+      child: Container(
+        width: MediaQuery.of(context).size.width,
+        height: MediaQuery.of(context).size.width / 97 * 145,
+        child: Column(
+          children: [
+            //260
+            Expanded(
+              flex: 26,
+              child: Container(
+                width: MediaQuery.of(context).size.width,
+                color: Colors.white,
+                child: Text(
+                  '梆梆鱼',
+                  style: TextStyle(
+                      color: MyColors.cFF4233,
+                      fontSize: MediaQuery.of(context).size.width / 97 * 10,
+                      fontWeight: FontWeight.bold),
+                ),
+                alignment: Alignment.center,
+              ),
+            ),
+            Expanded(
+              flex: 119,
+              child: Container(
+                width: MediaQuery.of(context).size.width,
+                child: Column(
+                  children: [
+                    //575
+                    Container(
+                      margin: EdgeInsets.only(
+                          bottom: MediaQuery.of(context).size.width / 97 * 6),
+                      height: MediaQuery.of(context).size.width / 97 * 57.5,
+                      width: MediaQuery.of(context).size.width / 97 * 57.5,
+                      padding: EdgeInsets.all(2),
+                      decoration: BoxDecoration(
+                          borderRadius: BorderRadius.circular(9.6),
+                          color: Colors.white),
+                      child: QrImage(
+                        data:
+                            'http://www.banghuo.net/bby/pay/pay.html?shop_uid=${widget.data.shopUid}',
+                        gapless: false,
+                        version: QrVersions.auto,
+                        size: MediaQuery.of(context).size.width / 97 * 57.5,
+                      ),
+                    ),
+                    //42
+                    Text(
+                      '支付宝或微信扫一扫进行付款',
+                      style: TextStyle(
+                          color: Colors.white,
+                          fontSize:
+                              MediaQuery.of(context).size.width / 97 * 4.2),
+                    )
+                  ],
+                  mainAxisAlignment: MainAxisAlignment.center,
+                ),
+                decoration: BoxDecoration(
+                  gradient: LinearGradient(
+                      colors: MyColors.lg2,
+                      begin: Alignment.topCenter,
+                      end: Alignment.bottomCenter),
+                  // color: Colors.yellow
+                ),
+              ),
+            ),
+          ],
+        ),
+      ),
+    );
+  }
+
   Future<Uint8List> _capturePng() async {
     try {
       RenderRepaintBoundary boundary =
@@ -176,9 +214,8 @@ class _QRCodeForStorePaymentPageState extends State<QRCodeForStorePaymentPage> {
       final result = await ImageGallerySaver.saveImage(pngBytes,
           name: 'bby_${DateTime.now()}');
       print('======================|\n$result\n|===========================');
-      SaveImageBeanEntity entity =
-          SaveImageBeanEntity().fromJson(json.decode(result));
-      showToast(entity.isSuccess ? '保存成功' : '保存失败');
+      bool isSuccess = result.toString().contains('isSuccess: true');
+      showToast(isSuccess ? '保存成功,请前往相册查看': '保存失败');
       return pngBytes;
     } catch (e) {
       print(e);