[iOS & Android] iOS 1.3.0 & Android 1.8.0
All checks were successful
OpenClimb Docker Deploy / build-and-push (push) Successful in 2m13s
All checks were successful
OpenClimb Docker Deploy / build-and-push (push) Successful in 2m13s
This commit is contained in:
54
ios/OpenClimb/Components/CameraImagePicker.swift
Normal file
54
ios/OpenClimb/Components/CameraImagePicker.swift
Normal file
@@ -0,0 +1,54 @@
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
|
||||
struct CameraImagePicker: UIViewControllerRepresentable {
|
||||
@Binding var isPresented: Bool
|
||||
let onImageCaptured: (UIImage) -> Void
|
||||
|
||||
func makeUIViewController(context: Context) -> UIImagePickerController {
|
||||
let picker = UIImagePickerController()
|
||||
picker.delegate = context.coordinator
|
||||
picker.sourceType = .camera
|
||||
picker.cameraCaptureMode = .photo
|
||||
picker.cameraDevice = .rear
|
||||
picker.allowsEditing = false
|
||||
return picker
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: UIImagePickerController, context: Context) {
|
||||
// Nothing here actually... Q_Q
|
||||
}
|
||||
|
||||
func makeCoordinator() -> Coordinator {
|
||||
Coordinator(self)
|
||||
}
|
||||
|
||||
class Coordinator: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
|
||||
let parent: CameraImagePicker
|
||||
|
||||
init(_ parent: CameraImagePicker) {
|
||||
self.parent = parent
|
||||
}
|
||||
|
||||
func imagePickerController(
|
||||
_ picker: UIImagePickerController,
|
||||
didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]
|
||||
) {
|
||||
if let image = info[.originalImage] as? UIImage {
|
||||
parent.onImageCaptured(image)
|
||||
}
|
||||
parent.isPresented = false
|
||||
}
|
||||
|
||||
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
|
||||
parent.isPresented = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Extension to check camera availability
|
||||
extension CameraImagePicker {
|
||||
static var isCameraAvailable: Bool {
|
||||
UIImagePickerController.isSourceTypeAvailable(.camera)
|
||||
}
|
||||
}
|
||||
83
ios/OpenClimb/Components/PhotoOptionSheet.swift
Normal file
83
ios/OpenClimb/Components/PhotoOptionSheet.swift
Normal file
@@ -0,0 +1,83 @@
|
||||
import PhotosUI
|
||||
import SwiftUI
|
||||
|
||||
struct PhotoOptionSheet: View {
|
||||
@Binding var selectedPhotos: [PhotosPickerItem]
|
||||
@Binding var imageData: [Data]
|
||||
let maxImages: Int
|
||||
let onCameraSelected: () -> Void
|
||||
let onPhotoLibrarySelected: () -> Void
|
||||
let onDismiss: () -> Void
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
VStack(spacing: 20) {
|
||||
Text("Add Photo")
|
||||
.font(.title2)
|
||||
.fontWeight(.semibold)
|
||||
.padding(.top)
|
||||
|
||||
Text("Choose how you'd like to add a photo")
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
VStack(spacing: 16) {
|
||||
Button(action: {
|
||||
onPhotoLibrarySelected()
|
||||
onDismiss()
|
||||
}) {
|
||||
HStack {
|
||||
Image(systemName: "photo.on.rectangle")
|
||||
.font(.title2)
|
||||
.foregroundColor(.blue)
|
||||
Text("Photo Library")
|
||||
.font(.headline)
|
||||
Spacer()
|
||||
Image(systemName: "chevron.right")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.padding()
|
||||
.background(.regularMaterial)
|
||||
.cornerRadius(12)
|
||||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
|
||||
Button(action: {
|
||||
onCameraSelected()
|
||||
onDismiss()
|
||||
}) {
|
||||
HStack {
|
||||
Image(systemName: "camera.fill")
|
||||
.font(.title2)
|
||||
.foregroundColor(.blue)
|
||||
Text("Camera")
|
||||
.font(.headline)
|
||||
Spacer()
|
||||
Image(systemName: "chevron.right")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.padding()
|
||||
.background(.regularMaterial)
|
||||
.cornerRadius(12)
|
||||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
}
|
||||
.padding(.horizontal)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button("Cancel") {
|
||||
onDismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.presentationDetents([.height(300)])
|
||||
.interactiveDismissDisabled(false)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user