You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
PadelClub/PadelClub/Views/Components/CopyPasteButtonView.swift

43 lines
1012 B

//
// CopyPasteButtonView.swift
// PadelClub
//
// Created by Razmig Sarkissian on 17/07/2024.
//
import SwiftUI
struct CopyPasteButtonView: View {
var title: String?
let pasteValue: String?
@State private var copied: Bool = false
@ViewBuilder
var body: some View {
if let pasteValue {
Button {
let pasteboard = UIPasteboard.general
pasteboard.string = pasteValue
copied = true
} label: {
Label(copied ? "Copié" : "Copier", systemImage: "doc.on.doc").symbolVariant(copied ? .fill : .none)
if let title {
Text(title)
}
}
}
}
}
struct PasteButtonView: View {
@Binding var text: String
@ViewBuilder
var body: some View {
PasteButton(payloadType: String.self) { strings in
if let pasteboard = strings.first {
text = pasteboard
}
}
}
}