Skip to content

Commit 60ec0d5

Browse files
committed
text [nfc]: Remove some now-redundant fontFamily{,Fallback} attributes
1 parent d33dece commit 60ec0d5

8 files changed

+40
-57
lines changed

lib/widgets/content.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,10 @@ class Paragraph extends StatelessWidget {
9898

9999
final ParagraphNode node;
100100

101-
static TextStyle getTextStyle(BuildContext context) => TextStyle(
102-
fontFamily: kDefaultFontFamily,
103-
fontFamilyFallback: kDefaultFontFamilyFallback,
101+
static TextStyle getTextStyle(BuildContext context) => const TextStyle(
104102
fontSize: kBaseFontSize,
105103
height: (17 / kBaseFontSize),
106-
).merge(weightVariableTextStyle(context));
104+
);
107105

108106
@override
109107
Widget build(BuildContext context) {

lib/widgets/emoji_reaction.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ class ReactionChip extends StatelessWidget {
174174
textWidthBasis: TextWidthBasis.longestLine,
175175
textScaler: _labelTextScalerClamped(context),
176176
style: TextStyle(
177-
fontFamily: kDefaultFontFamily,
178-
fontFamilyFallback: kDefaultFontFamilyFallback,
179177
fontSize: (14 * 0.90),
180178
height: 13 / (14 * 0.90),
181179
color: labelColor,
@@ -352,8 +350,6 @@ class _TextEmoji extends StatelessWidget {
352350
textAlign: TextAlign.end,
353351
textScaler: _textEmojiScalerClamped(context),
354352
style: TextStyle(
355-
fontFamily: kDefaultFontFamily,
356-
fontFamilyFallback: kDefaultFontFamilyFallback,
357353
fontSize: 14 * 0.8,
358354
height: 1, // to be denser when we have to wrap
359355
color: selected ? _textColorSelected : _textColorUnselected,

lib/widgets/inbox.dart

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,10 @@ abstract class _HeaderItem extends StatelessWidget {
239239
Expanded(child: Padding(
240240
padding: const EdgeInsets.symmetric(vertical: 4),
241241
child: Text(
242-
style: TextStyle(
243-
fontFamily: kDefaultFontFamily,
244-
fontFamilyFallback: kDefaultFontFamilyFallback,
242+
style: const TextStyle(
245243
fontSize: 17,
246244
height: (20 / 17),
247-
color: const Color(0xFF222222),
245+
color: Color(0xFF222222),
248246
).merge(weightVariableTextStyle(context, wght: 600)),
249247
maxLines: 1,
250248
overflow: TextOverflow.ellipsis,
@@ -361,13 +359,11 @@ class _DmItem extends StatelessWidget {
361359
Expanded(child: Padding(
362360
padding: const EdgeInsets.symmetric(vertical: 4),
363361
child: Text(
364-
style: TextStyle(
365-
fontFamily: kDefaultFontFamily,
366-
fontFamilyFallback: kDefaultFontFamilyFallback,
362+
style: const TextStyle(
367363
fontSize: 17,
368364
height: (20 / 17),
369-
color: const Color(0xFF222222),
370-
).merge(weightVariableTextStyle(context)),
365+
color: Color(0xFF222222),
366+
),
371367
maxLines: 2,
372368
overflow: TextOverflow.ellipsis,
373369
title))),
@@ -488,13 +484,11 @@ class _TopicItem extends StatelessWidget {
488484
Expanded(child: Padding(
489485
padding: const EdgeInsets.symmetric(vertical: 4),
490486
child: Text(
491-
style: TextStyle(
492-
fontFamily: kDefaultFontFamily,
493-
fontFamilyFallback: kDefaultFontFamilyFallback,
487+
style: const TextStyle(
494488
fontSize: 17,
495489
height: (20 / 17),
496-
color: const Color(0xFF222222),
497-
).merge(weightVariableTextStyle(context)),
490+
color: Color(0xFF222222),
491+
),
498492
maxLines: 2,
499493
overflow: TextOverflow.ellipsis,
500494
topic))),

lib/widgets/message_list.dart

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,15 @@ class MarkAsReadWidget extends StatelessWidget {
435435
style: FilledButton.styleFrom(
436436
backgroundColor: _UnreadMarker.color,
437437
minimumSize: const Size.fromHeight(38),
438-
textStyle: TextStyle(
439-
fontFamily: kDefaultFontFamily,
440-
fontFamilyFallback: kDefaultFontFamilyFallback,
441-
fontSize: 18,
442-
height: (23 / 18),
443-
).merge(weightVariableTextStyle(context)),
438+
textStyle:
439+
// Restate [FilledButton]'s default, which inherits from
440+
// [zulipTypography]…
441+
Theme.of(context).textTheme.labelLarge!
442+
// …then clobber some attributes to follow Figma:
443+
.merge(const TextStyle(
444+
fontSize: 18,
445+
height: (23 / 18))
446+
.merge(weightVariableTextStyle(context, wght: 400))),
444447
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)),
445448
),
446449
onPressed: () => _handlePress(context),
@@ -574,8 +577,6 @@ class StreamMessageRecipientHeader extends StatelessWidget {
574577
}
575578
final textStyle = TextStyle(
576579
color: contrastingColor,
577-
fontFamily: kDefaultFontFamily,
578-
fontFamilyFallback: kDefaultFontFamilyFallback,
579580
fontSize: 16,
580581
letterSpacing: 0.02 * 16,
581582
height: (18 / 16),
@@ -685,9 +686,7 @@ class DmRecipientHeader extends StatelessWidget {
685686
child: Icon(size: 16, ZulipIcons.user)),
686687
Expanded(
687688
child: Text(title,
688-
style: TextStyle(
689-
fontFamily: kDefaultFontFamily,
690-
fontFamilyFallback: kDefaultFontFamilyFallback,
689+
style: const TextStyle(
691690
fontSize: 16,
692691
letterSpacing: 0.02 * 16,
693692
height: (18 / 16),
@@ -719,8 +718,6 @@ class RecipientHeaderDate extends StatelessWidget {
719718
child: Text(
720719
style: TextStyle(
721720
color: color,
722-
fontFamily: kDefaultFontFamily,
723-
fontFamilyFallback: kDefaultFontFamilyFallback,
724721
fontSize: 16,
725722
// In Figma this has a line-height of 19, but using 18
726723
// here to match the stream/topic text widgets helps
@@ -729,7 +726,7 @@ class RecipientHeaderDate extends StatelessWidget {
729726
// This is equivalent to css `all-small-caps`, see:
730727
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-caps#all-small-caps
731728
fontFeatures: const [FontFeature.enable('c2sc'), FontFeature.enable('smcp')],
732-
).merge(weightVariableTextStyle(context)),
729+
),
733730
formatHeaderDate(
734731
zulipLocalizations,
735732
DateTime.fromMillisecondsSinceEpoch(message.timestamp * 1000),

lib/widgets/recent_dm_conversations.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import 'icons.dart';
88
import 'message_list.dart';
99
import 'page.dart';
1010
import 'store.dart';
11-
import 'text.dart';
1211
import 'unread_count_badge.dart';
1312

1413
class RecentDmConversationsPage extends StatefulWidget {
@@ -126,13 +125,11 @@ class RecentDmConversationsItem extends StatelessWidget {
126125
Expanded(child: Padding(
127126
padding: const EdgeInsets.symmetric(vertical: 4),
128127
child: Text(
129-
style: TextStyle(
130-
fontFamily: kDefaultFontFamily,
131-
fontFamilyFallback: kDefaultFontFamilyFallback,
128+
style: const TextStyle(
132129
fontSize: 17,
133130
height: (20 / 17),
134-
color: const Color(0xFF222222),
135-
).merge(weightVariableTextStyle(context)),
131+
color: Color(0xFF222222),
132+
),
136133
maxLines: 2,
137134
overflow: TextOverflow.ellipsis,
138135
title))),

lib/widgets/subscription_list.dart

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,9 @@ class _NoSubscriptionsItem extends StatelessWidget {
119119
textAlign: TextAlign.center,
120120
style: TextStyle(
121121
color: const HSLColor.fromAHSL(1.0, 240, 0.1, 0.5).toColor(),
122-
fontFamily: kDefaultFontFamily,
123-
fontFamilyFallback: kDefaultFontFamilyFallback,
124122
fontSize: 18,
125123
height: (20 / 18),
126-
).merge(weightVariableTextStyle(context)))));
124+
))));
127125
}
128126
}
129127

@@ -149,12 +147,10 @@ class _SubscriptionListHeader extends StatelessWidget {
149147
textAlign: TextAlign.center,
150148
style: TextStyle(
151149
color: const HSLColor.fromAHSL(1.0, 240, 0.1, 0.5).toColor(),
152-
fontFamily: kDefaultFontFamily,
153-
fontFamilyFallback: kDefaultFontFamilyFallback,
154150
fontSize: 14,
155151
letterSpacing: 0.04 * 14,
156152
height: (16 / 14),
157-
).merge(weightVariableTextStyle(context)))),
153+
))),
158154
const SizedBox(width: 8),
159155
Expanded(child: Divider(
160156
color: const HSLColor.fromAHSL(0.2, 240, 0.1, 0.5).toColor())),
@@ -221,12 +217,10 @@ class SubscriptionItem extends StatelessWidget {
221217
// or only those with unreads:
222218
// https://github.com/zulip/zulip-flutter/pull/397#pullrequestreview-1742524205
223219
child: Text(
224-
style: TextStyle(
225-
fontFamily: kDefaultFontFamily,
226-
fontFamilyFallback: kDefaultFontFamilyFallback,
220+
style: const TextStyle(
227221
fontSize: 18,
228222
height: (20 / 18),
229-
color: const Color(0xFF262626),
223+
color: Color(0xFF262626),
230224
).merge(weightVariableTextStyle(context,
231225
wght: hasUnreads ? 600 : null)),
232226
maxLines: 1,

lib/widgets/text.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ import 'package:flutter/material.dart';
1111
/// Material library's widgets, such as the default styling of
1212
/// an [AppBar]'s title, of an [ElevatedButton]'s label, and so on.
1313
///
14+
/// As of writing, it turns out that these styles flow naturally into
15+
/// most of our own widgets' text styles as well.
16+
/// We often see this in the child of a [Material], for example,
17+
/// since by default [Material] applies an [AnimatedDefaultTextStyle]
18+
/// with the [TextTheme.bodyMedium] that gets its value from here.
19+
///
1420
/// In all the comprised [TextStyle]s, this sets:
1521
///
1622
/// - [TextStyle.fontFamily] to [kDefaultFontFamily], and
@@ -27,6 +33,9 @@ import 'package:flutter/material.dart';
2733
/// to set font weights on variable-weight fonts. If this causes visible bugs,
2834
/// we should investigate and fix, but they should become less likely as
2935
/// we transition from Material's widgets to our own bespoke ones.)
36+
// TODO decide if we like this data flow for our own widgets' text styles.
37+
// Does our design fit well with the fields of a [TextTheme]?
38+
// (That's [TextTheme.titleLarge], [TextTheme.bodyMedium], etc.)
3039
Typography zulipTypography(BuildContext context) {
3140
final typography = Theme.of(context).typography;
3241
return weightVariableTypography(context, typography)

lib/widgets/unread_count_badge.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,11 @@ class UnreadCountBadge extends StatelessWidget {
4444
child: Padding(
4545
padding: const EdgeInsets.fromLTRB(4, 0, 4, 1),
4646
child: Text(
47-
style: TextStyle(
48-
fontFamily: kDefaultFontFamily,
49-
fontFamilyFallback: kDefaultFontFamilyFallback,
47+
style: const TextStyle(
5048
fontSize: 16,
5149
height: (18 / 16),
52-
fontFeatures: const [FontFeature.enable('smcp')], // small caps
53-
color: const Color(0xFF222222),
50+
fontFeatures: [FontFeature.enable('smcp')], // small caps
51+
color: Color(0xFF222222),
5452
).merge(weightVariableTextStyle(context,
5553
wght: bold ? 600 : null)),
5654
count.toString())));

0 commit comments

Comments
 (0)