diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b16e81..b13333a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 1.0.3 + +* Added the ability to switch back to the normal environment from the debug environment in ArcaneEnvironment +* (breaking) Made the optional `onLoggedOut` callback a Future instead of a void function in ArcaneAuthenticationService +* Added additional error handling to the login method in ArcaneAuthenticationService +* Added support for following the system's theme in ArcaneTheme +* Removed the BuildContext parameter from the `switchTheme` method in ArcaneTheme + ## 1.0.2 * Migrated ArcaneAuthenticationService's isSignedIn to a ValueListenable diff --git a/README.md b/README.md index 9b36911..77f574a 100644 --- a/README.md +++ b/README.md @@ -452,7 +452,7 @@ await Arcane.auth.setDebug(); The Arcane Framework provides a simple interface for managing themes in your application, with dynamic switching between dark and light themes based on the user's system settings, or manually switching between themes. -To get started, first register your `ThemeData` objects with the Arcane theme module, then reference the theme in your `MaterialApp` or `CupertinoApp`: +To get started, first register your `ThemeData` objects with the Arcane theme module: ```dart void main() { @@ -463,21 +463,66 @@ void main() { runApp( ArcaneApp( - child: MaterialApp( - theme: Arcane.theme.light, - darkTheme: Arcane.theme.dark, - themeMode: context.isDarkMode ? ThemeMode.dark : ThemeMode.light, - ), + child: MainApp(), ), ); } ``` -Once configured, you'll have access to theme-related methods and properties: +From here, you can either follow the system theme: + +```dart +// Follow the system's theme mode +class MainApp extends StatefulWidget { + const MainApp({super.key}); + + @override + State createState() => _MainAppState(); +} + +class _MainAppState extends State { + @override + Widget build(BuildContext context) { + return ArcaneApp( + child: MaterialApp( + theme: Arcane.theme.light, + darkTheme: Arcane.theme.dark, + themeMode: Arcane.theme.systemTheme.value, + ), + ); + } + + @override + void didChangeDependencies() { + Arcane.theme.followSystemTheme(context); + super.didChangeDependencies(); + } +} +``` + +or manually control the theme mode: + +```dart +// Manually control the theme mode +class MainApp extends StatelessWidget { + @override + Widget build(BuildContext context) { + return ArcaneApp( + child: MaterialApp( + theme: Arcane.theme.light, + darkTheme: Arcane.theme.dark, + themeMode: Arcane.theme.currentMode, + ), + ); + } +} +``` + +Then, you can switch modes whenever you want: ```dart // Switch between light and dark themes -Arcane.theme.switchTheme(context); +Arcane.theme.switchTheme(); // Access current theme data final ThemeData currentTheme = Arcane.theme.currentMode == ThemeMode.dark diff --git a/pubspec.yaml b/pubspec.yaml index 4537c3e..2da903f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: arcane_framework description: "Agnostic Reusable Component Architecture for New Ecosystems" -version: 1.0.2 +version: 1.0.3 repository: https://github.com/hanskokx/arcane_framework issue_tracker: https://github.com/hanskokx/arcane_framework/issues