mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-18 07:44:26 +01:00
new: use browser to upgrade
This commit is contained in:
@@ -86,10 +86,25 @@ Future<void> _doUpdate(AppUpdate update, BuildContext context) async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isAndroid) {
|
if (isAndroid) {
|
||||||
|
final useBrowser = await _openUrlUpdate(context);
|
||||||
|
final _ = switch (useBrowser) {
|
||||||
|
1 => await RUpgrade.upgrade(url, fileName: url.split('/').last),
|
||||||
|
2 => await openUrl(url),
|
||||||
|
_ => null,
|
||||||
|
};
|
||||||
|
} else if (isIOS) {
|
||||||
|
await RUpgrade.upgradeFromAppStore('1586449703');
|
||||||
|
} else {
|
||||||
|
await openUrl(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<int?> _openUrlUpdate(BuildContext context) async {
|
||||||
final inAppUpdate = Stores.setting.inAppUpdate;
|
final inAppUpdate = Stores.setting.inAppUpdate;
|
||||||
|
final val = inAppUpdate.fetch();
|
||||||
|
if (val == 0) {
|
||||||
var remember = true;
|
var remember = true;
|
||||||
if (inAppUpdate.fetch() == 0) {
|
final selection = await context.showRoundDialog<int>(
|
||||||
final cancel = await context.showRoundDialog(
|
|
||||||
title: Text(l10n.attention),
|
title: Text(l10n.attention),
|
||||||
child: StatefulBuilder(builder: (_, setState) {
|
child: StatefulBuilder(builder: (_, setState) {
|
||||||
return Column(
|
return Column(
|
||||||
@@ -108,13 +123,15 @@ Future<void> _doUpdate(AppUpdate update, BuildContext context) async {
|
|||||||
}),
|
}),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => context.pop(true), child: Text(l10n.cancel)),
|
onPressed: () => context.pop(0),
|
||||||
|
child: Text(l10n.cancel),
|
||||||
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (remember) {
|
if (remember) {
|
||||||
inAppUpdate.put(1);
|
inAppUpdate.put(1);
|
||||||
}
|
}
|
||||||
context.pop();
|
context.pop(1);
|
||||||
},
|
},
|
||||||
child: const Text('App'),
|
child: const Text('App'),
|
||||||
),
|
),
|
||||||
@@ -123,27 +140,15 @@ Future<void> _doUpdate(AppUpdate update, BuildContext context) async {
|
|||||||
if (remember) {
|
if (remember) {
|
||||||
inAppUpdate.put(2);
|
inAppUpdate.put(2);
|
||||||
}
|
}
|
||||||
context.pop();
|
context.pop(2);
|
||||||
},
|
},
|
||||||
child: Text(l10n.browser),
|
child: Text(l10n.browser),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
if (cancel != false) {
|
return selection;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (inAppUpdate.fetch() == 2) {
|
|
||||||
await openUrl(url);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final fileName = url.split('/').last;
|
|
||||||
await RUpgrade.upgrade(url, fileName: fileName);
|
|
||||||
} else if (isIOS) {
|
|
||||||
await RUpgrade.upgradeFromAppStore('1586449703');
|
|
||||||
} else {
|
|
||||||
await openUrl(url);
|
|
||||||
}
|
}
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
// rmdir Download
|
// rmdir Download
|
||||||
|
|||||||
@@ -167,9 +167,7 @@ class _EditorPageState extends State<EditorPage> {
|
|||||||
Widget _buildBody() {
|
Widget _buildBody() {
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
child: CodeTheme(
|
child: CodeTheme(
|
||||||
data: CodeThemeData(
|
data: CodeThemeData(styles: _codeTheme),
|
||||||
styles: _codeTheme,
|
|
||||||
),
|
|
||||||
child: CodeField(
|
child: CodeField(
|
||||||
wrap: Stores.setting.editorSoftWrap.fetch(),
|
wrap: Stores.setting.editorSoftWrap.fetch(),
|
||||||
focusNode: _focusNode,
|
focusNode: _focusNode,
|
||||||
|
|||||||
Reference in New Issue
Block a user