添加 r_upgrade

修改弹窗
master
张萌 2 years ago
parent b97acacbeb
commit 9676d13777

@ -4,10 +4,4 @@ package_info_plus_linux=/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/pack
package_info_plus_macos=/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/package_info_plus_macos-1.3.0/ package_info_plus_macos=/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/package_info_plus_macos-1.3.0/
package_info_plus_web=/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/package_info_plus_web-1.0.5/ package_info_plus_web=/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/package_info_plus_web-1.0.5/
package_info_plus_windows=/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/package_info_plus_windows-1.0.5/ package_info_plus_windows=/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/package_info_plus_windows-1.0.5/
url_launcher=/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.1.2/ r_upgrade=/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/r_upgrade-0.3.8+2/
url_launcher_android=/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/url_launcher_android-6.0.17/
url_launcher_ios=/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/url_launcher_ios-6.0.17/
url_launcher_linux=/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-3.0.1/
url_launcher_macos=/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-3.0.1/
url_launcher_web=/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-2.0.11/
url_launcher_windows=/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/url_launcher_windows-3.0.1/

@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"package_info_plus","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/package_info_plus-1.4.2/","native_build":true,"dependencies":[]},{"name":"url_launcher_ios","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/url_launcher_ios-6.0.17/","native_build":true,"dependencies":[]}],"android":[{"name":"package_info_plus","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/package_info_plus-1.4.2/","native_build":true,"dependencies":[]},{"name":"url_launcher_android","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/url_launcher_android-6.0.17/","native_build":true,"dependencies":[]}],"macos":[{"name":"package_info_plus_macos","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/package_info_plus_macos-1.3.0/","native_build":true,"dependencies":[]},{"name":"url_launcher_macos","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-3.0.1/","native_build":true,"dependencies":[]}],"linux":[{"name":"package_info_plus_linux","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/package_info_plus_linux-1.0.5/","native_build":false,"dependencies":[]},{"name":"url_launcher_linux","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-3.0.1/","native_build":true,"dependencies":[]}],"windows":[{"name":"package_info_plus_windows","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/package_info_plus_windows-1.0.5/","native_build":false,"dependencies":[]},{"name":"url_launcher_windows","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/url_launcher_windows-3.0.1/","native_build":true,"dependencies":[]}],"web":[{"name":"package_info_plus_web","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/package_info_plus_web-1.0.5/","dependencies":[]},{"name":"url_launcher_web","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-2.0.11/","dependencies":[]}]},"dependencyGraph":[{"name":"package_info_plus","dependencies":["package_info_plus_linux","package_info_plus_macos","package_info_plus_windows","package_info_plus_web"]},{"name":"package_info_plus_linux","dependencies":[]},{"name":"package_info_plus_macos","dependencies":[]},{"name":"package_info_plus_web","dependencies":[]},{"name":"package_info_plus_windows","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_android","url_launcher_ios","url_launcher_linux","url_launcher_macos","url_launcher_web","url_launcher_windows"]},{"name":"url_launcher_android","dependencies":[]},{"name":"url_launcher_ios","dependencies":[]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2022-06-02 10:29:21.647080","version":"3.0.0"} {"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"package_info_plus","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/package_info_plus-1.4.2/","native_build":true,"dependencies":[]},{"name":"r_upgrade","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/r_upgrade-0.3.8+2/","native_build":true,"dependencies":[]}],"android":[{"name":"package_info_plus","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/package_info_plus-1.4.2/","native_build":true,"dependencies":[]},{"name":"r_upgrade","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/r_upgrade-0.3.8+2/","native_build":true,"dependencies":[]}],"macos":[{"name":"package_info_plus_macos","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/package_info_plus_macos-1.3.0/","native_build":true,"dependencies":[]}],"linux":[{"name":"package_info_plus_linux","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/package_info_plus_linux-1.0.5/","native_build":false,"dependencies":[]}],"windows":[{"name":"package_info_plus_windows","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/package_info_plus_windows-1.0.5/","native_build":false,"dependencies":[]}],"web":[{"name":"package_info_plus_web","path":"/Users/zhangmeng/.pub-cache/hosted/pub.dartlang.org/package_info_plus_web-1.0.5/","dependencies":[]}]},"dependencyGraph":[{"name":"package_info_plus","dependencies":["package_info_plus_linux","package_info_plus_macos","package_info_plus_windows","package_info_plus_web"]},{"name":"package_info_plus_linux","dependencies":[]},{"name":"package_info_plus_macos","dependencies":[]},{"name":"package_info_plus_web","dependencies":[]},{"name":"package_info_plus_windows","dependencies":[]},{"name":"r_upgrade","dependencies":[]}],"date_created":"2022-06-07 14:38:49.619690","version":"3.0.0"}

