-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
no feat(router): implement GoRouter navigation system
conflict: resolved conflicts approved by esmaeil-ahmadipour
- Loading branch information
Showing
15 changed files
with
760 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/// # [ThemeModes] Documentation | ||
/// | ||
/// An enumeration representing different modes of application themes. | ||
/// | ||
/// ## Enum Overview | ||
/// | ||
/// - Enum Name: [ThemeModes] | ||
/// - Values: | ||
/// - [light] : Represents the light theme mode. | ||
/// - [dark] : Represents the dark theme mode. | ||
enum ThemeModes { light, dark } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:gui/src/core/enums/theme_modes.dart'; | ||
import 'package:gui/src/features/main/theme/theme_data/app_theme_data.dart'; | ||
|
||
part 'theme_event.dart'; | ||
part 'theme_state.dart'; | ||
|
||
class ThemeBloc extends Bloc<ThemeEvent, ThemeState> { | ||
ThemeBloc() | ||
: super( | ||
ThemeState.initial(AppThemeData.themeDataModes[ThemeModes.light]!), | ||
) { | ||
on<ThemeChanged>(_onThemeChanged); | ||
} | ||
|
||
void _onThemeChanged(ThemeChanged event, Emitter<ThemeState> emit) { | ||
final isLightTheme = event.theme == ThemeModes.light; | ||
|
||
final textTheme = | ||
isLightTheme ? AppThemeData.lightTextTheme : AppThemeData.darkTextTheme; | ||
|
||
emit( | ||
ThemeState.initial( | ||
AppThemeData.themeDataModes[event.theme]! | ||
.copyWith(textTheme: textTheme), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
part of 'theme_bloc.dart'; | ||
|
||
abstract class ThemeEvent {} | ||
|
||
class ThemeChanged extends ThemeEvent { | ||
ThemeChanged({required this.theme}); | ||
final ThemeModes theme; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
part of 'theme_bloc.dart'; | ||
|
||
class ThemeState { | ||
ThemeState._({required this.themeData}); | ||
|
||
factory ThemeState.initial(ThemeData themeData) { | ||
return ThemeState._(themeData: themeData); | ||
} | ||
final ThemeData themeData; | ||
} |
33 changes: 33 additions & 0 deletions
33
lib/src/features/main/theme/presentation/widgets/theme_selector.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:gui/src/core/enums/theme_modes.dart'; | ||
import 'package:gui/src/features/main/theme/bloc/theme_bloc.dart'; | ||
import 'package:gui/src/features/main/theme/theme_data/pallets/on_surface_pallet.dart'; | ||
|
||
class ThemeSelector extends StatelessWidget { | ||
const ThemeSelector({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final theme = Theme.of(context); | ||
final isLightTheme = theme.brightness == Brightness.light; | ||
return Row( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
ElevatedButton( | ||
onPressed: () { | ||
context.read<ThemeBloc>().add( | ||
ThemeChanged( | ||
theme: isLightTheme ? ThemeModes.dark : ThemeModes.light, | ||
), | ||
); | ||
}, | ||
child: Icon( | ||
isLightTheme ? Icons.nightlight_round_rounded : Icons.sunny, | ||
color: theme.extension<OnSurfacePallet>()!.onSurface3, | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} |
Oops, something went wrong.