mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-10 01:01:56 +01:00
feat: theme switching.
This commit is contained in:
parent
3f45dd2db9
commit
4d0dcf407b
7 changed files with 104 additions and 50 deletions
|
@ -54,8 +54,6 @@
|
|||
"languageLabel": "Language",
|
||||
"themeLabel": "Theme",
|
||||
"themeHint": "Change the theme of the app",
|
||||
"dynamicColorsLabel": "Dynamic Colors",
|
||||
"dynamicColorsHint": "Enable dynamic colors",
|
||||
"darkThemeLabel": "Dark",
|
||||
"lightThemeLabel": "Light",
|
||||
"versionLabel": "Version",
|
||||
|
|
|
@ -12,8 +12,10 @@ import 'package:revanced_manager/ui/views/patcher/patcher_view.dart';
|
|||
import 'package:revanced_manager/ui/views/settings/settings_view.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
import 'package:stacked_themes/stacked_themes.dart';
|
||||
|
||||
void main() async {
|
||||
Future main() async {
|
||||
await ThemeManager.initialise();
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
setupLocator();
|
||||
runApp(const MyApp());
|
||||
|
@ -24,24 +26,30 @@ class MyApp extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'ReVanced Manager',
|
||||
theme: lightTheme,
|
||||
return ThemeBuilder(
|
||||
defaultThemeMode: ThemeMode.dark,
|
||||
darkTheme: darkTheme,
|
||||
navigatorKey: StackedService.navigatorKey,
|
||||
onGenerateRoute: StackedRouter().onGenerateRoute,
|
||||
home: const Navigation(),
|
||||
localizationsDelegates: [
|
||||
FlutterI18nDelegate(
|
||||
translationLoader: FileTranslationLoader(
|
||||
fallbackFile: 'en',
|
||||
basePath: 'assets/i18n',
|
||||
lightTheme: lightTheme,
|
||||
builder: (context, regularTheme, darkTheme, themeMode) => MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'ReVanced Manager',
|
||||
theme: lightTheme,
|
||||
darkTheme: darkTheme,
|
||||
themeMode: themeMode,
|
||||
navigatorKey: StackedService.navigatorKey,
|
||||
onGenerateRoute: StackedRouter().onGenerateRoute,
|
||||
home: const Navigation(),
|
||||
localizationsDelegates: [
|
||||
FlutterI18nDelegate(
|
||||
translationLoader: FileTranslationLoader(
|
||||
fallbackFile: 'en',
|
||||
basePath: 'assets/i18n',
|
||||
),
|
||||
),
|
||||
),
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate
|
||||
],
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import 'package:revanced_manager/ui/widgets/available_updates_card.dart';
|
|||
import 'package:revanced_manager/ui/widgets/installed_apps_card.dart';
|
||||
import 'package:revanced_manager/ui/widgets/latest_commit_card.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_themes/stacked_themes.dart';
|
||||
|
||||
class HomeView extends StatelessWidget {
|
||||
const HomeView({Key? key}) : super(key: key);
|
||||
|
@ -25,7 +26,7 @@ class HomeView extends StatelessWidget {
|
|||
Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: IconButton(
|
||||
onPressed: () => {},
|
||||
onPressed: () {},
|
||||
icon: const Icon(
|
||||
Icons.more_vert,
|
||||
),
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_themes/stacked_themes.dart';
|
||||
|
||||
class SettingsView extends StatelessWidget {
|
||||
const SettingsView({Key? key}) : super(key: key);
|
||||
|
@ -29,29 +30,16 @@ class SettingsView extends StatelessWidget {
|
|||
trailing: Switch(
|
||||
value: model.isDarkMode,
|
||||
onChanged: (value) {
|
||||
model.toggleTheme();
|
||||
model.isDarkMode = value;
|
||||
getThemeManager(context).toggleDarkLightTheme();
|
||||
},
|
||||
),
|
||||
onTap: () {
|
||||
model.toggleTheme;
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: I18nText('settingsView.dynamicColorsLabel'),
|
||||
subtitle: I18nText('settingsView.dynamicColorsHint'),
|
||||
trailing: Switch(
|
||||
value: model.isDynamicColors,
|
||||
onChanged: (value) {
|
||||
model.toggleDynamicColors();
|
||||
},
|
||||
),
|
||||
onTap: () {
|
||||
model.toggleDynamicColors();
|
||||
},
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16.0, vertical: 8.0),
|
||||
horizontal: 16.0,
|
||||
vertical: 8.0,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
|
|
|
@ -2,18 +2,6 @@ import 'package:stacked/stacked.dart';
|
|||
|
||||
class SettingsViewModel extends BaseViewModel {
|
||||
bool isDarkMode = true;
|
||||
bool isDynamicColors = false;
|
||||
|
||||
void toggleDynamicColors() {
|
||||
isDynamicColors = !isDynamicColors;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void toggleTheme() {
|
||||
isDarkMode = !isDarkMode;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setLanguage(String language) {
|
||||
notifyListeners();
|
||||
}
|
||||
|
|
70
pubspec.lock
70
pubspec.lock
|
@ -228,6 +228,13 @@ packages:
|
|||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_statusbarcolor_ns:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_statusbarcolor_ns
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.4.0"
|
||||
flutter_svg:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -581,6 +588,62 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.27.5"
|
||||
shared_preferences:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.15"
|
||||
shared_preferences_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_android
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.12"
|
||||
shared_preferences_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_ios
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
shared_preferences_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_linux
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
shared_preferences_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_macos
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.4"
|
||||
shared_preferences_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
shared_preferences_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_web
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.4"
|
||||
shared_preferences_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_windows
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
shelf:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -670,6 +733,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.9.3"
|
||||
stacked_themes:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: stacked_themes
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.9"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -28,6 +28,7 @@ dependencies:
|
|||
stacked: ^2.3.15
|
||||
stacked_generator: ^0.7.14
|
||||
stacked_services: ^0.9.3
|
||||
stacked_themes: ^0.3.9
|
||||
timeago: ^3.2.2
|
||||
|
||||
dev_dependencies:
|
||||
|
|
Loading…
Reference in a new issue