-
Notifications
You must be signed in to change notification settings - Fork 0
/
SampleDataPreviews.kt
64 lines (57 loc) 路 2.22 KB
/
SampleDataPreviews.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.kotlindojo.learningpreviews.ui.previews
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight.Companion.Bold
import androidx.compose.ui.tooling.preview.Devices
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
/**
* PreviewParameters
* https://developer.android.com/jetpack/compose/tooling?hl=it&skip_cache=false#previewparameter
*/
// Return sample data as sequence
class DojoSlideParameterProvider : PreviewParameterProvider<Talk> {
override val values = sequenceOf(
Talk(title = "Jetpack Compose Navigation", presenter = "Elisha Lye"),
Talk(title = "Make use of a use case", presenter = "Sarah Bernard"),
Talk(title = "Security and Storage", presenter = "Swapnil Gupta"),
)
}
// Pass in sample data as Preview Parameter
@Preview(device = Devices.DESKTOP)
@Composable
fun DojoSlidePreview(
@PreviewParameter(DojoSlideParameterProvider::class) talk: Talk
) {
DojoSlide(title = talk.title, presenter = talk.presenter)
}
data class Talk (
val title: String,
val presenter: String
)
@Composable
fun DojoSlide(title: String, presenter: String){
Column(
modifier = Modifier
.fillMaxSize()
.background(color = Color(13, 92, 99)),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
) {
Text(text = title, fontWeight = Bold, fontSize = 84.sp, color = Color(120, 205, 215))
Spacer(modifier = Modifier.height(32.dp))
Text(text = presenter, fontSize = 54.sp, color = Color(120, 205, 215))
}
}