From 9711df185e4e6c5266b9055d0195c23f5eaff0e1 Mon Sep 17 00:00:00 2001 From: trumanfromkorea Date: Mon, 12 Dec 2022 16:31:28 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[fix]=20=EC=BA=A1=EC=8A=90=20=EC=A0=9C?= =?UTF-8?q?=EB=AA=A9=20=EC=9E=85=EB=A0=A5=20=EA=B8=B8=EC=9D=B4=EC=A0=9C?= =?UTF-8?q?=ED=95=9C=20(#103)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CapsuleCreate/CapsuleCreateView.swift | 8 +++++++- .../CapsuleCreateViewController.swift | 18 ++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/CapsuleCreateView.swift b/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/CapsuleCreateView.swift index 2a055e7..bac2ac4 100644 --- a/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/CapsuleCreateView.swift +++ b/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/CapsuleCreateView.swift @@ -34,7 +34,13 @@ final class CapsuleCreateView: UIView, BaseView { private let dateLabel = ThemeLabel(text: "추억 날짜", size: FrameResource.fontSize110, color: .themeGray300) private let descriptionLabel = ThemeLabel(text: "내용", size: FrameResource.fontSize110, color: .themeGray300) - let titleTextField = ThemeTextField(placeholder: "추억하고 싶은 캡슐의 이름을 적어주세요") + let titleTextField: ThemeTextField = { + let textField = ThemeTextField(placeholder: "추억하고 싶은 캡슐의 이름을 적어주세요 (최대 15자)") + + + return textField + }() + let locationSelectView = SelectButton(text: "주소를 선택하세요") let dateSelectView = SelectButton(text: "날짜를 선택하세요") diff --git a/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/CapsuleCreateViewController.swift b/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/CapsuleCreateViewController.swift index 07c8d5f..7ca6ba0 100644 --- a/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/CapsuleCreateViewController.swift +++ b/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/CapsuleCreateViewController.swift @@ -44,6 +44,8 @@ final class CapsuleCreateViewController: UIViewController, BaseViewController { setUpNavigation() addSubViews() makeConstraints() + + mainView.titleTextField.delegate = self mainView.imageCollectionView.applyDataSource() @@ -256,7 +258,7 @@ extension CapsuleCreateViewController: PHPickerViewControllerDelegate { return } - itemProvider.loadObject(ofClass: UIImage.self) { [weak self] image, _ in + itemProvider.loadObject(ofClass: UIImage.self) { image, _ in guard let selectedImage = image as? UIImage, let data = selectedImage.jpegData(compressionQuality: 0.2) else { dispatchGroup.leave() @@ -272,8 +274,20 @@ extension CapsuleCreateViewController: PHPickerViewControllerDelegate { let orderedData = dataDict .sorted(by: { $0.key < $1.key }) .compactMap { $0.value } - + self?.viewModel?.addImage(orderedData: orderedData) } } } + +extension CapsuleCreateViewController: UITextFieldDelegate { + func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { + guard let textValue = textField.text else { + return false + } + let currentString = textValue as NSString + let newString = currentString.replacingCharacters(in: range, with: string) as NSString + + return newString.length <= 15 + } +} From 6a931df4ae833a97bb8bc5fd7ed2498bb766bba7 Mon Sep 17 00:00:00 2001 From: trumanfromkorea Date: Mon, 12 Dec 2022 16:45:33 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[fix]=20=EC=82=AC=EC=A7=84=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EC=8B=9C=20EmptyView=20=EC=B6=9C=EB=A0=A5=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0=20(#103)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Extensions/KingReceiver+UIImageView.swift | 9 +++++++-- .../KingReceiver/Extensions/UIImage+resize.swift | 3 ++- .../CapsuleCreate/CapsuleCreateView.swift | 3 +-- .../CapsuleCreateViewController.swift | 16 ++++++++-------- .../CapsuleCreate/Components/AddImageCell.swift | 13 +++++++++---- 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/SpaceCapsule/SpaceCapsule/Manager/KingReceiver/Extensions/KingReceiver+UIImageView.swift b/SpaceCapsule/SpaceCapsule/Manager/KingReceiver/Extensions/KingReceiver+UIImageView.swift index 0f26f62..bdda65c 100644 --- a/SpaceCapsule/SpaceCapsule/Manager/KingReceiver/Extensions/KingReceiver+UIImageView.swift +++ b/SpaceCapsule/SpaceCapsule/Manager/KingReceiver/Extensions/KingReceiver+UIImageView.swift @@ -46,8 +46,13 @@ extension KingReceiverWrapper where Base: UIImageView { } } - func setImage(with data: Data, placeholder: UIImage? = nil, width: CGFloat, scale: CGFloat = 1) { - guard let image = UIImage.resize(data: data, to: base.frame.size, scale: scale) else { + func setImage( + with data: Data, + placeholder: UIImage? = nil, + to targetSize: CGSize, + scale: CGFloat = 1 + ) { + guard let image = UIImage.resize(data: data, to: targetSize, scale: scale) else { base.image = placeholder return } diff --git a/SpaceCapsule/SpaceCapsule/Manager/KingReceiver/Extensions/UIImage+resize.swift b/SpaceCapsule/SpaceCapsule/Manager/KingReceiver/Extensions/UIImage+resize.swift index 725ad95..788f3ab 100644 --- a/SpaceCapsule/SpaceCapsule/Manager/KingReceiver/Extensions/UIImage+resize.swift +++ b/SpaceCapsule/SpaceCapsule/Manager/KingReceiver/Extensions/UIImage+resize.swift @@ -21,8 +21,9 @@ extension UIImage { kCGImageSourceCreateThumbnailWithTransform: true, kCGImageSourceThumbnailMaxPixelSize: maxDimension, ] as CFDictionary - + guard let resizedImage = CGImageSourceCreateThumbnailAtIndex(imageSource, 0, resizingOptions) else { + print("resized error") return nil } diff --git a/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/CapsuleCreateView.swift b/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/CapsuleCreateView.swift index bac2ac4..d19900a 100644 --- a/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/CapsuleCreateView.swift +++ b/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/CapsuleCreateView.swift @@ -36,8 +36,7 @@ final class CapsuleCreateView: UIView, BaseView { let titleTextField: ThemeTextField = { let textField = ThemeTextField(placeholder: "추억하고 싶은 캡슐의 이름을 적어주세요 (최대 15자)") - - + return textField }() diff --git a/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/CapsuleCreateViewController.swift b/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/CapsuleCreateViewController.swift index 7ca6ba0..9758a6d 100644 --- a/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/CapsuleCreateViewController.swift +++ b/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/CapsuleCreateViewController.swift @@ -44,14 +44,7 @@ final class CapsuleCreateViewController: UIViewController, BaseViewController { setUpNavigation() addSubViews() makeConstraints() - - mainView.titleTextField.delegate = self - - mainView.imageCollectionView.applyDataSource() - - addTapGestureRecognizer() - scrollView.addKeyboardNotification() - + configure() bind() } @@ -62,6 +55,13 @@ final class CapsuleCreateViewController: UIViewController, BaseViewController { scrollView.removeKeyboardNotification() } + private func configure() { + mainView.titleTextField.delegate = self + mainView.imageCollectionView.applyDataSource() + addTapGestureRecognizer() + scrollView.addKeyboardNotification() + } + func bind() { closeButton.rx.tap .withUnretained(self) diff --git a/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/Components/AddImageCell.swift b/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/Components/AddImageCell.swift index 1cb6721..f536e71 100644 --- a/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/Components/AddImageCell.swift +++ b/SpaceCapsule/SpaceCapsule/Scene/TabBar/CapsuleAdd/CapsuleCreate/Components/AddImageCell.swift @@ -11,16 +11,16 @@ import UIKit final class AddImageCell: UICollectionViewCell { let imageView: UIImageView = { let imageView = UIImageView() - imageView.contentMode = .scaleAspectFit + imageView.contentMode = .scaleAspectFill return imageView }() override init(frame: CGRect) { super.init(frame: frame) - + backgroundColor = .themeBlack - + addSubViews() makeConstraints() } @@ -31,7 +31,12 @@ final class AddImageCell: UICollectionViewCell { } func configure(data: Data) { - imageView.kr.setImage(with: data, placeholder: .empty, width: frame.size.width) + imageView.kr.setImage( + with: data, + placeholder: .empty, + to: frame.size, + scale: FrameResource.openableImageScale + ) } private func addSubViews() { From 8b83b149ad6f740655be4d0f8d42917c87c48685 Mon Sep 17 00:00:00 2001 From: trumanfromkorea Date: Mon, 12 Dec 2022 17:02:15 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[fix]=20=EC=95=8C=EB=A6=BC,=20=EC=9C=84?= =?UTF-8?q?=EC=B9=98=EC=A0=95=EB=B3=B4=20=EC=84=A4=EC=A0=95=20=ED=81=B4?= =?UTF-8?q?=EB=A6=AD=20=EC=8B=9C=20=EC=84=A4=EC=A0=95=EC=95=B1=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20(#103)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Profile/ProfileViewController.swift | 67 +++++-------------- 1 file changed, 18 insertions(+), 49 deletions(-) diff --git a/SpaceCapsule/SpaceCapsule/Scene/TabBar/Profile/ProfileViewController.swift b/SpaceCapsule/SpaceCapsule/Scene/TabBar/Profile/ProfileViewController.swift index b4bd595..5bc99f9 100644 --- a/SpaceCapsule/SpaceCapsule/Scene/TabBar/Profile/ProfileViewController.swift +++ b/SpaceCapsule/SpaceCapsule/Scene/TabBar/Profile/ProfileViewController.swift @@ -38,31 +38,27 @@ final class ProfileViewController: UIViewController, BaseViewController { } func bind() { - guard let viewModel else { - return - } - profileView.notificationButton.rx.tap - .bind { - viewModel.input.tapSetupNotification.onNext(()) + .bind { [weak self] in + self?.viewModel?.input.tapSetupNotification.onNext(()) } .disposed(by: disposeBag) profileView.settingButton.rx.tap - .bind { - viewModel.input.tapSetting.onNext(()) + .bind { [weak self] in + self?.viewModel?.input.tapSetting.onNext(()) } .disposed(by: disposeBag) profileView.signOutButton.rx.tap - .bind { - viewModel.input.tapSignOut.onNext(()) + .bind { [weak self] in + self?.viewModel?.input.tapSignOut.onNext(()) } .disposed(by: disposeBag) profileView.deleteAccountButton.rx.tap - .bind { - viewModel.input.tapWithdrawal.onNext(()) + .bind { [weak self] in + self?.viewModel?.input.tapWithdrawal.onNext(()) } .disposed(by: disposeBag) @@ -77,28 +73,18 @@ final class ProfileViewController: UIViewController, BaseViewController { guard let viewModel else { return } + viewModel.input.tapSetupNotification .withUnretained(self) .bind { owner, _ in - NotificationManager.shared.checkNotificationAuthorization { isAuthorized in - if isAuthorized { - owner.showAlreadyAllowed(type: .notification) - } else { - owner.showRequestAuthorization(type: .notification) - } - } + owner.showSettings(type: UIApplication.openNotificationSettingsURLString) } .disposed(by: disposeBag) + viewModel.input.tapSetting .withUnretained(self) .bind { owner, _ in - LocationManager.shared.checkLocationAuthorization { isAuthorized in - if isAuthorized { - owner.showAlreadyAllowed(type: .location) - } else { - owner.showRequestAuthorization(type: .location) - } - } + owner.showSettings(type: UIApplication.openSettingsURLString) } .disposed(by: disposeBag) @@ -138,29 +124,12 @@ final class ProfileViewController: UIViewController, BaseViewController { alertController.addAction(acceptAction) present(alertController, animated: true, completion: nil) } - - private func showAlreadyAllowed(type: Authorization) { - let alertController = UIAlertController(title: type.description, message: "이미 동의하셨습니다.", preferredStyle: .alert) - let acceptAction = UIAlertAction(title: "확인", style: .default, handler: nil) - alertController.addAction(acceptAction) - DispatchQueue.main.async { [weak self] in - self?.present(alertController, animated: true, completion: nil) - } - } - - private func showRequestAuthorization(type: Authorization) { - guard let url = URL(string: UIApplication.openSettingsURLString) else { - return - } - let alertController = UIAlertController(title: type.description, message: "앱 설정에서 \(type.description)을 허용해주세요.", preferredStyle: .alert) - let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) - let acceptAction = UIAlertAction(title: "OK", style: .default, handler: { _ in - UIApplication.shared.open(url) - }) - alertController.addAction(cancelAction) - alertController.addAction(acceptAction) - DispatchQueue.main.async { [weak self] in - self?.present(alertController, animated: true, completion: nil) + + private func showSettings(type: String) { + guard let url = URL(string: type) else { + return } + + UIApplication.shared.open(url) } }