Re-add getters on ArcaneTheme

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2025-04-28 14:33:26 +02:00
parent bfa5c646d7
commit 68595f0a20
@@ -1,3 +1,6 @@
import "dart:async";
import "package:arcane_framework/src/services/reactive_theme/reactive_theme_service.dart";
import "package:flutter/material.dart"; import "package:flutter/material.dart";
class ArcaneTheme extends InheritedWidget { class ArcaneTheme extends InheritedWidget {
@@ -20,4 +23,58 @@ class ArcaneTheme extends InheritedWidget {
return themeMode != oldWidget.themeMode || return themeMode != oldWidget.themeMode ||
followSystem != oldWidget.followSystem; followSystem != oldWidget.followSystem;
} }
/// Returns the singleton instance of the [ArcaneReactiveTheme] service.
ArcaneReactiveTheme get service => ArcaneReactiveTheme.I;
/// Indicates whether the theme is currently set to follow the system theme.
bool get isFollowingSystemTheme => service.isFollowingSystemTheme;
/// Provides a stream of [ThemeMode] changes that can be listened to for reactive updates.
Stream<ThemeMode> get themeChanges => service.themeChanges;
/// Returns the currently active [ThemeMode].
ThemeMode get currentTheme => service.currentTheme;
/// Returns the [ThemeMode] currently set at the OS/system level.
ThemeMode get systemTheme => service.systemTheme;
/// Returns the dark [ThemeData] configuration.
ThemeData get dark => service.dark;
/// Returns a [ValueNotifier] containing the dark [ThemeData], allowing for reactive updates.
ValueNotifier<ThemeData> get darkTheme => service.darkTheme;
/// Returns the light [ThemeData] configuration.
ThemeData get light => service.light;
/// Returns a [ValueNotifier] containing the light [ThemeData], allowing for reactive updates.
ValueNotifier<ThemeData> get lightTheme => service.lightTheme;
/// A shortcut to the [ArcaneReactiveTheme] function that switches the active theme mode.
///
/// - [themeMode] (Optional): Specify which theme mode to switch to.
/// Otherwise, tries to determine whether to switch to light or dark mode, automatically.
ArcaneReactiveTheme Function({ThemeMode? themeMode}) get switchTheme =>
service.switchTheme;
/// A shortcut to the [ArcaneReactiveTheme] function that follows the system theme.
///
/// - [context]: The [BuildContext] required to access system theme information.
void Function(BuildContext context) followSystemTheme(
BuildContext context,
) =>
service.followSystemTheme;
/// A shortcut to the [ArcaneReactiveTheme] function that updates the dark theme configuration.
///
/// The function accepts a [ThemeData] parameter to set as the new dark theme.
ArcaneReactiveTheme Function(ThemeData theme) get setDarkTheme =>
service.setDarkTheme;
/// A shortcut to the [ArcaneReactiveTheme] function that updates the light theme configuration.
///
/// The function accepts a [ThemeData] parameter to set as the new light theme.
ArcaneReactiveTheme Function(ThemeData theme) get setLightTheme =>
service.setLightTheme;
} }