2022-08-15 19:42:09 +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-15 19:42:09 +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-15 19:42:09 +02:00
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
2022-08-06 14:13:28 +02:00
|
|
|
import 'package:stacked/stacked.dart';
|
|
|
|
|
2022-08-15 19:42:09 +02:00
|
|
|
@lazySingleton
|
2022-08-06 14:13:28 +02:00
|
|
|
class HomeViewModel extends BaseViewModel {
|
|
|
|
Future downloadPatches() => locator<ManagerAPI>().downloadPatches();
|
|
|
|
Future downloadIntegrations() => locator<ManagerAPI>().downloadIntegrations();
|
2022-08-15 19:42:09 +02:00
|
|
|
|
|
|
|
Future<List<PatchedApplication>> getPatchedApps() 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
|
|
|
}
|