refactor: major theming overhual, fix light theme.

This commit is contained in:
Aunali321 2022-08-12 15:12:43 +05:30
parent 458f7925b2
commit 4d3ea65d7f
18 changed files with 144 additions and 107 deletions

View file

@ -9,18 +9,24 @@ import 'package:revanced_manager/ui/views/patches_selector/patches_selector_view
import 'package:revanced_manager/ui/views/settings/settings_view.dart';
import 'package:stacked/stacked_annotations.dart';
import 'package:stacked_services/stacked_services.dart';
import 'package:stacked_themes/stacked_themes.dart';
@StackedApp(routes: [
MaterialRoute(page: HomeView),
MaterialRoute(page: AppSelectorView),
MaterialRoute(page: PatcherView),
MaterialRoute(page: PatchesSelectorView),
MaterialRoute(page: SettingsView)
], dependencies: [
LazySingleton(classType: NavigationService),
LazySingleton(classType: PatcherAPI),
LazySingleton(classType: PatcherViewModel),
LazySingleton(classType: AppSelectorViewModel),
LazySingleton(classType: PatchesSelectorViewModel),
])
@StackedApp(
routes: [
MaterialRoute(page: HomeView),
MaterialRoute(page: AppSelectorView),
MaterialRoute(page: PatcherView),
MaterialRoute(page: PatchesSelectorView),
MaterialRoute(page: SettingsView)
],
dependencies: [
LazySingleton(classType: NavigationService),
LazySingleton(classType: PatcherAPI),
LazySingleton(classType: PatcherViewModel),
LazySingleton(classType: AppSelectorViewModel),
LazySingleton(classType: PatchesSelectorViewModel),
LazySingleton(
classType: ThemeService, resolveUsing: ThemeService.getInstance),
],
)
class AppSetup {}

View file

@ -8,6 +8,7 @@
import 'package:stacked_core/stacked_core.dart';
import 'package:stacked_services/src/navigation/navigation_service.dart';
import 'package:stacked_themes/src/theme_service.dart';
import '../services/patcher_api.dart';
import '../ui/views/app_selector/app_selector_viewmodel.dart';
@ -28,4 +29,5 @@ Future<void> setupLocator(
locator.registerLazySingleton(() => PatcherViewModel());
locator.registerLazySingleton(() => AppSelectorViewModel());
locator.registerLazySingleton(() => PatchesSelectorViewModel());
locator.registerLazySingleton(() => ThemeService.getInstance());
}

View file

@ -15,9 +15,10 @@ import 'package:stacked_services/stacked_services.dart';
import 'package:stacked_themes/stacked_themes.dart';
Future main() async {
await ThemeManager.initialise();
WidgetsFlutterBinding.ensureInitialized();
setupLocator();
await ThemeManager.initialise();
setupLocator();
WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp());
}

View file

