werewolf-ui 0.1.0-beta.2 → 0.1.0-beta.4
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 +15 -5
- package/data/manifest.json +16077 -6044
- package/data/native/android/WerewolfAccordion.kt +256 -0
- package/data/native/android/WerewolfAlert.kt +4 -4
- package/data/native/android/WerewolfAlertDialog.kt +156 -0
- package/data/native/android/WerewolfAttachmentPreview.kt +273 -0
- package/data/native/android/WerewolfAvatar.kt +393 -0
- package/data/native/android/WerewolfAvatarStack.kt +178 -0
- package/data/native/android/WerewolfBackdropBlur.kt +89 -0
- package/data/native/android/WerewolfBadge.kt +71 -3
- package/data/native/android/WerewolfBottomNav.kt +354 -0
- package/data/native/android/WerewolfBreadcrumb.kt +22 -0
- package/data/native/android/WerewolfBreadcrumbRuntime.kt +177 -0
- package/data/native/android/WerewolfButton.kt +12 -3
- package/data/native/android/WerewolfButtonGroup.kt +54 -0
- package/data/native/android/WerewolfCalendar.kt +85 -0
- package/data/native/android/WerewolfCalendarGrid.kt +412 -0
- package/data/native/android/WerewolfCalendarMath.kt +252 -0
- package/data/native/android/WerewolfCard.kt +3 -3
- package/data/native/android/WerewolfCarousel.kt +177 -0
- package/data/native/android/WerewolfChart.kt +200 -0
- package/data/native/android/WerewolfChartAccessibility.kt +69 -0
- package/data/native/android/WerewolfChartFormat.kt +18 -0
- package/data/native/android/WerewolfChartGeometry.kt +397 -0
- package/data/native/android/WerewolfChartInteraction.kt +106 -0
- package/data/native/android/WerewolfChartModel.kt +238 -0
- package/data/native/android/WerewolfChartPalette.kt +34 -0
- package/data/native/android/WerewolfChatRuntime.kt +242 -0
- package/data/native/android/WerewolfCheckbox.kt +387 -0
- package/data/native/android/WerewolfChecklist.kt +249 -0
- package/data/native/android/WerewolfCodeBlock.kt +353 -0
- package/data/native/android/WerewolfColorPicker.kt +84 -0
- package/data/native/android/WerewolfColorPickerRuntime.kt +592 -0
- package/data/native/android/WerewolfCombobox.kt +371 -0
- package/data/native/android/WerewolfComposer.kt +300 -0
- package/data/native/android/WerewolfContextMenu.kt +26 -0
- package/data/native/android/WerewolfContextMenuRuntime.kt +116 -0
- package/data/native/android/WerewolfConversationList.kt +182 -0
- package/data/native/android/WerewolfCounter.kt +640 -0
- package/data/native/android/WerewolfDataTrend.kt +245 -0
- package/data/native/android/WerewolfDatePicker.kt +334 -0
- package/data/native/android/WerewolfDialog.kt +131 -0
- package/data/native/android/WerewolfDropdownMenu.kt +30 -0
- package/data/native/android/WerewolfEmojiData.kt +594 -0
- package/data/native/android/WerewolfEmojiPicker.kt +67 -0
- package/data/native/android/WerewolfEmojiPickerRuntime.kt +627 -0
- package/data/native/android/WerewolfEmptyState.kt +1 -1
- package/data/native/android/WerewolfField.kt +66 -0
- package/data/native/android/WerewolfGroupAvatar.kt +126 -0
- package/data/native/android/WerewolfIcons.kt +448 -1
- package/data/native/android/WerewolfImage.kt +82 -0
- package/data/native/android/WerewolfInput.kt +3 -3
- package/data/native/android/WerewolfKbd.kt +3 -3
- package/data/native/android/WerewolfLabel.kt +2 -2
- package/data/native/android/WerewolfLayers.kt +1173 -0
- package/data/native/android/WerewolfLink.kt +163 -0
- package/data/native/android/WerewolfList.kt +504 -0
- package/data/native/android/WerewolfListRuntime.kt +383 -0
- package/data/native/android/WerewolfMessageActions.kt +86 -0
- package/data/native/android/WerewolfMessageActionsRuntime.kt +568 -0
- package/data/native/android/WerewolfMessageBubble.kt +402 -0
- package/data/native/android/WerewolfMessageList.kt +133 -0
- package/data/native/android/WerewolfMetadata.kt +180 -0
- package/data/native/android/WerewolfMeter.kt +189 -0
- package/data/native/android/WerewolfModifiers.kt +309 -4
- package/data/native/android/WerewolfNumberInput.kt +665 -0
- package/data/native/android/WerewolfOtpInput.kt +246 -0
- package/data/native/android/WerewolfPageRuntime.kt +83 -0
- package/data/native/android/WerewolfPagination.kt +29 -0
- package/data/native/android/WerewolfPaginationRuntime.kt +245 -0
- package/data/native/android/WerewolfPlot.kt +1129 -0
- package/data/native/android/WerewolfPopover.kt +92 -0
- package/data/native/android/WerewolfProgress.kt +281 -0
- package/data/native/android/WerewolfRadioGroup.kt +382 -0
- package/data/native/android/WerewolfRangeMath.kt +80 -0
- package/data/native/android/WerewolfRating.kt +44 -0
- package/data/native/android/WerewolfRatingRuntime.kt +113 -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 +4 -4
- package/data/native/android/WerewolfSlider.kt +214 -0
- package/data/native/android/WerewolfSliderRuntime.kt +307 -0
- package/data/native/android/WerewolfSortableList.kt +34 -0
- package/data/native/android/WerewolfSortableListRuntime.kt +232 -0
- package/data/native/android/WerewolfSpinner.kt +1 -1
- package/data/native/android/WerewolfStepper.kt +690 -0
- package/data/native/android/WerewolfSwitch.kt +9 -57
- package/data/native/android/WerewolfTable.kt +134 -0
- package/data/native/android/WerewolfTableRuntime.kt +55 -0
- package/data/native/android/WerewolfTabs.kt +591 -0
- package/data/native/android/WerewolfTextarea.kt +329 -0
- package/data/native/android/WerewolfTheme.kt +17 -3
- package/data/native/android/WerewolfTimeColumns.kt +333 -0
- package/data/native/android/WerewolfTimePicker.kt +319 -0
- package/data/native/android/WerewolfTimeline.kt +382 -0
- package/data/native/android/WerewolfToast.kt +226 -0
- package/data/native/android/WerewolfToaster.kt +281 -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/android/WerewolfTokenizer.kt +54 -0
- package/data/native/android/WerewolfTokenizerRuntime.kt +221 -0
- package/data/native/android/WerewolfTooltip.kt +78 -0
- package/data/native/ios/WerewolfAccordion.swift +340 -0
- package/data/native/ios/WerewolfAlert.swift +3 -3
- package/data/native/ios/WerewolfAlertDialog.swift +187 -0
- package/data/native/ios/WerewolfAttachmentPreview.swift +323 -0
- package/data/native/ios/WerewolfAvatar.swift +552 -0
- package/data/native/ios/WerewolfAvatarStack.swift +214 -0
- package/data/native/ios/WerewolfBadge.swift +74 -22
- package/data/native/ios/WerewolfBottomNav.swift +463 -0
- package/data/native/ios/WerewolfBreadcrumb.swift +22 -0
- package/data/native/ios/WerewolfBreadcrumbRuntime.swift +96 -0
- package/data/native/ios/WerewolfButton.swift +22 -5
- package/data/native/ios/WerewolfButtonGroup.swift +62 -0
- package/data/native/ios/WerewolfCalendar.swift +98 -0
- package/data/native/ios/WerewolfCalendarGrid.swift +453 -0
- package/data/native/ios/WerewolfCalendarMath.swift +321 -0
- package/data/native/ios/WerewolfCard.swift +2 -2
- package/data/native/ios/WerewolfCarousel.swift +168 -0
- package/data/native/ios/WerewolfChart.swift +206 -0
- package/data/native/ios/WerewolfChartAccessibility.swift +59 -0
- package/data/native/ios/WerewolfChartFormat.swift +14 -0
- package/data/native/ios/WerewolfChartGeometry.swift +479 -0
- package/data/native/ios/WerewolfChartInteraction.swift +113 -0
- package/data/native/ios/WerewolfChartModel.swift +337 -0
- package/data/native/ios/WerewolfChartPalette.swift +37 -0
- package/data/native/ios/WerewolfChatRuntime.swift +216 -0
- package/data/native/ios/WerewolfCheckbox.swift +623 -0
- package/data/native/ios/WerewolfChecklist.swift +276 -0
- package/data/native/ios/WerewolfCodeBlock.swift +405 -0
- package/data/native/ios/WerewolfColorPicker.swift +136 -0
- package/data/native/ios/WerewolfColorPickerRuntime.swift +469 -0
- package/data/native/ios/WerewolfCombobox.swift +469 -0
- package/data/native/ios/WerewolfComposer.swift +269 -0
- package/data/native/ios/WerewolfContextMenu.swift +21 -0
- package/data/native/ios/WerewolfConversationList.swift +141 -0
- package/data/native/ios/WerewolfCounter.swift +770 -0
- package/data/native/ios/WerewolfDataTrend.swift +292 -0
- package/data/native/ios/WerewolfDatePicker.swift +388 -0
- package/data/native/ios/WerewolfDialog.swift +172 -0
- package/data/native/ios/WerewolfDropdownMenu.swift +35 -0
- package/data/native/ios/WerewolfEmojiData.swift +600 -0
- package/data/native/ios/WerewolfEmojiPicker.swift +74 -0
- package/data/native/ios/WerewolfEmojiPickerRuntime.swift +361 -0
- package/data/native/ios/WerewolfEmptyState.swift +1 -1
- package/data/native/ios/WerewolfField.swift +103 -0
- package/data/native/ios/WerewolfGroupAvatar.swift +165 -0
- package/data/native/ios/WerewolfIcons.swift +85 -1
- package/data/native/ios/WerewolfImage.swift +118 -0
- package/data/native/ios/WerewolfInput.swift +5 -3
- package/data/native/ios/WerewolfKbd.swift +2 -2
- package/data/native/ios/WerewolfLabel.swift +2 -2
- package/data/native/ios/WerewolfLayers.swift +929 -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/WerewolfMessageActions.swift +99 -0
- package/data/native/ios/WerewolfMessageActionsRuntime.swift +218 -0
- package/data/native/ios/WerewolfMessageBubble.swift +474 -0
- package/data/native/ios/WerewolfMessageList.swift +123 -0
- package/data/native/ios/WerewolfMetadata.swift +205 -0
- package/data/native/ios/WerewolfMeter.swift +186 -0
- package/data/native/ios/WerewolfModifiers.swift +205 -1
- package/data/native/ios/WerewolfNumberInput.swift +808 -0
- package/data/native/ios/WerewolfOtpInput.swift +326 -0
- package/data/native/ios/WerewolfPageRuntime.swift +98 -0
- package/data/native/ios/WerewolfPagination.swift +34 -0
- package/data/native/ios/WerewolfPaginationRuntime.swift +165 -0
- package/data/native/ios/WerewolfPlot.swift +1249 -0
- package/data/native/ios/WerewolfPopover.swift +132 -0
- package/data/native/ios/WerewolfProgress.swift +338 -0
- package/data/native/ios/WerewolfRadioGroup.swift +485 -0
- package/data/native/ios/WerewolfRangeMath.swift +87 -0
- package/data/native/ios/WerewolfRating.swift +52 -0
- package/data/native/ios/WerewolfRatingRuntime.swift +100 -0
- package/data/native/ios/WerewolfSelect.swift +420 -0
- package/data/native/ios/WerewolfSeparator.swift +1 -1
- package/data/native/ios/WerewolfSheet.swift +208 -0
- package/data/native/ios/WerewolfSkeleton.swift +3 -3
- package/data/native/ios/WerewolfSlider.swift +330 -0
- package/data/native/ios/WerewolfSliderRuntime.swift +260 -0
- package/data/native/ios/WerewolfSortableList.swift +40 -0
- package/data/native/ios/WerewolfSortableListRuntime.swift +192 -0
- package/data/native/ios/WerewolfSpinner.swift +1 -1
- package/data/native/ios/WerewolfStepper.swift +802 -0
- package/data/native/ios/WerewolfSwitch.swift +21 -78
- package/data/native/ios/WerewolfTable.swift +185 -0
- package/data/native/ios/WerewolfTableRuntime.swift +47 -0
- package/data/native/ios/WerewolfTabs.swift +758 -0
- package/data/native/ios/WerewolfTextarea.swift +405 -0
- package/data/native/ios/WerewolfTheme.swift +17 -2
- package/data/native/ios/WerewolfTimeColumns.swift +134 -0
- package/data/native/ios/WerewolfTimePicker.swift +365 -0
- package/data/native/ios/WerewolfTimeline.swift +526 -0
- package/data/native/ios/WerewolfToast.swift +280 -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/data/native/ios/WerewolfTokenizer.swift +77 -0
- package/data/native/ios/WerewolfTokenizerRuntime.swift +214 -0
- package/data/native/ios/WerewolfTooltip.swift +106 -0
- package/dist/cli.mjs +8573 -672
- package/dist/core.mjs +8279 -566
- package/dist/lint.mjs +205 -21
- package/dist/paths.mjs +2 -1
- package/dist/project.mjs +56 -10
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated file, must not be edited by hand. Source: components/switch.spec.json (werewolf-ui 0.1.0-beta.
|
|
1
|
+
// Generated file, must not be edited by hand. Source: components/switch.spec.json (werewolf-ui 0.1.0-beta.4).
|
|
2
2
|
package dev.werewolfui
|
|
3
3
|
|
|
4
4
|
import androidx.compose.animation.animateColorAsState
|
|
@@ -55,7 +55,6 @@ import dev.werewolfui.tokens.WerewolfEasing
|
|
|
55
55
|
import dev.werewolfui.tokens.WerewolfShadowLayer
|
|
56
56
|
|
|
57
57
|
enum class WerewolfSwitchSize {
|
|
58
|
-
Sm,
|
|
59
58
|
Md,
|
|
60
59
|
Lg,
|
|
61
60
|
Xl,
|
|
@@ -69,7 +68,7 @@ fun WerewolfSwitch(
|
|
|
69
68
|
enabled: Boolean = true,
|
|
70
69
|
invalid: Boolean = false,
|
|
71
70
|
required: Boolean = false,
|
|
72
|
-
size: WerewolfSwitchSize = WerewolfSwitchSize.
|
|
71
|
+
size: WerewolfSwitchSize = WerewolfSwitchSize.Lg,
|
|
73
72
|
description: (@Composable () -> Unit)? = null,
|
|
74
73
|
label: (@Composable () -> Unit)? = null,
|
|
75
74
|
requiredText: (@Composable () -> Unit)? = null,
|
|
@@ -90,11 +89,11 @@ fun WerewolfSwitch(
|
|
|
90
89
|
}
|
|
91
90
|
// werewolf:state=checked+pressed
|
|
92
91
|
if (checked && pressed) {
|
|
93
|
-
return@run t.
|
|
92
|
+
return@run t.colorBackgroundGray
|
|
94
93
|
}
|
|
95
94
|
// werewolf:state=checked+hover
|
|
96
95
|
if (checked && hovered) {
|
|
97
|
-
return@run t.
|
|
96
|
+
return@run t.colorBackgroundGray
|
|
98
97
|
}
|
|
99
98
|
// werewolf:state=disabled
|
|
100
99
|
if (!enabled) {
|
|
@@ -105,7 +104,7 @@ fun WerewolfSwitch(
|
|
|
105
104
|
return@run t.colorAccent
|
|
106
105
|
}
|
|
107
106
|
// werewolf:state=default
|
|
108
|
-
t.
|
|
107
|
+
t.colorBackgroundGray
|
|
109
108
|
}
|
|
110
109
|
// werewolf:property=root.border-color
|
|
111
110
|
val rootBorderColor: Color? = run {
|
|
@@ -135,8 +134,6 @@ fun WerewolfSwitch(
|
|
|
135
134
|
}
|
|
136
135
|
// werewolf:property=root.height
|
|
137
136
|
val rootHeight: Dp = when (size) {
|
|
138
|
-
// werewolf:size=sm
|
|
139
|
-
WerewolfSwitchSize.Sm -> t.sizeElementSm / 2 + 2 * t.borderWidth
|
|
140
137
|
// werewolf:size=md
|
|
141
138
|
WerewolfSwitchSize.Md -> t.sizeElementMd / 2 + 2 * t.borderWidth
|
|
142
139
|
// werewolf:size=lg
|
|
@@ -211,8 +208,6 @@ fun WerewolfSwitch(
|
|
|
211
208
|
val rootTransitionTimingFunction = t.easeStandard
|
|
212
209
|
// werewolf:property=root.width
|
|
213
210
|
val rootWidth: Dp = when (size) {
|
|
214
|
-
// werewolf:size=sm
|
|
215
|
-
WerewolfSwitchSize.Sm -> t.sizeElementSm
|
|
216
211
|
// werewolf:size=md
|
|
217
212
|
WerewolfSwitchSize.Md -> t.sizeElementMd
|
|
218
213
|
// werewolf:size=lg
|
|
@@ -226,8 +221,6 @@ fun WerewolfSwitch(
|
|
|
226
221
|
val thumbBoxShadow = t.shadowLow
|
|
227
222
|
// werewolf:property=thumb.height
|
|
228
223
|
val thumbHeight: Dp = when (size) {
|
|
229
|
-
// werewolf:size=sm
|
|
230
|
-
WerewolfSwitchSize.Sm -> t.sizeElementSm / 2 - t.spacingXs
|
|
231
224
|
// werewolf:size=md
|
|
232
225
|
WerewolfSwitchSize.Md -> t.sizeElementMd / 2 - t.spacingXs
|
|
233
226
|
// werewolf:size=lg
|
|
@@ -237,27 +230,6 @@ fun WerewolfSwitch(
|
|
|
237
230
|
}
|
|
238
231
|
// werewolf:property=thumb.offset-inline-start
|
|
239
232
|
val thumbOffsetInlineStart: Dp = when (size) {
|
|
240
|
-
// werewolf:size=sm
|
|
241
|
-
WerewolfSwitchSize.Sm -> run {
|
|
242
|
-
// werewolf:state=checked+disabled
|
|
243
|
-
if (checked && !enabled) {
|
|
244
|
-
return@run t.spacingXs / 2
|
|
245
|
-
}
|
|
246
|
-
// werewolf:state=checked+pressed
|
|
247
|
-
if (checked && pressed) {
|
|
248
|
-
return@run t.spacingXs / 2
|
|
249
|
-
}
|
|
250
|
-
// werewolf:state=checked+hover
|
|
251
|
-
if (checked && hovered) {
|
|
252
|
-
return@run t.spacingXs / 2
|
|
253
|
-
}
|
|
254
|
-
// werewolf:state=checked
|
|
255
|
-
if (checked) {
|
|
256
|
-
return@run t.sizeElementSm / 2 - 2 * t.borderWidth + t.spacingXs / 2
|
|
257
|
-
}
|
|
258
|
-
// werewolf:state=default
|
|
259
|
-
t.spacingXs / 2
|
|
260
|
-
}
|
|
261
233
|
// werewolf:size=md
|
|
262
234
|
WerewolfSwitchSize.Md -> run {
|
|
263
235
|
// werewolf:state=checked+disabled
|
|
@@ -324,8 +296,6 @@ fun WerewolfSwitch(
|
|
|
324
296
|
}
|
|
325
297
|
// werewolf:property=thumb.width
|
|
326
298
|
val thumbWidth: Dp = when (size) {
|
|
327
|
-
// werewolf:size=sm
|
|
328
|
-
WerewolfSwitchSize.Sm -> t.sizeElementSm / 2 - t.spacingXs
|
|
329
299
|
// werewolf:size=md
|
|
330
300
|
WerewolfSwitchSize.Md -> t.sizeElementMd / 2 - t.spacingXs
|
|
331
301
|
// werewolf:size=lg
|
|
@@ -334,31 +304,13 @@ fun WerewolfSwitch(
|
|
|
334
304
|
WerewolfSwitchSize.Xl -> t.sizeElementXl / 2 - t.spacingXs
|
|
335
305
|
}
|
|
336
306
|
// werewolf:property=label.font-size
|
|
337
|
-
val labelFontSize
|
|
338
|
-
// werewolf:size=sm
|
|
339
|
-
WerewolfSwitchSize.Sm -> t.fontSizeXs
|
|
340
|
-
// werewolf:size=md
|
|
341
|
-
WerewolfSwitchSize.Md -> t.fontSizeSm
|
|
342
|
-
// werewolf:size=lg
|
|
343
|
-
WerewolfSwitchSize.Lg -> t.fontSizeSm
|
|
344
|
-
// werewolf:size=xl
|
|
345
|
-
WerewolfSwitchSize.Xl -> t.fontSizeSm
|
|
346
|
-
}
|
|
307
|
+
val labelFontSize = t.fontSizeSm
|
|
347
308
|
// werewolf:property=description.color
|
|
348
309
|
val descriptionColor = t.colorTextSecondary
|
|
349
310
|
// werewolf:property=description.font-family
|
|
350
311
|
val descriptionFontFamily = t.fontFamilySans
|
|
351
312
|
// werewolf:property=description.font-size
|
|
352
|
-
val descriptionFontSize
|
|
353
|
-
// werewolf:size=sm
|
|
354
|
-
WerewolfSwitchSize.Sm -> t.fontSizeXs
|
|
355
|
-
// werewolf:size=md
|
|
356
|
-
WerewolfSwitchSize.Md -> t.fontSizeSm
|
|
357
|
-
// werewolf:size=lg
|
|
358
|
-
WerewolfSwitchSize.Lg -> t.fontSizeSm
|
|
359
|
-
// werewolf:size=xl
|
|
360
|
-
WerewolfSwitchSize.Xl -> t.fontSizeSm
|
|
361
|
-
}
|
|
313
|
+
val descriptionFontSize = t.fontSizeSm
|
|
362
314
|
val rootShape = CircleShape
|
|
363
315
|
val thumbShape = CircleShape
|
|
364
316
|
val animatedRootBackgroundColor by animateColorAsState(
|
|
@@ -438,7 +390,7 @@ fun WerewolfSwitch(
|
|
|
438
390
|
if (label != null) {
|
|
439
391
|
Column(
|
|
440
392
|
verticalArrangement = Arrangement.Top,
|
|
441
|
-
horizontalAlignment = Alignment.
|
|
393
|
+
horizontalAlignment = Alignment.Start,
|
|
442
394
|
) {
|
|
443
395
|
CompositionLocalProvider(
|
|
444
396
|
LocalWerewolfTextStyle provides TextStyle(fontSize = labelFontSize),
|
|
@@ -464,7 +416,7 @@ fun WerewolfSwitch(
|
|
|
464
416
|
enabled: Boolean = true,
|
|
465
417
|
invalid: Boolean = false,
|
|
466
418
|
required: Boolean = false,
|
|
467
|
-
size: WerewolfSwitchSize = WerewolfSwitchSize.
|
|
419
|
+
size: WerewolfSwitchSize = WerewolfSwitchSize.Lg,
|
|
468
420
|
description: (@Composable () -> Unit)? = null,
|
|
469
421
|
label: (@Composable () -> Unit)? = null,
|
|
470
422
|
requiredText: (@Composable () -> Unit)? = null,
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Generated file, must not be edited by hand. Source: components/table.spec.json (werewolf-ui 0.1.0-beta.4).
|
|
2
|
+
package dev.werewolfui
|
|
3
|
+
|
|
4
|
+
import androidx.compose.foundation.background
|
|
5
|
+
import androidx.compose.foundation.border
|
|
6
|
+
import androidx.compose.foundation.layout.Arrangement
|
|
7
|
+
import androidx.compose.foundation.layout.Box
|
|
8
|
+
import androidx.compose.foundation.layout.Column
|
|
9
|
+
import androidx.compose.foundation.layout.ColumnScope
|
|
10
|
+
import androidx.compose.foundation.layout.Row
|
|
11
|
+
import androidx.compose.foundation.layout.RowScope
|
|
12
|
+
import androidx.compose.foundation.layout.WindowInsets
|
|
13
|
+
import androidx.compose.foundation.layout.fillMaxSize
|
|
14
|
+
import androidx.compose.foundation.layout.fillMaxWidth
|
|
15
|
+
import androidx.compose.foundation.layout.navigationBars
|
|
16
|
+
import androidx.compose.foundation.layout.padding
|
|
17
|
+
import androidx.compose.foundation.layout.windowInsetsPadding
|
|
18
|
+
import androidx.compose.foundation.rememberScrollState
|
|
19
|
+
import androidx.compose.foundation.verticalScroll
|
|
20
|
+
import androidx.compose.runtime.Composable
|
|
21
|
+
import androidx.compose.runtime.CompositionLocalProvider
|
|
22
|
+
import androidx.compose.runtime.getValue
|
|
23
|
+
import androidx.compose.runtime.mutableStateOf
|
|
24
|
+
import androidx.compose.runtime.remember
|
|
25
|
+
import androidx.compose.runtime.setValue
|
|
26
|
+
import androidx.compose.ui.Alignment
|
|
27
|
+
import androidx.compose.ui.Modifier
|
|
28
|
+
import androidx.compose.ui.graphics.Color
|
|
29
|
+
import androidx.compose.ui.layout.onSizeChanged
|
|
30
|
+
import androidx.compose.ui.platform.LocalDensity
|
|
31
|
+
import androidx.compose.ui.semantics.contentDescription
|
|
32
|
+
import androidx.compose.ui.semantics.semantics
|
|
33
|
+
import androidx.compose.ui.unit.Dp
|
|
34
|
+
import androidx.compose.ui.unit.TextUnit
|
|
35
|
+
import androidx.compose.ui.unit.dp
|
|
36
|
+
import dev.werewolfui.runtime.LocalWerewolf
|
|
37
|
+
import dev.werewolfui.runtime.LocalWerewolfBottomInset
|
|
38
|
+
import dev.werewolfui.runtime.LocalWerewolfContentColor
|
|
39
|
+
import dev.werewolfui.runtime.WerewolfBarArrival
|
|
40
|
+
import dev.werewolfui.runtime.werewolfCornerShape
|
|
41
|
+
import dev.werewolfui.runtime.werewolfPending
|
|
42
|
+
|
|
43
|
+
@Composable
|
|
44
|
+
fun WerewolfTable(
|
|
45
|
+
label: String,
|
|
46
|
+
modifier: Modifier = Modifier,
|
|
47
|
+
pending: Boolean = false,
|
|
48
|
+
pendingLabel: String = "Loading",
|
|
49
|
+
isEmpty: Boolean = false,
|
|
50
|
+
selectionMode: Boolean = false,
|
|
51
|
+
selectionBar: (@Composable RowScope.() -> Unit)? = null,
|
|
52
|
+
empty: @Composable () -> Unit,
|
|
53
|
+
content: @Composable ColumnScope.() -> Unit,
|
|
54
|
+
) {
|
|
55
|
+
val t = LocalWerewolf.current
|
|
56
|
+
val bottomInset = LocalWerewolfBottomInset.current
|
|
57
|
+
val density = LocalDensity.current
|
|
58
|
+
// werewolf:property=root.color
|
|
59
|
+
val rootColor = t.colorTextPrimary
|
|
60
|
+
// werewolf:property=root.font-family
|
|
61
|
+
val rootFontFamily = t.fontFamilySans
|
|
62
|
+
// werewolf:property=root.font-size
|
|
63
|
+
val rootFontSize = t.fontSizeSm
|
|
64
|
+
// werewolf:property=empty.color
|
|
65
|
+
val emptyColor = t.colorTextSecondary
|
|
66
|
+
// werewolf:property=empty.font-size
|
|
67
|
+
val emptyFontSize = t.fontSizeSm
|
|
68
|
+
// werewolf:property=empty.padding-block
|
|
69
|
+
val emptyPaddingBlock = t.spacing2xl
|
|
70
|
+
// werewolf:property=empty.padding-inline
|
|
71
|
+
val emptyPaddingInline = t.spacingMd
|
|
72
|
+
// werewolf:property=selectionBar.background-color
|
|
73
|
+
val selectionBarBackgroundColor = t.colorBackgroundSurface
|
|
74
|
+
// werewolf:property=selectionBar.border-color
|
|
75
|
+
val selectionBarBorderColor = t.colorBorder
|
|
76
|
+
// werewolf:property=selectionBar.border-radius
|
|
77
|
+
val selectionBarBorderRadius = t.radiusContainer
|
|
78
|
+
// werewolf:property=selectionBar.border-width
|
|
79
|
+
val selectionBarBorderWidth = t.borderWidth
|
|
80
|
+
// werewolf:property=selectionBar.gap
|
|
81
|
+
val selectionBarGap = t.spacingMd
|
|
82
|
+
// werewolf:property=selectionBar.padding-block
|
|
83
|
+
val selectionBarPaddingBlock = t.spacingMd
|
|
84
|
+
// werewolf:property=selectionBar.padding-inline
|
|
85
|
+
val selectionBarPaddingInline = t.spacingLg
|
|
86
|
+
val selectionBarShape = werewolfCornerShape(selectionBarBorderRadius)
|
|
87
|
+
var barHeight by remember { mutableStateOf(0.dp) }
|
|
88
|
+
val showsBar = selectionMode && selectionBar != null
|
|
89
|
+
CompositionLocalProvider(LocalWerewolfContentColor provides rootColor) {
|
|
90
|
+
Box(
|
|
91
|
+
modifier = modifier.semantics { contentDescription = label },
|
|
92
|
+
) {
|
|
93
|
+
Column(
|
|
94
|
+
modifier = Modifier
|
|
95
|
+
.fillMaxSize()
|
|
96
|
+
.verticalScroll(rememberScrollState())
|
|
97
|
+
.padding(bottom = if (showsBar) barHeight + bottomInset + selectionBarGap + selectionBarGap else 0.dp)
|
|
98
|
+
.werewolfPending(pending, pendingLabel),
|
|
99
|
+
) {
|
|
100
|
+
if (isEmpty) {
|
|
101
|
+
Box(
|
|
102
|
+
modifier = Modifier
|
|
103
|
+
.fillMaxWidth()
|
|
104
|
+
.padding(start = emptyPaddingInline, end = emptyPaddingInline)
|
|
105
|
+
.padding(top = emptyPaddingBlock, bottom = emptyPaddingBlock),
|
|
106
|
+
contentAlignment = Alignment.Center,
|
|
107
|
+
) {
|
|
108
|
+
empty()
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
content()
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
WerewolfBarArrival(shown = showsBar, modifier = Modifier.align(Alignment.BottomCenter)) {
|
|
115
|
+
Row(
|
|
116
|
+
modifier = Modifier
|
|
117
|
+
.fillMaxWidth()
|
|
118
|
+
.windowInsetsPadding(WindowInsets.navigationBars)
|
|
119
|
+
.padding(horizontal = selectionBarGap)
|
|
120
|
+
.padding(bottom = bottomInset + selectionBarGap)
|
|
121
|
+
.onSizeChanged { barHeight = with(density) { it.height.toDp() } }
|
|
122
|
+
.background(selectionBarBackgroundColor, selectionBarShape)
|
|
123
|
+
.border(selectionBarBorderWidth, selectionBarBorderColor, selectionBarShape)
|
|
124
|
+
.padding(start = selectionBarPaddingInline, end = selectionBarPaddingInline)
|
|
125
|
+
.padding(top = selectionBarPaddingBlock, bottom = selectionBarPaddingBlock),
|
|
126
|
+
horizontalArrangement = Arrangement.spacedBy(selectionBarGap),
|
|
127
|
+
verticalAlignment = Alignment.CenterVertically,
|
|
128
|
+
) {
|
|
129
|
+
selectionBar?.invoke(this)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Werewolf native runtime. Hand-written, independent of the seed.
|
|
2
|
+
package dev.werewolfui.runtime
|
|
3
|
+
|
|
4
|
+
import androidx.compose.animation.AnimatedVisibility
|
|
5
|
+
import androidx.compose.animation.EnterTransition
|
|
6
|
+
import androidx.compose.animation.ExitTransition
|
|
7
|
+
import androidx.compose.animation.core.animateFloatAsState
|
|
8
|
+
import androidx.compose.animation.core.snap
|
|
9
|
+
import androidx.compose.animation.core.tween
|
|
10
|
+
import androidx.compose.animation.fadeIn
|
|
11
|
+
import androidx.compose.animation.fadeOut
|
|
12
|
+
import androidx.compose.animation.slideInVertically
|
|
13
|
+
import androidx.compose.animation.slideOutVertically
|
|
14
|
+
import androidx.compose.runtime.Composable
|
|
15
|
+
import androidx.compose.runtime.getValue
|
|
16
|
+
import androidx.compose.ui.Modifier
|
|
17
|
+
import androidx.compose.ui.graphics.graphicsLayer
|
|
18
|
+
import androidx.compose.ui.semantics.LiveRegionMode
|
|
19
|
+
import androidx.compose.ui.semantics.liveRegion
|
|
20
|
+
import androidx.compose.ui.semantics.semantics
|
|
21
|
+
import androidx.compose.ui.semantics.stateDescription
|
|
22
|
+
import androidx.compose.ui.unit.IntOffset
|
|
23
|
+
|
|
24
|
+
@Composable
|
|
25
|
+
fun Modifier.werewolfPending(pending: Boolean, label: String): Modifier {
|
|
26
|
+
val theme = LocalWerewolf.current
|
|
27
|
+
val reduced = rememberReduceMotion()
|
|
28
|
+
val alpha by animateFloatAsState(
|
|
29
|
+
targetValue = if (pending) theme.opacityPending else 1f,
|
|
30
|
+
animationSpec = if (reduced) snap() else tween(durationMillis = theme.durationMediumMs, easing = theme.easeStandard.toCubicBezierEasing()),
|
|
31
|
+
label = "werewolfPending",
|
|
32
|
+
)
|
|
33
|
+
return this
|
|
34
|
+
.graphicsLayer { this.alpha = alpha }
|
|
35
|
+
.semantics {
|
|
36
|
+
stateDescription = if (pending) label else ""
|
|
37
|
+
liveRegion = LiveRegionMode.Polite
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Composable
|
|
42
|
+
fun WerewolfBarArrival(shown: Boolean, modifier: Modifier = Modifier, content: @Composable () -> Unit) {
|
|
43
|
+
val theme = LocalWerewolf.current
|
|
44
|
+
val reduced = rememberReduceMotion()
|
|
45
|
+
val spec = tween<Float>(durationMillis = theme.durationMediumMs, easing = theme.easeEnter.toCubicBezierEasing())
|
|
46
|
+
val slide = tween<IntOffset>(durationMillis = theme.durationMediumMs, easing = theme.easeEnter.toCubicBezierEasing())
|
|
47
|
+
AnimatedVisibility(
|
|
48
|
+
visible = shown,
|
|
49
|
+
modifier = modifier,
|
|
50
|
+
enter = if (reduced) EnterTransition.None else fadeIn(spec) + slideInVertically(slide) { it },
|
|
51
|
+
exit = if (reduced) ExitTransition.None else fadeOut(spec) + slideOutVertically(slide) { it },
|
|
52
|
+
) {
|
|
53
|
+
content()
|
|
54
|
+
}
|
|
55
|
+
}
|