revanced-manager/lib/ui/views/home/home_viewmodel.dart
Aunali321 106d77ea0c
feat: "New dashboard UI". (#3)
* feat: "New dashboard UI".

* fix: some improvenents

* fix: fix inconsistencies and light theme.

* fix: save patched and installed apps on prefs, improve installer log, improve dashboard with real data (wip)

Co-authored-by: Aunali321 <aunvakil.aa@gmail.com>

* feat: move chips to a separate widget.

Co-authored-by: Alberto Ponces <ponces26@gmail.com>
2022-08-16 14:06:56 +01:00

29 lines
1.0 KiB
Dart

import 'dart:convert';
import 'package:injectable/injectable.dart';
import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/services/manager_api.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:stacked/stacked.dart';
@lazySingleton
class HomeViewModel extends BaseViewModel {
bool showUpdatableApps = true;
void toggleUpdatableApps(bool value) {
showUpdatableApps = value;
notifyListeners();
}
Future downloadPatches() => locator<ManagerAPI>().downloadPatches();
Future downloadIntegrations() => locator<ManagerAPI>().downloadIntegrations();
Future<List<PatchedApplication>> getPatchedApps(bool isUpdatable) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
List<String> patchedApps = prefs.getStringList('patchedApps') ?? [];
return patchedApps
.map((app) => PatchedApplication.fromJson(json.decode(app)))
.toList();
}
}