@ -1,9 +1,17 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:revanced_manager/constants.dart';
import 'package:stacked_themes/stacked_themes.dart';
import 'app/app.locator.dart';
final _themeService = locator<ThemeService>();
bool isDark = _themeService.isDarkMode;
var lightTheme = ThemeData.light().copyWith(
navigationBarTheme: NavigationBarThemeData(
indicatorColor: const Color.fromRGBO(75, 129, 210, 0.20),
backgroundColor: const Color(0xffCBDFFC),
labelTextStyle: MaterialStateProperty.all(
GoogleFonts.roboto(
fontSize: 12,
@ -12,11 +20,24 @@ var lightTheme = ThemeData.light().copyWith(
),
backgroundColor: Colors.red,
useMaterial3: true,
textButtonTheme: TextButtonThemeData(
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(
const EdgeInsets.symmetric(
vertical: 8,
horizontal: 12,
),
),
backgroundColor: MaterialStateProperty.all<Color>(
const Color(0xff4B7CC6),
),
),
),
colorScheme: const ColorScheme.light(
primary: purple40,
secondary: purpleGrey40,
tertiary: pink40,
background: Colors.red,
primary: Color.fromRGBO(154, 193, 252, 0.18),
secondary: Color(0xff3868AF),
tertiary: Color(0xff485A74),
background: Color(0xffDFD5EC),
),
);
@ -36,10 +57,23 @@ var darkTheme = ThemeData.dark().copyWith(
backgroundColor: Colors.red,
useMaterial3: true,
scaffoldBackgroundColor: const Color(0xff0A0D11),
textButtonTheme: TextButtonThemeData(
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(
const EdgeInsets.symmetric(
vertical: 8,
horizontal: 12,
),
),
backgroundColor: MaterialStateProperty.all<Color>(
const Color.fromRGBO(119, 146, 168, 1),
),
),
),
colorScheme: const ColorScheme.dark(
primary: purple80,
secondary: purpleGrey80,
tertiary: pink80,
background: Colors.red,
primary: Color(0x1B222B6B),
secondary: Color(0xff7792BA),
tertiary: Color(0xff8691A0),
background: Color(0xff0A0D11),
),
);

View file

@ -1,11 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/theme.dart';
import 'package:revanced_manager/ui/widgets/installed_app_item.dart';
import 'package:revanced_manager/ui/widgets/search_bar.dart';
import 'package:stacked/stacked.dart';
import 'package:revanced_manager/ui/views/app_selector/app_selector_viewmodel.dart';
import 'package:stacked_themes/stacked_themes.dart';
class AppSelectorView extends StatefulWidget {
const AppSelectorView({Key? key}) : super(key: key);
@ -19,7 +19,6 @@ class _AppSelectorViewState extends State<AppSelectorView> {
@override
Widget build(BuildContext context) {
bool isDark = getThemeManager(context).isDarkMode;
return ViewModelBuilder<AppSelectorViewModel>.reactive(
disposeViewModel: false,
onModelReady: (model) => model.initialise(),
@ -34,12 +33,12 @@ class _AppSelectorViewState extends State<AppSelectorView> {
children: [
SearchBar(
fillColor:
isDark ? Colors.blueGrey[700] : Colors.grey[400],
isDark ? const Color(0xff1B222B) : Colors.grey[200],
hintText: FlutterI18n.translate(
context,
'appSelectorView.searchBarHint',
),
hintTextColor: isDark ? Colors.white : Colors.grey[800],
hintTextColor: Theme.of(context).colorScheme.tertiary,
onQueryChanged: (searchQuery) {
setState(() {
query = searchQuery;
@ -53,9 +52,9 @@ class _AppSelectorViewState extends State<AppSelectorView> {
],
)
: query.isEmpty || query.length < 2
? const Center(
? Center(
child: CircularProgressIndicator(
color: Color(0xff7792BA),
color: Theme.of(context).colorScheme.secondary,
),
)
: Center(

View file

@ -1,19 +1,18 @@
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/home/home_viewmodel.dart';
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);
@override
Widget build(BuildContext context) {
bool isDark = getThemeManager(context).isDarkMode;
return ViewModelBuilder.reactive(
viewModelBuilder: () => HomeViewModel(),
builder: (context, model, child) => Scaffold(
@ -49,31 +48,36 @@ class HomeView extends StatelessWidget {
child: Text(
'',
style: GoogleFonts.inter(
fontSize: 18,
fontSize: 20,
color: isDark
? const Color(0xffD1E1FA)
: const Color(0xff384E6E),
),
),
),
const SizedBox(height: 10),
LatestCommitCard(
color: isDark ? const Color(0xff1B222B) : Colors.grey[350],
),
color: Theme.of(context).colorScheme.primary),
const SizedBox(height: 14),
I18nText(
'homeView.patchedSubtitle',
child: Text(
'',
style: GoogleFonts.inter(
fontSize: 18,
fontSize: 20,
color: isDark
? const Color(0xffD1E1FA)
: const Color(0xff384E6E),
),
),
),
const SizedBox(height: 14),
AvailableUpdatesCard(
color: isDark ? const Color(0xff1B222B) : Colors.grey[350],
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(height: 15),
InstalledAppsCard(
color: isDark ? const Color(0xff1B222B) : Colors.grey[350],
color: Theme.of(context).colorScheme.primary,
),
],
),

View file

@ -2,10 +2,10 @@ 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/widgets/app_selector_card.dart';
import 'package:revanced_manager/ui/widgets/patch_selector_card.dart';
import 'package:stacked/stacked.dart';
import 'package:stacked_themes/stacked_themes.dart';
import 'patcher_viewmodel.dart';
@ -14,7 +14,6 @@ class PatcherView extends StatelessWidget {
@override
Widget build(BuildContext context) {
bool isDark = getThemeManager(context).isDarkMode;
return ViewModelBuilder<PatcherViewModel>.reactive(
disposeViewModel: false,
viewModelBuilder: () => locator<PatcherViewModel>(),
@ -25,7 +24,7 @@ class PatcherView extends StatelessWidget {
onPressed: () => {},
label: I18nText('patcherView.fabButton'),
icon: const Icon(Icons.build),
backgroundColor: const Color(0xff7792BA),
backgroundColor: Theme.of(context).colorScheme.secondary,
foregroundColor: Colors.white,
),
),
@ -49,7 +48,7 @@ class PatcherView extends StatelessWidget {
const SizedBox(height: 23),
AppSelectorCard(
onPressed: model.navigateToAppSelector,
color: isDark ? const Color(0xff1B222B) : Colors.grey[350],
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(height: 16),
Opacity(
@ -58,7 +57,7 @@ class PatcherView extends StatelessWidget {
: (model.dimPatchCard ? 0.75 : 1),
child: PatchSelectorCard(
onPressed: model.navigateToPatchesSelector,
color: isDark ? const Color(0xff1B222B) : Colors.grey[350],
color: Theme.of(context).colorScheme.primary,
),
),
],

View file

@ -1,11 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:revanced_manager/app/app.locator.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/patch_item.dart';
import 'package:revanced_manager/ui/widgets/search_bar.dart';
import 'package:stacked/stacked.dart';
import 'package:stacked_themes/stacked_themes.dart';
class PatchesSelectorView extends StatefulWidget {
const PatchesSelectorView({Key? key}) : super(key: key);
@ -20,7 +20,6 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
@override
Widget build(BuildContext context) {
bool isDark = getThemeManager(context).isDarkMode;
return ViewModelBuilder<PatchesSelectorViewModel>.reactive(
disposeViewModel: false,
onModelReady: (model) => model.initialise(),
@ -35,12 +34,12 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
children: [
SearchBar(
fillColor:
isDark ? Colors.blueGrey[700] : Colors.grey[400],
isDark ? const Color(0xff1B222B) : Colors.grey[200],
hintText: FlutterI18n.translate(
context,
'patchesSelectorView.searchBarHint',
),
hintTextColor: isDark ? Colors.white : Colors.grey[800],
hintTextColor: Theme.of(context).colorScheme.tertiary,
onQueryChanged: (searchQuery) {
setState(() {
query = searchQuery;
@ -70,9 +69,9 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
),
],
)
: const Center(
: Center(
child: CircularProgressIndicator(
color: Color(0xff7792BA),
color: Theme.of(context).colorScheme.secondary,
),
),
),

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:revanced_manager/theme.dart';
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart';
import 'package:stacked/stacked.dart';
import 'package:stacked_themes/stacked_themes.dart';
@ -28,9 +29,9 @@ class SettingsView extends StatelessWidget {
title: I18nText('settingsView.themeLabel'),
subtitle: I18nText('settingsView.themeHint'),
trailing: Switch(
value: model.isDarkMode,
value: isDark,
onChanged: (value) {
model.isDarkMode = value;
isDark = value;
getThemeManager(context).toggleDarkLightTheme();
},
),

View file

@ -1,7 +1,6 @@
import 'package:stacked/stacked.dart';
class SettingsViewModel extends BaseViewModel {
bool isDarkMode = true;
void setLanguage(String language) {
notifyListeners();
}

View file

@ -38,7 +38,8 @@ class ApplicationItem extends StatelessWidget {
title: Text(
name,
style: GoogleFonts.roboto(
color: const Color(0xff7792BA),
color: Theme.of(context).colorScheme.secondary,
fontWeight: FontWeight.w600,
),
),
subtitle: Text(

View file

@ -3,7 +3,6 @@ import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:revanced_manager/ui/widgets/application_item.dart';
import 'package:revanced_manager/ui/widgets/patch_text_button.dart';
import 'package:stacked_themes/stacked_themes.dart';
class AvailableUpdatesCard extends StatelessWidget {
final Color? color;
@ -14,40 +13,42 @@ class AvailableUpdatesCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
bool isDark = getThemeManager(context).isDarkMode;
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: color,
),
padding: const EdgeInsets.symmetric(vertical: 18, horizontal: 20),
padding: const EdgeInsets.symmetric(vertical: 18, horizontal: 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
I18nText(
'availableUpdatesCard.widgetTitle',
child: Text(
'',
style: GoogleFonts.inter(
fontSize: 16,
color: const Color(0xff7792BA),
fontWeight: FontWeight.w500,
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
I18nText(
'availableUpdatesCard.widgetTitle',
child: Text(
'',
style: GoogleFonts.inter(
fontSize: 16,
color: Theme.of(context).colorScheme.secondary,
fontWeight: FontWeight.w500,
),
),
),
),
PatchTextButton(
text: FlutterI18n.translate(
context,
'availableUpdatesCard.patchButton',
PatchTextButton(
text: FlutterI18n.translate(
context,
'availableUpdatesCard.patchButton',
),
onPressed: () => {},
backgroundColor: Theme.of(context).colorScheme.secondary,
),
onPressed: () => {},
backgroundColor: const Color(0xff7792BA),
),
],
],
),
),
ApplicationItem(
asset: 'assets/images/revanced.svg',
@ -67,7 +68,7 @@ class AvailableUpdatesCard extends StatelessWidget {
child: Text(
'',
style: GoogleFonts.roboto(
color: const Color(0xff8691A0),
color: Theme.of(context).colorScheme.tertiary,
fontWeight: FontWeight.w700,
),
),
@ -76,14 +77,14 @@ class AvailableUpdatesCard extends StatelessWidget {
Text(
'fix: we made the player even worse (you love)',
style: GoogleFonts.roboto(
color: const Color(0xff8691A0),
color: Theme.of(context).colorScheme.tertiary,
),
),
const SizedBox(height: 4),
Text(
'chore: guhhughghu',
style: GoogleFonts.roboto(
color: const Color(0xff8691A0),
color: Theme.of(context).colorScheme.tertiary,
),
),
],

View file

@ -3,7 +3,6 @@ import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:revanced_manager/constants.dart';
import 'package:stacked_themes/stacked_themes.dart';
class InstalledAppItem extends StatefulWidget {
final String name;
@ -24,14 +23,13 @@ class InstalledAppItem extends StatefulWidget {
class _InstalledAppItemState extends State<InstalledAppItem> {
@override
Widget build(BuildContext context) {
bool isDark = getThemeManager(context).isDarkMode;
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0),
child: Container(
padding: const EdgeInsets.all(12.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: isDark ? const Color(0xff1B222B) : Colors.grey[350],
color: Theme.of(context).colorScheme.primary,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,

View file

@ -28,7 +28,7 @@ class InstalledAppsCard extends StatelessWidget {
'',
style: GoogleFonts.inter(
fontSize: 16,
color: const Color(0xff7792BA),
color: Theme.of(context).colorScheme.secondary,
fontWeight: FontWeight.w500,
),
),
@ -44,7 +44,7 @@ class InstalledAppsCard extends StatelessWidget {
child: Text(
'',
style: GoogleFonts.roboto(
color: const Color(0xff8691A0),
color: Theme.of(context).colorScheme.tertiary,
fontWeight: FontWeight.w700,
),
),
@ -53,14 +53,14 @@ class InstalledAppsCard extends StatelessWidget {
Text(
'fix: we made the player even worse (you love)',
style: GoogleFonts.roboto(
color: const Color(0xff8691A0),
color: Theme.of(context).colorScheme.tertiary,
),
),
const SizedBox(height: 4),
Text(
'chore: guhhughghu',
style: GoogleFonts.roboto(
color: const Color(0xff8691A0),
color: Theme.of(context).colorScheme.tertiary,
),
),
],

View file

@ -95,7 +95,7 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
'latestCommitCard.updateButton',
),
onPressed: () => {},
backgroundColor: const Color(0xff7792BA),
backgroundColor: Theme.of(context).colorScheme.secondary,
),
],
),

View file

@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:stacked_themes/stacked_themes.dart';
// ignore: must_be_immutable
class PatchItem extends StatefulWidget {
@ -26,11 +25,9 @@ class PatchItem extends StatefulWidget {
class _PatchItemState extends State<PatchItem> {
@override
Widget build(BuildContext context) {
bool isDark = getThemeManager(context).isDarkMode;
return Container(
decoration: BoxDecoration(
color: isDark ? const Color(0xff1B222B) : Colors.grey[300],
borderRadius: BorderRadius.circular(10),
color: Theme.of(context).colorScheme.primary,
),
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 12),
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),

View file

@ -5,7 +5,6 @@ import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/constants.dart';
import 'package:revanced_manager/ui/views/app_selector/app_selector_viewmodel.dart';
import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart';
import 'package:stacked_themes/stacked_themes.dart';
class PatchSelectorCard extends StatelessWidget {
final Function()? onPressed;

View file

@ -18,24 +18,21 @@ class PatchTextButton extends StatelessWidget {
Widget build(BuildContext context) {
return TextButton(
onPressed: onPressed,
style: TextButton.styleFrom(
side: BorderSide(
color: borderColor,
width: 1,
),
primary: Colors.white,
backgroundColor: backgroundColor,
padding: const EdgeInsets.symmetric(
vertical: 10,
horizontal: 24,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
),
style: Theme.of(context).textButtonTheme.style?.copyWith(
backgroundColor: MaterialStateProperty.all<Color?>(backgroundColor),
side: MaterialStateProperty.all<BorderSide>(
BorderSide(
color: borderColor,
width: 1,
),
),
),
child: Text(
text,
style: interTextStyle,
style: interTextStyle.copyWith(
color: backgroundColor == Colors.transparent
? const Color.fromRGBO(119, 146, 186, 1)
: Colors.white),
),
);
}