From b97acacbeba7730fadc646466407cd4da8196229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=90=8C?= <494089941@qq.com> Date: Thu, 2 Jun 2022 17:03:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/aku_app_upgrade.dart | 126 ++++++++++++++++++++++++++++----------- 1 file changed, 92 insertions(+), 34 deletions(-) diff --git a/lib/aku_app_upgrade.dart b/lib/aku_app_upgrade.dart index 8fd4791..47ed7cb 100644 --- a/lib/aku_app_upgrade.dart +++ b/lib/aku_app_upgrade.dart @@ -6,6 +6,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:dio/dio.dart'; +import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher_string.dart'; enum ForceUpgrade { @@ -64,8 +65,8 @@ class AppUpgrade { onWillPop: () async { return akuAppVersion.forceEM != ForceUpgrade.force; }, - child: upgradeDialog(context, - packageInfo: packageInfo, onLaunchFail: onLaunchFail)); + child: upgradeDialog( + context, packageInfo, onLaunchFail, akuAppVersion)); }); } } else { @@ -73,44 +74,101 @@ class AppUpgrade { } } - Widget upgradeDialog( - BuildContext context, { - required PackageInfo packageInfo, - Function()? onLaunchFail, - }) { + upgradeDialog(BuildContext context, PackageInfo packageInfo, + Function()? onLaunchFail, AkuAppVersion akuAppVersion) { return Center( child: Material( + borderRadius: BorderRadius.circular(16), child: Container( - width: 200, + width: 300, height: 200, - decoration: BoxDecoration(borderRadius: BorderRadius.circular(16)), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + // gradient: LinearGradient(colors: [ + // Colors.yellow.withOpacity(0.05), + // Colors.white, + // ], begin: Alignment.topCenter, end: Alignment.bottomCenter), + color: Colors.white, + boxShadow: const [ + BoxShadow( + color: Colors.blue, + blurRadius: 5, + spreadRadius: 0, + ) + ]), child: Column( children: [ - const Text('当前不是最新版本,请升级最新版'), - Row( - children: [ - TextButton( - onPressed: () { - Navigator.pop(context); - }, - child: Text('取消'), - ), - TextButton( - onPressed: () async { - if (Platform.isAndroid) { - var re = await launchUrlString( - 'market://detail?id=${packageInfo.packageName}'); - if (!re && onLaunchFail != null) { - onLaunchFail.call(); - } - } else if (Platform.isIOS) { - launchUrlString( - 'itms-apps://itunes.apple.com/app/${packageInfo.packageName}'); - } else {} - }, - child: Text('去升级'), - ) - ], + const Padding( + padding: EdgeInsets.all(32), + child: Text( + '当前不是最新版本\n请升级最新版', + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.black, + fontSize: 24, + fontWeight: FontWeight.bold), + ), + ), + const Spacer(), + Container( + height: 1, + width: double.infinity, + color: Colors.black.withOpacity(0.45), + ), + SizedBox( + height: 50, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + if (akuAppVersion.forceEM != ForceUpgrade.force) + Expanded( + child: TextButton( + onPressed: () { + Navigator.pop(context); + }, + child: const Text( + '取消', + style: TextStyle( + color: Colors.black, + fontSize: 20, + fontWeight: FontWeight.normal), + ), + ), + ), + Offstage( + offstage: akuAppVersion.forceEM == ForceUpgrade.force, + child: Container( + height: double.infinity, + width: 1, + color: Colors.black.withOpacity(0.45), + ), + ), + Expanded( + child: TextButton( + onPressed: () async { + if (Platform.isAndroid) { + var re = await launchUrlString( + 'mimarket://detail?id=${packageInfo.packageName}'); + if (!re && onLaunchFail != null) { + onLaunchFail.call(); + } + } else if (Platform.isIOS) { + launchUrlString( + 'itms-apps://itunes.apple.com/app/${packageInfo.packageName}'); + } else {} + }, + child: const Text( + '去升级', + style: TextStyle( + color: Colors.black, + fontSize: 20, + fontWeight: FontWeight.normal), + ), + ), + ) + ], + ), ), ], ),