|
|
|
@ -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),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|