|
|
@ -6,6 +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:url_launcher/url_launcher_string.dart';
|
|
|
|
import 'package:url_launcher/url_launcher_string.dart';
|
|
|
|
|
|
|
|
|
|
|
|
enum ForceUpgrade {
|
|
|
|
enum ForceUpgrade {
|
|
|
@ -64,8 +65,8 @@ class AppUpgrade {
|
|
|
|
onWillPop: () async {
|
|
|
|
onWillPop: () async {
|
|
|
|
return akuAppVersion.forceEM != ForceUpgrade.force;
|
|
|
|
return akuAppVersion.forceEM != ForceUpgrade.force;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
child: upgradeDialog(context,
|
|
|
|
child: upgradeDialog(
|
|
|
|
packageInfo: packageInfo, onLaunchFail: onLaunchFail));
|
|
|
|
context, packageInfo, onLaunchFail, akuAppVersion));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -73,44 +74,101 @@ class AppUpgrade {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget upgradeDialog(
|
|
|
|
upgradeDialog(BuildContext context, PackageInfo packageInfo,
|
|
|
|
BuildContext context, {
|
|
|
|
Function()? onLaunchFail, AkuAppVersion akuAppVersion) {
|
|
|
|
required PackageInfo packageInfo,
|
|
|
|
|
|
|
|
Function()? onLaunchFail,
|
|
|
|
|
|
|
|
}) {
|
|
|
|
|
|
|
|
return Center(
|
|
|
|
return Center(
|
|
|
|
child: Material(
|
|
|
|
child: Material(
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.circular(16),
|
|
|
|
child: Container(
|
|
|
|
child: Container(
|
|
|
|
width: 200,
|
|
|
|
width: 300,
|
|
|
|
height: 200,
|
|
|
|
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(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
const Text('当前不是最新版本,请升级最新版'),
|
|
|
|
const Padding(
|
|
|
|
Row(
|
|
|
|
padding: EdgeInsets.all(32),
|
|
|
|
children: [
|
|
|
|
child: Text(
|
|
|
|
TextButton(
|
|
|
|
'当前不是最新版本\n请升级最新版',
|
|
|
|
onPressed: () {
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
Navigator.pop(context);
|
|
|
|
style: TextStyle(
|
|
|
|
},
|
|
|
|
color: Colors.black,
|
|
|
|
child: Text('取消'),
|
|
|
|
fontSize: 24,
|
|
|
|
),
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
TextButton(
|
|
|
|
),
|
|
|
|
onPressed: () async {
|
|
|
|
),
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
const Spacer(),
|
|
|
|
var re = await launchUrlString(
|
|
|
|
Container(
|
|
|
|
'market://detail?id=${packageInfo.packageName}');
|
|
|
|
height: 1,
|
|
|
|
if (!re && onLaunchFail != null) {
|
|
|
|
width: double.infinity,
|
|
|
|
onLaunchFail.call();
|
|
|
|
color: Colors.black.withOpacity(0.45),
|
|
|
|
}
|
|
|
|
),
|
|
|
|
} else if (Platform.isIOS) {
|
|
|
|
SizedBox(
|
|
|
|
launchUrlString(
|
|
|
|
height: 50,
|
|
|
|
'itms-apps://itunes.apple.com/app/${packageInfo.packageName}');
|
|
|
|
child: Row(
|
|
|
|
} else {}
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
},
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
child: Text('去升级'),
|
|
|
|
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),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|