mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-04-21 16:01:58 +00:00
refactor: improve download button logic and clean up code
This commit is contained in:
parent
a26a764753
commit
a0df094504
2 changed files with 25 additions and 22 deletions
|
|
@ -74,25 +74,28 @@ class _DownloadFileScreenState extends ConsumerState<DownloadFileScreen> {
|
||||||
),
|
),
|
||||||
const SizedBox(width: 15),
|
const SizedBox(width: 15),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed:
|
||||||
if (Platform.isAndroid) {
|
_total == 0
|
||||||
final deviceInfo = DeviceInfoPlugin();
|
? () async {
|
||||||
final androidInfo = await deviceInfo.androidInfo;
|
if (Platform.isAndroid) {
|
||||||
String apkUrl = "";
|
final deviceInfo = DeviceInfoPlugin();
|
||||||
for (String abi in androidInfo.supportedAbis) {
|
final androidInfo = await deviceInfo.androidInfo;
|
||||||
final url = updateAvailable.$4.firstWhereOrNull(
|
String apkUrl = "";
|
||||||
(apk) => (apk as String).contains(abi),
|
for (String abi in androidInfo.supportedAbis) {
|
||||||
);
|
final url = updateAvailable.$4.firstWhereOrNull(
|
||||||
if (url != null) {
|
(apk) => (apk as String).contains(abi),
|
||||||
apkUrl = url;
|
);
|
||||||
break;
|
if (url != null) {
|
||||||
}
|
apkUrl = url;
|
||||||
}
|
break;
|
||||||
await _downloadApk(apkUrl);
|
}
|
||||||
} else {
|
}
|
||||||
_launchInBrowser(Uri.parse(updateAvailable.$3));
|
await _downloadApk(apkUrl);
|
||||||
}
|
} else {
|
||||||
},
|
_launchInBrowser(Uri.parse(updateAvailable.$3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
: null,
|
||||||
child: Text(l10n.download),
|
child: Text(l10n.download),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
@ -113,7 +116,7 @@ class _DownloadFileScreenState extends ConsumerState<DownloadFileScreen> {
|
||||||
);
|
);
|
||||||
if (await file.exists()) {
|
if (await file.exists()) {
|
||||||
await _installApk(file);
|
await _installApk(file);
|
||||||
if (context.mounted) {
|
if (mounted) {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
@ -129,7 +132,7 @@ class _DownloadFileScreenState extends ConsumerState<DownloadFileScreen> {
|
||||||
_subscription?.onDone(() async {
|
_subscription?.onDone(() async {
|
||||||
await file.writeAsBytes(_bytes);
|
await file.writeAsBytes(_bytes);
|
||||||
await _installApk(file);
|
await _installApk(file);
|
||||||
if (context.mounted) {
|
if (mounted) {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class WindowsProtocolHandler extends ProtocolHandler {
|
||||||
hKey,
|
hKey,
|
||||||
txtKey,
|
txtKey,
|
||||||
txtValue,
|
txtValue,
|
||||||
REG_VALUE_TYPE.REG_SZ,
|
REG_SZ,
|
||||||
txtData,
|
txtData,
|
||||||
txtData.length * 2 + 2,
|
txtData.length * 2 + 2,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue