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,333 @@
|
|
|
1
|
+
// Generated file, must not be edited by hand. Source: components/bottom-nav.spec.json (werewolf-ui 0.1.0-beta.3).
|
|
2
|
+
package dev.werewolfui
|
|
3
|
+
|
|
4
|
+
import androidx.compose.animation.core.animateFloatAsState
|
|
5
|
+
import androidx.compose.animation.core.snap
|
|
6
|
+
import androidx.compose.animation.core.tween
|
|
7
|
+
import androidx.compose.foundation.background
|
|
8
|
+
import androidx.compose.foundation.focusable
|
|
9
|
+
import androidx.compose.foundation.hoverable
|
|
10
|
+
import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
11
|
+
import androidx.compose.foundation.interaction.collectIsFocusedAsState
|
|
12
|
+
import androidx.compose.foundation.interaction.collectIsHoveredAsState
|
|
13
|
+
import androidx.compose.foundation.interaction.collectIsPressedAsState
|
|
14
|
+
import androidx.compose.foundation.layout.Arrangement
|
|
15
|
+
import androidx.compose.foundation.layout.Box
|
|
16
|
+
import androidx.compose.foundation.layout.Column
|
|
17
|
+
import androidx.compose.foundation.layout.Row
|
|
18
|
+
import androidx.compose.foundation.layout.RowScope
|
|
19
|
+
import androidx.compose.foundation.layout.fillMaxWidth
|
|
20
|
+
import androidx.compose.foundation.layout.heightIn
|
|
21
|
+
import androidx.compose.foundation.layout.offset
|
|
22
|
+
import androidx.compose.foundation.layout.padding
|
|
23
|
+
import androidx.compose.foundation.selection.selectable
|
|
24
|
+
import androidx.compose.foundation.selection.selectableGroup
|
|
25
|
+
import androidx.compose.foundation.shape.CircleShape
|
|
26
|
+
import androidx.compose.foundation.text.BasicText
|
|
27
|
+
import androidx.compose.runtime.Composable
|
|
28
|
+
import androidx.compose.runtime.CompositionLocalProvider
|
|
29
|
+
import androidx.compose.runtime.DisposableEffect
|
|
30
|
+
import androidx.compose.runtime.SideEffect
|
|
31
|
+
import androidx.compose.runtime.getValue
|
|
32
|
+
import androidx.compose.runtime.mutableStateMapOf
|
|
33
|
+
import androidx.compose.runtime.remember
|
|
34
|
+
import androidx.compose.runtime.staticCompositionLocalOf
|
|
35
|
+
import androidx.compose.ui.Alignment
|
|
36
|
+
import androidx.compose.ui.Modifier
|
|
37
|
+
import androidx.compose.ui.draw.drawBehind
|
|
38
|
+
import androidx.compose.ui.geometry.Size
|
|
39
|
+
import androidx.compose.ui.graphics.Color
|
|
40
|
+
import androidx.compose.ui.graphics.drawOutline
|
|
41
|
+
import androidx.compose.ui.graphics.drawscope.translate
|
|
42
|
+
import androidx.compose.ui.layout.onGloballyPositioned
|
|
43
|
+
import androidx.compose.ui.layout.positionInParent
|
|
44
|
+
import androidx.compose.ui.semantics.Role
|
|
45
|
+
import androidx.compose.ui.semantics.clearAndSetSemantics
|
|
46
|
+
import androidx.compose.ui.semantics.contentDescription
|
|
47
|
+
import androidx.compose.ui.semantics.semantics
|
|
48
|
+
import androidx.compose.ui.text.TextStyle
|
|
49
|
+
import androidx.compose.ui.unit.Dp
|
|
50
|
+
import androidx.compose.ui.unit.IntRect
|
|
51
|
+
import androidx.compose.ui.unit.TextUnit
|
|
52
|
+
import androidx.compose.ui.unit.round
|
|
53
|
+
import dev.werewolfui.runtime.LocalWerewolf
|
|
54
|
+
import dev.werewolfui.runtime.LocalWerewolfContentColor
|
|
55
|
+
import dev.werewolfui.runtime.LocalWerewolfFonts
|
|
56
|
+
import dev.werewolfui.runtime.WerewolfFontRole
|
|
57
|
+
import dev.werewolfui.runtime.rememberReduceMotion
|
|
58
|
+
import dev.werewolfui.runtime.toCubicBezierEasing
|
|
59
|
+
import dev.werewolfui.runtime.werewolfBarInsets
|
|
60
|
+
import dev.werewolfui.runtime.werewolfBarWidth
|
|
61
|
+
import dev.werewolfui.runtime.werewolfFocusRing
|
|
62
|
+
import dev.werewolfui.runtime.werewolfFontWeight
|
|
63
|
+
import dev.werewolfui.runtime.werewolfGlass
|
|
64
|
+
import dev.werewolfui.runtime.werewolfHitArea
|
|
65
|
+
import dev.werewolfui.runtime.werewolfIconFrame
|
|
66
|
+
import dev.werewolfui.runtime.werewolfOverlay
|
|
67
|
+
import dev.werewolfui.runtime.werewolfPressScale
|
|
68
|
+
import dev.werewolfui.runtime.werewolfReportBottomInset
|
|
69
|
+
import dev.werewolfui.runtime.werewolfRequireBarItems
|
|
70
|
+
import dev.werewolfui.runtime.werewolfShadow
|
|
71
|
+
import dev.werewolfui.tokens.WerewolfEasing
|
|
72
|
+
import dev.werewolfui.tokens.WerewolfShadowLayer
|
|
73
|
+
|
|
74
|
+
internal class WerewolfBottomNavSelection(
|
|
75
|
+
val value: String?,
|
|
76
|
+
val onSelect: (String) -> Unit,
|
|
77
|
+
val showLabels: Boolean,
|
|
78
|
+
val countLabel: (String, Int) -> String,
|
|
79
|
+
val bounds: MutableMap<String, IntRect>,
|
|
80
|
+
val destinations: MutableSet<String>,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
internal val LocalWerewolfBottomNav = staticCompositionLocalOf { WerewolfBottomNavSelection(null, {}, true, { label, _ -> label }, mutableStateMapOf(), mutableSetOf()) }
|
|
84
|
+
|
|
85
|
+
@Composable
|
|
86
|
+
fun WerewolfBottomNav(
|
|
87
|
+
selectedValue: String?,
|
|
88
|
+
onSelect: (String) -> Unit,
|
|
89
|
+
modifier: Modifier = Modifier,
|
|
90
|
+
label: String = "Main",
|
|
91
|
+
showLabels: Boolean = true,
|
|
92
|
+
countLabel: (String, Int) -> String = { itemLabel, count -> "$itemLabel, $count new" },
|
|
93
|
+
children: @Composable RowScope.() -> Unit,
|
|
94
|
+
) {
|
|
95
|
+
val t = LocalWerewolf.current
|
|
96
|
+
val reduced = rememberReduceMotion()
|
|
97
|
+
val bounds = remember { mutableStateMapOf<String, IntRect>() }
|
|
98
|
+
val destinations = remember { mutableSetOf<String>() }
|
|
99
|
+
// werewolf:property=list.background-color
|
|
100
|
+
val listBackgroundColor = t.colorBackgroundMaterialThin
|
|
101
|
+
// werewolf:property=list.border-radius
|
|
102
|
+
val listBorderRadius = t.radiusFull
|
|
103
|
+
// werewolf:property=list.box-shadow
|
|
104
|
+
val listBoxShadow = t.shadowMed
|
|
105
|
+
// werewolf:property=list.gap
|
|
106
|
+
val listGap = t.spacingXs
|
|
107
|
+
// werewolf:property=list.margin-bottom
|
|
108
|
+
val listMarginBottom = t.spacingSm
|
|
109
|
+
// werewolf:property=list.padding
|
|
110
|
+
val listPadding = t.spacingXs
|
|
111
|
+
// werewolf:property=indicator.background-color
|
|
112
|
+
val indicatorBackgroundColor = t.colorAccentMuted
|
|
113
|
+
// werewolf:property=indicator.border-radius
|
|
114
|
+
val indicatorBorderRadius = t.radiusFull
|
|
115
|
+
// werewolf:property=indicator.transition-duration
|
|
116
|
+
val indicatorTransitionDuration = t.durationMediumMs
|
|
117
|
+
// werewolf:property=indicator.transition-timing-function
|
|
118
|
+
val indicatorTransitionTimingFunction = t.easeStandard
|
|
119
|
+
val listShape = CircleShape
|
|
120
|
+
val indicatorShape = CircleShape
|
|
121
|
+
val indicatorBounds = selectedValue?.let { bounds[it] }
|
|
122
|
+
val indicatorX by animateFloatAsState(
|
|
123
|
+
targetValue = (indicatorBounds?.left ?: 0).toFloat(),
|
|
124
|
+
animationSpec = if (reduced) snap() else tween(durationMillis = indicatorTransitionDuration, easing = indicatorTransitionTimingFunction.toCubicBezierEasing()),
|
|
125
|
+
label = "indicatorX",
|
|
126
|
+
)
|
|
127
|
+
val indicatorWidth by animateFloatAsState(
|
|
128
|
+
targetValue = (indicatorBounds?.width ?: 0).toFloat(),
|
|
129
|
+
animationSpec = if (reduced) snap() else tween(durationMillis = indicatorTransitionDuration, easing = indicatorTransitionTimingFunction.toCubicBezierEasing()),
|
|
130
|
+
label = "indicatorWidth",
|
|
131
|
+
)
|
|
132
|
+
CompositionLocalProvider(LocalWerewolfBottomNav provides WerewolfBottomNavSelection(selectedValue, onSelect, showLabels, countLabel, bounds, destinations)) {
|
|
133
|
+
Box(
|
|
134
|
+
modifier = modifier.fillMaxWidth().werewolfBarInsets(),
|
|
135
|
+
contentAlignment = Alignment.BottomCenter,
|
|
136
|
+
) {
|
|
137
|
+
Row(
|
|
138
|
+
modifier = Modifier
|
|
139
|
+
.padding(bottom = listMarginBottom)
|
|
140
|
+
.werewolfReportBottomInset(listMarginBottom)
|
|
141
|
+
.werewolfBarWidth()
|
|
142
|
+
.werewolfShadow(listBoxShadow)
|
|
143
|
+
.werewolfGlass(listShape, listBackgroundColor)
|
|
144
|
+
.selectableGroup()
|
|
145
|
+
.semantics { contentDescription = label }
|
|
146
|
+
.padding(listPadding)
|
|
147
|
+
.drawBehind {
|
|
148
|
+
if (indicatorBounds != null) {
|
|
149
|
+
val outline = indicatorShape.createOutline(Size(indicatorWidth, indicatorBounds.height.toFloat()), layoutDirection, this)
|
|
150
|
+
translate(left = indicatorX, top = indicatorBounds.top.toFloat()) {
|
|
151
|
+
drawOutline(outline, indicatorBackgroundColor)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
horizontalArrangement = Arrangement.spacedBy(listGap, Alignment.CenterHorizontally),
|
|
156
|
+
verticalAlignment = Alignment.CenterVertically,
|
|
157
|
+
) {
|
|
158
|
+
children()
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
SideEffect { werewolfRequireBarItems(destinations.size) }
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
@Composable
|
|
166
|
+
fun RowScope.WerewolfBottomNavItem(
|
|
167
|
+
destination: String,
|
|
168
|
+
icon: @Composable () -> Unit,
|
|
169
|
+
activeIcon: @Composable () -> Unit,
|
|
170
|
+
label: String,
|
|
171
|
+
modifier: Modifier = Modifier,
|
|
172
|
+
count: Int = 0,
|
|
173
|
+
) {
|
|
174
|
+
val t = LocalWerewolf.current
|
|
175
|
+
val navigation = LocalWerewolfBottomNav.current
|
|
176
|
+
val selected = navigation.value == destination
|
|
177
|
+
val interactionSource = remember { MutableInteractionSource() }
|
|
178
|
+
val pressed by interactionSource.collectIsPressedAsState()
|
|
179
|
+
val hovered by interactionSource.collectIsHoveredAsState()
|
|
180
|
+
val focusVisible by interactionSource.collectIsFocusedAsState()
|
|
181
|
+
// werewolf:property=item.border-radius
|
|
182
|
+
val itemBorderRadius = t.radiusFull
|
|
183
|
+
// werewolf:property=item.gap
|
|
184
|
+
val itemGap = t.spacing2xs
|
|
185
|
+
// werewolf:property=item.min-height
|
|
186
|
+
val itemMinHeight = t.sizeElementXl
|
|
187
|
+
// werewolf:property=item.outline-color
|
|
188
|
+
val itemOutlineColor: Color? = run {
|
|
189
|
+
// werewolf:state=focus-visible
|
|
190
|
+
if (focusVisible) {
|
|
191
|
+
return@run t.colorFocusRing
|
|
192
|
+
}
|
|
193
|
+
// werewolf:state=default
|
|
194
|
+
null
|
|
195
|
+
}
|
|
196
|
+
// werewolf:property=item.outline-offset
|
|
197
|
+
val itemOutlineOffset: Dp? = run {
|
|
198
|
+
// werewolf:state=focus-visible
|
|
199
|
+
if (focusVisible) {
|
|
200
|
+
return@run t.outlineOffsetFocusRing
|
|
201
|
+
}
|
|
202
|
+
// werewolf:state=default
|
|
203
|
+
null
|
|
204
|
+
}
|
|
205
|
+
// werewolf:property=item.outline-width
|
|
206
|
+
val itemOutlineWidth: Dp? = run {
|
|
207
|
+
// werewolf:state=focus-visible
|
|
208
|
+
if (focusVisible) {
|
|
209
|
+
return@run t.outlineWidthFocusRing
|
|
210
|
+
}
|
|
211
|
+
// werewolf:state=default
|
|
212
|
+
null
|
|
213
|
+
}
|
|
214
|
+
// werewolf:property=item.overlay
|
|
215
|
+
val itemOverlay: Color? = run {
|
|
216
|
+
// werewolf:state=pressed
|
|
217
|
+
if (pressed) {
|
|
218
|
+
return@run t.colorOverlayPressed
|
|
219
|
+
}
|
|
220
|
+
// werewolf:state=hover
|
|
221
|
+
if (hovered) {
|
|
222
|
+
return@run t.colorOverlayHover
|
|
223
|
+
}
|
|
224
|
+
// werewolf:state=default
|
|
225
|
+
null
|
|
226
|
+
}
|
|
227
|
+
// werewolf:property=item.padding-block
|
|
228
|
+
val itemPaddingBlock = t.spacingXs
|
|
229
|
+
// werewolf:property=item.padding-inline
|
|
230
|
+
val itemPaddingInline = t.spacingXs
|
|
231
|
+
// werewolf:property=item.scale
|
|
232
|
+
val itemScale: Float? = run {
|
|
233
|
+
// werewolf:state=pressed
|
|
234
|
+
if (pressed) {
|
|
235
|
+
return@run t.scalePressed
|
|
236
|
+
}
|
|
237
|
+
// werewolf:state=default
|
|
238
|
+
null
|
|
239
|
+
}
|
|
240
|
+
// werewolf:property=item.transition-duration
|
|
241
|
+
val itemTransitionDuration = t.durationFastMs
|
|
242
|
+
// werewolf:property=item.transition-timing-function
|
|
243
|
+
val itemTransitionTimingFunction = t.easeStandard
|
|
244
|
+
// werewolf:property=icon.color
|
|
245
|
+
val iconColor: Color = run {
|
|
246
|
+
// werewolf:state=selected
|
|
247
|
+
if (selected) {
|
|
248
|
+
return@run t.colorIconAccent
|
|
249
|
+
}
|
|
250
|
+
// werewolf:state=default
|
|
251
|
+
t.colorIconSecondary
|
|
252
|
+
}
|
|
253
|
+
// werewolf:property=badge.background-color
|
|
254
|
+
val badgeBackgroundColor = t.colorDanger
|
|
255
|
+
// werewolf:property=badge.border-radius
|
|
256
|
+
val badgeBorderRadius = t.radiusFull
|
|
257
|
+
// werewolf:property=badge.color
|
|
258
|
+
val badgeColor = t.colorTextOnDanger
|
|
259
|
+
// werewolf:property=badge.padding-inline
|
|
260
|
+
val badgePaddingInline = t.spacingXs
|
|
261
|
+
// werewolf:property=label.color
|
|
262
|
+
val labelColor: Color = run {
|
|
263
|
+
// werewolf:state=selected
|
|
264
|
+
if (selected) {
|
|
265
|
+
return@run t.colorTextOnMuted
|
|
266
|
+
}
|
|
267
|
+
// werewolf:state=default
|
|
268
|
+
t.colorTextSecondary
|
|
269
|
+
}
|
|
270
|
+
// werewolf:property=label.font-family
|
|
271
|
+
val labelFontFamily = t.fontFamilySans
|
|
272
|
+
// werewolf:property=label.font-size
|
|
273
|
+
val labelFontSize = t.fontSizeXs
|
|
274
|
+
// werewolf:property=label.font-weight
|
|
275
|
+
val labelFontWeight = t.fontWeightMedium
|
|
276
|
+
val itemShape = CircleShape
|
|
277
|
+
val badgeShape = CircleShape
|
|
278
|
+
val accessibleName = if (count > 0) navigation.countLabel(label, count) else label
|
|
279
|
+
DisposableEffect(destination) {
|
|
280
|
+
navigation.destinations.add(destination)
|
|
281
|
+
onDispose { navigation.destinations.remove(destination) }
|
|
282
|
+
}
|
|
283
|
+
Column(
|
|
284
|
+
modifier = modifier
|
|
285
|
+
.weight(1f)
|
|
286
|
+
.onGloballyPositioned { coordinates -> navigation.bounds[destination] = IntRect(coordinates.positionInParent().round(), coordinates.size) }
|
|
287
|
+
.werewolfHitArea()
|
|
288
|
+
.heightIn(min = itemMinHeight)
|
|
289
|
+
.selectable(
|
|
290
|
+
selected = selected,
|
|
291
|
+
interactionSource = interactionSource,
|
|
292
|
+
indication = null,
|
|
293
|
+
role = Role.Tab,
|
|
294
|
+
onClick = { navigation.onSelect(destination) },
|
|
295
|
+
)
|
|
296
|
+
.hoverable(interactionSource = interactionSource)
|
|
297
|
+
.focusable(interactionSource = interactionSource)
|
|
298
|
+
.semantics { contentDescription = accessibleName }
|
|
299
|
+
.werewolfPressScale(itemScale != null)
|
|
300
|
+
.werewolfOverlay(itemOverlay ?: Color.Transparent, itemShape, itemOverlay != null)
|
|
301
|
+
.werewolfFocusRing(itemOutlineColor != null, itemShape)
|
|
302
|
+
.padding(horizontal = itemPaddingInline, vertical = itemPaddingBlock),
|
|
303
|
+
verticalArrangement = Arrangement.spacedBy(itemGap, Alignment.CenterVertically),
|
|
304
|
+
horizontalAlignment = Alignment.CenterHorizontally,
|
|
305
|
+
) {
|
|
306
|
+
Box(contentAlignment = Alignment.TopEnd) {
|
|
307
|
+
CompositionLocalProvider(LocalWerewolfContentColor provides iconColor) {
|
|
308
|
+
Box(modifier = Modifier.werewolfIconFrame().clearAndSetSemantics {}) {
|
|
309
|
+
if (selected) activeIcon() else icon()
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (count > 0) {
|
|
313
|
+
BasicText(
|
|
314
|
+
text = count.toString(),
|
|
315
|
+
modifier = Modifier
|
|
316
|
+
.offset(x = t.spacingXs, y = -t.spacingXs)
|
|
317
|
+
.background(badgeBackgroundColor, badgeShape)
|
|
318
|
+
.padding(horizontal = badgePaddingInline)
|
|
319
|
+
.clearAndSetSemantics {},
|
|
320
|
+
style = TextStyle(color = badgeColor, fontFamily = LocalWerewolfFonts.current.resolve(when (labelFontFamily) { t.fontFamilySans -> WerewolfFontRole.Sans; else -> WerewolfFontRole.Mono }), fontSize = labelFontSize, fontWeight = werewolfFontWeight(labelFontWeight)),
|
|
321
|
+
)
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if (navigation.showLabels) {
|
|
325
|
+
BasicText(
|
|
326
|
+
text = label,
|
|
327
|
+
modifier = Modifier.clearAndSetSemantics {},
|
|
328
|
+
maxLines = 1,
|
|
329
|
+
style = TextStyle(color = labelColor, fontFamily = LocalWerewolfFonts.current.resolve(when (labelFontFamily) { t.fontFamilySans -> WerewolfFontRole.Sans; else -> WerewolfFontRole.Mono }), fontSize = labelFontSize, fontWeight = werewolfFontWeight(labelFontWeight)),
|
|
330
|
+
)
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated file, must not be edited by hand. Source: components/button.spec.json (werewolf-ui 0.1.0-beta.
|
|
1
|
+
// Generated file, must not be edited by hand. Source: components/button.spec.json (werewolf-ui 0.1.0-beta.3).
|
|
2
2
|
package dev.werewolfui
|
|
3
3
|
|
|
4
4
|
import androidx.compose.animation.animateColorAsState
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Generated file, must not be edited by hand. Source: components/button-group.spec.json (werewolf-ui 0.1.0-beta.3).
|
|
2
|
+
package dev.werewolfui
|
|
3
|
+
|
|
4
|
+
import androidx.compose.foundation.layout.Arrangement
|
|
5
|
+
import androidx.compose.foundation.layout.Column
|
|
6
|
+
import androidx.compose.foundation.layout.Row
|
|
7
|
+
import androidx.compose.foundation.layout.fillMaxWidth
|
|
8
|
+
import androidx.compose.runtime.Composable
|
|
9
|
+
import androidx.compose.ui.Alignment
|
|
10
|
+
import androidx.compose.ui.Modifier
|
|
11
|
+
import androidx.compose.ui.unit.Dp
|
|
12
|
+
import dev.werewolfui.runtime.LocalWerewolf
|
|
13
|
+
|
|
14
|
+
enum class WerewolfButtonGroupOrientation {
|
|
15
|
+
Horizontal,
|
|
16
|
+
Vertical,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Composable
|
|
20
|
+
fun WerewolfButtonGroup(
|
|
21
|
+
modifier: Modifier = Modifier,
|
|
22
|
+
fullWidth: Boolean = false,
|
|
23
|
+
orientation: WerewolfButtonGroupOrientation = WerewolfButtonGroupOrientation.Horizontal,
|
|
24
|
+
children: @Composable () -> Unit,
|
|
25
|
+
) {
|
|
26
|
+
val t = LocalWerewolf.current
|
|
27
|
+
// werewolf:property=row.gap
|
|
28
|
+
val rowGap = t.spacingSm
|
|
29
|
+
// werewolf:property=column.gap
|
|
30
|
+
val columnGap = t.spacingSm
|
|
31
|
+
Column(
|
|
32
|
+
modifier = modifier
|
|
33
|
+
.then(if (fullWidth) Modifier.fillMaxWidth() else Modifier),
|
|
34
|
+
verticalArrangement = Arrangement.Top,
|
|
35
|
+
horizontalAlignment = Alignment.CenterHorizontally,
|
|
36
|
+
) {
|
|
37
|
+
if (orientation == WerewolfButtonGroupOrientation.Horizontal) {
|
|
38
|
+
Row(
|
|
39
|
+
horizontalArrangement = Arrangement.spacedBy(rowGap, Alignment.CenterHorizontally),
|
|
40
|
+
verticalAlignment = Alignment.CenterVertically,
|
|
41
|
+
) {
|
|
42
|
+
children()
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (orientation == WerewolfButtonGroupOrientation.Vertical) {
|
|
46
|
+
Column(
|
|
47
|
+
verticalArrangement = Arrangement.spacedBy(columnGap, Alignment.CenterVertically),
|
|
48
|
+
horizontalAlignment = Alignment.CenterHorizontally,
|
|
49
|
+
) {
|
|
50
|
+
children()
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated file, must not be edited by hand. Source: components/card.spec.json (werewolf-ui 0.1.0-beta.
|
|
1
|
+
// Generated file, must not be edited by hand. Source: components/card.spec.json (werewolf-ui 0.1.0-beta.3).
|
|
2
2
|
package dev.werewolfui
|
|
3
3
|
|
|
4
4
|
import androidx.compose.foundation.background
|