mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
new: use browser to upgrade
This commit is contained in:
@@ -86,59 +86,12 @@ Future<void> _doUpdate(AppUpdate update, BuildContext context) async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isAndroid) {
|
if (isAndroid) {
|
||||||
final inAppUpdate = Stores.setting.inAppUpdate;
|
final useBrowser = await _openUrlUpdate(context);
|
||||||
var remember = true;
|
final _ = switch (useBrowser) {
|
||||||
if (inAppUpdate.fetch() == 0) {
|
1 => await RUpgrade.upgrade(url, fileName: url.split('/').last),
|
||||||
final cancel = await context.showRoundDialog(
|
2 => await openUrl(url),
|
||||||
title: Text(l10n.attention),
|
_ => null,
|
||||||
child: StatefulBuilder(builder: (_, setState) {
|
};
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Text(l10n.inAppUpdate, style: UIs.text15Bold),
|
|
||||||
CheckboxListTile(
|
|
||||||
contentPadding: EdgeInsets.zero,
|
|
||||||
value: remember,
|
|
||||||
onChanged: (v) => setState(() => remember = v ?? true),
|
|
||||||
title: Text(l10n.rememberChoice),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => context.pop(true), child: Text(l10n.cancel)),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
if (remember) {
|
|
||||||
inAppUpdate.put(1);
|
|
||||||
}
|
|
||||||
context.pop();
|
|
||||||
},
|
|
||||||
child: const Text('App'),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
if (remember) {
|
|
||||||
inAppUpdate.put(2);
|
|
||||||
}
|
|
||||||
context.pop();
|
|
||||||
},
|
|
||||||
child: Text(l10n.browser),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
if (cancel != false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (inAppUpdate.fetch() == 2) {
|
|
||||||
await openUrl(url);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final fileName = url.split('/').last;
|
|
||||||
await RUpgrade.upgrade(url, fileName: fileName);
|
|
||||||
} else if (isIOS) {
|
} else if (isIOS) {
|
||||||
await RUpgrade.upgradeFromAppStore('1586449703');
|
await RUpgrade.upgradeFromAppStore('1586449703');
|
||||||
} else {
|
} else {
|
||||||
@@ -146,6 +99,58 @@ Future<void> _doUpdate(AppUpdate update, BuildContext context) async {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<int?> _openUrlUpdate(BuildContext context) async {
|
||||||
|
final inAppUpdate = Stores.setting.inAppUpdate;
|
||||||
|
final val = inAppUpdate.fetch();
|
||||||
|
if (val == 0) {
|
||||||
|
var remember = true;
|
||||||
|
final selection = await context.showRoundDialog<int>(
|
||||||
|
title: Text(l10n.attention),
|
||||||
|
child: StatefulBuilder(builder: (_, setState) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(l10n.inAppUpdate, style: UIs.text15Bold),
|
||||||
|
CheckboxListTile(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
value: remember,
|
||||||
|
onChanged: (v) => setState(() => remember = v ?? true),
|
||||||
|
title: Text(l10n.rememberChoice),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => context.pop(0),
|
||||||
|
child: Text(l10n.cancel),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
if (remember) {
|
||||||
|
inAppUpdate.put(1);
|
||||||
|
}
|
||||||
|
context.pop(1);
|
||||||
|
},
|
||||||
|
child: const Text('App'),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
if (remember) {
|
||||||
|
inAppUpdate.put(2);
|
||||||
|
}
|
||||||
|
context.pop(2);
|
||||||
|
},
|
||||||
|
child: Text(l10n.browser),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
return selection;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
// rmdir Download
|
// rmdir Download
|
||||||
Future<void> _rmDownloadApks() async {
|
Future<void> _rmDownloadApks() async {
|
||||||
if (!isAndroid) return;
|
if (!isAndroid) return;
|
||||||
|
|||||||
@@ -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