Skip to content

Commit

Permalink
text [nfc]: Remove some now-redundant fontFamily{,Fallback} attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbobbe committed Dec 6, 2023
1 parent d33dece commit 60ec0d5
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 57 deletions.
6 changes: 2 additions & 4 deletions lib/widgets/content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,10 @@ class Paragraph extends StatelessWidget {

final ParagraphNode node;

static TextStyle getTextStyle(BuildContext context) => TextStyle(
fontFamily: kDefaultFontFamily,
fontFamilyFallback: kDefaultFontFamilyFallback,
static TextStyle getTextStyle(BuildContext context) => const TextStyle(
fontSize: kBaseFontSize,
height: (17 / kBaseFontSize),
).merge(weightVariableTextStyle(context));
);

@override
Widget build(BuildContext context) {
Expand Down
4 changes: 0 additions & 4 deletions lib/widgets/emoji_reaction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ class ReactionChip extends StatelessWidget {
textWidthBasis: TextWidthBasis.longestLine,
textScaler: _labelTextScalerClamped(context),
style: TextStyle(
fontFamily: kDefaultFontFamily,
fontFamilyFallback: kDefaultFontFamilyFallback,
fontSize: (14 * 0.90),
height: 13 / (14 * 0.90),
color: labelColor,
Expand Down Expand Up @@ -352,8 +350,6 @@ class _TextEmoji extends StatelessWidget {
textAlign: TextAlign.end,
textScaler: _textEmojiScalerClamped(context),
style: TextStyle(
fontFamily: kDefaultFontFamily,
fontFamilyFallback: kDefaultFontFamilyFallback,
fontSize: 14 * 0.8,
height: 1, // to be denser when we have to wrap
color: selected ? _textColorSelected : _textColorUnselected,
Expand Down
22 changes: 8 additions & 14 deletions lib/widgets/inbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,10 @@ abstract class _HeaderItem extends StatelessWidget {
Expanded(child: Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Text(
style: TextStyle(
fontFamily: kDefaultFontFamily,
fontFamilyFallback: kDefaultFontFamilyFallback,
style: const TextStyle(
fontSize: 17,
height: (20 / 17),
color: const Color(0xFF222222),
color: Color(0xFF222222),
).merge(weightVariableTextStyle(context, wght: 600)),
maxLines: 1,
overflow: TextOverflow.ellipsis,
Expand Down Expand Up @@ -361,13 +359,11 @@ class _DmItem extends StatelessWidget {
Expanded(child: Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Text(
style: TextStyle(
fontFamily: kDefaultFontFamily,
fontFamilyFallback: kDefaultFontFamilyFallback,
style: const TextStyle(
fontSize: 17,
height: (20 / 17),
color: const Color(0xFF222222),
).merge(weightVariableTextStyle(context)),
color: Color(0xFF222222),
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
title))),
Expand Down Expand Up @@ -488,13 +484,11 @@ class _TopicItem extends StatelessWidget {
Expanded(child: Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Text(
style: TextStyle(
fontFamily: kDefaultFontFamily,
fontFamilyFallback: kDefaultFontFamilyFallback,
style: const TextStyle(
fontSize: 17,
height: (20 / 17),
color: const Color(0xFF222222),
).merge(weightVariableTextStyle(context)),
color: Color(0xFF222222),
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
topic))),
Expand Down
25 changes: 11 additions & 14 deletions lib/widgets/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,15 @@ class MarkAsReadWidget extends StatelessWidget {
style: FilledButton.styleFrom(
backgroundColor: _UnreadMarker.color,
minimumSize: const Size.fromHeight(38),
textStyle: TextStyle(
fontFamily: kDefaultFontFamily,
fontFamilyFallback: kDefaultFontFamilyFallback,
fontSize: 18,
height: (23 / 18),
).merge(weightVariableTextStyle(context)),
textStyle:
// Restate [FilledButton]'s default, which inherits from
// [zulipTypography]…
Theme.of(context).textTheme.labelLarge!
// …then clobber some attributes to follow Figma:
.merge(const TextStyle(
fontSize: 18,
height: (23 / 18))
.merge(weightVariableTextStyle(context, wght: 400))),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)),
),
onPressed: () => _handlePress(context),
Expand Down Expand Up @@ -574,8 +577,6 @@ class StreamMessageRecipientHeader extends StatelessWidget {
}
final textStyle = TextStyle(
color: contrastingColor,
fontFamily: kDefaultFontFamily,
fontFamilyFallback: kDefaultFontFamilyFallback,
fontSize: 16,
letterSpacing: 0.02 * 16,
height: (18 / 16),
Expand Down Expand Up @@ -685,9 +686,7 @@ class DmRecipientHeader extends StatelessWidget {
child: Icon(size: 16, ZulipIcons.user)),
Expanded(
child: Text(title,
style: TextStyle(
fontFamily: kDefaultFontFamily,
fontFamilyFallback: kDefaultFontFamilyFallback,
style: const TextStyle(
fontSize: 16,
letterSpacing: 0.02 * 16,
height: (18 / 16),
Expand Down Expand Up @@ -719,8 +718,6 @@ class RecipientHeaderDate extends StatelessWidget {
child: Text(
style: TextStyle(
color: color,
fontFamily: kDefaultFontFamily,
fontFamilyFallback: kDefaultFontFamilyFallback,
fontSize: 16,
// In Figma this has a line-height of 19, but using 18
// here to match the stream/topic text widgets helps
Expand All @@ -729,7 +726,7 @@ class RecipientHeaderDate extends StatelessWidget {
// This is equivalent to css `all-small-caps`, see:
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-caps#all-small-caps
fontFeatures: const [FontFeature.enable('c2sc'), FontFeature.enable('smcp')],
).merge(weightVariableTextStyle(context)),
),
formatHeaderDate(
zulipLocalizations,
DateTime.fromMillisecondsSinceEpoch(message.timestamp * 1000),
Expand Down
9 changes: 3 additions & 6 deletions lib/widgets/recent_dm_conversations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'icons.dart';
import 'message_list.dart';
import 'page.dart';
import 'store.dart';
import 'text.dart';
import 'unread_count_badge.dart';

class RecentDmConversationsPage extends StatefulWidget {
Expand Down Expand Up @@ -126,13 +125,11 @@ class RecentDmConversationsItem extends StatelessWidget {
Expanded(child: Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Text(
style: TextStyle(
fontFamily: kDefaultFontFamily,
fontFamilyFallback: kDefaultFontFamilyFallback,
style: const TextStyle(
fontSize: 17,
height: (20 / 17),
color: const Color(0xFF222222),
).merge(weightVariableTextStyle(context)),
color: Color(0xFF222222),
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
title))),
Expand Down
14 changes: 4 additions & 10 deletions lib/widgets/subscription_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,9 @@ class _NoSubscriptionsItem extends StatelessWidget {
textAlign: TextAlign.center,
style: TextStyle(
color: const HSLColor.fromAHSL(1.0, 240, 0.1, 0.5).toColor(),
fontFamily: kDefaultFontFamily,
fontFamilyFallback: kDefaultFontFamilyFallback,
fontSize: 18,
height: (20 / 18),
).merge(weightVariableTextStyle(context)))));
))));
}
}

Expand All @@ -149,12 +147,10 @@ class _SubscriptionListHeader extends StatelessWidget {
textAlign: TextAlign.center,
style: TextStyle(
color: const HSLColor.fromAHSL(1.0, 240, 0.1, 0.5).toColor(),
fontFamily: kDefaultFontFamily,
fontFamilyFallback: kDefaultFontFamilyFallback,
fontSize: 14,
letterSpacing: 0.04 * 14,
height: (16 / 14),
).merge(weightVariableTextStyle(context)))),
))),
const SizedBox(width: 8),
Expanded(child: Divider(
color: const HSLColor.fromAHSL(0.2, 240, 0.1, 0.5).toColor())),
Expand Down Expand Up @@ -221,12 +217,10 @@ class SubscriptionItem extends StatelessWidget {
// or only those with unreads:
// https://github.com/zulip/zulip-flutter/pull/397#pullrequestreview-1742524205
child: Text(
style: TextStyle(
fontFamily: kDefaultFontFamily,
fontFamilyFallback: kDefaultFontFamilyFallback,
style: const TextStyle(
fontSize: 18,
height: (20 / 18),
color: const Color(0xFF262626),
color: Color(0xFF262626),
).merge(weightVariableTextStyle(context,
wght: hasUnreads ? 600 : null)),
maxLines: 1,
Expand Down
9 changes: 9 additions & 0 deletions lib/widgets/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import 'package:flutter/material.dart';
/// Material library's widgets, such as the default styling of
/// an [AppBar]'s title, of an [ElevatedButton]'s label, and so on.
///
/// As of writing, it turns out that these styles flow naturally into
/// most of our own widgets' text styles as well.
/// We often see this in the child of a [Material], for example,
/// since by default [Material] applies an [AnimatedDefaultTextStyle]
/// with the [TextTheme.bodyMedium] that gets its value from here.
///
/// In all the comprised [TextStyle]s, this sets:
///
/// - [TextStyle.fontFamily] to [kDefaultFontFamily], and
Expand All @@ -27,6 +33,9 @@ import 'package:flutter/material.dart';
/// to set font weights on variable-weight fonts. If this causes visible bugs,
/// we should investigate and fix, but they should become less likely as
/// we transition from Material's widgets to our own bespoke ones.)
// TODO decide if we like this data flow for our own widgets' text styles.
// Does our design fit well with the fields of a [TextTheme]?
// (That's [TextTheme.titleLarge], [TextTheme.bodyMedium], etc.)
Typography zulipTypography(BuildContext context) {
final typography = Theme.of(context).typography;
return weightVariableTypography(context, typography)
Expand Down
8 changes: 3 additions & 5 deletions lib/widgets/unread_count_badge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@ class UnreadCountBadge extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.fromLTRB(4, 0, 4, 1),
child: Text(
style: TextStyle(
fontFamily: kDefaultFontFamily,
fontFamilyFallback: kDefaultFontFamilyFallback,
style: const TextStyle(
fontSize: 16,
height: (18 / 16),
fontFeatures: const [FontFeature.enable('smcp')], // small caps
color: const Color(0xFF222222),
fontFeatures: [FontFeature.enable('smcp')], // small caps
color: Color(0xFF222222),
).merge(weightVariableTextStyle(context,
wght: bold ? 600 : null)),
count.toString())));
Expand Down

0 comments on commit 60ec0d5

Please sign in to comment.