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:
@@ -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