-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace ThemeBloc
with ThemeSettings
class to change ThemeBrightness, textScalingFactor and VisualDensity.
#158
Conversation
Visit the preview URL for this PR (updated for commit e6c1d6c): https://sharezone-test--pr158-theme-settings-eo83ht8t.web.app (expires Thu, 12 May 2022 12:32:31 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
ThemeBloc
with ThemeSettings
class to change ThemeBrightness, textScalingFactor and VisualDensity.
This is how it looks like if you change textScalingFactor TextScalingFactor.movVisualDensity Visual.Density.mov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 🚀
LGTM
Can you add tests for ThemeSettings
?
And we should also have Analytics, when someone changes the theme. Should we do this in another PR?
extension on ThemeBrightness { | ||
String serialize() { | ||
return { | ||
ThemeBrightness.dark: 'dark', | ||
ThemeBrightness.light: 'light', | ||
ThemeBrightness.system: 'system', | ||
}[this]!; | ||
} | ||
} | ||
|
||
extension on String? { | ||
ThemeBrightness? toThemeBrightness() { | ||
if (this == null) return null; | ||
|
||
return { | ||
'dark': ThemeBrightness.dark, | ||
'light': ThemeBrightness.light, | ||
'system': ThemeBrightness.system, | ||
}[this]; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When #153 is merged, we can use the built in Dart features for this (released in 2.15):
enum MyEnum {
one, two, three
}
void main() {
print(MyEnum.one.name); // Prints "one".
}
print(MyEnum.values.byName('two') == MyEnum.two); // Prints "true".
Co-authored-by: Nils Reichardt <[email protected]>
Co-authored-by: Nils Reichardt <[email protected]>
…ezone-app into theme-settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Replaced
ThemeBloc
with a new class calledThemeSettings
that can be used to:VisualDensity
of the apptextScalingFactor
Currently the user can still only toggle the brightness (e.g. dark-mode).
Another PR in the Future might add a nicer UI to change also the other settings.
The
ThemeSettings
class is used viaProvider
and doesn't need aStreamProvider
: