forked from microsoft/fluentui-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathV2LabelActivity.kt
186 lines (178 loc) · 6.48 KB
/
V2LabelActivity.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package com.microsoft.fluentuidemo.demos
import android.os.Bundle
import androidx.compose.foundation.background
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.microsoft.fluentui.theme.token.FluentAliasTokens.TypographyTokens
import com.microsoft.fluentui.theme.token.controlTokens.ColorStyle
import com.microsoft.fluentui.tokenized.controls.Label
import com.microsoft.fluentui.tokenized.segmentedcontrols.PillMetaData
import com.microsoft.fluentui.tokenized.segmentedcontrols.PillTabs
import com.microsoft.fluentuidemo.V2DemoActivity
class V2LabelActivity : V2DemoActivity() {
init {
setupActivity(this)
}
override val paramsUrl = "https://github.com/microsoft/fluentui-android/wiki/Controls#params-20"
override val controlTokensUrl = "https://github.com/microsoft/fluentui-android/wiki/Controls#control-tokens-20"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setActivityContent {
CreateLabelUI()
}
}
@Composable
private fun CreateLabelUI() {
var colorStyle by rememberSaveable { mutableStateOf(ColorStyle.Primary) }
var selectedTab by rememberSaveable { mutableStateOf(0) }
var isBackgroundChange by rememberSaveable { mutableStateOf(false) }
var tabsList: MutableList<PillMetaData> = mutableListOf()
tabsList.add(
PillMetaData(
text = "Primary",
onClick = {
colorStyle = ColorStyle.Primary
selectedTab = 0
isBackgroundChange = false
}
)
)
tabsList.add(
PillMetaData(
text = "Secondary",
onClick = {
colorStyle = ColorStyle.Secondary
selectedTab = 1
isBackgroundChange = false
}
)
)
tabsList.add(
PillMetaData(
text = "White",
onClick = {
colorStyle = ColorStyle.White
isBackgroundChange = true
selectedTab = 2
}
)
)
tabsList.add(
PillMetaData(
text = "Brand",
onClick = {
colorStyle = ColorStyle.Brand
selectedTab = 3
isBackgroundChange = false
}
)
)
tabsList.add(
PillMetaData(
text = "Error",
onClick = {
colorStyle = ColorStyle.Error
selectedTab = 4
isBackgroundChange = false
}
)
)
Column(
modifier = Modifier
.then(
if (isBackgroundChange) {
Modifier.background(Color.Black)
} else {
Modifier
}
)
.padding(top = 16.dp)
) {
PillTabs(metadataList = tabsList, scrollable = true, selectedIndex = selectedTab)
Column(
modifier = Modifier
.padding(all = 16.dp)
.horizontalScroll(
rememberScrollState()
)
.verticalScroll(
rememberScrollState()
),
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
Label(
text = "Display is Regular 60sp",
textStyle = TypographyTokens.Display,
colorStyle = colorStyle
)
Label(
text = "LargeTitle is Regular 34sp",
textStyle = TypographyTokens.LargeTitle,
colorStyle = colorStyle
)
Label(
text = "Title1 is Bold 24sp",
textStyle = TypographyTokens.Title1,
colorStyle = colorStyle
)
Label(
text = "Title2 is Medium 20sp",
textStyle = TypographyTokens.Title2,
colorStyle = colorStyle
)
Label(
text = "Title3 is Medium is 18sp",
textStyle = TypographyTokens.Title3,
colorStyle = colorStyle
)
Label(
text = "Body1Strong is SemiBold 16sp",
textStyle = TypographyTokens.Body1Strong,
colorStyle = colorStyle
)
Label(
text = "Body1 is Regular 16sp",
textStyle = TypographyTokens.Body1,
colorStyle = colorStyle
)
Label(
text = "Body2Strong is Medium 14sp",
textStyle = TypographyTokens.Body2Strong,
colorStyle = colorStyle
)
Label(
text = "Body2 is Regular 14sp",
textStyle = TypographyTokens.Body2,
colorStyle = colorStyle
)
Label(
text = "Caption1Strong is Medium 13sp",
textStyle = TypographyTokens.Caption1Strong,
colorStyle = colorStyle
)
Label(
text = "Caption1 is Regular 13sp",
textStyle = TypographyTokens.Caption1,
colorStyle = colorStyle
)
Label(
text = "Caption2 is Regular 12sp",
textStyle = TypographyTokens.Caption2,
colorStyle = colorStyle
)
}
}
}
}