Created
November 21, 2020 10:21
-
-
Save laevandus/6af262b795c066db89de4ae05c74f5be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension ContentView { | |
final class ViewModel: ObservableObject { | |
@Published var selectedImage: UIImage? | |
@Published var isPresentingImagePicker = false | |
private(set) var sourceType: ImagePicker.SourceType = .camera | |
func choosePhoto() { | |
sourceType = .photoLibrary | |
isPresentingImagePicker = true | |
} | |
func takePhoto() { | |
sourceType = .camera | |
isPresentingImagePicker = true | |
} | |
func didSelectImage(_ image: UIImage?) { | |
selectedImage = image | |
isPresentingImagePicker = false | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment