-
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.
fix: update functionality switch between themes after migrate to `wid…
…getbook`
- Loading branch information
1 parent
99d0370
commit 48083c3
Showing
10 changed files
with
81 additions
and
119 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
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,21 @@ | ||
import 'package:fluent_ui/fluent_ui.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:gui/src/core/enums/theme_modes.dart'; | ||
import 'package:pactus_gui_widgetbook/app_styles.dart'; | ||
|
||
part 'theme_event.dart'; | ||
part 'theme_state.dart'; | ||
|
||
class ThemeBloc extends Bloc<ThemeEvent, ThemeState> { | ||
ThemeBloc() | ||
: super( | ||
ThemeState.initial(AppThemeData.lightTheme()), | ||
ThemeState.initial(ThemeMode.light), | ||
) { | ||
on<ThemeChanged>(_onThemeChanged); | ||
} | ||
|
||
void _onThemeChanged(ThemeChanged event, Emitter<ThemeState> emit) { | ||
final isLightTheme = event.theme == ThemeModes.light; | ||
|
||
final themeData = | ||
isLightTheme ? AppThemeData.lightTheme() : AppThemeData.darkTheme(); | ||
|
||
final toggleThemeMode=event.theme==ThemeMode.light?ThemeMode.dark:ThemeMode.light; | ||
emit( | ||
ThemeState.initial(themeData), | ||
ThemeState.initial(event.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
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
part of 'theme_bloc.dart'; | ||
|
||
class ThemeState { | ||
ThemeState._({required this.themeData}); | ||
ThemeState._({required this.themeMode,}); | ||
|
||
factory ThemeState.initial(FluentThemeData themeData) { | ||
return ThemeState._(themeData: themeData); | ||
factory ThemeState.initial(ThemeMode themeMode) { | ||
return ThemeState._(themeMode: themeMode); | ||
} | ||
final FluentThemeData themeData; | ||
final ThemeMode themeMode; | ||
} |
33 changes: 0 additions & 33 deletions
33
lib/src/features/main/theme/presentation/widgets/theme_selector.dart
This file was deleted.
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
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