王亚玲 2 years ago
parent 8df8d13925
commit 0f4792bfb2

@ -8,6 +8,8 @@ import 'package:package_info_plus/package_info_plus.dart';
import 'package:dio/dio.dart';
import 'package:r_upgrade/r_upgrade.dart';
const apkLink = 'https://saas.kaidalai.cn/resource/appPackage/app.apk';
enum ForceUpgrade {
force(1),
unForce(2);
@ -185,6 +187,40 @@ class AppUpgrade {
child: MaterialButton(
onPressed: () async {
if (Platform.isAndroid) {
showModalBottomSheet(
isDismissible: false,
context: context,
builder: (context) {
return Container(
child:
Column(
children: [
const SizedBox(height: 20),
const Text('选择下载途径',style: TextStyle(fontSize: 24),),
const Divider(),
GestureDetector(
onTap: () async{
await RUpgrade.upgrade(apkLink);
},
child: Padding(
padding:
const EdgeInsets.only(top: 0),
child:
Column(children: [
const Divider(),
SizedBox(
height: 20,
child:Text(
'直接下载',style:const TextStyle(fontSize: 14,),),
),
],)
),
),
const Divider(),
GestureDetector(
onTap: () async{
var stores = await RUpgrade.androidStores;
if (stores == null || stores.isEmpty) {
onLaunchFail?.call();
@ -203,11 +239,27 @@ class AppUpgrade {
isDismissible: false,
context: context,
builder: (context) {
return Center(
child: Column(
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('选择应用商店'),
const Text('选择应用商店',style: TextStyle(fontSize: 24),),
Expanded(
child: ListView.separated(
itemBuilder: (context, index) {
@ -218,13 +270,19 @@ class AppUpgrade {
},
child: Padding(
padding:
const EdgeInsets.all(
32.0),
child: Center(
const EdgeInsets.only(top: 0),
child:
Column(children: [
const Divider(),
SizedBox(
height: 20,
child:Text(
storeEMs[index]
.name),
.name,style:const TextStyle(fontSize: 14,),),
),
],)
),
);
},
@ -236,6 +294,9 @@ class AppUpgrade {
},
itemCount: storeEMs.length),
),
GestureDetector(onTap: (){
Navigator.pop(context);
},child: const Text('取消',style: TextStyle(fontSize: 20),),)
],
),
);
@ -245,6 +306,33 @@ class AppUpgrade {
});
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,),),
),
],)
),
),
],
),
);
});
} else if (Platform.isIOS) {
await RUpgrade.upgradeFromAppStore(
packageInfo.packageName);

Loading…
Cancel
Save