Files
zeekayandHanzo Dev c8bfbebc15 Keep ZAMA's copyright notices
This app is ZAMA's BSD 3-Clause Clear demo. The license requires its notices to
survive redistribution, and a rebrand had replaced every one of them with ours:
the LICENSE text, 66 source headers and the app's copyright string. They are
back, each with our line beside it for our changes.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-23 01:55:03 -07:00

59 lines
1.6 KiB
Swift

// Copyright © 2025 Zama. All rights reserved.
// Copyright © 2025 Lux Industries Inc.
import SwiftUI
#Preview {
Group {
CopyableText("This is some copyable text.")
CopyableText("This is some copyable text.", fullWidth: true)
CopyableText("This is some copyable text.")
.font(.largeTitle)
CopyableText("This is some copyable text.", fullWidth: true)
.font(.largeTitle)
CopyableText("This is some copyable text.")
.font(.caption2)
}
.padding()
.border(.secondary)
}
struct CopyableText: View {
let text: String?
let fullWidth: Bool
@State private var justCopied: Bool = false
init(_ text: String?, fullWidth: Bool = false) {
self.text = text
self.fullWidth = fullWidth
}
var body: some View {
if let text {
Text(text)
.padding(.trailing, 24)
.frame(maxWidth: fullWidth ? .infinity : nil, alignment: .leading)
.overlay(alignment: .trailingFirstTextBaseline) {
if !text.isEmpty {
Button(action: copyToClipboard) {
Image(systemName: justCopied ? "checkmark" : "doc.on.doc")
}
.buttonStyle(.borderless)
}
}
}
}
private func copyToClipboard() {
UIPasteboard.general.string = text
justCopied = true
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
justCopied = false
}
}
}