Files
letro-ios/ElementX/Sources/Other/SwiftUI/Views/CopyTextButton.swift
Mauro 0b3633ea57 Space Settings UI tweaks (#4678)
* design tweaks for the space settings flow

* pr suggestions

* update proj
2025-10-31 12:52:56 +01:00

40 lines
1.1 KiB
Swift

//
// Copyright 2025 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
// Please see LICENSE files in the repository root for full details.
//
import Compound
import SwiftUI
/// A button that contains text that is copied on tap
struct CopyTextButton: View {
let content: String
var body: some View {
Button {
UIPasteboard.general.string = content
} label: {
Label {
Text(content)
.lineLimit(1)
} icon: {
CompoundIcon(\.copy, size: .small, relativeTo: .compound.bodyLG)
.accessibilityHidden(true)
}
.font(.compound.bodyLG)
.foregroundStyle(.compound.textSecondary)
.labelStyle(.custom(spacing: 4, iconLayout: .trailing))
}
.accessibilityHint(L10n.actionCopy)
}
}
struct CopyTextButton_Previews: PreviewProvider, TestablePreview {
static var previews: some View {
CopyTextButton(content: "Copy me!")
.previewLayout(.sizeThatFits)
}
}