werewolf-ui 0.1.0-beta.2 → 0.1.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -5
- package/data/manifest.json +3779 -484
- package/data/native/android/WerewolfAlert.kt +1 -1
- package/data/native/android/WerewolfAlertDialog.kt +156 -0
- package/data/native/android/WerewolfAvatar.kt +393 -0
- package/data/native/android/WerewolfBackdropBlur.kt +89 -0
- package/data/native/android/WerewolfBadge.kt +1 -1
- package/data/native/android/WerewolfBottomNav.kt +333 -0
- package/data/native/android/WerewolfButton.kt +1 -1
- package/data/native/android/WerewolfButtonGroup.kt +54 -0
- package/data/native/android/WerewolfCard.kt +1 -1
- package/data/native/android/WerewolfCheckbox.kt +387 -0
- package/data/native/android/WerewolfCounter.kt +640 -0
- package/data/native/android/WerewolfDialog.kt +131 -0
- package/data/native/android/WerewolfEmptyState.kt +1 -1
- package/data/native/android/WerewolfField.kt +66 -0
- package/data/native/android/WerewolfIcons.kt +39 -1
- package/data/native/android/WerewolfInput.kt +1 -1
- package/data/native/android/WerewolfKbd.kt +1 -1
- package/data/native/android/WerewolfLabel.kt +2 -2
- package/data/native/android/WerewolfLayers.kt +385 -0
- package/data/native/android/WerewolfLink.kt +163 -0
- package/data/native/android/WerewolfList.kt +504 -0
- package/data/native/android/WerewolfListRuntime.kt +384 -0
- package/data/native/android/WerewolfMetadata.kt +180 -0
- package/data/native/android/WerewolfMeter.kt +189 -0
- package/data/native/android/WerewolfModifiers.kt +58 -4
- package/data/native/android/WerewolfProgress.kt +281 -0
- package/data/native/android/WerewolfRadioGroup.kt +382 -0
- package/data/native/android/WerewolfSelect.kt +330 -0
- package/data/native/android/WerewolfSeparator.kt +1 -1
- package/data/native/android/WerewolfSheet.kt +204 -0
- package/data/native/android/WerewolfSkeleton.kt +1 -1
- package/data/native/android/WerewolfSpinner.kt +1 -1
- package/data/native/android/WerewolfSwitch.kt +9 -57
- package/data/native/android/WerewolfTabs.kt +591 -0
- package/data/native/android/WerewolfTextarea.kt +329 -0
- package/data/native/android/WerewolfTheme.kt +3 -2
- package/data/native/android/WerewolfToast.kt +226 -0
- package/data/native/android/WerewolfToaster.kt +282 -0
- package/data/native/android/WerewolfToggle.kt +395 -0
- package/data/native/android/WerewolfToggleGroup.kt +427 -0
- package/data/native/android/WerewolfToken.kt +1 -1
- package/data/native/ios/WerewolfAlert.swift +1 -1
- package/data/native/ios/WerewolfAlertDialog.swift +185 -0
- package/data/native/ios/WerewolfAvatar.swift +552 -0
- package/data/native/ios/WerewolfBadge.swift +1 -1
- package/data/native/ios/WerewolfBottomNav.swift +422 -0
- package/data/native/ios/WerewolfButton.swift +1 -1
- package/data/native/ios/WerewolfButtonGroup.swift +62 -0
- package/data/native/ios/WerewolfCard.swift +1 -1
- package/data/native/ios/WerewolfCheckbox.swift +621 -0
- package/data/native/ios/WerewolfCounter.swift +768 -0
- package/data/native/ios/WerewolfDialog.swift +170 -0
- package/data/native/ios/WerewolfEmptyState.swift +1 -1
- package/data/native/ios/WerewolfField.swift +103 -0
- package/data/native/ios/WerewolfIcons.swift +13 -1
- package/data/native/ios/WerewolfInput.swift +1 -1
- package/data/native/ios/WerewolfKbd.swift +1 -1
- package/data/native/ios/WerewolfLabel.swift +2 -2
- package/data/native/ios/WerewolfLayers.swift +376 -0
- package/data/native/ios/WerewolfLink.swift +188 -0
- package/data/native/ios/WerewolfList.swift +603 -0
- package/data/native/ios/WerewolfListRuntime.swift +414 -0
- package/data/native/ios/WerewolfMetadata.swift +205 -0
- package/data/native/ios/WerewolfMeter.swift +186 -0
- package/data/native/ios/WerewolfModifiers.swift +106 -1
- package/data/native/ios/WerewolfProgress.swift +338 -0
- package/data/native/ios/WerewolfRadioGroup.swift +483 -0
- package/data/native/ios/WerewolfSelect.swift +418 -0
- package/data/native/ios/WerewolfSeparator.swift +1 -1
- package/data/native/ios/WerewolfSheet.swift +208 -0
- package/data/native/ios/WerewolfSkeleton.swift +1 -1
- package/data/native/ios/WerewolfSpinner.swift +1 -1
- package/data/native/ios/WerewolfSwitch.swift +18 -77
- package/data/native/ios/WerewolfTabs.swift +756 -0
- package/data/native/ios/WerewolfTextarea.swift +403 -0
- package/data/native/ios/WerewolfTheme.swift +1 -1
- package/data/native/ios/WerewolfToast.swift +278 -0
- package/data/native/ios/WerewolfToaster.swift +269 -0
- package/data/native/ios/WerewolfToggle.swift +647 -0
- package/data/native/ios/WerewolfToggleGroup.swift +511 -0
- package/data/native/ios/WerewolfToken.swift +1 -1
- package/dist/cli.mjs +2212 -352
- package/dist/core.mjs +2121 -308
- package/dist/lint.mjs +142 -18
- package/dist/project.mjs +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
// Generated file, must not be edited by hand. Source: components/checkbox.spec.json (werewolf-ui 0.1.0-beta.3).
|
|
2
|
+
package dev.werewolfui
|
|
3
|
+
|
|
4
|
+
import androidx.compose.animation.animateColorAsState
|
|
5
|
+
import androidx.compose.animation.core.animateFloatAsState
|
|
6
|
+
import androidx.compose.animation.core.snap
|
|
7
|
+
import androidx.compose.animation.core.tween
|
|
8
|
+
import androidx.compose.foundation.Image
|
|
9
|
+
import androidx.compose.foundation.background
|
|
10
|
+
import androidx.compose.foundation.border
|
|
11
|
+
import androidx.compose.foundation.focusable
|
|
12
|
+
import androidx.compose.foundation.hoverable
|
|
13
|
+
import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
14
|
+
import androidx.compose.foundation.interaction.collectIsFocusedAsState
|
|
15
|
+
import androidx.compose.foundation.interaction.collectIsHoveredAsState
|
|
16
|
+
import androidx.compose.foundation.interaction.collectIsPressedAsState
|
|
17
|
+
import androidx.compose.foundation.layout.Arrangement
|
|
18
|
+
import androidx.compose.foundation.layout.Box
|
|
19
|
+
import androidx.compose.foundation.layout.Column
|
|
20
|
+
import androidx.compose.foundation.layout.Row
|
|
21
|
+
import androidx.compose.foundation.layout.fillMaxWidth
|
|
22
|
+
import androidx.compose.foundation.layout.height
|
|
23
|
+
import androidx.compose.foundation.layout.size
|
|
24
|
+
import androidx.compose.foundation.layout.width
|
|
25
|
+
import androidx.compose.foundation.selection.triStateToggleable
|
|
26
|
+
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
27
|
+
import androidx.compose.runtime.Composable
|
|
28
|
+
import androidx.compose.runtime.CompositionLocalProvider
|
|
29
|
+
import androidx.compose.runtime.getValue
|
|
30
|
+
import androidx.compose.runtime.mutableStateOf
|
|
31
|
+
import androidx.compose.runtime.remember
|
|
32
|
+
import androidx.compose.runtime.setValue
|
|
33
|
+
import androidx.compose.ui.Alignment
|
|
34
|
+
import androidx.compose.ui.Modifier
|
|
35
|
+
import androidx.compose.ui.graphics.Color
|
|
36
|
+
import androidx.compose.ui.graphics.ColorFilter
|
|
37
|
+
import androidx.compose.ui.graphics.graphicsLayer
|
|
38
|
+
import androidx.compose.ui.semantics.Role
|
|
39
|
+
import androidx.compose.ui.state.ToggleableState
|
|
40
|
+
import androidx.compose.ui.text.TextStyle
|
|
41
|
+
import androidx.compose.ui.unit.Dp
|
|
42
|
+
import androidx.compose.ui.unit.TextUnit
|
|
43
|
+
import dev.werewolfui.runtime.LocalWerewolf
|
|
44
|
+
import dev.werewolfui.runtime.LocalWerewolfFonts
|
|
45
|
+
import dev.werewolfui.runtime.LocalWerewolfIcons
|
|
46
|
+
import dev.werewolfui.runtime.LocalWerewolfTextStyle
|
|
47
|
+
import dev.werewolfui.runtime.WerewolfFontRole
|
|
48
|
+
import dev.werewolfui.runtime.rememberReduceMotion
|
|
49
|
+
import dev.werewolfui.runtime.toCubicBezierEasing
|
|
50
|
+
import dev.werewolfui.runtime.werewolfFocusRing
|
|
51
|
+
import dev.werewolfui.runtime.werewolfFontWeight
|
|
52
|
+
import dev.werewolfui.runtime.werewolfHitArea
|
|
53
|
+
import dev.werewolfui.runtime.werewolfOverlay
|
|
54
|
+
import dev.werewolfui.runtime.werewolfShadow
|
|
55
|
+
import dev.werewolfui.tokens.WerewolfEasing
|
|
56
|
+
import dev.werewolfui.tokens.WerewolfShadowLayer
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@Composable
|
|
60
|
+
fun WerewolfCheckbox(
|
|
61
|
+
checked: Boolean,
|
|
62
|
+
onCheckedChange: (Boolean) -> Unit,
|
|
63
|
+
modifier: Modifier = Modifier,
|
|
64
|
+
enabled: Boolean = true,
|
|
65
|
+
indeterminate: Boolean = false,
|
|
66
|
+
invalid: Boolean = false,
|
|
67
|
+
required: Boolean = false,
|
|
68
|
+
description: (@Composable () -> Unit)? = null,
|
|
69
|
+
label: (@Composable () -> Unit)? = null,
|
|
70
|
+
) {
|
|
71
|
+
val t = LocalWerewolf.current
|
|
72
|
+
val reduced = rememberReduceMotion()
|
|
73
|
+
val interactionSource = remember { MutableInteractionSource() }
|
|
74
|
+
val pressed by interactionSource.collectIsPressedAsState()
|
|
75
|
+
val hovered by interactionSource.collectIsHoveredAsState()
|
|
76
|
+
val focusVisible by interactionSource.collectIsFocusedAsState()
|
|
77
|
+
// werewolf:property=row.gap
|
|
78
|
+
val rowGap = t.spacingSm
|
|
79
|
+
// werewolf:property=root.background-color
|
|
80
|
+
val rootBackgroundColor: Color = run {
|
|
81
|
+
// werewolf:state=checked+disabled
|
|
82
|
+
if (checked && !enabled) {
|
|
83
|
+
return@run t.colorBackgroundDisabled
|
|
84
|
+
}
|
|
85
|
+
// werewolf:state=indeterminate+disabled
|
|
86
|
+
if (indeterminate && !enabled) {
|
|
87
|
+
return@run t.colorBackgroundDisabled
|
|
88
|
+
}
|
|
89
|
+
// werewolf:state=checked+pressed
|
|
90
|
+
if (checked && pressed) {
|
|
91
|
+
return@run t.colorBackgroundRaised
|
|
92
|
+
}
|
|
93
|
+
// werewolf:state=indeterminate+pressed
|
|
94
|
+
if (indeterminate && pressed) {
|
|
95
|
+
return@run t.colorBackgroundRaised
|
|
96
|
+
}
|
|
97
|
+
// werewolf:state=checked+hover
|
|
98
|
+
if (checked && hovered) {
|
|
99
|
+
return@run t.colorBackgroundRaised
|
|
100
|
+
}
|
|
101
|
+
// werewolf:state=indeterminate+hover
|
|
102
|
+
if (indeterminate && hovered) {
|
|
103
|
+
return@run t.colorBackgroundRaised
|
|
104
|
+
}
|
|
105
|
+
// werewolf:state=disabled
|
|
106
|
+
if (!enabled) {
|
|
107
|
+
return@run t.colorBackgroundDisabled
|
|
108
|
+
}
|
|
109
|
+
// werewolf:state=checked
|
|
110
|
+
if (checked) {
|
|
111
|
+
return@run t.colorAccent
|
|
112
|
+
}
|
|
113
|
+
// werewolf:state=indeterminate
|
|
114
|
+
if (indeterminate) {
|
|
115
|
+
return@run t.colorAccent
|
|
116
|
+
}
|
|
117
|
+
// werewolf:state=default
|
|
118
|
+
t.colorBackgroundRaised
|
|
119
|
+
}
|
|
120
|
+
// werewolf:property=root.border-color
|
|
121
|
+
val rootBorderColor: Color = run {
|
|
122
|
+
// werewolf:state=checked+hover
|
|
123
|
+
if (checked && hovered) {
|
|
124
|
+
return@run t.colorBorderStrong
|
|
125
|
+
}
|
|
126
|
+
// werewolf:state=indeterminate+hover
|
|
127
|
+
if (indeterminate && hovered) {
|
|
128
|
+
return@run t.colorBorderStrong
|
|
129
|
+
}
|
|
130
|
+
// werewolf:state=invalid
|
|
131
|
+
if (invalid) {
|
|
132
|
+
return@run t.colorBorderDanger
|
|
133
|
+
}
|
|
134
|
+
// werewolf:state=hover
|
|
135
|
+
if (hovered) {
|
|
136
|
+
return@run t.colorBorderControl
|
|
137
|
+
}
|
|
138
|
+
// werewolf:state=default
|
|
139
|
+
t.colorBorderStrong
|
|
140
|
+
}
|
|
141
|
+
// werewolf:property=root.border-radius
|
|
142
|
+
val rootBorderRadius = t.radiusInner
|
|
143
|
+
// werewolf:property=root.border-width
|
|
144
|
+
val rootBorderWidth = t.borderWidth
|
|
145
|
+
// werewolf:property=root.box-shadow
|
|
146
|
+
val rootBoxShadow = t.shadowLow
|
|
147
|
+
// werewolf:property=root.height
|
|
148
|
+
val rootHeight = t.sizeIconMd
|
|
149
|
+
// werewolf:property=root.outline-color
|
|
150
|
+
val rootOutlineColor: Color? = run {
|
|
151
|
+
// werewolf:state=focus-visible
|
|
152
|
+
if (focusVisible) {
|
|
153
|
+
return@run t.colorFocusRing
|
|
154
|
+
}
|
|
155
|
+
// werewolf:state=default
|
|
156
|
+
null
|
|
157
|
+
}
|
|
158
|
+
// werewolf:property=root.outline-offset
|
|
159
|
+
val rootOutlineOffset: Dp? = run {
|
|
160
|
+
// werewolf:state=focus-visible
|
|
161
|
+
if (focusVisible) {
|
|
162
|
+
return@run t.outlineOffsetFocusRing
|
|
163
|
+
}
|
|
164
|
+
// werewolf:state=default
|
|
165
|
+
null
|
|
166
|
+
}
|
|
167
|
+
// werewolf:property=root.outline-width
|
|
168
|
+
val rootOutlineWidth: Dp? = run {
|
|
169
|
+
// werewolf:state=focus-visible
|
|
170
|
+
if (focusVisible) {
|
|
171
|
+
return@run t.outlineWidthFocusRing
|
|
172
|
+
}
|
|
173
|
+
// werewolf:state=default
|
|
174
|
+
null
|
|
175
|
+
}
|
|
176
|
+
// werewolf:property=root.overlay
|
|
177
|
+
val rootOverlay: Color? = run {
|
|
178
|
+
// werewolf:state=checked+pressed
|
|
179
|
+
if (checked && pressed) {
|
|
180
|
+
return@run t.colorOverlayPressedOnAccent
|
|
181
|
+
}
|
|
182
|
+
// werewolf:state=indeterminate+pressed
|
|
183
|
+
if (indeterminate && pressed) {
|
|
184
|
+
return@run t.colorOverlayPressedOnAccent
|
|
185
|
+
}
|
|
186
|
+
// werewolf:state=checked+hover
|
|
187
|
+
if (checked && hovered) {
|
|
188
|
+
return@run t.colorOverlayHoverOnAccent
|
|
189
|
+
}
|
|
190
|
+
// werewolf:state=indeterminate+hover
|
|
191
|
+
if (indeterminate && hovered) {
|
|
192
|
+
return@run t.colorOverlayHoverOnAccent
|
|
193
|
+
}
|
|
194
|
+
// werewolf:state=pressed
|
|
195
|
+
if (pressed) {
|
|
196
|
+
return@run t.colorOverlayPressed
|
|
197
|
+
}
|
|
198
|
+
// werewolf:state=hover
|
|
199
|
+
if (hovered) {
|
|
200
|
+
return@run t.colorOverlayHover
|
|
201
|
+
}
|
|
202
|
+
// werewolf:state=default
|
|
203
|
+
null
|
|
204
|
+
}
|
|
205
|
+
// werewolf:property=root.scale
|
|
206
|
+
val rootScale: Float? = run {
|
|
207
|
+
// werewolf:state=checked+pressed
|
|
208
|
+
if (checked && pressed) {
|
|
209
|
+
return@run null
|
|
210
|
+
}
|
|
211
|
+
// werewolf:state=indeterminate+pressed
|
|
212
|
+
if (indeterminate && pressed) {
|
|
213
|
+
return@run null
|
|
214
|
+
}
|
|
215
|
+
// werewolf:state=pressed
|
|
216
|
+
if (pressed) {
|
|
217
|
+
return@run t.scalePressed
|
|
218
|
+
}
|
|
219
|
+
// werewolf:state=default
|
|
220
|
+
null
|
|
221
|
+
}
|
|
222
|
+
// werewolf:property=root.transition-duration
|
|
223
|
+
val rootTransitionDuration = t.durationFastMs
|
|
224
|
+
// werewolf:property=root.transition-timing-function
|
|
225
|
+
val rootTransitionTimingFunction = t.easeStandard
|
|
226
|
+
// werewolf:property=root.width
|
|
227
|
+
val rootWidth = t.sizeIconMd
|
|
228
|
+
// werewolf:property=icon.color
|
|
229
|
+
val iconColor: Color = run {
|
|
230
|
+
// werewolf:state=checked+disabled
|
|
231
|
+
if (checked && !enabled) {
|
|
232
|
+
return@run t.colorIconOnAccent
|
|
233
|
+
}
|
|
234
|
+
// werewolf:state=indeterminate+disabled
|
|
235
|
+
if (indeterminate && !enabled) {
|
|
236
|
+
return@run t.colorIconOnAccent
|
|
237
|
+
}
|
|
238
|
+
// werewolf:state=disabled
|
|
239
|
+
if (!enabled) {
|
|
240
|
+
return@run t.colorIconDisabled
|
|
241
|
+
}
|
|
242
|
+
// werewolf:state=default
|
|
243
|
+
t.colorIconOnAccent
|
|
244
|
+
}
|
|
245
|
+
// werewolf:property=icon.height
|
|
246
|
+
val iconHeight = t.sizeIconMd
|
|
247
|
+
// werewolf:property=icon.width
|
|
248
|
+
val iconWidth = t.sizeIconMd
|
|
249
|
+
// werewolf:property=label.color
|
|
250
|
+
val labelColor = t.colorTextPrimary
|
|
251
|
+
// werewolf:property=label.font-family
|
|
252
|
+
val labelFontFamily = t.fontFamilySans
|
|
253
|
+
// werewolf:property=label.font-size
|
|
254
|
+
val labelFontSize = t.fontSizeSm
|
|
255
|
+
// werewolf:property=label.font-weight
|
|
256
|
+
val labelFontWeight = t.fontWeightMedium
|
|
257
|
+
// werewolf:property=description.color
|
|
258
|
+
val descriptionColor = t.colorTextSecondary
|
|
259
|
+
// werewolf:property=description.font-family
|
|
260
|
+
val descriptionFontFamily = t.fontFamilySans
|
|
261
|
+
// werewolf:property=description.font-size
|
|
262
|
+
val descriptionFontSize = t.fontSizeSm
|
|
263
|
+
val rootShape = RoundedCornerShape(rootBorderRadius)
|
|
264
|
+
val animatedRootBackgroundColor by animateColorAsState(
|
|
265
|
+
targetValue = rootBackgroundColor,
|
|
266
|
+
animationSpec = if (reduced) snap() else tween(durationMillis = rootTransitionDuration, easing = rootTransitionTimingFunction.toCubicBezierEasing()),
|
|
267
|
+
label = "rootBackgroundColor",
|
|
268
|
+
)
|
|
269
|
+
val animatedIconColor by animateColorAsState(
|
|
270
|
+
targetValue = iconColor,
|
|
271
|
+
animationSpec = if (reduced) snap() else tween(durationMillis = rootTransitionDuration, easing = rootTransitionTimingFunction.toCubicBezierEasing()),
|
|
272
|
+
label = "iconColor",
|
|
273
|
+
)
|
|
274
|
+
val animatedLabelColor by animateColorAsState(
|
|
275
|
+
targetValue = labelColor,
|
|
276
|
+
animationSpec = if (reduced) snap() else tween(durationMillis = rootTransitionDuration, easing = rootTransitionTimingFunction.toCubicBezierEasing()),
|
|
277
|
+
label = "labelColor",
|
|
278
|
+
)
|
|
279
|
+
val animatedDescriptionColor by animateColorAsState(
|
|
280
|
+
targetValue = descriptionColor,
|
|
281
|
+
animationSpec = if (reduced) snap() else tween(durationMillis = rootTransitionDuration, easing = rootTransitionTimingFunction.toCubicBezierEasing()),
|
|
282
|
+
label = "descriptionColor",
|
|
283
|
+
)
|
|
284
|
+
val scale by animateFloatAsState(
|
|
285
|
+
targetValue = if (reduced || rootScale == null) 1f else rootScale,
|
|
286
|
+
animationSpec = if (reduced) snap() else tween(durationMillis = rootTransitionDuration, easing = rootTransitionTimingFunction.toCubicBezierEasing()),
|
|
287
|
+
label = "scale",
|
|
288
|
+
)
|
|
289
|
+
Row(
|
|
290
|
+
modifier = modifier
|
|
291
|
+
.werewolfHitArea()
|
|
292
|
+
.triStateToggleable(
|
|
293
|
+
state = if (indeterminate) ToggleableState.Indeterminate else if (checked) ToggleableState.On else ToggleableState.Off,
|
|
294
|
+
interactionSource = interactionSource,
|
|
295
|
+
indication = null,
|
|
296
|
+
enabled = enabled,
|
|
297
|
+
role = Role.Checkbox,
|
|
298
|
+
onClick = { onCheckedChange(indeterminate || !checked) },
|
|
299
|
+
)
|
|
300
|
+
.hoverable(interactionSource = interactionSource)
|
|
301
|
+
.focusable(interactionSource = interactionSource),
|
|
302
|
+
horizontalArrangement = Arrangement.spacedBy(rowGap, Alignment.CenterHorizontally),
|
|
303
|
+
verticalAlignment = Alignment.Top,
|
|
304
|
+
) {
|
|
305
|
+
Box(
|
|
306
|
+
modifier = Modifier
|
|
307
|
+
.graphicsLayer {
|
|
308
|
+
scaleX = scale
|
|
309
|
+
scaleY = scale
|
|
310
|
+
}
|
|
311
|
+
.width(rootWidth)
|
|
312
|
+
.height(rootHeight)
|
|
313
|
+
.then(if (rootWidth == null) Modifier.fillMaxWidth() else Modifier)
|
|
314
|
+
.background(animatedRootBackgroundColor, rootShape)
|
|
315
|
+
.border(rootBorderWidth, rootBorderColor, rootShape)
|
|
316
|
+
.werewolfShadow(rootBoxShadow)
|
|
317
|
+
.werewolfOverlay(rootOverlay ?: Color.Transparent, rootShape, rootOverlay != null)
|
|
318
|
+
.werewolfFocusRing(
|
|
319
|
+
rootOutlineColor != null,
|
|
320
|
+
rootShape,
|
|
321
|
+
),
|
|
322
|
+
contentAlignment = Alignment.Center,
|
|
323
|
+
) {
|
|
324
|
+
if (checked && !indeterminate) {
|
|
325
|
+
Image(
|
|
326
|
+
imageVector = LocalWerewolfIcons.current.check,
|
|
327
|
+
contentDescription = null,
|
|
328
|
+
colorFilter = ColorFilter.tint(animatedIconColor),
|
|
329
|
+
modifier = Modifier.size(width = iconWidth, height = iconHeight),
|
|
330
|
+
)
|
|
331
|
+
}
|
|
332
|
+
if (indeterminate) {
|
|
333
|
+
Image(
|
|
334
|
+
imageVector = LocalWerewolfIcons.current.minus,
|
|
335
|
+
contentDescription = null,
|
|
336
|
+
colorFilter = ColorFilter.tint(animatedIconColor),
|
|
337
|
+
modifier = Modifier.size(width = iconWidth, height = iconHeight),
|
|
338
|
+
)
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
if (label != null) {
|
|
342
|
+
Column(
|
|
343
|
+
verticalArrangement = Arrangement.Top,
|
|
344
|
+
horizontalAlignment = Alignment.Start,
|
|
345
|
+
) {
|
|
346
|
+
CompositionLocalProvider(
|
|
347
|
+
LocalWerewolfTextStyle provides TextStyle(color = animatedLabelColor, fontFamily = LocalWerewolfFonts.current.resolve(when (labelFontFamily) { t.fontFamilySans -> WerewolfFontRole.Sans; else -> WerewolfFontRole.Mono }), fontSize = labelFontSize, fontWeight = werewolfFontWeight(labelFontWeight)),
|
|
348
|
+
) {
|
|
349
|
+
label?.invoke()
|
|
350
|
+
}
|
|
351
|
+
if (description != null) {
|
|
352
|
+
CompositionLocalProvider(
|
|
353
|
+
LocalWerewolfTextStyle provides TextStyle(color = animatedDescriptionColor, fontFamily = LocalWerewolfFonts.current.resolve(when (descriptionFontFamily) { t.fontFamilySans -> WerewolfFontRole.Sans; else -> WerewolfFontRole.Mono }), fontSize = descriptionFontSize),
|
|
354
|
+
) {
|
|
355
|
+
description?.invoke()
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
@Composable
|
|
364
|
+
fun WerewolfCheckbox(
|
|
365
|
+
defaultChecked: Boolean = false,
|
|
366
|
+
modifier: Modifier = Modifier,
|
|
367
|
+
enabled: Boolean = true,
|
|
368
|
+
indeterminate: Boolean = false,
|
|
369
|
+
invalid: Boolean = false,
|
|
370
|
+
required: Boolean = false,
|
|
371
|
+
description: (@Composable () -> Unit)? = null,
|
|
372
|
+
label: (@Composable () -> Unit)? = null,
|
|
373
|
+
) {
|
|
374
|
+
var checked by remember { mutableStateOf(defaultChecked) }
|
|
375
|
+
var mixed by remember { mutableStateOf(indeterminate) }
|
|
376
|
+
WerewolfCheckbox(
|
|
377
|
+
checked = checked,
|
|
378
|
+
onCheckedChange = { mixed = false; checked = it },
|
|
379
|
+
modifier = modifier,
|
|
380
|
+
enabled = enabled,
|
|
381
|
+
indeterminate = mixed,
|
|
382
|
+
invalid = invalid,
|
|
383
|
+
required = required,
|
|
384
|
+
description = description,
|
|
385
|
+
label = label,
|
|
386
|
+
)
|
|
387
|
+
}
|