From 643452459bfedb285a7c6fa79c8a406a526d4a43 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 25 Aug 2021 11:26:21 -0400 Subject: [PATCH] Add copying --- OTP/Views/KeyView.swift | 77 ++++++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 28 deletions(-) diff --git a/OTP/Views/KeyView.swift b/OTP/Views/KeyView.swift index 26db0e1..3143d88 100644 --- a/OTP/Views/KeyView.swift +++ b/OTP/Views/KeyView.swift @@ -11,8 +11,9 @@ import OTPKit struct KeyView: View { let key: TOTPKey let currentCode: TOTPCode + @State private var copying = false - var formattedCode: String { + private var formattedCode: String { let code = currentCode.code let mid = code.index(code.startIndex, offsetBy: code.count / 2) return "\(code[code.startIndex.. Double { @@ -62,6 +73,16 @@ struct KeyView: View { let progress = 1 - seconds / Double(key.period) return progress } + + private func copy() { + UIPasteboard.general.string = currentCode.code + withAnimation(.easeInOut(duration: 0.5)) { + copying = true + } + withAnimation(.easeInOut(duration: 0.5).delay(0.65)) { + copying = false + } + } } struct KeyView_Previews: PreviewProvider {