diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj index 5e55e17..f39f3a5 100644 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ 180FD285D7885124BD5816FBD7F0AD99 /* LithoOperators.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF33FB01C4213CEE32E09EED17997D27 /* LithoOperators.framework */; }; 1D434F8521C7E91AD8F80A23B4362E35 /* Configurable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CE030D228DB4AAEE2102DC9C853F63 /* Configurable.swift */; }; 1F92193DF04628B442B81772C738256C /* FunNet-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = B5D86E2A2D236D7C6467065A1F0DB744 /* FunNet-dummy.m */; }; + 23111096275A8AB500EAFC55 /* ImagePickerAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23111095275A8AB500EAFC55 /* ImagePickerAlert.swift */; }; 23A8D2A3272A06DA00DE80DD /* CombineFilters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23A8D2A2272A06DA00DE80DD /* CombineFilters.swift */; }; 23E3D1DD2744938100CA18C0 /* OpenUrl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23E3D1DC2744938100CA18C0 /* OpenUrl.swift */; }; 25D51EEF4C17139A25B00F9E7A5440AC /* Comparables.swift in Sources */ = {isa = PBXBuildFile; fileRef = 972233FB326EAC8E2FF3A13DB7505C3C /* Comparables.swift */; }; @@ -186,6 +187,7 @@ 2003BB4FF9A1C347FD2F402DCA1B35F4 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; 20574C340C819F6F8A2A6D65C9FC616C /* FunNet.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = FunNet.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 21CA6E2DB0B479F011E59C27DA402759 /* FunNet.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = FunNet.modulemap; sourceTree = ""; }; + 23111095275A8AB500EAFC55 /* ImagePickerAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagePickerAlert.swift; sourceTree = ""; }; 23A8D2A2272A06DA00DE80DD /* CombineFilters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CombineFilters.swift; sourceTree = ""; }; 23E3D1DC2744938100CA18C0 /* OpenUrl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenUrl.swift; sourceTree = ""; }; 241E1965D10AF0AE661A0CDFA59A3C60 /* Prelude-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Prelude-Info.plist"; sourceTree = ""; }; @@ -478,6 +480,7 @@ isa = PBXGroup; children = ( 6F809047B82C91E63074AC48F900A909 /* Alert.swift */, + 23111095275A8AB500EAFC55 /* ImagePickerAlert.swift */, ); path = Alert; sourceTree = ""; @@ -1160,6 +1163,7 @@ D9C817158E83D667E13D24078FDBC479 /* LithoUtils-dummy.m in Sources */, 572C4D70B168372280193FC90E428E97 /* Styles.swift in Sources */, 9252A0860F6E944111EF1F40819480BA /* UIColor+hex.swift in Sources */, + 23111096275A8AB500EAFC55 /* ImagePickerAlert.swift in Sources */, 35B6C7EAA888AAC2D30B68CA2D5033B3 /* UIImage+Resize.swift in Sources */, 23A8D2A3272A06DA00DE80DD /* CombineFilters.swift in Sources */, DD2EB9C57A0742F83949E20E727EBF35 /* UIViewController+BarButtonItem.swift in Sources */, diff --git a/LithoUtils/Classes/Base/Alert/ImagePickerAlert.swift b/LithoUtils/Classes/Base/Alert/ImagePickerAlert.swift new file mode 100644 index 0000000..90c101f --- /dev/null +++ b/LithoUtils/Classes/Base/Alert/ImagePickerAlert.swift @@ -0,0 +1,30 @@ +// +// ImagePickerAlert.swift +// LithoUtils +// +// Created by Calvin Collins on 12/3/21. +// + +import Foundation +import fuikit +import LithoOperators + +public func imagePickerAlert(vc: UIViewController, imagePicker: UIImagePickerController, title: String? = "How do you want to upload your picture?", message: String? = nil) -> UIAlertController { + let alert = actionSheetPopoverSafe(title: title, message: message, sourceView: vc.view) + alert.addAction(defaultAlertAction(title: "Camera", handler: ignoreArg({ [weak vc] in + guard let vc = vc else { return } + if UIImagePickerController.isSourceTypeAvailable(.camera) { + imagePicker.sourceType = .camera + } + alert.dismissAnimated(imagePicker *> vc.presentClosure()) + }))) + alert.addAction(defaultAlertAction(title: "Library", handler: ignoreArg({ [weak vc] in + guard let vc = vc else { return } + imagePicker.sourceType = .photoLibrary + if UIImagePickerController.isSourceTypeAvailable(.photoLibrary) { + alert.dismissAnimated(imagePicker *> vc.presentClosure()) + } + }))) + alert.addAction(cancelAlertAction(title: "Cancel", handler: ignoreArg(nil *> alert.dismissClosure()))) + return alert +} diff --git a/LithoUtils/Classes/Base/Functions/OpenUrl.swift b/LithoUtils/Classes/Base/Functions/OpenUrl.swift index d66f35c..f121016 100644 --- a/LithoUtils/Classes/Base/Functions/OpenUrl.swift +++ b/LithoUtils/Classes/Base/Functions/OpenUrl.swift @@ -9,4 +9,4 @@ import Foundation import LithoOperators import UIKit -public let openUrl = URL.init(string:) >?> (([:], nil) -**> UIApplication.shared.open) +public let openURL = URL.init(string:) >?> (([:], nil) -**> UIApplication.shared.open)