FMPhotoPicker icon indicating copy to clipboard operation
FMPhotoPicker copied to clipboard

Feature/swift UI

Open ConfusedVorlon opened this issue 3 years ago • 1 comments

This adds a simple wrapper for SwiftUI users

It's documented in the Readme - but essentially, it uses a standard fullscreenModal with a binding to an image or an array of images

struct ContentView: View {
    @State var image:UIImage?
    @State var showPicker:Bool = false

    var body: some View {
        VStack {
            if let image {
                Image(uiImage:image)
                    .resizable()
                    .frame(width:100,height:100)
            }

            Button("Pick a Photo") {
                showPicker = true
            }

        }
        .padding()
		//Note - use fullScreenCover rather than sheet
		//to avoid display issues on iPads
        .fullScreenCover(isPresented: $showPicker) {
            FMSwiftUIImagePicker(config: FMPhotoPickerConfig(),
                                 selectedImage: self.$image)
        }
    }
}

For multiple selection - just change the binding to [UIImage]

ConfusedVorlon avatar Sep 29 '22 19:09 ConfusedVorlon

it would be nice to merge this?

squeaky-nose avatar Dec 04 '23 00:12 squeaky-nose