-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from Merrit/dev
- Loading branch information
Showing
21 changed files
with
484 additions
and
468 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 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 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:bloc/bloc.dart'; | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:nyrna/application/theme/enums/app_theme.dart'; | ||
import 'package:nyrna/settings/settings.dart'; | ||
|
||
part 'theme_state.dart'; | ||
|
||
late ThemeCubit themeCubit; | ||
|
||
class ThemeCubit extends Cubit<ThemeState> { | ||
ThemeCubit() : super(ThemeState(appTheme: Settings.instance.appTheme)) { | ||
themeCubit = this; | ||
} | ||
|
||
void changeTheme(AppTheme appTheme) { | ||
Settings.instance.appTheme = appTheme; | ||
emit(state.copyWith(appTheme: appTheme)); | ||
} | ||
} |
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,49 @@ | ||
part of 'theme_cubit.dart'; | ||
|
||
@immutable | ||
class ThemeState extends Equatable { | ||
final AppTheme appTheme; | ||
|
||
ThemeState({ | ||
required this.appTheme, | ||
}); | ||
|
||
final Color pitchBlack = Colors.black; | ||
|
||
ThemeData get themeData { | ||
final brightness = | ||
(appTheme == AppTheme.light) ? Brightness.light : Brightness.dark; | ||
final isPitchBlack = (appTheme == AppTheme.pitchBlack); | ||
final appBarTheme = AppBarTheme( | ||
centerTitle: true, | ||
backgroundColor: isPitchBlack ? pitchBlack : null, | ||
); | ||
final cardColor = isPitchBlack ? pitchBlack : null; | ||
final colorScheme = ThemeData().colorScheme.copyWith( | ||
brightness: brightness, | ||
secondary: Colors.lightBlueAccent, | ||
); | ||
final scaffoldBackgroundColor = isPitchBlack ? pitchBlack : null; | ||
|
||
final toggleableActiveColor = | ||
isPitchBlack ? Colors.blue[900] : Colors.lightBlueAccent; | ||
return ThemeData( | ||
appBarTheme: appBarTheme, | ||
cardColor: cardColor, | ||
colorScheme: colorScheme, | ||
scaffoldBackgroundColor: scaffoldBackgroundColor, | ||
toggleableActiveColor: toggleableActiveColor, | ||
); | ||
} | ||
|
||
ThemeState copyWith({ | ||
AppTheme? appTheme, | ||
}) { | ||
return ThemeState( | ||
appTheme: appTheme ?? this.appTheme, | ||
); | ||
} | ||
|
||
@override | ||
List<Object> get props => [appTheme]; | ||
} |
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,5 @@ | ||
enum AppTheme { | ||
light, | ||
dark, | ||
pitchBlack, | ||
} |
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,2 @@ | ||
export 'enums/app_theme.dart'; | ||
export 'cubit/theme_cubit.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
Oops, something went wrong.