Repository navigation
Expand file tree
/
Copy pathLGComposerAttachmentRemove.swift
More file actions
49 lines (44 loc) · 1.82 KB
/
Copy pathLGComposerAttachmentRemove.swift
File metadata and controls
49 lines (44 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#if os(iOS)
import LUIAppleBackend
import SwiftUI
struct LGComposerAttachmentRemove: View {
let context: LUIAppleExtensionViewContext
static func register(in registry: LUIAppleExtensionRegistry) throws {
try registry.register(LUIAppleExtension(
identifier: "composer-attachment-remove",
fingerprint: "lui-extension-v1|26:composer-attachment-remove|profiles:ios/swiftui|standard-children:1|children:|properties:5:label:string:required:none|events:6:remove[]",
acceptsStandardChildren: true,
properties: [.init(name: "label", kind: .string, isRequired: true)],
events: [.init(name: "remove", fields: [])]
) { AnyView(LGComposerAttachmentRemove(context: $0)) })
}
var body: some View {
let _ = context.revision
context.content
.allowsHitTesting(false)
.overlay(alignment: .topTrailing) { removeButton }
}
private var removeButton: some View {
Button {
guard context.isUserInteractionEnabled else { return }
try? context.emit(name: "remove")
} label: {
Image(systemName: "xmark")
.font(.system(size: 11, weight: .semibold))
.foregroundStyle(.white)
.frame(width: 22, height: 22)
.background(.black.opacity(0.6), in: Circle())
.padding([.top, .trailing], 8)
.frame(width: 44, height: 44, alignment: .topTrailing)
.contentShape(Rectangle())
}
.buttonStyle(.plain)
.accessibilityLabel(Text(verbatim: label))
.accessibilityIdentifier("composer.asset.remove")
}
private var label: String {
guard case let .string(label) = context.property("label") else { return "Remove attachment" }
return label
}
}
#endif