From 1e3ece600d37dd9683a87073f81eab7f3511c7a2 Mon Sep 17 00:00:00 2001 From: Max Goedjen Date: Fri, 20 Mar 2020 21:07:58 -0700 Subject: [PATCH] Fixes #51. --- Secretive/Views/SetupView.swift | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/Secretive/Views/SetupView.swift b/Secretive/Views/SetupView.swift index d2b61c6..7e2600e 100644 --- a/Secretive/Views/SetupView.swift +++ b/Secretive/Views/SetupView.swift @@ -87,16 +87,30 @@ struct SetupStepCommandView: View { let text: String var body: some View { - Text(text) - .font(.system(.caption, design: .monospaced)) - .lineLimit(nil) - .frame(idealHeight: 0, maxHeight: .infinity) - .padding() - .background(Color(white: 0, opacity: 0.10)) - .cornerRadius(10) - .onDrag { - return NSItemProvider(item: NSData(data: self.text.data(using: .utf8)!), typeIdentifier: kUTTypeUTF8PlainText as String) + VStack(alignment: .leading) { + Text(text) + .lineLimit(nil) + .font(.system(.caption, design: .monospaced)) + .multilineTextAlignment(.leading) + HStack { + Spacer() + Button(action: copy) { + Text("Copy") + } + } } + .padding() + .background(Color(white: 0, opacity: 0.10)) + .cornerRadius(10) + .onDrag { + return NSItemProvider(item: NSData(data: self.text.data(using: .utf8)!), typeIdentifier: kUTTypeUTF8PlainText as String) + + } + } + + func copy() { + NSPasteboard.general.declareTypes([.string], owner: nil) + NSPasteboard.general.setString(text, forType: .string) } }