Skip to content

Commit 5a43d1c

Browse files
committed
refactor: extract all text styles
1 parent a014bc3 commit 5a43d1c

File tree

2 files changed

+84
-83
lines changed

2 files changed

+84
-83
lines changed

app/src/main/java/to/bitkit/ui/components/Text.kt

Lines changed: 18 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,13 @@ fun Display(
2323
modifier: Modifier = Modifier,
2424
fontWeight: FontWeight = FontWeight.Black,
2525
fontSize: TextUnit = 44.sp,
26-
lineHeight: TextUnit = 44.sp,
2726
color: Color = MaterialTheme.colorScheme.primary,
2827
) {
2928
Text(
3029
text = text.uppercase(),
31-
style = TextStyle(
30+
style = AppTextStyles.Display.merge(
3231
fontWeight = fontWeight,
3332
fontSize = fontSize,
34-
lineHeight = lineHeight,
35-
letterSpacing = (-1).sp,
36-
fontFamily = InterFontFamily,
3733
color = color,
3834
),
3935
modifier = modifier,
@@ -44,19 +40,11 @@ fun Display(
4440
fun Display(
4541
text: AnnotatedString,
4642
modifier: Modifier = Modifier,
47-
fontWeight: FontWeight = FontWeight.Black,
48-
fontSize: TextUnit = 44.sp,
49-
lineHeight: TextUnit = 44.sp,
5043
color: Color = MaterialTheme.colorScheme.primary,
5144
) {
5245
Text(
5346
text = text.toUpperCase(),
54-
style = TextStyle(
55-
fontWeight = fontWeight,
56-
fontSize = fontSize,
57-
lineHeight = lineHeight,
58-
letterSpacing = (-1).sp,
59-
fontFamily = InterFontFamily,
47+
style = AppTextStyles.Display.merge(
6048
color = color,
6149
),
6250
modifier = modifier,
@@ -67,17 +55,11 @@ fun Display(
6755
fun Headline(
6856
text: AnnotatedString,
6957
modifier: Modifier = Modifier,
70-
lineHeight: TextUnit = 30.sp,
7158
color: Color = MaterialTheme.colorScheme.primary,
7259
) {
7360
Text(
7461
text = text.toUpperCase(),
75-
style = TextStyle(
76-
fontWeight = FontWeight.Black,
77-
fontSize = 30.sp,
78-
lineHeight = lineHeight,
79-
letterSpacing = (-1).sp,
80-
fontFamily = InterFontFamily,
62+
style = AppTextStyles.Headline.merge(
8163
color = color,
8264
),
8365
modifier = modifier,
@@ -88,17 +70,14 @@ fun Headline(
8870
fun Headline20(
8971
text: AnnotatedString,
9072
modifier: Modifier = Modifier,
91-
lineHeight: TextUnit = 20.sp,
92-
color: Color = Colors.White,
73+
color: Color = MaterialTheme.colorScheme.primary,
9374
) {
9475
Text(
9576
text = text.toUpperCase(),
96-
style = TextStyle(
97-
fontWeight = FontWeight.Black,
77+
style = AppTextStyles.Headline.merge(
9878
fontSize = 20.sp,
99-
lineHeight = lineHeight,
79+
lineHeight = 20.sp,
10080
letterSpacing = (-.5).sp,
101-
fontFamily = InterFontFamily,
10281
color = color,
10382
),
10483
modifier = modifier,
@@ -173,12 +152,7 @@ fun BodyM(
173152
) {
174153
Text(
175154
text = text,
176-
style = TextStyle(
177-
fontWeight = FontWeight.Normal,
178-
fontSize = 17.sp,
179-
lineHeight = 22.sp,
180-
letterSpacing = 0.4.sp,
181-
fontFamily = InterFontFamily,
155+
style = AppTextStyles.BodyM.merge(
182156
color = color,
183157
textAlign = textAlign,
184158
),
@@ -239,12 +213,7 @@ fun BodyMB(
239213
) {
240214
Text(
241215
text = text,
242-
style = TextStyle(
243-
fontWeight = FontWeight.Bold,
244-
fontSize = 17.sp,
245-
lineHeight = 22.sp,
246-
letterSpacing = 0.4.sp,
247-
fontFamily = InterFontFamily,
216+
style = AppTextStyles.BodyMB.merge(
248217
color = color,
249218
textAlign = textAlign,
250219
),
@@ -327,17 +296,13 @@ fun BodySB(
327296
text: String,
328297
modifier: Modifier = Modifier,
329298
color: Color = MaterialTheme.colorScheme.primary,
299+
textAlign: TextAlign = TextAlign.Start,
330300
) {
331301
Text(
332302
text = text,
333-
style = TextStyle(
334-
fontWeight = FontWeight.Bold,
335-
fontSize = 15.sp,
336-
lineHeight = 20.sp,
337-
letterSpacing = 0.4.sp,
338-
fontFamily = InterFontFamily,
303+
style = AppTextStyles.BodySB.merge(
339304
color = color,
340-
textAlign = TextAlign.Start,
305+
textAlign = textAlign,
341306
),
342307
modifier = modifier,
343308
)
@@ -348,17 +313,13 @@ fun Text13Up(
348313
text: String,
349314
modifier: Modifier = Modifier,
350315
color: Color = MaterialTheme.colorScheme.primary,
316+
textAlign: TextAlign = TextAlign.Start,
351317
) {
352318
Text(
353319
text = text.uppercase(),
354-
style = TextStyle(
355-
fontWeight = FontWeight.Medium,
356-
fontSize = 13.sp,
357-
lineHeight = 18.sp,
358-
letterSpacing = 0.4.sp,
359-
fontFamily = InterFontFamily,
320+
style = AppTextStyles.CaptionM.merge(
360321
color = color,
361-
textAlign = TextAlign.Start,
322+
textAlign = textAlign,
362323
),
363324
modifier = modifier,
364325
)
@@ -375,12 +336,7 @@ fun Caption(
375336
) {
376337
Text(
377338
text = text,
378-
style = TextStyle(
379-
fontWeight = FontWeight.Normal,
380-
fontSize = 13.sp,
381-
lineHeight = 18.sp,
382-
letterSpacing = 0.4.sp,
383-
fontFamily = InterFontFamily,
339+
style = AppTextStyles.Caption.merge(
384340
color = color,
385341
textAlign = textAlign,
386342
),
@@ -420,12 +376,7 @@ fun CaptionB(
420376
) {
421377
Text(
422378
text = text,
423-
style = TextStyle(
424-
fontWeight = FontWeight.SemiBold,
425-
fontSize = 13.sp,
426-
lineHeight = 18.sp,
427-
letterSpacing = 0.4.sp,
428-
fontFamily = InterFontFamily,
379+
style = AppTextStyles.CaptionB.merge(
429380
color = color,
430381
textAlign = textAlign,
431382
),
@@ -444,12 +395,7 @@ fun Caption13Up(
444395
) {
445396
Text(
446397
text = text.uppercase(),
447-
style = TextStyle(
448-
fontWeight = FontWeight.Medium,
449-
fontSize = 13.sp,
450-
lineHeight = 18.sp,
451-
letterSpacing = 0.4.sp,
452-
fontFamily = InterFontFamily,
398+
style = AppTextStyles.CaptionM.merge(
453399
color = color,
454400
textAlign = textAlign,
455401
),
@@ -468,12 +414,7 @@ fun Footnote(
468414
) {
469415
Text(
470416
text = text,
471-
style = TextStyle(
472-
fontWeight = FontWeight.Medium,
473-
fontSize = 12.sp,
474-
lineHeight = 16.sp,
475-
letterSpacing = 0.4.sp,
476-
fontFamily = InterFontFamily,
417+
style = AppTextStyles.FootnoteM.merge(
477418
color = color,
478419
textAlign = textAlign,
479420
),

app/src/main/java/to/bitkit/ui/theme/Type.kt

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ val Typography = Typography(
4444
)
4545

4646
object AppTextStyles {
47+
val Display = TextStyle(
48+
fontWeight = FontWeight.Black,
49+
fontSize = 44.sp,
50+
lineHeight = 44.sp,
51+
letterSpacing = (-1).sp,
52+
fontFamily = InterFontFamily,
53+
)
54+
val Headline = TextStyle(
55+
fontWeight = FontWeight.Black,
56+
fontSize = 30.sp,
57+
lineHeight = 30.sp,
58+
letterSpacing = (-1).sp,
59+
fontFamily = InterFontFamily,
60+
)
4761
val Title = TextStyle(
4862
fontWeight = FontWeight.Bold,
4963
fontSize = 22.sp,
@@ -57,28 +71,74 @@ object AppTextStyles {
5771
letterSpacing = 0.4.sp,
5872
fontFamily = InterFontFamily,
5973
)
60-
val BodyS = TextStyle(
74+
val BodyM = TextStyle(
6175
fontWeight = FontWeight.Normal,
62-
fontSize = 15.sp,
63-
lineHeight = 20.sp,
76+
fontSize = 17.sp,
77+
lineHeight = 22.sp,
6478
letterSpacing = 0.4.sp,
6579
fontFamily = InterFontFamily,
66-
textAlign = TextAlign.Start,
6780
)
6881
val BodyMSB = TextStyle(
6982
fontWeight = FontWeight.SemiBold,
7083
fontSize = 17.sp,
7184
lineHeight = 22.sp,
7285
letterSpacing = 0.4.sp,
7386
fontFamily = InterFontFamily,
74-
textAlign = TextAlign.Start,
87+
)
88+
val BodyMB = TextStyle(
89+
fontWeight = FontWeight.Bold,
90+
fontSize = 17.sp,
91+
lineHeight = 22.sp,
92+
letterSpacing = 0.4.sp,
93+
fontFamily = InterFontFamily,
94+
)
95+
val BodyS = TextStyle(
96+
fontWeight = FontWeight.Normal,
97+
fontSize = 15.sp,
98+
lineHeight = 20.sp,
99+
letterSpacing = 0.4.sp,
100+
fontFamily = InterFontFamily,
75101
)
76102
val BodySSB = TextStyle(
77103
fontWeight = FontWeight.SemiBold,
78104
fontSize = 15.sp,
79105
lineHeight = 20.sp,
80106
letterSpacing = 0.4.sp,
81107
fontFamily = InterFontFamily,
82-
textAlign = TextAlign.Start,
108+
)
109+
val BodySB = TextStyle(
110+
fontWeight = FontWeight.Bold,
111+
fontSize = 15.sp,
112+
lineHeight = 20.sp,
113+
letterSpacing = 0.4.sp,
114+
fontFamily = InterFontFamily,
115+
)
116+
val Caption = TextStyle(
117+
fontWeight = FontWeight.Normal,
118+
fontSize = 13.sp,
119+
lineHeight = 18.sp,
120+
letterSpacing = 0.4.sp,
121+
fontFamily = InterFontFamily,
122+
)
123+
val CaptionM = TextStyle(
124+
fontWeight = FontWeight.Medium,
125+
fontSize = 13.sp,
126+
lineHeight = 18.sp,
127+
letterSpacing = 0.4.sp,
128+
fontFamily = InterFontFamily,
129+
)
130+
val CaptionB = TextStyle(
131+
fontWeight = FontWeight.SemiBold,
132+
fontSize = 13.sp,
133+
lineHeight = 18.sp,
134+
letterSpacing = 0.4.sp,
135+
fontFamily = InterFontFamily,
136+
)
137+
val FootnoteM = TextStyle(
138+
fontWeight = FontWeight.Medium,
139+
fontSize = 12.sp,
140+
lineHeight = 16.sp,
141+
letterSpacing = 0.4.sp,
142+
fontFamily = InterFontFamily,
83143
)
84144
}

0 commit comments

Comments
 (0)