revanced-manager/lib/ui/views/home/home_viewmodel.dart

23 lines
885 B
Dart
Raw Normal View History

import 'dart:convert';
import 'package:injectable/injectable.dart';
2022-08-06 23:35:35 +02:00
import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/models/patched_application.dart';
2022-08-06 23:35:35 +02:00
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 {
Future downloadPatches() => locator<ManagerAPI>().downloadPatches();
Future downloadIntegrations() => locator<ManagerAPI>().downloadIntegrations();
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();
}
}