From e6846953b7dc746a3dfe2ffd5a2afbada23ac3fa Mon Sep 17 00:00:00 2001 From: relikd Date: Tue, 8 Sep 2020 18:35:30 +0200 Subject: [PATCH] Copy upload key to clipboard --- main/Recordings/TVCShareRecording.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/main/Recordings/TVCShareRecording.swift b/main/Recordings/TVCShareRecording.swift index d16befb..9b8a353 100644 --- a/main/Recordings/TVCShareRecording.swift +++ b/main/Recordings/TVCShareRecording.swift @@ -86,6 +86,13 @@ class TVCShareRecording : UITableViewController, UITextViewDelegate, VCEditTextD } } + override func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) { + if motion == .motionShake, let key = record.uploadkey { + UIPasteboard.general.string = key + banner(.ok, "Copied to clipboard", timeout: 1) + } + } + // MARK: - Table Data Source @@ -234,8 +241,8 @@ class TVCShareRecording : UITableViewController, UITextViewDelegate, VCEditTextD // MARK: - Alerts & Banner - private func banner(_ style: NotificationBanner.Style, _ msg: String) { - NotificationBanner(msg, style: style).present(in: navigationController!) + private func banner(_ style: NotificationBanner.Style, _ msg: String, timeout: TimeInterval = 3) { + NotificationBanner(msg, style: style).present(in: navigationController!, hideAfter: timeout) } private func showAlertAvailableSoon(_ urlStr: String, when: Int?) {