mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
feat: root and nonroot toggle.
This commit is contained in:
parent
2abe051483
commit
2f83ea290b
@ -69,7 +69,9 @@
|
||||
"lightThemeLabel": "Light",
|
||||
"versionLabel": "Version",
|
||||
"aboutLabel": "About",
|
||||
"contributorsLabel": "Contributors"
|
||||
"contributorsLabel": "Contributors",
|
||||
"rootModeLabel": "Root Mode",
|
||||
"rootModeHint": "Enable this if you want to patch applications as rooted."
|
||||
},
|
||||
"rootCheckerView": {
|
||||
"widgetTitle": "Is your device rooted?",
|
||||
|
@ -14,7 +14,9 @@ class SettingsView extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<SettingsViewModel>.reactive(
|
||||
disposeViewModel: false,
|
||||
viewModelBuilder: () => SettingsViewModel(),
|
||||
onModelReady: (model) => model.initialize(),
|
||||
builder: (context, SettingsViewModel model, child) => Scaffold(
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
@ -51,6 +53,35 @@ class SettingsView extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: I18nText(
|
||||
'settingsView.rootModeLabel',
|
||||
child: Text(
|
||||
'',
|
||||
style: kSettingItemTextStyle,
|
||||
),
|
||||
),
|
||||
subtitle: I18nText('settingsView.rootModeHint'),
|
||||
trailing: GestureDetector(
|
||||
onTap: () {
|
||||
model.navigateToRootChecker();
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
width: 1,
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
model.isRooted ? 'Rooted' : 'Not rooted',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16.0,
|
||||
|
@ -1,9 +1,18 @@
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/app/app.router.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
class SettingsViewModel extends BaseViewModel {
|
||||
bool isRooted = false;
|
||||
|
||||
Future<void> initialize() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
isRooted = prefs.getBool('isRooted') ?? false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
final NavigationService _navigationService = locator<NavigationService>();
|
||||
|
||||
void setLanguage(String language) {
|
||||
@ -13,4 +22,8 @@ class SettingsViewModel extends BaseViewModel {
|
||||
void navigateToContributors() {
|
||||
_navigationService.navigateTo(Routes.contributorsView);
|
||||
}
|
||||
|
||||
void navigateToRootChecker() {
|
||||
_navigationService.navigateTo(Routes.rootCheckerView);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user