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
class MImage: Codable { | |
/* | |
if your response json like: | |
{ | |
"id": "5f6c2b39f1966ce3d67f52a7", | |
"url": "https://storage.googleapis.com/meme-image-dev/oESZ3bm36kHibV37whWofy.jpg", | |
"thumbnail_url": "https://storage.googleapis.com/meme-image-dev/iofTbsJis81RTTHgBKCG43.jpg", | |
"usage": 1, | |
"created_at": "2020-09-24T05:14:33.295Z" | |
} |
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
struct ContentView: View { | |
@State var showImagePicker: Bool = false | |
var body: some View { | |
Button("From Libiary"){ | |
showImagePicker = true | |
}.sheet(isPresented: $showImagePicker) { | |
PhotoPicker(sourceType: .photoLibrary) { imageData in | |
// process your data | |
} |
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
import SwiftUI | |
import Photos | |
public struct ImagePicker: UIViewControllerRepresentable { | |
private let sourceType: UIImagePickerController.SourceType | |
private let onImagePicked: (Data) -> Void | |
@Environment(\.presentationMode) private var presentationMode | |
init(sourceType: UIImagePickerController.SourceType, onImagePicked: @escaping (Data) -> Void) { |