Skip to content

Commit 35cb9b8

Browse files
authored
[JetNews] Adding Heading and Paragraph linebreak example to typography styles (#1119)
before -- after <img width="1132" alt="Screenshot 2023-04-27 at 12 30 33" src="https://user-images.githubusercontent.com/8226593/234849825-c8affb34-fdcc-4417-877b-a80024581f94.png"> <img width="1095" alt="Screenshot 2023-04-27 at 12 31 56" src="https://user-images.githubusercontent.com/8226593/234849829-ff82f166-f30d-443f-a971-e2072df89256.png">
2 parents cb72005 + 0e04e1e commit 35cb9b8

File tree

1 file changed

+24
-11
lines changed
  • JetNews/app/src/main/java/com/example/jetnews/ui/theme

1 file changed

+24
-11
lines changed

JetNews/app/src/main/java/com/example/jetnews/ui/theme/Type.kt

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
package com.example.jetnews.ui.theme
1818

1919
import androidx.compose.material3.Typography
20-
import androidx.compose.ui.text.ExperimentalTextApi
2120
import androidx.compose.ui.text.PlatformTextStyle
2221
import androidx.compose.ui.text.TextStyle
2322
import androidx.compose.ui.text.font.Font
2423
import androidx.compose.ui.text.font.FontFamily
2524
import androidx.compose.ui.text.font.FontWeight
25+
import androidx.compose.ui.text.style.LineBreak
2626
import androidx.compose.ui.text.style.LineHeightStyle
2727
import androidx.compose.ui.unit.sp
2828
import com.example.jetnews.R
@@ -33,7 +33,6 @@ private val Montserrat = FontFamily(
3333
)
3434

3535
@Suppress("DEPRECATION")
36-
@OptIn(ExperimentalTextApi::class)
3736
val defaultTextStyle = TextStyle(
3837
fontFamily = Montserrat,
3938
platformStyle = PlatformTextStyle(
@@ -56,25 +55,30 @@ val JetnewsTypography = Typography(
5655
fontSize = 36.sp, lineHeight = 44.sp, letterSpacing = 0.sp
5756
),
5857
headlineLarge = defaultTextStyle.copy(
59-
fontSize = 32.sp, lineHeight = 40.sp, letterSpacing = 0.sp
58+
fontSize = 32.sp, lineHeight = 40.sp, letterSpacing = 0.sp, lineBreak = LineBreak.Heading
6059
),
6160
headlineMedium = defaultTextStyle.copy(
62-
fontSize = 28.sp, lineHeight = 36.sp, letterSpacing = 0.sp
61+
fontSize = 28.sp, lineHeight = 36.sp, letterSpacing = 0.sp, lineBreak = LineBreak.Heading
6362
),
6463
headlineSmall = defaultTextStyle.copy(
65-
fontSize = 24.sp, lineHeight = 32.sp, letterSpacing = 0.sp
64+
fontSize = 24.sp, lineHeight = 32.sp, letterSpacing = 0.sp, lineBreak = LineBreak.Heading
6665
),
6766
titleLarge = defaultTextStyle.copy(
68-
fontSize = 22.sp, lineHeight = 28.sp, letterSpacing = 0.sp
67+
fontSize = 22.sp, lineHeight = 28.sp, letterSpacing = 0.sp, lineBreak = LineBreak.Heading
6968
),
7069
titleMedium = defaultTextStyle.copy(
7170
fontSize = 16.sp,
7271
lineHeight = 24.sp,
7372
letterSpacing = 0.15.sp,
74-
fontWeight = FontWeight.Medium
73+
fontWeight = FontWeight.Medium,
74+
lineBreak = LineBreak.Heading
7575
),
7676
titleSmall = defaultTextStyle.copy(
77-
fontSize = 14.sp, lineHeight = 20.sp, letterSpacing = 0.1.sp, fontWeight = FontWeight.Medium
77+
fontSize = 14.sp,
78+
lineHeight = 20.sp,
79+
letterSpacing = 0.1.sp,
80+
fontWeight = FontWeight.Medium,
81+
lineBreak = LineBreak.Heading
7882
),
7983
labelLarge = defaultTextStyle.copy(
8084
fontSize = 14.sp, lineHeight = 20.sp, letterSpacing = 0.1.sp, fontWeight = FontWeight.Medium
@@ -86,12 +90,21 @@ val JetnewsTypography = Typography(
8690
fontSize = 11.sp, lineHeight = 16.sp, letterSpacing = 0.5.sp, fontWeight = FontWeight.Medium
8791
),
8892
bodyLarge = defaultTextStyle.copy(
89-
fontSize = 16.sp, lineHeight = 24.sp, letterSpacing = 0.5.sp
93+
fontSize = 16.sp,
94+
lineHeight = 24.sp,
95+
letterSpacing = 0.5.sp,
96+
lineBreak = LineBreak.Paragraph
9097
),
9198
bodyMedium = defaultTextStyle.copy(
92-
fontSize = 14.sp, lineHeight = 20.sp, letterSpacing = 0.25.sp
99+
fontSize = 14.sp,
100+
lineHeight = 20.sp,
101+
letterSpacing = 0.25.sp,
102+
lineBreak = LineBreak.Paragraph
93103
),
94104
bodySmall = defaultTextStyle.copy(
95-
fontSize = 12.sp, lineHeight = 16.sp, letterSpacing = 0.4.sp
105+
fontSize = 12.sp,
106+
lineHeight = 16.sp,
107+
letterSpacing = 0.4.sp,
108+
lineBreak = LineBreak.Paragraph
96109
),
97110
)

0 commit comments

Comments
 (0)