feat: show patch bundle version in patch selector screen.

This commit is contained in:
Aunali321 2022-10-17 01:40:16 +05:30
parent 5b38c9442a
commit 074d8005bc
3 changed files with 36 additions and 0 deletions

View File

@ -228,6 +228,13 @@ class ManagerAPI {
);
}
Future<String?> getLatestPatchesVersion() async {
return await _revancedAPI.getLatestReleaseVersion(
'.json',
defaultPatchesRepo,
);
}
Future<String> getCurrentManagerVersion() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
return packageInfo.version;

View File

@ -55,6 +55,25 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
),
onPressed: () => Navigator.of(context).pop(),
),
actions: [
Container(
height: 2,
margin: const EdgeInsets.only(right: 16, top: 12, bottom: 12),
padding:
const EdgeInsets.symmetric(horizontal: 6, vertical: 6),
decoration: BoxDecoration(
color:
Theme.of(context).colorScheme.tertiary.withOpacity(0.5),
borderRadius: BorderRadius.circular(6),
),
child: Text(
model.patchesVersion!,
style: TextStyle(
color: Theme.of(context).textTheme.headline6!.color,
),
),
),
],
bottom: PreferredSize(
preferredSize: const Size.fromHeight(64.0),
child: Padding(

View File

@ -3,6 +3,7 @@ import 'package:flutter_i18n/widgets/I18nText.dart';
import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/models/patch.dart';
import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/services/patcher_api.dart';
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
@ -11,11 +12,14 @@ import 'package:flutter/material.dart';
class PatchesSelectorViewModel extends BaseViewModel {
final PatcherAPI _patcherAPI = locator<PatcherAPI>();
final ManagerAPI _managerAPI = locator<ManagerAPI>();
final List<Patch> patches = [];
final List<Patch> selectedPatches =
locator<PatcherViewModel>().selectedPatches;
String? patchesVersion = '';
Future<void> initialize() async {
getPatchesVersion();
patches.addAll(await _patcherAPI.getFilteredPatches(
locator<PatcherViewModel>().selectedApp!.originalPackageName,
));
@ -68,6 +72,12 @@ class PatchesSelectorViewModel extends BaseViewModel {
locator<PatcherViewModel>().notifyListeners();
}
Future<String?> getPatchesVersion() async {
patchesVersion = await _managerAPI.getLatestPatchesVersion();
// print('Patches version: $patchesVersion');
return patchesVersion ?? '0.0.0';
}
List<Patch> getQueriedPatches(String query) {
return patches
.where((patch) =>