mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
feat: theme switching.
This commit is contained in:
parent
3f45dd2db9
commit
4d0dcf407b
@ -54,8 +54,6 @@
|
|||||||
"languageLabel": "Language",
|
"languageLabel": "Language",
|
||||||
"themeLabel": "Theme",
|
"themeLabel": "Theme",
|
||||||
"themeHint": "Change the theme of the app",
|
"themeHint": "Change the theme of the app",
|
||||||
"dynamicColorsLabel": "Dynamic Colors",
|
|
||||||
"dynamicColorsHint": "Enable dynamic colors",
|
|
||||||
"darkThemeLabel": "Dark",
|
"darkThemeLabel": "Dark",
|
||||||
"lightThemeLabel": "Light",
|
"lightThemeLabel": "Light",
|
||||||
"versionLabel": "Version",
|
"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:revanced_manager/ui/views/settings/settings_view.dart';
|
||||||
import 'package:stacked/stacked.dart';
|
import 'package:stacked/stacked.dart';
|
||||||
import 'package:stacked_services/stacked_services.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();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
setupLocator();
|
setupLocator();
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
@ -24,24 +26,30 @@ class MyApp extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return ThemeBuilder(
|
||||||
debugShowCheckedModeBanner: false,
|
defaultThemeMode: ThemeMode.dark,
|
||||||
title: 'ReVanced Manager',
|
|
||||||
theme: lightTheme,
|
|
||||||
darkTheme: darkTheme,
|
darkTheme: darkTheme,
|
||||||
navigatorKey: StackedService.navigatorKey,
|
lightTheme: lightTheme,
|
||||||
onGenerateRoute: StackedRouter().onGenerateRoute,
|
builder: (context, regularTheme, darkTheme, themeMode) => MaterialApp(
|
||||||
home: const Navigation(),
|
debugShowCheckedModeBanner: false,
|
||||||
localizationsDelegates: [
|
title: 'ReVanced Manager',
|
||||||
FlutterI18nDelegate(
|
theme: lightTheme,
|
||||||
translationLoader: FileTranslationLoader(
|
darkTheme: darkTheme,
|
||||||
fallbackFile: 'en',
|
themeMode: themeMode,
|
||||||
basePath: 'assets/i18n',
|
navigatorKey: StackedService.navigatorKey,
|
||||||
|
onGenerateRoute: StackedRouter().onGenerateRoute,
|
||||||
|
home: const Navigation(),
|
||||||
|
localizationsDelegates: [
|
||||||
|
FlutterI18nDelegate(
|
||||||
|
translationLoader: FileTranslationLoader(
|
||||||
|
fallbackFile: 'en',
|
||||||
|
basePath: 'assets/i18n',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
GlobalMaterialLocalizations.delegate,
|
||||||
GlobalMaterialLocalizations.delegate,
|
GlobalWidgetsLocalizations.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/installed_apps_card.dart';
|
||||||
import 'package:revanced_manager/ui/widgets/latest_commit_card.dart';
|
import 'package:revanced_manager/ui/widgets/latest_commit_card.dart';
|
||||||
import 'package:stacked/stacked.dart';
|
import 'package:stacked/stacked.dart';
|
||||||
|
import 'package:stacked_themes/stacked_themes.dart';
|
||||||
|
|
||||||
class HomeView extends StatelessWidget {
|
class HomeView extends StatelessWidget {
|
||||||
const HomeView({Key? key}) : super(key: key);
|
const HomeView({Key? key}) : super(key: key);
|
||||||
@ -25,7 +26,7 @@ class HomeView extends StatelessWidget {
|
|||||||
Align(
|
Align(
|
||||||
alignment: Alignment.topRight,
|
alignment: Alignment.topRight,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
onPressed: () => {},
|
onPressed: () {},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.more_vert,
|
Icons.more_vert,
|
||||||
),
|
),
|
||||||
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||||
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart';
|
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart';
|
||||||
import 'package:stacked/stacked.dart';
|
import 'package:stacked/stacked.dart';
|
||||||
|
import 'package:stacked_themes/stacked_themes.dart';
|
||||||
|
|
||||||
class SettingsView extends StatelessWidget {
|
class SettingsView extends StatelessWidget {
|
||||||
const SettingsView({Key? key}) : super(key: key);
|
const SettingsView({Key? key}) : super(key: key);
|
||||||
@ -29,29 +30,16 @@ class SettingsView extends StatelessWidget {
|
|||||||
trailing: Switch(
|
trailing: Switch(
|
||||||
value: model.isDarkMode,
|
value: model.isDarkMode,
|
||||||
onChanged: (value) {
|
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(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 16.0, vertical: 8.0),
|
horizontal: 16.0,
|
||||||
|
vertical: 8.0,
|
||||||
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
|
@ -2,18 +2,6 @@ import 'package:stacked/stacked.dart';
|
|||||||
|
|
||||||
class SettingsViewModel extends BaseViewModel {
|
class SettingsViewModel extends BaseViewModel {
|
||||||
bool isDarkMode = true;
|
bool isDarkMode = true;
|
||||||
bool isDynamicColors = false;
|
|
||||||
|
|
||||||
void toggleDynamicColors() {
|
|
||||||
isDynamicColors = !isDynamicColors;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
void toggleTheme() {
|
|
||||||
isDarkMode = !isDarkMode;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setLanguage(String language) {
|
void setLanguage(String language) {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
70
pubspec.lock
70
pubspec.lock
@ -228,6 +228,13 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
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:
|
flutter_svg:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -581,6 +588,62 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.27.5"
|
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:
|
shelf:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -670,6 +733,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.9.3"
|
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:
|
stream_channel:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -28,6 +28,7 @@ dependencies:
|
|||||||
stacked: ^2.3.15
|
stacked: ^2.3.15
|
||||||
stacked_generator: ^0.7.14
|
stacked_generator: ^0.7.14
|
||||||
stacked_services: ^0.9.3
|
stacked_services: ^0.9.3
|
||||||
|
stacked_themes: ^0.3.9
|
||||||
timeago: ^3.2.2
|
timeago: ^3.2.2
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
Loading…
Reference in New Issue
Block a user