From f1a7c0edede323ef8190d994084247a5e7729ce7 Mon Sep 17 00:00:00 2001 From: Suhail Saqan Date: Fri, 14 Apr 2023 20:45:43 -0700 Subject: [PATCH] Add paste button to login Changelog-Added: Add paste button to login Closes: #927 --- damus/Views/LoginView.swift | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/damus/Views/LoginView.swift b/damus/Views/LoginView.swift index 1930a2be..06fa53d6 100644 --- a/damus/Views/LoginView.swift +++ b/damus/Views/LoginView.swift @@ -158,6 +158,8 @@ struct LoginView: View { .foregroundColor(.white) .padding() } + + Spacer() if let p = parsed { DamusWhiteButton(NSLocalizedString("Login", comment: "Button to log into account.")) { @@ -268,18 +270,29 @@ struct KeyInput: View { } var body: some View { - TextField("", text: key) - .placeholder(when: key.wrappedValue.isEmpty) { - Text(title).foregroundColor(.white.opacity(0.6)) + ZStack(alignment: .leading) { + TextField("", text: key) + .placeholder(when: key.wrappedValue.isEmpty) { + Text(title).foregroundColor(.white.opacity(0.6)) + } + .padding() + .padding(.leading, 20) + .background { + RoundedRectangle(cornerRadius: 4.0).opacity(0.2) + } + .autocapitalization(.none) + .foregroundColor(.white) + .font(.body.monospaced()) + .textContentType(.password) + + Label("", systemImage: "doc.on.clipboard") + .padding(.leading, 10) + .onTapGesture { + if let pastedkey = UIPasteboard.general.string { + self.key.wrappedValue = pastedkey + } } - .padding() - .background { - RoundedRectangle(cornerRadius: 4.0).opacity(0.2) - } - .autocapitalization(.none) - .foregroundColor(.white) - .font(.body.monospaced()) - .textContentType(.password) + } } }