mirror of
https://github.com/hanskokx/arcane_framework.git
synced 2026-05-14 10:29:06 +02:00
Made ArcaneTheme private (_ArcaneTheme)
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -235,7 +235,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"The current theme mode is ${context.themeMode.name} and "
|
||||
"The current theme mode is ${Arcane.theme.currentModeOf(context).name} and "
|
||||
"is ${Arcane.theme.isFollowingSystemTheme ? "" : "not "}"
|
||||
"following the system theme.",
|
||||
),
|
||||
|
||||
@@ -44,7 +44,6 @@ export "package:arcane_framework/src/providers/service_provider.dart";
|
||||
export "package:arcane_framework/src/services/authentication/authentication_service.dart";
|
||||
export "package:arcane_framework/src/services/feature_flags/feature_flags_service.dart";
|
||||
export "package:arcane_framework/src/services/logging/logging_service.dart";
|
||||
export "package:arcane_framework/src/services/reactive_theme/arcane_theme.dart";
|
||||
export "package:arcane_framework/src/services/reactive_theme/reactive_theme_service.dart";
|
||||
export "package:arcane_framework/src/services/reactive_theme/reactive_theme_switcher.dart";
|
||||
export "package:result_monad/result_monad.dart";
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
class ArcaneTheme extends InheritedWidget {
|
||||
final ThemeMode themeMode;
|
||||
final bool followSystem;
|
||||
final ThemeData? theme;
|
||||
|
||||
const ArcaneTheme({
|
||||
required super.child,
|
||||
this.themeMode = ThemeMode.light,
|
||||
this.followSystem = false,
|
||||
this.theme,
|
||||
super.key,
|
||||
});
|
||||
|
||||
static ArcaneTheme? of(BuildContext context) {
|
||||
return context.dependOnInheritedWidgetOfExactType<ArcaneTheme>();
|
||||
}
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(ArcaneTheme oldWidget) {
|
||||
return themeMode != oldWidget.themeMode ||
|
||||
followSystem != oldWidget.followSystem ||
|
||||
theme != oldWidget.theme;
|
||||
}
|
||||
}
|
||||
@@ -19,11 +19,3 @@ extension DarkMode on BuildContext {
|
||||
return brightness == Brightness.dark;
|
||||
}
|
||||
}
|
||||
|
||||
extension ArcaneThemeContext on BuildContext {
|
||||
/// Get the current theme mode from the nearest ArcaneThemeInherited widget
|
||||
ThemeMode get themeMode {
|
||||
return ArcaneTheme.of(this)?.themeMode ??
|
||||
ArcaneReactiveTheme.I.currentThemeMode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class _ArcaneThemeSwitcherState extends State<ArcaneThemeSwitcher>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ArcaneTheme(
|
||||
return _ArcaneTheme(
|
||||
themeMode: ArcaneReactiveTheme.I.currentThemeMode,
|
||||
followSystem: ArcaneReactiveTheme.I.isFollowingSystemTheme,
|
||||
theme: ArcaneReactiveTheme.I.currentTheme,
|
||||
@@ -68,3 +68,35 @@ class _ArcaneThemeSwitcherState extends State<ArcaneThemeSwitcher>
|
||||
super.didChangePlatformBrightness();
|
||||
}
|
||||
}
|
||||
|
||||
class _ArcaneTheme extends InheritedWidget {
|
||||
final ThemeMode themeMode;
|
||||
final bool followSystem;
|
||||
final ThemeData? theme;
|
||||
|
||||
const _ArcaneTheme({
|
||||
required super.child,
|
||||
this.themeMode = ThemeMode.light,
|
||||
this.followSystem = false,
|
||||
this.theme,
|
||||
});
|
||||
|
||||
static _ArcaneTheme? of(BuildContext context) {
|
||||
return context.dependOnInheritedWidgetOfExactType<_ArcaneTheme>();
|
||||
}
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(_ArcaneTheme oldWidget) {
|
||||
return themeMode != oldWidget.themeMode ||
|
||||
followSystem != oldWidget.followSystem ||
|
||||
theme != oldWidget.theme;
|
||||
}
|
||||
}
|
||||
|
||||
extension ArcaneThemeContext on BuildContext {
|
||||
/// Get the current theme mode from the nearest ArcaneThemeInherited widget
|
||||
ThemeMode get themeMode {
|
||||
return _ArcaneTheme.of(this)?.themeMode ??
|
||||
ArcaneReactiveTheme.I.currentThemeMode;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user