mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 12:47:37 +02:00
feat: improve app theming code and add Material You (#58)
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:revanced_manager/theme.dart';
|
||||
import 'package:revanced_manager/ui/widgets/appSelectorView/installed_app_item.dart';
|
||||
import 'package:revanced_manager/ui/widgets/shared/search_bar.dart';
|
||||
import 'package:revanced_manager/ui/widgets/appSelectorView/app_skeleton_loader.dart';
|
||||
@ -30,11 +29,6 @@ class _AppSelectorViewState extends State<AppSelectorView> {
|
||||
model.selectAppFromStorage(context);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||
foregroundColor: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
@ -50,15 +44,10 @@ class _AppSelectorViewState extends State<AppSelectorView> {
|
||||
children: <Widget>[
|
||||
SearchBar(
|
||||
showSelectIcon: false,
|
||||
fillColor: isDark
|
||||
? const Color(0xff1B222B)
|
||||
: Colors.grey[200],
|
||||
hintText: FlutterI18n.translate(
|
||||
context,
|
||||
'appSelectorView.searchBarHint',
|
||||
),
|
||||
hintTextColor:
|
||||
Theme.of(context).colorScheme.tertiary,
|
||||
onQueryChanged: (searchQuery) {
|
||||
setState(() {
|
||||
_query = searchQuery;
|
||||
|
@ -6,12 +6,13 @@ import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:revanced_manager/app/app.locator.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:shared_preferences/shared_preferences.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
class AppSelectorViewModel extends BaseViewModel {
|
||||
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
||||
final PatcherAPI _patcherAPI = locator<PatcherAPI>();
|
||||
final List<ApplicationWithIcon> apps = [];
|
||||
bool noApps = false;
|
||||
@ -21,8 +22,7 @@ class AppSelectorViewModel extends BaseViewModel {
|
||||
apps.addAll(await _patcherAPI.getFilteredInstalledApps());
|
||||
apps.sort((a, b) => a.appName.compareTo(b.appName));
|
||||
noApps = apps.isEmpty;
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
_isRooted = prefs.getBool('isRooted') ?? false;
|
||||
_isRooted = _managerAPI.isRooted() ?? false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
@ -2,10 +2,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/theme.dart';
|
||||
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/widgets/homeView/available_updates_card.dart';
|
||||
import 'package:revanced_manager/ui/widgets/homeView/dashboard_raw_chip.dart';
|
||||
import 'package:revanced_manager/ui/widgets/homeView/dashboard_chip.dart';
|
||||
import 'package:revanced_manager/ui/widgets/homeView/installed_apps_card.dart';
|
||||
import 'package:revanced_manager/ui/widgets/homeView/latest_commit_card.dart';
|
||||
import 'package:revanced_manager/ui/widgets/shared/custom_sliver_app_bar.dart';
|
||||
@ -29,8 +28,7 @@ class HomeView extends StatelessWidget {
|
||||
child: Text(
|
||||
'',
|
||||
style: GoogleFonts.inter(
|
||||
color: Theme.of(context).textTheme.headline5!.color,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).textTheme.headline6!.color,
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -44,13 +42,7 @@ class HomeView extends StatelessWidget {
|
||||
'homeView.updatesSubtitle',
|
||||
child: Text(
|
||||
'',
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: isDark
|
||||
? const Color(0xffD1E1FA)
|
||||
: const Color(0xff384E6E),
|
||||
),
|
||||
style: Theme.of(context).textTheme.headline6!,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
@ -62,12 +54,7 @@ class HomeView extends StatelessWidget {
|
||||
'homeView.patchedSubtitle',
|
||||
child: Text(
|
||||
'',
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 20,
|
||||
color: isDark
|
||||
? const Color(0xffD1E1FA)
|
||||
: const Color(0xff384E6E),
|
||||
),
|
||||
style: Theme.of(context).textTheme.headline6!,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
@ -3,6 +3,7 @@ import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager/ui/views/installer/installer_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart';
|
||||
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
|
||||
import 'package:revanced_manager/ui/widgets/shared/custom_sliver_app_bar.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
@ -23,14 +24,13 @@ class InstallerView extends StatelessWidget {
|
||||
title: Text(
|
||||
model.headerLogs,
|
||||
style: GoogleFonts.inter(
|
||||
color: Theme.of(context).textTheme.headline5!.color,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).textTheme.headline6!.color,
|
||||
),
|
||||
),
|
||||
bottom: PreferredSize(
|
||||
preferredSize: const Size(double.infinity, 1.0),
|
||||
child: LinearProgressIndicator(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
backgroundColor: Colors.white,
|
||||
value: model.progress,
|
||||
),
|
||||
@ -41,13 +41,7 @@ class InstallerView extends StatelessWidget {
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildListDelegate.fixed(
|
||||
<Widget>[
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
CustomCard(
|
||||
child: Text(
|
||||
model.logs,
|
||||
style: GoogleFonts.jetBrainsMono(
|
||||
|
@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/theme.dart';
|
||||
import 'package:revanced_manager/ui/views/app_selector/app_selector_view.dart';
|
||||
import 'package:revanced_manager/ui/views/installer/installer_view.dart';
|
||||
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
|
||||
@ -30,11 +29,6 @@ class PatcherView extends StatelessWidget {
|
||||
label: I18nText('patcherView.patchButton'),
|
||||
icon: const Icon(Icons.build),
|
||||
onPressed: openContainer,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||
foregroundColor: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -46,8 +40,7 @@ class PatcherView extends StatelessWidget {
|
||||
child: Text(
|
||||
'',
|
||||
style: GoogleFonts.inter(
|
||||
color: Theme.of(context).textTheme.headline5!.color,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).textTheme.headline6!.color,
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -65,9 +58,7 @@ class PatcherView extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Opacity(
|
||||
opacity: isDark
|
||||
? (model.dimPatchesCard() ? 0.5 : 1)
|
||||
: (model.dimPatchesCard() ? 0.75 : 1),
|
||||
opacity: model.dimPatchesCard() ? 0.5 : 1,
|
||||
child: OpenContainerWrapper(
|
||||
openBuilder: (_, __) => const PatchesSelectorView(),
|
||||
closedBuilder: (_, openContainer) => PatchSelectorCard(
|
||||
|
@ -2,7 +2,6 @@ import 'package:expandable/expandable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager/theme.dart';
|
||||
import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/widgets/patchesSelectorView/patch_item.dart';
|
||||
import 'package:revanced_manager/ui/widgets/patchesSelectorView/patch_options_fields.dart';
|
||||
@ -35,11 +34,6 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
|
||||
model.selectPatches();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||
foregroundColor: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
),
|
||||
body: SafeArea(
|
||||
@ -49,20 +43,17 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
|
||||
child: model.patches.isEmpty
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
)
|
||||
: Column(
|
||||
children: <Widget>[
|
||||
SearchBar(
|
||||
showSelectIcon: true,
|
||||
fillColor:
|
||||
isDark ? const Color(0xff1B222B) : Colors.grey[200],
|
||||
hintText: FlutterI18n.translate(
|
||||
context,
|
||||
'patchesSelectorView.searchBarHint',
|
||||
),
|
||||
hintTextColor: Theme.of(context).colorScheme.tertiary,
|
||||
onQueryChanged: (searchQuery) {
|
||||
setState(() {
|
||||
_query = searchQuery;
|
||||
|
@ -17,11 +17,6 @@ class RootCheckerView extends StatelessWidget {
|
||||
label: I18nText('rootCheckerView.nonRootButton'),
|
||||
icon: const Icon(Icons.keyboard_arrow_right),
|
||||
onPressed: () => model.navigateAsNonRoot(),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||
foregroundColor: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
body: Container(
|
||||
height: double.infinity,
|
||||
@ -41,10 +36,10 @@ class RootCheckerView extends StatelessWidget {
|
||||
const SizedBox(height: 24),
|
||||
I18nText(
|
||||
'rootCheckerView.widgetDescription',
|
||||
child: Text(
|
||||
child: const Text(
|
||||
'',
|
||||
textAlign: TextAlign.center,
|
||||
style: GoogleFonts.roboto(
|
||||
style: TextStyle(
|
||||
fontSize: 17,
|
||||
letterSpacing: 1.1,
|
||||
),
|
||||
@ -62,10 +57,6 @@ class RootCheckerView extends StatelessWidget {
|
||||
translationParams: {
|
||||
'isRooted': model.isRooted.toString(),
|
||||
},
|
||||
child: Text(
|
||||
'',
|
||||
style: GoogleFonts.poppins(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -1,12 +1,13 @@
|
||||
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:revanced_manager/services/manager_api.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:root/root.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
class RootCheckerViewModel extends BaseViewModel {
|
||||
final NavigationService _navigationService = locator<NavigationService>();
|
||||
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
||||
bool isRooted = false;
|
||||
|
||||
Future<void> navigateAsRoot() async {
|
||||
@ -25,8 +26,7 @@ class RootCheckerViewModel extends BaseViewModel {
|
||||
}
|
||||
|
||||
Future<void> navigateToHome() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool('isRooted', isRooted);
|
||||
_managerAPI.setIsRooted(isRooted);
|
||||
_navigationService.navigateTo(Routes.navigation);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager/constants.dart';
|
||||
import 'package:revanced_manager/theme.dart';
|
||||
import 'package:revanced_manager/ui/views/contributors/contributors_view.dart';
|
||||
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/about_widget.dart';
|
||||
@ -14,7 +12,6 @@ import 'package:revanced_manager/ui/widgets/settingsView/sources_widget.dart';
|
||||
import 'package:revanced_manager/ui/widgets/shared/custom_sliver_app_bar.dart';
|
||||
import 'package:revanced_manager/ui/widgets/shared/open_container_wrapper.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_themes/stacked_themes.dart';
|
||||
|
||||
class SettingsView extends StatelessWidget {
|
||||
final TextEditingController organizationController = TextEditingController();
|
||||
@ -37,8 +34,7 @@ class SettingsView extends StatelessWidget {
|
||||
child: Text(
|
||||
'',
|
||||
style: GoogleFonts.inter(
|
||||
color: Theme.of(context).textTheme.headline5!.color,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).textTheme.headline6!.color,
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -56,18 +52,39 @@ class SettingsView extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
CustomSwitchTile(
|
||||
title: I18nText(
|
||||
'settingsView.themeLabel',
|
||||
child: Text(
|
||||
'settingsView.darkThemeLabel',
|
||||
child: const Text(
|
||||
'',
|
||||
style: kSettingItemTextStyle,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
subtitle: I18nText('settingsView.themeHint'),
|
||||
value: isDark,
|
||||
onTap: (value) {
|
||||
isDark = value;
|
||||
getThemeManager(context).toggleDarkLightTheme();
|
||||
},
|
||||
subtitle: I18nText('settingsView.darkThemeHint'),
|
||||
value: model.getDarkThemeStatus(),
|
||||
onTap: (value) => model.setUseDarkTheme(
|
||||
context,
|
||||
value,
|
||||
),
|
||||
),
|
||||
CustomSwitchTile(
|
||||
title: I18nText(
|
||||
'settingsView.dynamicThemeLabel',
|
||||
child: const Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
subtitle: I18nText('settingsView.dynamicThemeHint'),
|
||||
value: model.getDynamicThemeStatus(),
|
||||
onTap: (value) => model.setUseDynamicTheme(
|
||||
context,
|
||||
value,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -102,9 +119,12 @@ class SettingsView extends StatelessWidget {
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: I18nText(
|
||||
'settingsView.rootModeLabel',
|
||||
child: Text(
|
||||
child: const Text(
|
||||
'',
|
||||
style: kSettingItemTextStyle,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
subtitle: I18nText('settingsView.rootModeHint'),
|
||||
@ -129,7 +149,13 @@ class SettingsView extends StatelessWidget {
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: I18nText(
|
||||
'settingsView.contributorsLabel',
|
||||
child: Text('', style: kSettingItemTextStyle),
|
||||
child: const Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
subtitle: I18nText('settingsView.contributorsHint'),
|
||||
onTap: openContainer,
|
||||
|
@ -1,13 +1,18 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
|
||||
import 'package:dynamic_themes/dynamic_themes.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/app/app.router.dart';
|
||||
import 'package:revanced_manager/services/manager_api.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
import 'package:timeago/timeago.dart';
|
||||
|
||||
class SettingsViewModel extends BaseViewModel {
|
||||
final NavigationService _navigationService = locator<NavigationService>();
|
||||
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
||||
|
||||
void setLanguage(String language) {
|
||||
notifyListeners();
|
||||
@ -23,4 +28,34 @@ class SettingsViewModel extends BaseViewModel {
|
||||
setLocaleMessages(value, EnMessages());
|
||||
}
|
||||
}
|
||||
|
||||
bool getDynamicThemeStatus() {
|
||||
return _managerAPI.getUseDynamicTheme();
|
||||
}
|
||||
|
||||
void setUseDynamicTheme(BuildContext context, bool value) async {
|
||||
await _managerAPI.setUseDynamicTheme(value);
|
||||
int currentTheme = DynamicTheme.of(context)!.themeId;
|
||||
if (currentTheme.isEven) {
|
||||
DynamicTheme.of(context)!.setTheme(value ? 2 : 0);
|
||||
} else {
|
||||
DynamicTheme.of(context)!.setTheme(value ? 3 : 1);
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool getDarkThemeStatus() {
|
||||
return _managerAPI.getUseDarkTheme();
|
||||
}
|
||||
|
||||
void setUseDarkTheme(BuildContext context, bool value) async {
|
||||
await _managerAPI.setUseDarkTheme(value);
|
||||
int currentTheme = DynamicTheme.of(context)!.themeId;
|
||||
if (currentTheme < 2) {
|
||||
DynamicTheme.of(context)!.setTheme(value ? 1 : 0);
|
||||
} else {
|
||||
DynamicTheme.of(context)!.setTheme(value ? 3 : 2);
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user