-
Notifications
You must be signed in to change notification settings - Fork 3
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
1696: Apply fonts #1728
1696: Apply fonts #1728
Conversation
Have you considered adding a DefaultTextStyle widget instead? This one would be added to the "root" widget and then all Text Widgets would use this text style as their default. |
Hm i could set the I see your point and i may add this additionally but i also see the risk that styles will be forgotten. With this approach we have a standard way to style text elements. |
After diving a little bit into the theming / styling system built into Flutter, these were my findings:
If we render more "custom" widgets - such as the Tappable Cards in the Ausweisen Tab when no card is active - we still should supply theme with the appropriate text style. I believe, however, that even then a reasonable default will be set which is also taken from the theme.
By now, I believe, we should not render this DefaultTextStyle widget at the root of our app. The flutter MaterialApp widget and friends will supply the correct defaults already. We only have to take care of the ThemeData object.
Yes, I agree. But this design system is already in place and specified by the Material design guidelines. The widgets use these design guidelines when defining their defaults. |
Alright thx for this great explanation. |
I see... have you tried to use the tips discussed here? https://stackoverflow.com/a/74263526/3245533 |
Yes i always use this hovering mode. I really find this very difficult and some inherited styles are not should. For tiles with proper styles applied everything looks fine I see the point in removing unneeded styles but its super difficult to keep all the docs you mentioned in mind and to double check if everything applied correctly. So i'm not sure which way to go tbh. |
I think my argument would be the exact opposite: It's much harder to always remember the correct style (for e.g. ListTile title, ListTile subtitle, etc.). Therefore, it's much easier to be able to rely on the defaults that are set by ListTile. The fact that they are always based on the theme, makes it easy to know that it always uses the correct font family. But I agree that the experience of the inspector is quite unpleasant when it comes to inspecting text styles. You have to dig through this dependencies set (expand every "bucket") and eventually you can find the DefaultTextStyle dependency which then tells you the text style it applies. |
Okay i think then a good solution would be to define the typography classes like
And apply them on textTheme and on f.e. subtitle and title of the ListTile f.e. and the other themes we adjust. Then it should automatically rely on that |
…ables, removed unneeded variables
# Conflicts: # frontend/lib/identification/util/activate_card.dart
@michael-markl i think i moved everything that should be defined in the theme to the |
One more remark: Everything inside a Material widget (such as everything inside a Scaffold or a Dialog) uses |
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.
deleted. sorry got lost in my browser tabs.
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.
Code looks good. couldn't test as i need to fix protobuf before.
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.
frontend/lib/widgets/app_bars.dart
Outdated
@@ -101,10 +104,10 @@ class SearchSliverAppBarState extends State<SearchSliverAppBar> { | |||
focusNode: focusNode, | |||
decoration: InputDecoration.collapsed( | |||
hintText: t.search.searchHint, | |||
hintStyle: TextStyle(color: foregroundColor?.withOpacity(0.8)), | |||
hintStyle: theme.textTheme.bodyLarge, |
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.
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.
alright. yes on dark theme it was fine. this styling stuff is so annoying. thx for the find
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.
yes, I agree 🙈
(I haven't checked all the views yet, maybe something else will arise)
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.
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.
I decided explicitly not to use opacity due to bad readability.
I think the label tells you what to do it's not just a pure placeholder.
I think it's more import that it can be read and users know that there is an input than user don't know that they can type in sth.
But maybe @hauf-toni has an opinion on that
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.
@@ -44,6 +45,7 @@ class ContactInfoRow extends StatelessWidget { | |||
Expanded( | |||
child: Text( | |||
_description, | |||
style: theme.textTheme.bodyMedium, |
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.
💭 not sure if that's important, but it was grey before (now it's black)
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.
hm i think thats okay
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.
I personally think it looks more appealing when colors are different, but maybe it's too subjective
@seluianova thx for proper testing. I addressed the issues. |
@@ -102,24 +102,21 @@ class _FilterBarButtonState extends State<FilterBarButton> with SingleTickerProv | |||
widget.onCategoryPress(widget.asset, isSelected); | |||
}); | |||
}, | |||
child: Padding( | |||
padding: const EdgeInsets.only(top: 4), |
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.
The padding should be readded.
@@ -87,7 +87,7 @@ class _FilterBarButtonState extends State<FilterBarButton> with SingleTickerProv | |||
builder: (context, child) { | |||
final color = Color.lerp(theme.colorScheme.background, selectedColor, colorTween.value); | |||
return ConstrainedBox( | |||
constraints: BoxConstraints.tightFor(width: width, height: 70), | |||
constraints: BoxConstraints.tightFor(width: width, height: 74), |
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.
Was there a specific reason to increase it? Maybe because of the different Koblenz font, we need more space?
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.
Indeed. the font exceeds line height. Maybe we could also decrease lineHeight
), | ||
const SizedBox(height: 4), | ||
Text( | ||
store.description ?? t.store.noDescriptionAvailable, | ||
maxLines: 1, | ||
overflow: TextOverflow.ellipsis, | ||
style: Theme.of(context).textTheme.bodyMedium, | ||
style: theme.textTheme.bodyLarge?.apply(color: theme.hintColor), |
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.
Is it intentional that you changed this to bodyLarge?
@@ -15,7 +15,7 @@ class NegativeVerificationResultDialog extends StatelessWidget { | |||
title: t.identification.notVerified, | |||
icon: Icons.error, | |||
iconColor: Colors.red, | |||
child: Text(reason), | |||
child: Text(reason, style: Theme.of(context).textTheme.bodyLarge), |
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.
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.
So, I tried to test as much as possible and noted some minor findings. Maybe I missed something because it was a lot to test...
Anyway if something else comes up I believe it can be fixed later.
Thanks for tackling this huge task 👍
💭 I think it would be nice to have a default text style (bodyMedium, for example), that doesn't need to be set explicitly to each text
UPD. ok, I see the discussion in the beginning about that
I believe the Scaffold widget has default body medium as michael mentioned and thats often a root widget. but you can create a task and we can add some default text widgets if you think its still needed. Thx for testing |
c0d487a
to
c820f44
Compare
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.
✅ Code Health Quality Gates: OK
Change in average Code Health of affected files: +0.00 (9.67 -> 9.67)
* 1696: add styles to texts and text buttons * 1696: move basic widget styles to theme, create typography class variables, removed unneeded variables * 1696: readd const * 1696: applied text color on tiles and dialog
Short description
Since we enabled a custom font for koblenz which is applies on the theme. we have to strictly style our texts and text buttons with our theme to apply the fonts everywhere.
Proposed changes
Side effects
Testing
Resolved issues
Fixes: #1696