fix: add changelog (wip) on each app item

This commit is contained in:
Alberto Ponces
2022-08-29 15:01:51 +01:00
parent 45f4a5b207
commit 080ceae784
10 changed files with 103 additions and 167 deletions

View File

@ -35,8 +35,6 @@ class AppSelectorViewModel extends BaseViewModel {
icon: application.icon,
patchDate: DateTime.now(),
isRooted: _isRooted,
isFromStorage: false,
appliedPatches: [],
);
locator<PatcherViewModel>().selectedPatches.clear();
locator<PatcherViewModel>().notifyListeners();
@ -63,7 +61,6 @@ class AppSelectorViewModel extends BaseViewModel {
patchDate: DateTime.now(),
isRooted: _isRooted,
isFromStorage: true,
appliedPatches: [],
);
locator<PatcherViewModel>().selectedPatches.clear();
locator<PatcherViewModel>().notifyListeners();

View File

@ -111,8 +111,8 @@ class HomeView extends StatelessWidget {
),
const SizedBox(height: 14),
model.showUpdatableApps
? AvailableUpdatesCard()
: InstalledAppsCard()
? const AvailableUpdatesCard()
: const InstalledAppsCard()
],
),
),

View File

@ -22,8 +22,11 @@ class HomeViewModel extends BaseViewModel {
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
bool showUpdatableApps = true;
List<PatchedApplication> patchedInstalledApps = [];
List<PatchedApplication> patchedUpdatableApps = [];
Future<void> initialize() async {
await _getPatchedApps();
await _patcherAPI.loadPatches();
await flutterLocalNotificationsPlugin.initialize(
const InitializationSettings(
@ -31,6 +34,7 @@ class HomeViewModel extends BaseViewModel {
),
onSelectNotification: (p) => DeviceApps.openApp('app.revanced.manager'),
);
_managerAPI.reAssessSavedApps().then((_) => notifyListeners());
}
void toggleUpdatableApps(bool value) {
@ -46,17 +50,16 @@ class HomeViewModel extends BaseViewModel {
locator<MainViewModel>().setIndex(1);
}
Future<List<PatchedApplication>> getPatchedApps(bool isUpdatable) async {
await _managerAPI.reAssessSavedApps();
List<PatchedApplication> list = [];
List<PatchedApplication> patchedApps = _managerAPI.getPatchedApps();
for (PatchedApplication app in patchedApps) {
bool hasUpdates = await _managerAPI.hasAppUpdates(app.packageName);
if (hasUpdates == isUpdatable) {
list.add(app);
}
}
return list;
Future<void> _getPatchedApps() async {
patchedInstalledApps = _managerAPI
.getPatchedApps()
.where((app) => app.hasUpdates == false)
.toList();
patchedUpdatableApps = _managerAPI
.getPatchedApps()
.where((app) => app.hasUpdates == true)
.toList();
notifyListeners();
}
Future<bool> hasManagerUpdates() async {

View File

@ -70,10 +70,10 @@ class InstallerViewModel extends BaseViewModel {
void update(double value, String header, String log) {
progress = value;
isInstalled = false;
isPatching = progress == 1.0 ? false : true;
if (progress == 0.0) {
logs = '';
isInstalled = false;
}
if (header.isNotEmpty) {
headerLogs = header;
@ -148,9 +148,9 @@ class InstallerViewModel extends BaseViewModel {
);
isInstalled = await _patcherAPI.installPatchedFile(_app!);
if (isInstalled) {
update(1.0, 'Installed!', 'Installed');
update(1.0, 'Installed!', 'Installed!');
_app!.patchDate = DateTime.now();
_app!.appliedPatches.addAll(_patches.map((p) => p.name).toList());
_app!.appliedPatches = _patches.map((p) => p.name).toList();
_managerAPI.savePatchedApp(_app!);
} else {
update(1.0, 'Aborting...', 'An error occurred! Aborting');