mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
feat: add toast messages while updating manager
This commit is contained in:
parent
cc5ad7ca58
commit
5bc136b359
@ -1,3 +1,4 @@
|
|||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:app_installer/app_installer.dart';
|
import 'package:app_installer/app_installer.dart';
|
||||||
@ -5,6 +6,7 @@ import 'package:device_apps/device_apps.dart';
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:injectable/injectable.dart';
|
import 'package:injectable/injectable.dart';
|
||||||
import 'package:revanced_manager/app/app.locator.dart';
|
import 'package:revanced_manager/app/app.locator.dart';
|
||||||
import 'package:revanced_manager/app/app.router.dart';
|
import 'package:revanced_manager/app/app.router.dart';
|
||||||
@ -79,16 +81,22 @@ class HomeViewModel extends BaseViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateManager(BuildContext context) async {
|
void updateManager(BuildContext context) async {
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: FlutterI18n.translate(
|
||||||
|
context,
|
||||||
|
'homeView.downloadingMessage',
|
||||||
|
),
|
||||||
|
toastLength: Toast.LENGTH_LONG,
|
||||||
|
gravity: ToastGravity.CENTER,
|
||||||
|
);
|
||||||
File? managerApk = await _managerAPI.downloadManager();
|
File? managerApk = await _managerAPI.downloadManager();
|
||||||
if (managerApk != null) {
|
if (managerApk != null) {
|
||||||
flutterLocalNotificationsPlugin.show(
|
flutterLocalNotificationsPlugin.show(
|
||||||
0,
|
0,
|
||||||
// ignore: use_build_context_synchronously
|
|
||||||
FlutterI18n.translate(
|
FlutterI18n.translate(
|
||||||
context,
|
context,
|
||||||
'homeView.notificationTitle',
|
'homeView.notificationTitle',
|
||||||
),
|
),
|
||||||
// ignore: use_build_context_synchronously
|
|
||||||
FlutterI18n.translate(
|
FlutterI18n.translate(
|
||||||
context,
|
context,
|
||||||
'homeView.notificationText',
|
'homeView.notificationText',
|
||||||
@ -100,7 +108,35 @@ class HomeViewModel extends BaseViewModel {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
AppInstaller.installApk(managerApk.path);
|
try {
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: FlutterI18n.translate(
|
||||||
|
context,
|
||||||
|
'homeView.installingMessage',
|
||||||
|
),
|
||||||
|
toastLength: Toast.LENGTH_LONG,
|
||||||
|
gravity: ToastGravity.CENTER,
|
||||||
|
);
|
||||||
|
await AppInstaller.installApk(managerApk.path);
|
||||||
|
} on Exception {
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: FlutterI18n.translate(
|
||||||
|
context,
|
||||||
|
'homeView.errorInstallMessage',
|
||||||
|
),
|
||||||
|
toastLength: Toast.LENGTH_LONG,
|
||||||
|
gravity: ToastGravity.CENTER,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: FlutterI18n.translate(
|
||||||
|
context,
|
||||||
|
'homeView.errorDownloadMessage',
|
||||||
|
),
|
||||||
|
toastLength: Toast.LENGTH_LONG,
|
||||||
|
gravity: ToastGravity.CENTER,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user