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
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// Werewolf native runtime. Hand-written, independent of the seed.
|
|
2
|
+
import SwiftUI
|
|
3
|
+
|
|
4
|
+
public enum WerewolfMessageActionsDefaults {
|
|
5
|
+
public static let quickReactions: [String] = ["👍", "❤️", "😂", "😮", "😢", "🙏"]
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
public struct WerewolfMessageActionsLabels: Hashable, Sendable {
|
|
9
|
+
public var toolbar: String
|
|
10
|
+
public var react: String
|
|
11
|
+
public var reply: String
|
|
12
|
+
public var forward: String
|
|
13
|
+
public var pin: String
|
|
14
|
+
public var select: String
|
|
15
|
+
public var moreReactions: String
|
|
16
|
+
public var quickReactions: String
|
|
17
|
+
public var emojiPicker: WerewolfEmojiPickerLabels
|
|
18
|
+
|
|
19
|
+
public init(
|
|
20
|
+
toolbar: String = "Message actions",
|
|
21
|
+
react: String = "React",
|
|
22
|
+
reply: String = "Reply",
|
|
23
|
+
forward: String = "Forward",
|
|
24
|
+
pin: String = "Pin",
|
|
25
|
+
select: String = "Select",
|
|
26
|
+
moreReactions: String = "More reactions",
|
|
27
|
+
quickReactions: String = "Quick reactions",
|
|
28
|
+
emojiPicker: WerewolfEmojiPickerLabels = WerewolfEmojiPickerLabels()
|
|
29
|
+
) {
|
|
30
|
+
self.toolbar = toolbar
|
|
31
|
+
self.react = react
|
|
32
|
+
self.reply = reply
|
|
33
|
+
self.forward = forward
|
|
34
|
+
self.pin = pin
|
|
35
|
+
self.select = select
|
|
36
|
+
self.moreReactions = moreReactions
|
|
37
|
+
self.quickReactions = quickReactions
|
|
38
|
+
self.emojiPicker = emojiPicker
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
struct WerewolfMessageActionsStyle {
|
|
43
|
+
var rootFontFamily: String
|
|
44
|
+
var rootGap: CGFloat
|
|
45
|
+
var rootRadius: CGFloat
|
|
46
|
+
var rootBackgroundColor: Color
|
|
47
|
+
var rootPadding: CGFloat
|
|
48
|
+
var rootShadow: [WerewolfShadowLayer]
|
|
49
|
+
var rootRingColor: Color
|
|
50
|
+
var reactionRadius: CGFloat
|
|
51
|
+
var reactionFontSize: CGFloat
|
|
52
|
+
var reactionHoverOverlay: Color
|
|
53
|
+
var reactionPressedOverlay: Color
|
|
54
|
+
var reactionScalePressed: CGFloat
|
|
55
|
+
var reactionTransitionDuration: Double
|
|
56
|
+
var reactionTransitionEasing: WerewolfEasing
|
|
57
|
+
var focusRingColor: Color
|
|
58
|
+
var focusRingWidth: CGFloat
|
|
59
|
+
var focusRingOffset: CGFloat
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private let messageActionsEmojiNames: [String: String] = Dictionary(
|
|
63
|
+
WerewolfEmojiData.categories.flatMap(\.emojis).map { ($0.emoji, $0.name) },
|
|
64
|
+
uniquingKeysWith: { first, _ in first }
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
private struct WerewolfMessageActionsAccessibility: ViewModifier {
|
|
68
|
+
let reactLabel: String
|
|
69
|
+
let canReact: Bool
|
|
70
|
+
let onOpenPicker: () -> Void
|
|
71
|
+
let sections: [WerewolfMenuSection]
|
|
72
|
+
let disabled: Bool
|
|
73
|
+
|
|
74
|
+
func body(content: Content) -> some View {
|
|
75
|
+
if disabled {
|
|
76
|
+
return AnyView(content)
|
|
77
|
+
}
|
|
78
|
+
var view = AnyView(content)
|
|
79
|
+
if canReact {
|
|
80
|
+
view = AnyView(view.accessibilityAction(named: Text(reactLabel)) { onOpenPicker() })
|
|
81
|
+
}
|
|
82
|
+
let enabledItems = sections.flatMap(\.items).filter { !$0.disabled }
|
|
83
|
+
return enabledItems.reduce(view) { current, item in
|
|
84
|
+
AnyView(current.accessibilityAction(named: Text(item.label)) { item.action() })
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
struct WerewolfMessageActionsView<Content: View, PickerSheet: View>: View {
|
|
90
|
+
@Environment(\.werewolfIcons) private var icons
|
|
91
|
+
@Environment(\.isEnabled) private var isEnabled
|
|
92
|
+
@State private var pickerOpen = false
|
|
93
|
+
|
|
94
|
+
let onReact: ((String) -> Void)?
|
|
95
|
+
let quickReactions: [String]
|
|
96
|
+
let frequentEmoji: [String]?
|
|
97
|
+
let onReply: (() -> Void)?
|
|
98
|
+
let onForward: (() -> Void)?
|
|
99
|
+
let pinned: Bool
|
|
100
|
+
let onPinnedChange: ((Bool) -> Void)?
|
|
101
|
+
let onSelect: (() -> Void)?
|
|
102
|
+
let sections: [WerewolfMenuSection]
|
|
103
|
+
let disabled: Bool
|
|
104
|
+
let labels: WerewolfMessageActionsLabels
|
|
105
|
+
let style: WerewolfMessageActionsStyle
|
|
106
|
+
let pickerSheet: (Binding<Bool>, @escaping (String) -> Void) -> PickerSheet
|
|
107
|
+
let content: Content
|
|
108
|
+
|
|
109
|
+
private var isDisabled: Bool { disabled || !isEnabled }
|
|
110
|
+
|
|
111
|
+
private var builtInItems: [WerewolfMenuItem] {
|
|
112
|
+
var items: [WerewolfMenuItem] = []
|
|
113
|
+
if let onReply {
|
|
114
|
+
items.append(WerewolfMenuItem(
|
|
115
|
+
id: "reply",
|
|
116
|
+
label: labels.reply,
|
|
117
|
+
leadingIcon: { Image(systemName: "arrowshape.turn.up.left") },
|
|
118
|
+
action: onReply
|
|
119
|
+
))
|
|
120
|
+
}
|
|
121
|
+
if let onForward {
|
|
122
|
+
items.append(WerewolfMenuItem(
|
|
123
|
+
id: "forward",
|
|
124
|
+
label: labels.forward,
|
|
125
|
+
leadingIcon: { Image(systemName: "arrowshape.turn.up.right") },
|
|
126
|
+
action: onForward
|
|
127
|
+
))
|
|
128
|
+
}
|
|
129
|
+
if let onPinnedChange {
|
|
130
|
+
items.append(WerewolfMenuItem(
|
|
131
|
+
id: "pin",
|
|
132
|
+
label: labels.pin,
|
|
133
|
+
leadingIcon: { Image(systemName: pinned ? "pin.fill" : "pin") },
|
|
134
|
+
action: { onPinnedChange(!pinned) }
|
|
135
|
+
))
|
|
136
|
+
}
|
|
137
|
+
if let onSelect {
|
|
138
|
+
items.append(WerewolfMenuItem(
|
|
139
|
+
id: "select",
|
|
140
|
+
label: labels.select,
|
|
141
|
+
leadingIcon: { Image(systemName: "checkmark.circle") },
|
|
142
|
+
action: onSelect
|
|
143
|
+
))
|
|
144
|
+
}
|
|
145
|
+
return items
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private var allSections: [WerewolfMenuSection] {
|
|
149
|
+
var result: [WerewolfMenuSection] = []
|
|
150
|
+
if !builtInItems.isEmpty {
|
|
151
|
+
result.append(WerewolfMenuSection(items: builtInItems))
|
|
152
|
+
}
|
|
153
|
+
result.append(contentsOf: sections)
|
|
154
|
+
return result
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private func emojiMenuLabel(_ emoji: String) -> String {
|
|
158
|
+
if let name = messageActionsEmojiNames[emoji] {
|
|
159
|
+
return "\(emoji) \(name)"
|
|
160
|
+
}
|
|
161
|
+
return emoji
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@ViewBuilder
|
|
165
|
+
private var triggerView: some View {
|
|
166
|
+
let accessible = content.modifier(
|
|
167
|
+
WerewolfMessageActionsAccessibility(
|
|
168
|
+
reactLabel: labels.react,
|
|
169
|
+
canReact: onReact != nil,
|
|
170
|
+
onOpenPicker: { pickerOpen = true },
|
|
171
|
+
sections: allSections,
|
|
172
|
+
disabled: isDisabled
|
|
173
|
+
)
|
|
174
|
+
)
|
|
175
|
+
if isDisabled || (onReact == nil && allSections.isEmpty) {
|
|
176
|
+
accessible
|
|
177
|
+
} else {
|
|
178
|
+
accessible.contextMenu {
|
|
179
|
+
if let onReact {
|
|
180
|
+
Menu {
|
|
181
|
+
ForEach(quickReactions, id: \.self) { emoji in
|
|
182
|
+
Button {
|
|
183
|
+
onReact(emoji)
|
|
184
|
+
} label: {
|
|
185
|
+
Text(emojiMenuLabel(emoji))
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
Divider()
|
|
189
|
+
Button {
|
|
190
|
+
pickerOpen = true
|
|
191
|
+
} label: {
|
|
192
|
+
Label {
|
|
193
|
+
Text(labels.moreReactions)
|
|
194
|
+
} icon: {
|
|
195
|
+
icons.plus
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
} label: {
|
|
199
|
+
Label(labels.react, systemImage: "face.smiling")
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
WerewolfMenuItemsView(sections: allSections)
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
var body: some View {
|
|
208
|
+
triggerView
|
|
209
|
+
.background {
|
|
210
|
+
if let onReact {
|
|
211
|
+
pickerSheet($pickerOpen) { emoji in
|
|
212
|
+
onReact(emoji)
|
|
213
|
+
pickerOpen = false
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
// Generated file, must not be edited by hand. Source: components/message-bubble.spec.json (werewolf-ui 0.1.0-beta.4).
|
|
2
|
+
import SwiftUI
|
|
3
|
+
|
|
4
|
+
public enum WerewolfMessageBubbleSide {
|
|
5
|
+
case start
|
|
6
|
+
case end
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
public enum WerewolfMessageBubbleVariant {
|
|
10
|
+
case `default`
|
|
11
|
+
case accent
|
|
12
|
+
case plain
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public enum WerewolfMessageBubbleStatus {
|
|
16
|
+
case sending
|
|
17
|
+
case sent
|
|
18
|
+
case delivered
|
|
19
|
+
case read
|
|
20
|
+
case failed
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public struct WerewolfMessageReaction: Equatable {
|
|
24
|
+
public var emoji: String
|
|
25
|
+
public var count: Int
|
|
26
|
+
public var reacted: Bool
|
|
27
|
+
|
|
28
|
+
public init(emoji: String, count: Int, reacted: Bool = false) {
|
|
29
|
+
self.emoji = emoji
|
|
30
|
+
self.count = count
|
|
31
|
+
self.reacted = reacted
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public struct WerewolfMessageBubbleLabels: Equatable {
|
|
36
|
+
public var sending: String
|
|
37
|
+
public var sent: String
|
|
38
|
+
public var delivered: String
|
|
39
|
+
public var read: String
|
|
40
|
+
public var failed: String
|
|
41
|
+
public var retry: String
|
|
42
|
+
public var edited: String
|
|
43
|
+
public var pinned: String
|
|
44
|
+
public var forwarded: String
|
|
45
|
+
|
|
46
|
+
public init(
|
|
47
|
+
sending: String = "Sending",
|
|
48
|
+
sent: String = "Sent",
|
|
49
|
+
delivered: String = "Delivered",
|
|
50
|
+
read: String = "Seen",
|
|
51
|
+
failed: String = "Not sent",
|
|
52
|
+
retry: String = "Retry",
|
|
53
|
+
edited: String = "Edited",
|
|
54
|
+
pinned: String = "Pinned",
|
|
55
|
+
forwarded: String = "Forwarded"
|
|
56
|
+
) {
|
|
57
|
+
self.sending = sending
|
|
58
|
+
self.sent = sent
|
|
59
|
+
self.delivered = delivered
|
|
60
|
+
self.read = read
|
|
61
|
+
self.failed = failed
|
|
62
|
+
self.retry = retry
|
|
63
|
+
self.edited = edited
|
|
64
|
+
self.pinned = pinned
|
|
65
|
+
self.forwarded = forwarded
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public struct WerewolfMessageBubble<Content: View>: View {
|
|
70
|
+
private let value: String?
|
|
71
|
+
private let side: WerewolfMessageBubbleSide
|
|
72
|
+
private let variant: WerewolfMessageBubbleVariant
|
|
73
|
+
private let author: AnyView?
|
|
74
|
+
private let avatar: AnyView?
|
|
75
|
+
private let time: AnyView?
|
|
76
|
+
private let status: WerewolfMessageBubbleStatus?
|
|
77
|
+
private let onRetry: (() -> Void)?
|
|
78
|
+
private let edited: Bool
|
|
79
|
+
private let pinned: Bool
|
|
80
|
+
private let forwarded: Bool
|
|
81
|
+
private let grouped: Bool
|
|
82
|
+
private let reactions: [WerewolfMessageReaction]
|
|
83
|
+
private let onReactionToggle: ((String) -> Void)?
|
|
84
|
+
private let labels: WerewolfMessageBubbleLabels
|
|
85
|
+
private let content: Content
|
|
86
|
+
|
|
87
|
+
public init(
|
|
88
|
+
value: String? = nil,
|
|
89
|
+
side: WerewolfMessageBubbleSide = .start,
|
|
90
|
+
variant: WerewolfMessageBubbleVariant = .default,
|
|
91
|
+
author: AnyView? = nil,
|
|
92
|
+
avatar: AnyView? = nil,
|
|
93
|
+
time: AnyView? = nil,
|
|
94
|
+
status: WerewolfMessageBubbleStatus? = nil,
|
|
95
|
+
onRetry: (() -> Void)? = nil,
|
|
96
|
+
edited: Bool = false,
|
|
97
|
+
pinned: Bool = false,
|
|
98
|
+
forwarded: Bool = false,
|
|
99
|
+
grouped: Bool = false,
|
|
100
|
+
reactions: [WerewolfMessageReaction] = [],
|
|
101
|
+
onReactionToggle: ((String) -> Void)? = nil,
|
|
102
|
+
labels: WerewolfMessageBubbleLabels = WerewolfMessageBubbleLabels(),
|
|
103
|
+
@ViewBuilder content: () -> Content
|
|
104
|
+
) {
|
|
105
|
+
self.value = value
|
|
106
|
+
self.side = side
|
|
107
|
+
self.variant = variant
|
|
108
|
+
self.author = author
|
|
109
|
+
self.avatar = avatar
|
|
110
|
+
self.time = time
|
|
111
|
+
self.status = status
|
|
112
|
+
self.onRetry = onRetry
|
|
113
|
+
self.edited = edited
|
|
114
|
+
self.pinned = pinned
|
|
115
|
+
self.forwarded = forwarded
|
|
116
|
+
self.grouped = grouped
|
|
117
|
+
self.reactions = reactions
|
|
118
|
+
self.onReactionToggle = onReactionToggle
|
|
119
|
+
self.labels = labels
|
|
120
|
+
self.content = content()
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
public var body: some View {
|
|
124
|
+
WerewolfMessageBubbleRendering(
|
|
125
|
+
value: value, side: side, variant: variant, author: author, avatar: avatar, time: time,
|
|
126
|
+
status: status, onRetry: onRetry, edited: edited, pinned: pinned, forwarded: forwarded,
|
|
127
|
+
grouped: grouped, reactions: reactions, onReactionToggle: onReactionToggle, labels: labels, content: content
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
private struct WerewolfMessageBubbleRendering<Content: View>: View {
|
|
133
|
+
@Environment(\.werewolfTheme) private var t
|
|
134
|
+
@Environment(\.werewolfIcons) private var werewolfIcons
|
|
135
|
+
@State private var appeared = false
|
|
136
|
+
private let motion = WerewolfMotion()
|
|
137
|
+
|
|
138
|
+
let value: String?
|
|
139
|
+
let side: WerewolfMessageBubbleSide
|
|
140
|
+
let variant: WerewolfMessageBubbleVariant
|
|
141
|
+
let author: AnyView?
|
|
142
|
+
let avatar: AnyView?
|
|
143
|
+
let time: AnyView?
|
|
144
|
+
let status: WerewolfMessageBubbleStatus?
|
|
145
|
+
let onRetry: (() -> Void)?
|
|
146
|
+
let edited: Bool
|
|
147
|
+
let pinned: Bool
|
|
148
|
+
let forwarded: Bool
|
|
149
|
+
let grouped: Bool
|
|
150
|
+
let reactions: [WerewolfMessageReaction]
|
|
151
|
+
let onReactionToggle: ((String) -> Void)?
|
|
152
|
+
let labels: WerewolfMessageBubbleLabels
|
|
153
|
+
let content: Content
|
|
154
|
+
|
|
155
|
+
private var hasFooter: Bool { time != nil || status != nil || edited || pinned }
|
|
156
|
+
private var hasInteractiveChildren: Bool { (onReactionToggle != nil && !reactions.isEmpty) || (status == .failed && onRetry != nil) }
|
|
157
|
+
|
|
158
|
+
var body: some View {
|
|
159
|
+
let _ = t.fontFamilySans
|
|
160
|
+
HStack(alignment: .top, spacing: t.spacingSm) {
|
|
161
|
+
if side == .end {
|
|
162
|
+
if variant != .plain {
|
|
163
|
+
Spacer(minLength: t.spacing3xl)
|
|
164
|
+
}
|
|
165
|
+
bodyColumn
|
|
166
|
+
avatarColumn
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
avatarColumn
|
|
170
|
+
bodyColumn
|
|
171
|
+
if variant != .plain {
|
|
172
|
+
Spacer(minLength: t.spacing3xl)
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
.werewolfFont(.sans, size: t.fontSizeSm, weight: .regular)
|
|
177
|
+
.opacity(appeared ? 1 : 0)
|
|
178
|
+
.animation(motion.animation(t.easeEnter, duration: t.durationMedium), value: appeared)
|
|
179
|
+
.onAppear { appeared = true }
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@ViewBuilder private var avatarColumn: some View {
|
|
183
|
+
if let avatar {
|
|
184
|
+
Group {
|
|
185
|
+
if !grouped {
|
|
186
|
+
avatar.accessibilityHidden(true)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
.frame(width: t.spacing2xl)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
private var bodyColumn: some View {
|
|
194
|
+
VStack(alignment: side == .end ? .trailing : .leading, spacing: t.spacingXs) {
|
|
195
|
+
if hasInteractiveChildren {
|
|
196
|
+
messageSummary
|
|
197
|
+
reactionsView
|
|
198
|
+
footerView
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
VStack(alignment: side == .end ? .trailing : .leading, spacing: t.spacingXs) {
|
|
202
|
+
messageSummary
|
|
203
|
+
reactionsView
|
|
204
|
+
footerView
|
|
205
|
+
}
|
|
206
|
+
.accessibilityElement(children: .combine)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
@ViewBuilder private var messageSummary: some View {
|
|
212
|
+
if forwarded {
|
|
213
|
+
Text(labels.forwarded)
|
|
214
|
+
.werewolfFont(.sans, size: t.fontSizeXs, weight: .regular)
|
|
215
|
+
.foregroundStyle(t.colorTextTertiary)
|
|
216
|
+
}
|
|
217
|
+
if let author, !grouped {
|
|
218
|
+
author
|
|
219
|
+
.werewolfFont(.sans, size: t.fontSizeXs, weight: WerewolfFonts.weight(forToken: t.fontWeightMedium))
|
|
220
|
+
.foregroundStyle(t.colorTextSecondary)
|
|
221
|
+
}
|
|
222
|
+
let shape = RoundedRectangle(cornerRadius: bubbleBorderRadius ?? 0, theme: t)
|
|
223
|
+
content
|
|
224
|
+
.werewolfFont(.sans, size: t.fontSizeSm, weight: .regular)
|
|
225
|
+
.foregroundStyle(bubbleColor)
|
|
226
|
+
.applying(bubblePaddingInline) { $0.padding(.horizontal, $1) }
|
|
227
|
+
.applying(bubblePaddingBlock) { $0.padding(.vertical, $1) }
|
|
228
|
+
.background(shape.fill(bubbleBackgroundColor ?? .clear))
|
|
229
|
+
.overlay(shape.strokeBorder(bubbleBorderColor ?? .clear, lineWidth: bubbleBorderWidth ?? 0))
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
@ViewBuilder private var reactionsView: some View {
|
|
233
|
+
if !reactions.isEmpty {
|
|
234
|
+
WerewolfFlowLayout(spacing: t.spacingXs) {
|
|
235
|
+
ForEach(Array(reactions.enumerated()), id: \.offset) { _, reaction in
|
|
236
|
+
reactionChip(reaction)
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
@ViewBuilder private func reactionChip(_ reaction: WerewolfMessageReaction) -> some View {
|
|
243
|
+
let shape = RoundedRectangle(cornerRadius: t.radiusFull, theme: t)
|
|
244
|
+
let labelView = Text("\(reaction.emoji) \(reaction.count)")
|
|
245
|
+
.werewolfFont(.sans, size: t.fontSizeXs, weight: WerewolfFonts.weight(forToken: t.fontWeightMedium))
|
|
246
|
+
.monospacedDigit()
|
|
247
|
+
.foregroundStyle(reaction.reacted ? t.colorTextOnMuted : t.colorTextSecondary)
|
|
248
|
+
.padding(.horizontal, t.spacingSm)
|
|
249
|
+
.frame(height: t.sizeInlineMd)
|
|
250
|
+
.background(shape.fill(reaction.reacted ? t.colorAccentMuted : t.colorBackgroundSurface))
|
|
251
|
+
.overlay(shape.strokeBorder(reaction.reacted ? Color.clear : t.colorBorder, lineWidth: t.borderWidth))
|
|
252
|
+
if let onReactionToggle {
|
|
253
|
+
Button(action: { onReactionToggle(reaction.emoji) }) {
|
|
254
|
+
labelView
|
|
255
|
+
}
|
|
256
|
+
.buttonStyle(WerewolfMessageReactionButtonStyle(shape: shape))
|
|
257
|
+
.accessibilityLabel("\(reaction.emoji) \(reaction.count)")
|
|
258
|
+
.accessibilityAddTraits(reaction.reacted ? [.isButton, .isSelected] : [.isButton])
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
labelView
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
@ViewBuilder private var footerView: some View {
|
|
266
|
+
if hasFooter {
|
|
267
|
+
HStack(spacing: t.spacingSm) {
|
|
268
|
+
HStack(spacing: t.spacingSm) {
|
|
269
|
+
if let time {
|
|
270
|
+
time
|
|
271
|
+
}
|
|
272
|
+
if edited {
|
|
273
|
+
Text(labels.edited)
|
|
274
|
+
}
|
|
275
|
+
if pinned {
|
|
276
|
+
Text(labels.pinned)
|
|
277
|
+
}
|
|
278
|
+
if let status {
|
|
279
|
+
HStack(spacing: t.spacing2xs) {
|
|
280
|
+
statusIcon(status)
|
|
281
|
+
.resizable()
|
|
282
|
+
.scaledToFit()
|
|
283
|
+
.frame(width: t.sizeIconSm, height: t.sizeIconSm)
|
|
284
|
+
.foregroundStyle(statusIconColor(status))
|
|
285
|
+
.accessibilityHidden(true)
|
|
286
|
+
if status == .failed {
|
|
287
|
+
Text(labels.failed).foregroundStyle(t.colorTextDanger)
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
.accessibilityElement(children: .ignore)
|
|
291
|
+
.accessibilityLabel(statusLabel(status))
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
.werewolfFont(.sans, size: t.fontSizeXs, weight: .regular)
|
|
295
|
+
.foregroundStyle(t.colorTextTertiary)
|
|
296
|
+
.accessibilityElement(children: .combine)
|
|
297
|
+
if status == .failed, let onRetry {
|
|
298
|
+
Button(action: onRetry) {
|
|
299
|
+
Text(labels.retry)
|
|
300
|
+
.underline()
|
|
301
|
+
.werewolfFont(.sans, size: t.fontSizeXs, weight: WerewolfFonts.weight(forToken: t.fontWeightMedium))
|
|
302
|
+
.foregroundStyle(t.colorTextPrimary)
|
|
303
|
+
.werewolfHitArea()
|
|
304
|
+
}
|
|
305
|
+
.buttonStyle(.plain)
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
private func statusIcon(_ status: WerewolfMessageBubbleStatus) -> Image {
|
|
312
|
+
switch status {
|
|
313
|
+
case .sending: return werewolfIcons.clock
|
|
314
|
+
case .sent: return werewolfIcons.check
|
|
315
|
+
case .delivered: return werewolfIcons.checkDouble
|
|
316
|
+
case .read: return werewolfIcons.checkDouble
|
|
317
|
+
case .failed: return werewolfIcons.alertTriangle
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
private func statusIconColor(_ status: WerewolfMessageBubbleStatus) -> Color {
|
|
322
|
+
switch status {
|
|
323
|
+
case .read: return t.colorIconAccent
|
|
324
|
+
case .failed: return t.colorTextDanger
|
|
325
|
+
default: return t.colorIconSecondary
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
private func statusLabel(_ status: WerewolfMessageBubbleStatus) -> String {
|
|
330
|
+
switch status {
|
|
331
|
+
case .sending: return labels.sending
|
|
332
|
+
case .sent: return labels.sent
|
|
333
|
+
case .delivered: return labels.delivered
|
|
334
|
+
case .read: return labels.read
|
|
335
|
+
case .failed: return labels.failed
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
private var bubbleBackgroundColor: Color? {
|
|
340
|
+
// werewolf:property=bubble.background-color
|
|
341
|
+
switch variant {
|
|
342
|
+
// werewolf:variant=default
|
|
343
|
+
case .`default`:
|
|
344
|
+
return t.colorBackgroundSurface
|
|
345
|
+
// werewolf:variant=accent
|
|
346
|
+
case .accent:
|
|
347
|
+
return t.colorAccent
|
|
348
|
+
// werewolf:variant=plain
|
|
349
|
+
case .plain:
|
|
350
|
+
return nil
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
private var bubbleBorderColor: Color? {
|
|
355
|
+
// werewolf:property=bubble.border-color
|
|
356
|
+
switch variant {
|
|
357
|
+
// werewolf:variant=default
|
|
358
|
+
case .`default`:
|
|
359
|
+
return t.colorBorder
|
|
360
|
+
// werewolf:variant=accent
|
|
361
|
+
case .accent:
|
|
362
|
+
return nil
|
|
363
|
+
// werewolf:variant=plain
|
|
364
|
+
case .plain:
|
|
365
|
+
return nil
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
private var bubbleBorderRadius: CGFloat? {
|
|
370
|
+
// werewolf:property=bubble.border-radius
|
|
371
|
+
switch variant {
|
|
372
|
+
// werewolf:variant=default
|
|
373
|
+
case .`default`:
|
|
374
|
+
return t.radiusContainer
|
|
375
|
+
// werewolf:variant=accent
|
|
376
|
+
case .accent:
|
|
377
|
+
return t.radiusContainer
|
|
378
|
+
// werewolf:variant=plain
|
|
379
|
+
case .plain:
|
|
380
|
+
return nil
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
private var bubbleBorderWidth: CGFloat? {
|
|
385
|
+
// werewolf:property=bubble.border-width
|
|
386
|
+
switch variant {
|
|
387
|
+
// werewolf:variant=default
|
|
388
|
+
case .`default`:
|
|
389
|
+
return t.borderWidth
|
|
390
|
+
// werewolf:variant=accent
|
|
391
|
+
case .accent:
|
|
392
|
+
return nil
|
|
393
|
+
// werewolf:variant=plain
|
|
394
|
+
case .plain:
|
|
395
|
+
return nil
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
private var bubbleColor: Color {
|
|
400
|
+
// werewolf:property=bubble.color
|
|
401
|
+
switch variant {
|
|
402
|
+
// werewolf:variant=default
|
|
403
|
+
case .`default`:
|
|
404
|
+
return t.colorTextPrimary
|
|
405
|
+
// werewolf:variant=accent
|
|
406
|
+
case .accent:
|
|
407
|
+
return t.colorTextOnAccent
|
|
408
|
+
// werewolf:variant=plain
|
|
409
|
+
case .plain:
|
|
410
|
+
return t.colorTextPrimary
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
private var bubblePaddingBlock: CGFloat? {
|
|
415
|
+
// werewolf:property=bubble.padding-block
|
|
416
|
+
switch variant {
|
|
417
|
+
// werewolf:variant=default
|
|
418
|
+
case .`default`:
|
|
419
|
+
return t.spacingSm
|
|
420
|
+
// werewolf:variant=accent
|
|
421
|
+
case .accent:
|
|
422
|
+
return t.spacingSm
|
|
423
|
+
// werewolf:variant=plain
|
|
424
|
+
case .plain:
|
|
425
|
+
return nil
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
private var bubblePaddingInline: CGFloat? {
|
|
430
|
+
// werewolf:property=bubble.padding-inline
|
|
431
|
+
switch variant {
|
|
432
|
+
// werewolf:variant=default
|
|
433
|
+
case .`default`:
|
|
434
|
+
return t.spacingMd
|
|
435
|
+
// werewolf:variant=accent
|
|
436
|
+
case .accent:
|
|
437
|
+
return t.spacingMd
|
|
438
|
+
// werewolf:variant=plain
|
|
439
|
+
case .plain:
|
|
440
|
+
return nil
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
private struct WerewolfMessageReactionButtonStyle: ButtonStyle {
|
|
447
|
+
@Environment(\.werewolfTheme) private var t
|
|
448
|
+
@State private var isHovered = false
|
|
449
|
+
@FocusState private var isFocused: Bool
|
|
450
|
+
let shape: RoundedRectangle
|
|
451
|
+
|
|
452
|
+
func makeBody(configuration: Configuration) -> some View {
|
|
453
|
+
configuration.label
|
|
454
|
+
.werewolfOverlay(t.colorOverlayHover, in: shape, active: isHovered)
|
|
455
|
+
.werewolfOverlay(t.colorOverlayPressed, in: shape, active: configuration.isPressed)
|
|
456
|
+
.werewolfPressScale(configuration.isPressed)
|
|
457
|
+
.werewolfFocusRing(isFocused, in: shape)
|
|
458
|
+
.werewolfHitArea()
|
|
459
|
+
.contentShape(Rectangle())
|
|
460
|
+
.onHover { isHovered = $0 }
|
|
461
|
+
.focused($isFocused)
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
private extension View {
|
|
466
|
+
@ViewBuilder
|
|
467
|
+
func applying<Value, Result: View>(_ value: Value?, _ transform: (Self, Value) -> Result) -> some View {
|
|
468
|
+
if let value {
|
|
469
|
+
transform(self, value)
|
|
470
|
+
} else {
|
|
471
|
+
self
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|