@@ -32,14 +32,12 @@ import androidx.compose.foundation.layout.width
32
32
import androidx.compose.foundation.lazy.LazyColumn
33
33
import androidx.compose.foundation.lazy.items
34
34
import androidx.compose.foundation.shape.CircleShape
35
- import androidx.compose.material.Colors
36
- import androidx.compose.material.ContentAlpha
37
- import androidx.compose.material.LocalContentAlpha
38
- import androidx.compose.material.LocalContentColor
39
- import androidx.compose.material.MaterialTheme
40
- import androidx.compose.material.Surface
41
- import androidx.compose.material.Text
42
- import androidx.compose.material.Typography
35
+ import androidx.compose.material3.ColorScheme
36
+ import androidx.compose.material3.LocalContentColor
37
+ import androidx.compose.material3.MaterialTheme
38
+ import androidx.compose.material3.Surface
39
+ import androidx.compose.material3.Text
40
+ import androidx.compose.material3.Typography
43
41
import androidx.compose.material.icons.Icons
44
42
import androidx.compose.material.icons.filled.AccountCircle
45
43
import androidx.compose.runtime.Composable
@@ -86,15 +84,15 @@ fun PostContent(post: Post, modifier: Modifier = Modifier) {
86
84
PostHeaderImage (post)
87
85
}
88
86
item {
89
- Text (text = post.title, style = MaterialTheme .typography.h4 )
87
+ Text (text = post.title, style = MaterialTheme .typography.headlineMedium )
90
88
Spacer (Modifier .height(8 .dp))
91
89
}
92
90
post.subtitle?.let { subtitle ->
93
91
item {
94
- CompositionLocalProvider (LocalContentAlpha provides ContentAlpha .medium ) {
92
+ CompositionLocalProvider (LocalContentColor provides MaterialTheme .colorScheme.onSurfaceVariant ) {
95
93
Text (
96
94
text = subtitle,
97
- style = MaterialTheme .typography.body2 ,
95
+ style = MaterialTheme .typography.bodyMedium ,
98
96
lineHeight = 20 .sp
99
97
)
100
98
}
@@ -144,14 +142,14 @@ private fun PostMetadata(metadata: Metadata) {
144
142
Column {
145
143
Text (
146
144
text = metadata.author.name,
147
- style = typography.caption ,
145
+ style = typography.bodySmall ,
148
146
modifier = Modifier .padding(top = 4 .dp)
149
147
)
150
148
151
- CompositionLocalProvider (LocalContentAlpha provides ContentAlpha .medium ) {
149
+ CompositionLocalProvider (LocalContentColor provides MaterialTheme .colorScheme.onSurfaceVariant ) {
152
150
Text (
153
151
text = " ${metadata.date} • ${metadata.readTimeMinutes} min read" ,
154
- style = typography.caption
152
+ style = typography.bodySmall
155
153
)
156
154
}
157
155
}
@@ -165,7 +163,7 @@ private fun Paragraph(paragraph: Paragraph) {
165
163
val annotatedString = paragraphToAnnotatedString(
166
164
paragraph,
167
165
MaterialTheme .typography,
168
- MaterialTheme .colors .codeBlockBackground
166
+ MaterialTheme .colorScheme .codeBlockBackground
169
167
)
170
168
Box (modifier = Modifier .padding(bottom = trailingPadding)) {
171
169
when (paragraph.type) {
@@ -202,7 +200,7 @@ private fun CodeBlockParagraph(
202
200
paragraphStyle : ParagraphStyle
203
201
) {
204
202
Surface (
205
- color = MaterialTheme .colors .codeBlockBackground,
203
+ color = MaterialTheme .colorScheme .codeBlockBackground,
206
204
shape = MaterialTheme .shapes.small,
207
205
modifier = Modifier .fillMaxWidth()
208
206
) {
@@ -252,29 +250,29 @@ private data class ParagraphStyling(
252
250
@Composable
253
251
private fun ParagraphType.getTextAndParagraphStyle (): ParagraphStyling {
254
252
val typography = MaterialTheme .typography
255
- var textStyle: TextStyle = typography.body1
253
+ var textStyle: TextStyle = typography.bodyLarge
256
254
var paragraphStyle = ParagraphStyle ()
257
255
var trailingPadding = 24 .dp
258
256
259
257
when (this ) {
260
- ParagraphType .Caption -> textStyle = typography.body1
261
- ParagraphType .Title -> textStyle = typography.h4
258
+ ParagraphType .Caption -> textStyle = typography.bodyLarge
259
+ ParagraphType .Title -> textStyle = typography.headlineMedium
262
260
ParagraphType .Subhead -> {
263
- textStyle = typography.h6
261
+ textStyle = typography.titleLarge
264
262
trailingPadding = 16 .dp
265
263
}
266
264
ParagraphType .Text -> {
267
- textStyle = typography.body1 .copy(lineHeight = 28 .sp)
265
+ textStyle = typography.bodyLarge .copy(lineHeight = 28 .sp)
268
266
paragraphStyle = paragraphStyle.copy(lineHeight = 28 .sp)
269
267
}
270
268
ParagraphType .Header -> {
271
- textStyle = typography.h5
269
+ textStyle = typography.headlineSmall
272
270
trailingPadding = 16 .dp
273
271
}
274
- ParagraphType .CodeBlock -> textStyle = typography.body1 .copy(
272
+ ParagraphType .CodeBlock -> textStyle = typography.bodyLarge .copy(
275
273
fontFamily = FontFamily .Monospace
276
274
)
277
- ParagraphType .Quote -> textStyle = typography.body1
275
+ ParagraphType .Quote -> textStyle = typography.bodyLarge
278
276
ParagraphType .Bullet -> {
279
277
paragraphStyle = ParagraphStyle (textIndent = TextIndent (firstLine = 8 .sp))
280
278
}
@@ -303,28 +301,28 @@ fun Markup.toAnnotatedStringItem(
303
301
return when (this .type) {
304
302
MarkupType .Italic -> {
305
303
AnnotatedString .Range (
306
- typography.body1 .copy(fontStyle = FontStyle .Italic ).toSpanStyle(),
304
+ typography.bodyLarge .copy(fontStyle = FontStyle .Italic ).toSpanStyle(),
307
305
start,
308
306
end
309
307
)
310
308
}
311
309
MarkupType .Link -> {
312
310
AnnotatedString .Range (
313
- typography.body1 .copy(textDecoration = TextDecoration .Underline ).toSpanStyle(),
311
+ typography.bodyLarge .copy(textDecoration = TextDecoration .Underline ).toSpanStyle(),
314
312
start,
315
313
end
316
314
)
317
315
}
318
316
MarkupType .Bold -> {
319
317
AnnotatedString .Range (
320
- typography.body1 .copy(fontWeight = FontWeight .Bold ).toSpanStyle(),
318
+ typography.bodyLarge .copy(fontWeight = FontWeight .Bold ).toSpanStyle(),
321
319
start,
322
320
end
323
321
)
324
322
}
325
323
MarkupType .Code -> {
326
324
AnnotatedString .Range (
327
- typography.body1
325
+ typography.bodyLarge
328
326
.copy(
329
327
background = codeBlockBackground,
330
328
fontFamily = FontFamily .Monospace
@@ -336,7 +334,7 @@ fun Markup.toAnnotatedStringItem(
336
334
}
337
335
}
338
336
339
- private val Colors .codeBlockBackground: Color
337
+ private val ColorScheme .codeBlockBackground: Color
340
338
get() = onSurface.copy(alpha = .15f )
341
339
342
340
@Preview(" Post content" )
0 commit comments