@ -0,0 +1 @@
/Users/zhangmeng/fvm/versions/3.0.0

@ -0,0 +1,4 @@
{
"flutterSdkVersion": "3.0.0",
"flavors": {}
}

@ -6,8 +6,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:package_info_plus/package_info_plus.dart'; import 'package:package_info_plus/package_info_plus.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:r_upgrade/r_upgrade.dart';
import 'package:url_launcher/url_launcher_string.dart';
enum ForceUpgrade { enum ForceUpgrade {
force(1), force(1),
@ -77,100 +76,111 @@ class AppUpgrade {
upgradeDialog(BuildContext context, PackageInfo packageInfo, upgradeDialog(BuildContext context, PackageInfo packageInfo,
Function()? onLaunchFail, AkuAppVersion akuAppVersion) { Function()? onLaunchFail, AkuAppVersion akuAppVersion) {
return Center( return Center(
child: Material( child: Container(
borderRadius: BorderRadius.circular(16), width: 300,
child: Container( height: 200,
width: 300, clipBehavior: Clip.antiAliasWithSaveLayer,
height: 200, decoration: BoxDecoration(
decoration: BoxDecoration( color: Colors.white,
borderRadius: BorderRadius.circular(16), boxShadow: const [
// gradient: LinearGradient(colors: [ BoxShadow(
// Colors.yellow.withOpacity(0.05), color: Colors.blue,
// Colors.white, blurRadius: 5,
// ], begin: Alignment.topCenter, end: Alignment.bottomCenter), spreadRadius: 0,
color: Colors.white, )
boxShadow: const [ ],
BoxShadow( borderRadius: BorderRadius.circular(24),
color: Colors.blue, ),
blurRadius: 5, child: Material(
spreadRadius: 0, child: Container(
) decoration: const BoxDecoration(
]), gradient: LinearGradient(
child: Column( begin: Alignment.topCenter,
children: [ end: Alignment.bottomCenter,
const Padding( stops: [0,0.7],
padding: EdgeInsets.all(32), colors: [
child: Text( Color(0x33FBE541),
'当前不是最新版本\n请升级最新版', Colors.white,
textAlign: TextAlign.center, ])),
style: TextStyle( child: Column(
color: Colors.black, children: [
fontSize: 24, const Padding(
fontWeight: FontWeight.bold), padding: EdgeInsets.all(32),
child: Text(
'当前不是最新版本\n请升级最新版',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black,
fontSize: 22,
fontWeight: FontWeight.bold),
),
),
const Spacer(),
Container(
height: 1,
width: double.infinity,
color: Colors.black.withOpacity(0.45),
), ),
), SizedBox(
const Spacer(), height: 50,
Container( child: Row(
height: 1, crossAxisAlignment: CrossAxisAlignment.center,
width: double.infinity, mainAxisAlignment: MainAxisAlignment.center,
color: Colors.black.withOpacity(0.45), children: [
), if (akuAppVersion.forceEM != ForceUpgrade.force)
SizedBox( Expanded(
height: 50, child: MaterialButton(
child: Row( onPressed: () {
crossAxisAlignment: CrossAxisAlignment.center, Navigator.pop(context);
mainAxisAlignment: MainAxisAlignment.center, },
children: [ child: const Text(
if (akuAppVersion.forceEM != ForceUpgrade.force) '取消',
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( Expanded(
child: TextButton( child: MaterialButton(
onPressed: () { onPressed: () async {
Navigator.pop(context); Navigator.pop(context);
if (Platform.isAndroid) {
var stores = await RUpgrade.androidStores;
if (stores == null || stores.isEmpty) {
onLaunchFail?.call();
return;
}
await RUpgrade.upgradeFromAndroidStore(
stores.first);
} else if (Platform.isIOS) {
await RUpgrade.upgradeFromAppStore(
packageInfo.packageName);
} else {}
}, },
child: const Text( child: const Text(
'取消', '去升级',
style: TextStyle( style: TextStyle(
color: Colors.black, color: Colors.black,
fontSize: 20, fontSize: 20,
fontWeight: FontWeight.normal), 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),
),
),
)
],
), ),
), ],
], ),
), ),
), ),
), ),

@ -11,8 +11,8 @@ dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
package_info_plus: ^1.4.2 package_info_plus: ^1.4.2
url_launcher: ^6.1.2
dio: ^4.0.6 dio: ^4.0.6
r_upgrade: ^0.3.8+2
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

Loading…
Cancel
Save