Skip to content

Commit

Permalink
✨ :: [#62] Add ImagePicker Extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Xixn2 committed Nov 14, 2024
1 parent 6269ae1 commit 7201008
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
42 changes: 42 additions & 0 deletions Projects/App/Sources/Extension/ImagePicker.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// ImagePicker.swift
// Expo-iOS
//
// Created by 서지완 on 11/14/24.
// Copyright © 2024 SchoolofCompany. All rights reserved.
//

import Foundation
import SwiftUI

struct ImagePicker: UIViewControllerRepresentable {
@Binding var selectedImage: UIImage?
@Environment(\.presentationMode) private var presentationMode

func makeUIViewController(context: UIViewControllerRepresentableContext<ImagePicker>) -> UIImagePickerController {
let picker = UIImagePickerController()
picker.delegate = context.coordinator
return picker
}

func updateUIViewController(_ uiViewController: UIImagePickerController, context: UIViewControllerRepresentableContext<ImagePicker>) {}

func makeCoordinator() -> Coordinator {
Coordinator(self)
}

class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
let parent: ImagePicker

init(_ parent: ImagePicker) {
self.parent = parent
}

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
if let image = info[.originalImage] as? UIImage {
parent.selectedImage = image
}
parent.presentationMode.wrappedValue.dismiss()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ struct ExpoEditView: View {
Text("박람회 수정하기")
.expoFont(.body1R)
}

ScrollView {
VStack(alignment: .leading, spacing: 0) {
Text("사진")
.expoFont(.body2B)
.padding(.leading, 14)
.padding(.top, 41)
.padding(.top, 20)

ExpoIOSAsset.Assets.photoget.swiftUIImage
.resizable()
Expand Down Expand Up @@ -125,6 +126,8 @@ struct ExpoEditView: View {
.expoFont(.caption2R)
.expoColor(ExpoColor.main)
}


}
Spacer()
}
Expand Down

0 comments on commit 7201008

Please sign in to comment.