forked from microsoft/fluentui-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathV2ShimmerActivity.kt
218 lines (209 loc) · 9.01 KB
/
V2ShimmerActivity.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
package com.microsoft.fluentuidemo.demos
import android.os.Bundle
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.unit.dp
import com.microsoft.fluentui.theme.token.FluentAliasTokens
import com.microsoft.fluentui.theme.token.controlTokens.AvatarSize
import com.microsoft.fluentui.theme.token.controlTokens.AvatarStatus
import com.microsoft.fluentui.theme.token.controlTokens.BadgeInfo
import com.microsoft.fluentui.theme.token.controlTokens.BadgeTokens
import com.microsoft.fluentui.theme.token.controlTokens.ColorStyle
import com.microsoft.fluentui.theme.token.controlTokens.PersonaChipSize
import com.microsoft.fluentui.theme.token.controlTokens.PersonaChipStyle
import com.microsoft.fluentui.theme.token.controlTokens.ShimmerInfo
import com.microsoft.fluentui.theme.token.controlTokens.ShimmerTokens
import com.microsoft.fluentui.tokenized.controls.Label
import com.microsoft.fluentui.tokenized.notification.Badge
import com.microsoft.fluentui.tokenized.persona.Avatar
import com.microsoft.fluentui.tokenized.persona.Person
import com.microsoft.fluentui.tokenized.persona.PersonaChip
import com.microsoft.fluentui.tokenized.shimmer.Shimmer
import com.microsoft.fluentuidemo.R
import com.microsoft.fluentuidemo.V2DemoActivity
class V2ShimmerActivity : V2DemoActivity() {
init {
setupActivity(this)
}
override val paramsUrl = "https://github.com/microsoft/fluentui-android/wiki/Controls#params-34"
override val controlTokensUrl =
"https://github.com/microsoft/fluentui-android/wiki/Controls#control-tokens-32"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setActivityContent {
CreateShimmerActivityUI()
}
}
@Composable
private fun CreateShimmerActivityUI() {
Column(
Modifier
.padding(all = 12.dp)
) {
Label(
text = "Box Shimmer",
textStyle = FluentAliasTokens.TypographyTokens.Title2,
colorStyle = ColorStyle.Brand
)
Row(
modifier = Modifier
.padding(top = 8.dp, bottom = 16.dp)
.height(80.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Shimmer(modifier = Modifier.size(120.dp, 80.dp))
Column(
Modifier
.height(80.dp)
.padding(top = 10.dp, bottom = 10.dp),
verticalArrangement = Arrangement.SpaceBetween
) {
Shimmer(modifier = Modifier.size(140.dp, 12.dp))
Shimmer(modifier = Modifier.size(180.dp, 12.dp))
Shimmer(modifier = Modifier.size(200.dp, 12.dp))
}
}
Label(
text = "Circle Shimmer",
textStyle = FluentAliasTokens.TypographyTokens.Title2,
colorStyle = ColorStyle.Brand
)
Row(
modifier = Modifier
.padding(top = 8.dp, bottom = 16.dp)
.height(60.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Shimmer(modifier = Modifier.size(60.dp, 60.dp).clip(RoundedCornerShape(50.dp)))
Column(
Modifier
.height(80.dp)
.padding(top = 10.dp, bottom = 10.dp),
verticalArrangement = Arrangement.SpaceBetween
) {
Shimmer(modifier = Modifier.size(180.dp, 12.dp))
Shimmer(modifier = Modifier.size(180.dp, 12.dp))
}
}
Row(
modifier = Modifier
.padding(top = 8.dp, bottom = 16.dp)
.height(60.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Shimmer(modifier = Modifier.size(60.dp, 60.dp).clip(RoundedCornerShape(50.dp)))
Column(
Modifier
.height(80.dp)
.padding(top = 10.dp, bottom = 10.dp),
verticalArrangement = Arrangement.SpaceBetween
) {
Shimmer(modifier = Modifier.size(140.dp, 12.dp))
Shimmer(modifier = Modifier.size(180.dp, 12.dp))
}
}
Row(
modifier = Modifier
.padding(top = 8.dp, bottom = 16.dp)
.height(60.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Shimmer(modifier = Modifier.size(60.dp, 60.dp).clip(RoundedCornerShape(50.dp)))
Column(
Modifier
.height(80.dp)
.padding(top = 10.dp, bottom = 10.dp),
verticalArrangement = Arrangement.SpaceBetween
) {
Shimmer(modifier = Modifier.size(140.dp, 12.dp))
Shimmer(modifier = Modifier.size(180.dp, 12.dp))
}
}
class ShimmerGoldEffectToken : ShimmerTokens() {
@Composable
override fun knockoutEffectColor(shimmerInfo: ShimmerInfo): Color {
return Color(0XFFE1BA27)
}
}
class BadgeColorToken : BadgeTokens() {
@Composable
override fun backgroundBrush(badgeInfo: BadgeInfo): Brush {
return SolidColor(Color(0xFFD59328))
}
@Composable
override fun borderStroke(badgeInfo: BadgeInfo): BorderStroke {
return BorderStroke(
width = 0.dp,
brush = SolidColor(Color(0xFFD59328))
)
}
}
Label(
text = "Shimmer with Content",
textStyle = FluentAliasTokens.TypographyTokens.Title2,
colorStyle = ColorStyle.Brand
)
Row(
modifier = Modifier
.padding(top = 8.dp, bottom = 16.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Label(text = "Badge", textStyle = FluentAliasTokens.TypographyTokens.Body1)
Shimmer(content = {
Badge(text = "Badge", badgeTokens = BadgeColorToken())
}, shimmerTokens = ShimmerGoldEffectToken(), cornerRadius = 100.dp)
}
Row(
modifier = Modifier
.padding(top = 8.dp, bottom = 16.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Label(text = "PersonaChip", textStyle = FluentAliasTokens.TypographyTokens.Body1)
Shimmer(cornerRadius = 2.dp, content = {
PersonaChip(
person = Person("PersonaChip"),
selected = true,
size = PersonaChipSize.Small,
style = PersonaChipStyle.Brand
)
})
}
Row(
modifier = Modifier
.padding(top = 8.dp, bottom = 16.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Label(text = "Avatar", textStyle = FluentAliasTokens.TypographyTokens.Body1)
Shimmer(cornerRadius = 50.dp, content = {
Avatar(
person = Person(
"Allan", "Munger",
image = R.drawable.avatar_allan_munger,
status = AvatarStatus.Available,
), size = AvatarSize.Size72, enableActivityRings = false
)
})
}
}
}
}