1 /*
2  * Copyright 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package androidx.compose.ui.text.samples
18 
19 import androidx.annotation.Sampled
20 import androidx.compose.material.Text
21 import androidx.compose.runtime.Composable
22 import androidx.compose.ui.graphics.Brush
23 import androidx.compose.ui.graphics.Color
24 import androidx.compose.ui.text.TextStyle
25 import androidx.compose.ui.text.font.FontFamily
26 import androidx.compose.ui.text.font.FontStyle
27 import androidx.compose.ui.text.font.FontWeight
28 import androidx.compose.ui.text.style.TextDecoration
29 import androidx.compose.ui.unit.em
30 import androidx.compose.ui.unit.sp
31 
32 @Sampled
33 @Composable
TextStyleSamplenull34 fun TextStyleSample() {
35     Text(
36         text = "Demo Text",
37         style =
38             TextStyle(
39                 color = Color.Red,
40                 fontSize = 16.sp,
41                 fontFamily = FontFamily.Monospace,
42                 fontWeight = FontWeight.W800,
43                 fontStyle = FontStyle.Italic,
44                 letterSpacing = 0.5.em,
45                 background = Color.LightGray,
46                 textDecoration = TextDecoration.Underline
47             )
48     )
49 }
50 
51 @Sampled
52 @Composable
TextStyleBrushSamplenull53 fun TextStyleBrushSample() {
54     Text(
55         text = "Demo Text",
56         style =
57             TextStyle(
58                 brush = Brush.linearGradient(listOf(Color.Red, Color.Blue, Color.Green)),
59                 alpha = 0.8f,
60                 fontSize = 16.sp,
61                 fontFamily = FontFamily.Monospace,
62                 fontWeight = FontWeight.W800,
63                 fontStyle = FontStyle.Italic,
64                 letterSpacing = 0.5.em,
65                 textDecoration = TextDecoration.Underline
66             )
67     )
68 }
69