2022-08-16 15:06:56 +02:00
|
|
|
import 'dart:convert';
|
|
|
|
import 'package:injectable/injectable.dart';
|
2022-08-06 23:35:35 +02:00
|
|
|
import 'package:revanced_manager/app/app.locator.dart';
|
2022-08-16 15:06:56 +02:00
|
|
|
import 'package:revanced_manager/models/patched_application.dart';
|
2022-08-06 23:35:35 +02:00
|
|
|
import 'package:revanced_manager/services/manager_api.dart';
|
2022-08-16 15:06:56 +02:00
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
2022-08-06 14:13:28 +02:00
|
|
|
import 'package:stacked/stacked.dart';
|
|
|
|
|
2022-08-16 15:06:56 +02:00
|
|
|
@lazySingleton
|
2022-08-06 14:13:28 +02:00
|
|
|
class HomeViewModel extends BaseViewModel {
|
2022-08-16 15:06:56 +02:00
|
|
|
bool showUpdatableApps = true;
|
|
|
|
|
|
|
|
void toggleUpdatableApps(bool value) {
|
|
|
|
showUpdatableApps = value;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
2022-08-06 14:13:28 +02:00
|
|
|
Future downloadPatches() => locator<ManagerAPI>().downloadPatches();
|
|
|
|
Future downloadIntegrations() => locator<ManagerAPI>().downloadIntegrations();
|
2022-08-16 15:06:56 +02:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
2022-08-06 14:13:28 +02:00
|
|
|
}
|