2022-09-05 04:32:36 +02:00
|
|
|
import 'package:dynamic_color/dynamic_color.dart';
|
|
|
|
import 'package:dynamic_themes/dynamic_themes.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
|
|
import 'package:revanced_manager/app/app.router.dart';
|
|
|
|
import 'package:revanced_manager/theme.dart';
|
|
|
|
import 'package:stacked_services/stacked_services.dart';
|
|
|
|
|
|
|
|
class DynamicThemeBuilder extends StatelessWidget {
|
|
|
|
const DynamicThemeBuilder({
|
|
|
|
Key? key,
|
|
|
|
required this.title,
|
|
|
|
required this.home,
|
|
|
|
required this.localizationsDelegates,
|
|
|
|
}) : super(key: key);
|
2023-01-30 13:35:06 +01:00
|
|
|
final String title;
|
|
|
|
final Widget home;
|
|
|
|
final Iterable<LocalizationsDelegate> localizationsDelegates;
|
2022-09-05 04:32:36 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return DynamicColorBuilder(
|
|
|
|
builder: (lightColorScheme, darkColorScheme) {
|
2023-01-30 13:35:06 +01:00
|
|
|
final ThemeData lightDynamicTheme = ThemeData(
|
2022-09-05 04:32:36 +02:00
|
|
|
useMaterial3: true,
|
2022-09-06 19:07:23 +02:00
|
|
|
navigationBarTheme: NavigationBarThemeData(
|
|
|
|
labelTextStyle: MaterialStateProperty.all(
|
2022-09-07 13:01:04 +02:00
|
|
|
GoogleFonts.roboto(
|
2023-02-07 13:46:29 +01:00
|
|
|
color: lightColorScheme?.onSurface,
|
2022-09-06 19:07:23 +02:00
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-09-05 04:32:36 +02:00
|
|
|
colorScheme: lightColorScheme?.harmonized(),
|
|
|
|
textTheme: GoogleFonts.robotoTextTheme(ThemeData.light().textTheme),
|
|
|
|
);
|
2023-01-30 13:35:06 +01:00
|
|
|
final ThemeData darkDynamicTheme = ThemeData(
|
2022-09-05 04:32:36 +02:00
|
|
|
useMaterial3: true,
|
2022-09-06 19:07:23 +02:00
|
|
|
navigationBarTheme: NavigationBarThemeData(
|
|
|
|
labelTextStyle: MaterialStateProperty.all(
|
2022-09-07 13:01:04 +02:00
|
|
|
GoogleFonts.roboto(
|
2023-02-07 13:46:29 +01:00
|
|
|
color: darkColorScheme?.onSurface,
|
2022-09-06 19:07:23 +02:00
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-09-05 04:32:36 +02:00
|
|
|
colorScheme: darkColorScheme?.harmonized(),
|
|
|
|
textTheme: GoogleFonts.robotoTextTheme(ThemeData.dark().textTheme),
|
|
|
|
);
|
|
|
|
return DynamicTheme(
|
|
|
|
themeCollection: ThemeCollection(
|
|
|
|
themes: {
|
|
|
|
0: lightCustomTheme,
|
|
|
|
1: darkCustomTheme,
|
|
|
|
2: lightDynamicTheme,
|
|
|
|
3: darkDynamicTheme,
|
|
|
|
},
|
2022-09-15 00:23:03 +02:00
|
|
|
fallbackTheme: lightCustomTheme,
|
2022-09-05 04:32:36 +02:00
|
|
|
),
|
|
|
|
builder: (context, theme) => MaterialApp(
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
title: title,
|
|
|
|
navigatorKey: StackedService.navigatorKey,
|
|
|
|
onGenerateRoute: StackedRouter().onGenerateRoute,
|
|
|
|
theme: theme,
|
|
|
|
home: home,
|
|
|
|
localizationsDelegates: localizationsDelegates,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
2023-02-19 04:16:49 +01:00
|
|
|
}
|