Skip to content

Commit 6784ef9

Browse files
committed
text [nfc]: Remove some now-redundant fontFamily{,Fallback} attributes
1 parent 16d925f commit 6784ef9

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
@@ -100,12 +100,10 @@ class Paragraph extends StatelessWidget {
100100

101101
final ParagraphNode node;
102102

103-
static TextStyle getTextStyle(BuildContext context) => TextStyle(
104-
fontFamily: kDefaultFontFamily,
105-
fontFamilyFallback: defaultFontFamilyFallback,
103+
static TextStyle getTextStyle(BuildContext context) => const TextStyle(
106104
fontSize: kBaseFontSize,
107105
height: (17 / kBaseFontSize),
108-
).merge(weightVariableTextStyle(context));
106+
);
109107

110108
@override
111109
Widget build(BuildContext context) {

lib/widgets/emoji_reaction.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,6 @@ class ReactionChip extends StatelessWidget {
173173
textWidthBasis: TextWidthBasis.longestLine,
174174
textScaler: _labelTextScalerClamped(context),
175175
style: TextStyle(
176-
fontFamily: kDefaultFontFamily,
177-
fontFamilyFallback: defaultFontFamilyFallback,
178176
fontSize: (14 * 0.90),
179177
height: 13 / (14 * 0.90),
180178
color: labelColor,
@@ -352,8 +350,6 @@ class _TextEmoji extends StatelessWidget {
352350
textScaler: _textEmojiScalerClamped(context),
353351
textWidthBasis: TextWidthBasis.longestLine,
354352
style: TextStyle(
355-
fontFamily: kDefaultFontFamily,
356-
fontFamilyFallback: defaultFontFamilyFallback,
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
@@ -237,12 +237,10 @@ abstract class _HeaderItem extends StatelessWidget {
237237
Expanded(child: Padding(
238238
padding: const EdgeInsets.symmetric(vertical: 4),
239239
child: Text(
240-
style: TextStyle(
241-
fontFamily: kDefaultFontFamily,
242-
fontFamilyFallback: defaultFontFamilyFallback,
240+
style: const TextStyle(
243241
fontSize: 17,
244242
height: (20 / 17),
245-
color: const Color(0xFF222222),
243+
color: Color(0xFF222222),
246244
).merge(weightVariableTextStyle(context, wght: 600)),
247245
maxLines: 1,
248246
overflow: TextOverflow.ellipsis,
@@ -359,13 +357,11 @@ class _DmItem extends StatelessWidget {
359357
Expanded(child: Padding(
360358
padding: const EdgeInsets.symmetric(vertical: 4),
361359
child: Text(
362-
style: TextStyle(
363-
fontFamily: kDefaultFontFamily,
364-
fontFamilyFallback: defaultFontFamilyFallback,
360+
style: const TextStyle(
365361
fontSize: 17,
366362
height: (20 / 17),
367-
color: const Color(0xFF222222),
368-
).merge(weightVariableTextStyle(context)),
363+
color: Color(0xFF222222),
364+
),
369365
maxLines: 2,
370366
overflow: TextOverflow.ellipsis,
371367
title))),
@@ -486,13 +482,11 @@ class _TopicItem extends StatelessWidget {
486482
Expanded(child: Padding(
487483
padding: const EdgeInsets.symmetric(vertical: 4),
488484
child: Text(
489-
style: TextStyle(
490-
fontFamily: kDefaultFontFamily,
491-
fontFamilyFallback: defaultFontFamilyFallback,
485+
style: const TextStyle(
492486
fontSize: 17,
493487
height: (20 / 17),
494-
color: const Color(0xFF222222),
495-
).merge(weightVariableTextStyle(context)),
488+
color: Color(0xFF222222),
489+
),
496490
maxLines: 2,
497491
overflow: TextOverflow.ellipsis,
498492
topic))),

lib/widgets/message_list.dart

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -449,12 +449,15 @@ class MarkAsReadWidget extends StatelessWidget {
449449
style: FilledButton.styleFrom(
450450
backgroundColor: _UnreadMarker.color,
451451
minimumSize: const Size.fromHeight(38),
452-
textStyle: TextStyle(
453-
fontFamily: kDefaultFontFamily,
454-
fontFamilyFallback: defaultFontFamilyFallback,
455-
fontSize: 18,
456-
height: (23 / 18),
457-
).merge(weightVariableTextStyle(context)),
452+
textStyle:
453+
// Restate [FilledButton]'s default, which inherits from
454+
// [zulipTypography]…
455+
Theme.of(context).textTheme.labelLarge!
456+
// …then clobber some attributes to follow Figma:
457+
.merge(const TextStyle(
458+
fontSize: 18,
459+
height: (23 / 18))
460+
.merge(weightVariableTextStyle(context, wght: 400))),
458461
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)),
459462
),
460463
onPressed: () => _handlePress(context),
@@ -632,8 +635,6 @@ class StreamMessageRecipientHeader extends StatelessWidget {
632635
}
633636
final textStyle = TextStyle(
634637
color: contrastingColor,
635-
fontFamily: kDefaultFontFamily,
636-
fontFamilyFallback: defaultFontFamilyFallback,
637638
fontSize: 16,
638639
letterSpacing: 0.02 * 16,
639640
height: (18 / 16),
@@ -743,9 +744,7 @@ class DmRecipientHeader extends StatelessWidget {
743744
child: Icon(size: 16, ZulipIcons.user)),
744745
Expanded(
745746
child: Text(title,
746-
style: TextStyle(
747-
fontFamily: kDefaultFontFamily,
748-
fontFamilyFallback: defaultFontFamilyFallback,
747+
style: const TextStyle(
749748
fontSize: 16,
750749
letterSpacing: 0.02 * 16,
751750
height: (18 / 16),
@@ -804,14 +803,12 @@ class DateText extends StatelessWidget {
804803
return Text(
805804
style: TextStyle(
806805
color: color,
807-
fontFamily: kDefaultFontFamily,
808-
fontFamilyFallback: defaultFontFamilyFallback,
809806
fontSize: fontSize,
810807
height: height,
811808
// This is equivalent to css `all-small-caps`, see:
812809
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-caps#all-small-caps
813810
fontFeatures: const [FontFeature.enable('c2sc'), FontFeature.enable('smcp')],
814-
).merge(weightVariableTextStyle(context)),
811+
),
815812
formatHeaderDate(
816813
zulipLocalizations,
817814
DateTime.fromMillisecondsSinceEpoch(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: defaultFontFamilyFallback,
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: defaultFontFamilyFallback,
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: defaultFontFamilyFallback,
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())),
@@ -222,12 +218,10 @@ class SubscriptionItem extends StatelessWidget {
222218
// or only those with unreads:
223219
// https://github.com/zulip/zulip-flutter/pull/397#pullrequestreview-1742524205
224220
child: Text(
225-
style: TextStyle(
226-
fontFamily: kDefaultFontFamily,
227-
fontFamilyFallback: defaultFontFamilyFallback,
221+
style: const TextStyle(
228222
fontSize: 18,
229223
height: (20 / 18),
230-
color: const Color(0xFF262626),
224+
color: Color(0xFF262626),
231225
).merge(weightVariableTextStyle(context,
232226
wght: hasUnreads ? 600 : null)),
233227
maxLines: 1,

lib/widgets/text.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ import 'package:flutter/material.dart';
1010
/// Material library's widgets, such as the default styling of
1111
/// an [AppBar]'s title, of an [ElevatedButton]'s label, and so on.
1212
///
13+
/// As of writing, it turns out that these styles also flow naturally into
14+
/// most of our own widgets' text styles.
15+
/// We often see this in the child of a [Material], for example,
16+
/// since by default [Material] applies an [AnimatedDefaultTextStyle]
17+
/// with the [TextTheme.bodyMedium] that gets its value from here.
18+
///
1319
/// Applies [kDefaultFontFamily] and [kDefaultFontFamilyFallback],
1420
/// being faithful to the Material-default font weights
1521
/// by running them through [weightVariableTextStyle].
@@ -22,6 +28,9 @@ import 'package:flutter/material.dart';
2228
/// to set font weights on variable-weight fonts. If this causes visible bugs,
2329
/// we should investigate and fix, but such bugs should become less likely as
2430
/// we transition from Material's widgets to our own bespoke ones.)
31+
// TODO decide if we like this data flow for our own widgets' text styles.
32+
// Does our design fit well with the fields of a [TextTheme]?
33+
// (That's [TextTheme.titleLarge], [TextTheme.bodyMedium], etc.)
2534
Typography zulipTypography(BuildContext context) {
2635
final typography = Theme.of(context).typography;
2736

lib/widgets/unread_count_badge.dart

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

0 commit comments

Comments
 (0)