From b44ec1f94f7b770e0a7b40625f2d64e68476707f Mon Sep 17 00:00:00 2001 From: Pinkesh Gjr Date: Fri, 26 Apr 2024 12:43:35 +0100 Subject: [PATCH] Added auto-paste support for enhanced user experience --- .../xcshareddata/swiftpm/Package.resolved | 5 +++-- Loadify/View/URLView.swift | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Loadify.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Loadify.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 304542b..58efd54 100644 --- a/Loadify.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Loadify.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,4 +1,5 @@ { + "originHash" : "0cf9c27f2acf675e9545d0a85d9f4d30d22bf1b8c6fb12a1097b499879c9e11f", "pins" : [ { "identity" : "fontkit", @@ -21,12 +22,12 @@ { "identity" : "loggerkit", "kind" : "remoteSourceControl", - "location" : "git@github.com:VishwaiOSDev/LoggerKit.git", + "location" : "https://github.com/VishwaiOSDev/LoggerKit", "state" : { "revision" : "d4c55d28e3eaa620c4a85c0fcf2ae03ffe889edb", "version" : "1.1.2" } } ], - "version" : 2 + "version" : 3 } diff --git a/Loadify/View/URLView.swift b/Loadify/View/URLView.swift index 988af5d..141a753 100644 --- a/Loadify/View/URLView.swift +++ b/Loadify/View/URLView.swift @@ -32,6 +32,16 @@ struct URLView: View { } .padding() } + .onAppear(perform: { + Task { + await checkPasteboard() + } + NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: .main) { _ in + Task { + await checkPasteboard() + } + } + }) .navigationBarHidden(true) .onDisappear(perform: viewModel.onDisappear) .showLoader(LoadifyTexts.loading, isPresented: $viewModel.showLoader) @@ -113,6 +123,12 @@ struct URLView: View { let trimmedURL = videoURL.trimmingCharacters(in: .whitespacesAndNewlines) await viewModel.getVideoDetails(for: trimmedURL) } + + private func checkPasteboard() async { + if let pasteboardString = UIPasteboard.general.string { + videoURL = pasteboardString + } + } } #Preview("iPhone 15 Pro Max") {