|
|
@ -8,6 +8,8 @@ import 'package:package_info_plus/package_info_plus.dart';
|
|
|
|
import 'package:dio/dio.dart';
|
|
|
|
import 'package:dio/dio.dart';
|
|
|
|
import 'package:r_upgrade/r_upgrade.dart';
|
|
|
|
import 'package:r_upgrade/r_upgrade.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const apkLink = 'https://saas.kaidalai.cn/resource/appPackage/app.apk';
|
|
|
|
|
|
|
|
|
|
|
|
enum ForceUpgrade {
|
|
|
|
enum ForceUpgrade {
|
|
|
|
force(1),
|
|
|
|
force(1),
|
|
|
|
unForce(2);
|
|
|
|
unForce(2);
|
|
|
@ -185,66 +187,152 @@ class AppUpgrade {
|
|
|
|
child: MaterialButton(
|
|
|
|
child: MaterialButton(
|
|
|
|
onPressed: () async {
|
|
|
|
onPressed: () async {
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
var stores = await RUpgrade.androidStores;
|
|
|
|
showModalBottomSheet(
|
|
|
|
if (stores == null || stores.isEmpty) {
|
|
|
|
|
|
|
|
onLaunchFail?.call();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var storeEMs = <AndroidStoreName>[];
|
|
|
|
|
|
|
|
for (var element in stores) {
|
|
|
|
|
|
|
|
var re = AndroidStoreName.getValue(
|
|
|
|
|
|
|
|
element.packageName);
|
|
|
|
|
|
|
|
if (re != AndroidStoreName.empty) {
|
|
|
|
|
|
|
|
storeEMs.add(re);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
AndroidStoreName? selectStore;
|
|
|
|
|
|
|
|
selectStore = await showModalBottomSheet(
|
|
|
|
|
|
|
|
isDismissible: false,
|
|
|
|
isDismissible: false,
|
|
|
|
context: context,
|
|
|
|
context: context,
|
|
|
|
builder: (context) {
|
|
|
|
builder: (context) {
|
|
|
|
return Center(
|
|
|
|
return Container(
|
|
|
|
child: Column(
|
|
|
|
child:
|
|
|
|
|
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
const Text('选择应用商店'),
|
|
|
|
const Text('选择下载途径',style: TextStyle(fontSize: 24),),
|
|
|
|
Expanded(
|
|
|
|
const Divider(),
|
|
|
|
child: ListView.separated(
|
|
|
|
GestureDetector(
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
onTap: () async{
|
|
|
|
return GestureDetector(
|
|
|
|
await RUpgrade.upgrade(apkLink);
|
|
|
|
onTap: () {
|
|
|
|
|
|
|
|
Navigator.pop(context,
|
|
|
|
|
|
|
|
storeEMs[index]);
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
child: Padding(
|
|
|
|
child: Padding(
|
|
|
|
padding:
|
|
|
|
padding:
|
|
|
|
const EdgeInsets.all(
|
|
|
|
const EdgeInsets.only(top: 0),
|
|
|
|
32.0),
|
|
|
|
child:
|
|
|
|
child: Center(
|
|
|
|
Column(children: [
|
|
|
|
child: Text(
|
|
|
|
const Divider(),
|
|
|
|
storeEMs[index]
|
|
|
|
SizedBox(
|
|
|
|
.name),
|
|
|
|
height: 20,
|
|
|
|
),
|
|
|
|
child:Text(
|
|
|
|
|
|
|
|
'直接下载',style:const TextStyle(fontSize: 14,),),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
],)
|
|
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
),
|
|
|
|
},
|
|
|
|
const Divider(),
|
|
|
|
separatorBuilder:
|
|
|
|
GestureDetector(
|
|
|
|
(context, index) {
|
|
|
|
onTap: () async{
|
|
|
|
return const SizedBox(
|
|
|
|
var stores = await RUpgrade.androidStores;
|
|
|
|
height: 10,
|
|
|
|
if (stores == null || stores.isEmpty) {
|
|
|
|
);
|
|
|
|
onLaunchFail?.call();
|
|
|
|
},
|
|
|
|
return;
|
|
|
|
itemCount: storeEMs.length),
|
|
|
|
}
|
|
|
|
|
|
|
|
var storeEMs = <AndroidStoreName>[];
|
|
|
|
|
|
|
|
for (var element in stores) {
|
|
|
|
|
|
|
|
var re = AndroidStoreName.getValue(
|
|
|
|
|
|
|
|
element.packageName);
|
|
|
|
|
|
|
|
if (re != AndroidStoreName.empty) {
|
|
|
|
|
|
|
|
storeEMs.add(re);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
AndroidStoreName? selectStore;
|
|
|
|
|
|
|
|
selectStore = await showModalBottomSheet(
|
|
|
|
|
|
|
|
isDismissible: false,
|
|
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
|
|
builder: (context) {
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
|
|
|
|
// decoration: const BoxDecoration(gradient: LinearGradient(
|
|
|
|
|
|
|
|
// begin: Alignment.topCenter,
|
|
|
|
|
|
|
|
// end: Alignment.bottomCenter,
|
|
|
|
|
|
|
|
// stops: [
|
|
|
|
|
|
|
|
// 0,
|
|
|
|
|
|
|
|
// 0.7
|
|
|
|
|
|
|
|
// ],
|
|
|
|
|
|
|
|
// colors: [
|
|
|
|
|
|
|
|
// Color(0x33FBE541),
|
|
|
|
|
|
|
|
// Colors.white,
|
|
|
|
|
|
|
|
// ]),
|
|
|
|
|
|
|
|
// // borderRadius: BorderRadius.only(
|
|
|
|
|
|
|
|
// // topLeft: Radius.circular(25.0),
|
|
|
|
|
|
|
|
// // topRight: Radius.circular(25.0))
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
child:
|
|
|
|
|
|
|
|
Column(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
|
|
|
|
const Text('选择应用商店',style: TextStyle(fontSize: 24),),
|
|
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
|
|
child: ListView.separated(
|
|
|
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
|
|
Navigator.pop(context,
|
|
|
|
|
|
|
|
storeEMs[index]);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
child: Padding(
|
|
|
|
|
|
|
|
padding:
|
|
|
|
|
|
|
|
const EdgeInsets.only(top: 0),
|
|
|
|
|
|
|
|
child:
|
|
|
|
|
|
|
|
Column(children: [
|
|
|
|
|
|
|
|
const Divider(),
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
|
|
height: 20,
|
|
|
|
|
|
|
|
child:Text(
|
|
|
|
|
|
|
|
storeEMs[index]
|
|
|
|
|
|
|
|
.name,style:const TextStyle(fontSize: 14,),),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
],)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
separatorBuilder:
|
|
|
|
|
|
|
|
(context, index) {
|
|
|
|
|
|
|
|
return const SizedBox(
|
|
|
|
|
|
|
|
height: 10,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
itemCount: storeEMs.length),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
GestureDetector(onTap: (){
|
|
|
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
|
|
|
},child: const Text('取消',style: TextStyle(fontSize: 20),),)
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
await Future.delayed(Duration.zero, () async {
|
|
|
|
|
|
|
|
if (selectStore == null) return;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
await RUpgrade.upgradeFromAndroidStore(
|
|
|
|
|
|
|
|
selectStore!.getAndroidStore);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
child: Padding(
|
|
|
|
|
|
|
|
padding:
|
|
|
|
|
|
|
|
const EdgeInsets.only(top: 0),
|
|
|
|
|
|
|
|
child:
|
|
|
|
|
|
|
|
Column(children: [
|
|
|
|
|
|
|
|
const Divider(),
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
|
|
height: 20,
|
|
|
|
|
|
|
|
child:Text(
|
|
|
|
|
|
|
|
'应用市场',style:const TextStyle(fontSize: 14,),),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
],)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
await Future.delayed(Duration.zero, () async {
|
|
|
|
|
|
|
|
if (selectStore == null) return;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
await RUpgrade.upgradeFromAndroidStore(
|
|
|
|
|
|
|
|
selectStore!.getAndroidStore);
|
|
|
|
|
|
|
|
} else if (Platform.isIOS) {
|
|
|
|
} else if (Platform.isIOS) {
|
|
|
|
await RUpgrade.upgradeFromAppStore(
|
|
|
|
await RUpgrade.upgradeFromAppStore(
|
|
|
|
packageInfo.packageName);
|
|
|
|
packageInfo.packageName);
|
|
|
|