master
张萌 2 years ago
parent fa4082ee7a
commit 6bb6d9d50b

@ -31,14 +31,17 @@ enum AndroidStoreName {
taobao('淘宝手机助手', 'com.taobao.appcenter'), taobao('淘宝手机助手', 'com.taobao.appcenter'),
hiApk('安卓市场', 'com.hiapk.marketpho'), hiApk('安卓市场', 'com.hiapk.marketpho'),
goApk('安智市场', 'cn.goapk.market'), goApk('安智市场', 'cn.goapk.market'),
coolApk('酷安', 'com.coolapk.market'); coolApk('酷安', 'com.coolapk.market'),
empty('', '');
final String name; final String name;
final String packageName; final String packageName;
static AndroidStoreName getValue(String packageName) => static AndroidStoreName getValue(String packageName) {
AndroidStoreName.values return AndroidStoreName.values.firstWhere(
.firstWhere((element) => element.packageName == packageName); (element) => element.packageName == packageName,
orElse: () => AndroidStoreName.empty);
}
AndroidStore get getAndroidStore => AndroidStore.internal(packageName); AndroidStore get getAndroidStore => AndroidStore.internal(packageName);
@ -181,44 +184,65 @@ class AppUpgrade {
Expanded( Expanded(
child: MaterialButton( child: MaterialButton(
onPressed: () async { onPressed: () async {
Navigator.pop(context);
if (Platform.isAndroid) { if (Platform.isAndroid) {
var stores = await RUpgrade.androidStores; var stores = await RUpgrade.androidStores;
if (stores == null || stores.isEmpty) { if (stores == null || stores.isEmpty) {
onLaunchFail?.call(); onLaunchFail?.call();
return; return;
} }
var storeEMs = <AndroidStoreName>[];
for (var element in stores) {
var re = AndroidStoreName.getValue(
element.packageName);
if (re != AndroidStoreName.empty) {
storeEMs.add(re);
}
}
AndroidStoreName? selectStore; AndroidStoreName? selectStore;
await showModalBottomSheet( selectStore = await showModalBottomSheet(
isDismissible: false, isDismissible: false,
context: context, context: context,
builder: (context) { builder: (context) {
return FittedBox( return Center(
child: ListView.separated( child: Column(
itemBuilder: (context, index) { children: [
var value = const SizedBox(height: 20),
AndroidStoreName.getValue( const Text('选择应用商店'),
stores[index].packageName); Expanded(
return GestureDetector( child: ListView.separated(
onTap: () { itemBuilder: (context, index) {
Navigator.pop(context); return GestureDetector(
selectStore = value; onTap: () {
}, Navigator.pop(context,
child: Center( storeEMs[index]);
child: Text(value.name), },
), child: Padding(
); padding:
}, const EdgeInsets.all(
separatorBuilder: (context, index) { 32.0),
return const SizedBox( child: Center(
height: 10, child: Text(
); storeEMs[index]
}, .name),
itemCount: stores.length), ),
),
);
},
separatorBuilder:
(context, index) {
return const SizedBox(
height: 10,
);
},
itemCount: storeEMs.length),
),
],
),
); );
}); });
await Future.delayed(Duration.zero, () async {
if (selectStore == null) return; if (selectStore == null) return;
});
await RUpgrade.upgradeFromAndroidStore( await RUpgrade.upgradeFromAndroidStore(
selectStore!.getAndroidStore); selectStore!.getAndroidStore);
} else if (Platform.isIOS) { } else if (Platform.isIOS) {

Loading…
Cancel
Save