Skip to content

Commit

Permalink
setting/#154- 갤러리 권한접근 추기
Browse files Browse the repository at this point in the history
  • Loading branch information
hooni0918 committed Jul 10, 2024
1 parent 50b1dd5 commit 8636c80
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 20 deletions.
4 changes: 4 additions & 0 deletions KkuMulKum/Resource/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!</string>
<key>NSCameraUsageDescription</key>
<string>정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!정혜진!</string>
<key>UIUserInterfaceStyle</key>
<string>Light</string>
<key>CFBundleURLTypes</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,32 @@
//
// Created by 이지훈 on 7/10/24.
//

import UIKit

class ProfileSetupViewController: BaseViewController {
class ProfileSetupViewController: BaseViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
private let rootView = ProfileSetupView()
private let viewModel = ProfileSetupViewModel()

override func loadView() {
view = rootView
}

override func setupView() {

override func viewDidLoad() {
super.viewDidLoad()
setupBindings()
setupAction()
}

private func setupBindings() {
viewModel.profileImage.bind(with: self) { (vc, image) in
vc.rootView.profileImageView.image = image
}

viewModel.isConfirmButtonEnabled.bind(with: self) { (vc, isEnabled) in
vc.rootView.confirmButton.isEnabled = isEnabled
vc.rootView.confirmButton.alpha = isEnabled ? 1.0 : 0.5
}
}

override func setupAction() {
Expand All @@ -23,20 +38,37 @@ class ProfileSetupViewController: BaseViewController {
rootView.cameraButton.addTarget(self, action: #selector(cameraButtonTapped), for: .touchUpInside)
}

override func setupDelegate() {

}

@objc private func confirmButtonTapped() {

// TODO: 확인 버튼 탭 시 동작 구현
print("프로필 이미지 설정 완료")
}

@objc private func skipButtonTapped() {

// TODO: 건너뛰기 버튼 탭 시 동작 구현
print("프로필 이미지 설정 건너뛰기")
}

@objc private func cameraButtonTapped() {

let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .photoLibrary
imagePicker.allowsEditing = true
present(imagePicker, animated: true)
}

// MARK: - UIImagePickerControllerDelegate

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
if let editedImage = info[.editedImage] as? UIImage {
viewModel.updateProfileImage(editedImage)
} else if let originalImage = info[.originalImage] as? UIImage {
viewModel.updateProfileImage(originalImage)
}
dismiss(animated: true)
}

func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
dismiss(animated: true)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@
// Created by 이지훈 on 7/10/24.
//

import Foundation

class ProfileViewModel {

var nickname: String = ""

func setNickname(_ nickname: String) {
self.nickname = nickname
}
import UIKit

class ProfileSetupViewModel {
let profileImage = ObservablePattern<UIImage?>(UIImage.imgProfile)
let isConfirmButtonEnabled = ObservablePattern<Bool>(false)

func getNickname() -> String {
return nickname
func updateProfileImage(_ image: UIImage?) {
profileImage.value = image
isConfirmButtonEnabled.value = image != nil
}
}

0 comments on commit 8636c80

Please sign in to comment.