From d1433e7e11b9c8e007f772d0e40081b8c979d0b7 Mon Sep 17 00:00:00 2001 From: LeeMyeongJin Date: Tue, 17 Oct 2023 01:42:43 +0900 Subject: [PATCH 1/8] =?UTF-8?q?[Feat]=20#200=20-=20=EB=B0=94=ED=85=80=20?= =?UTF-8?q?=EC=8B=9C=ED=8A=B8=20=ED=83=80=EC=9E=85,=20=EC=86=8D=EC=84=B1?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Global/UIComponents/CustomBottomSheetVC.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift index ed67043c..427fe81b 100644 --- a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift +++ b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift @@ -8,10 +8,24 @@ import UIKit import Combine +@frozen +enum SheetType { + case Image // 가운에 이미지가 있는 시트 + case TextField // 가운데 텍스트필드가 있는 시트 +} + final class CustomBottomSheetVC: UIViewController { // MARK: - Properties + private let backgroundView = UIView().then { + $0.backgroundColor = .black.withAlphaComponent(0.7) + } + private let titleNameMaxLength = 20 + private var BottomsheetType: SheetType! + + var backgroundTapAction: (() -> Void)? + var completeButtonTapped: Driver { completeButton.publisher(for: .touchUpInside) .map { _ in } From 0a8001cb57f32c2850eaf5a30551e0ed610700be Mon Sep 17 00:00:00 2001 From: LeeMyeongJin Date: Tue, 17 Oct 2023 01:43:23 +0900 Subject: [PATCH 2/8] =?UTF-8?q?[Feat]=20#200=20-=20=EB=B0=94=ED=85=80=20?= =?UTF-8?q?=EC=8B=9C=ED=8A=B8=20=ED=83=80=EC=9E=85,=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EC=9E=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UIComponents/CustomBottomSheetVC.swift | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift index 427fe81b..60908684 100644 --- a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift +++ b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift @@ -41,24 +41,52 @@ final class CustomBottomSheetVC: UIViewController { } private let contentsLabel = UILabel().then { - $0.text = "수고하셨습니다! 러닝을 완료했어요!" + $0.text = "코스 이름" $0.font = .h5 - $0.textColor = .g2 + $0.textColor = .g1 } + private let completeButton = CustomButton(title: "완료").setColor(bgColor: .m1, disableColor: .g3).setEnabled(false) + private let mainImageView = UIImageView().then { $0.image = ImageLiterals.imgSpaceship } - private let completeButton = CustomButton(title: "기록 보러 가기") + private lazy var bottomSheetTextField = UITextField().then { + let paragraphStyle = NSMutableParagraphStyle() + paragraphStyle.alignment = .center + $0.attributedPlaceholder = NSAttributedString(string: "코스의 이름을 입력해 주세요", attributes: [.font: UIFont.h5, .foregroundColor: UIColor.g3, .paragraphStyle: paragraphStyle]) + $0.font = .h5 + $0.textColor = .g1 + $0.textAlignment = .center + $0.layer.cornerRadius = 10 + $0.layer.borderWidth = 1 + $0.layer.borderColor = UIColor.g3.cgColor + $0.addTarget(self, action: #selector(textFieldTextDidChange), for: .editingChanged) + } + + // MARK: - initializtion + init(type: SheetType) { + super.init(nibName: nil, bundle: nil) + self.BottomsheetType = type + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } // MARK: - View Life Cycle override func viewDidLoad() { super.viewDidLoad() self.setUI() - self.setLayout() + self.setLayout(BottomsheetType) + self.setDelegate() + self.setTapGesture() + self.setAddTarget() + } + } // MARK: - Methods From fa63764fc0a5b5e85bec5de9de7abfb163d76b63 Mon Sep 17 00:00:00 2001 From: LeeMyeongJin Date: Tue, 17 Oct 2023 01:44:14 +0900 Subject: [PATCH 3/8] =?UTF-8?q?[Feat]=20#200=20-=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80,=20=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=EB=82=98=EB=88=84=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UIComponents/CustomBottomSheetVC.swift | 56 ++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift index 60908684..bb0a99df 100644 --- a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift +++ b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift @@ -106,16 +106,68 @@ extension CustomBottomSheetVC { self.completeButton.changeTitle(attributedString: title) return self } + + /// 이미지 교체 + @discardableResult + public func setImage(_ image: UIImage) -> Self { + self.mainImageView.image = image + return self + } + + private func setDelegate() { + bottomSheetTextField.delegate = self + } + + private func dismissBottomSheet() { + UIView.animate(withDuration: 0.25, delay: 0, options: .curveEaseOut, animations: { + self.view.layoutIfNeeded() + self.backgroundTapAction?() + }, completion: nil) + } + + private func setTapGesture() { + let tap = UITapGestureRecognizer(target: view, action: #selector(UIView.endEditing)) + tap.cancelsTouchesInView = false + view.addGestureRecognizer(tap) + + let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleBackgroundTap)) + backgroundView.addGestureRecognizer(tapGesture) + } + + private func setAddTarget() { + NotificationCenter.default.addObserver( + self, + selector: #selector(keyboardWillShow), + name: UIResponder.keyboardWillShowNotification, + object: nil) + NotificationCenter.default.addObserver( + self, + selector: #selector(keyboardWillHide), + name: UIResponder.keyboardWillHideNotification, + object: nil) + } } // MARK: - UI & Layout extension CustomBottomSheetVC { private func setUI() { - view.backgroundColor = .black.withAlphaComponent(0.8) + view.addSubview(backgroundView) + backgroundView.snp.makeConstraints { make in + make.edges.equalToSuperview() + } + } + + private func setLayout(_ type: SheetType) { + switch type { + case .Image: + setImageLayout() + case .TextField: + setTextFieldLayout() + } } - private func setLayout() { + private func setImageLayout() { view.addSubviews(bottomSheetView) bottomSheetView.addSubviews(contentsLabel, mainImageView, completeButton) From 5022f432af00c02d194388c8fba8a25ea3ae572e Mon Sep 17 00:00:00 2001 From: LeeMyeongJin Date: Tue, 17 Oct 2023 01:45:43 +0900 Subject: [PATCH 4/8] =?UTF-8?q?[Feat]=20#200=20-=20=EB=A0=88=EC=9D=B4?= =?UTF-8?q?=EC=95=84=EC=9B=83,=20=EB=A9=94=EC=84=9C=EB=93=9C,=20Delegate?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UIComponents/CustomBottomSheetVC.swift | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift index bb0a99df..b3926b59 100644 --- a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift +++ b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift @@ -194,4 +194,81 @@ extension CustomBottomSheetVC { make.leading.trailing.equalToSuperview().inset(16) } } + + private func setTextFieldLayout() { + view.addSubviews(bottomSheetView) + bottomSheetView.addSubviews(contentsLabel, bottomSheetTextField, completeButton) + + bottomSheetView.snp.makeConstraints { make in + make.leading.bottom.trailing.equalToSuperview() + make.height.equalTo(241) + } + + contentsLabel.snp.makeConstraints { make in + make.centerX.equalToSuperview() + make.top.equalToSuperview().inset(34) + } + + bottomSheetTextField.snp.makeConstraints { make in + make.centerX.equalToSuperview() + make.top.equalTo(contentsLabel.snp.bottom).offset(19) + make.leading.trailing.equalToSuperview().inset(16) + make.height.equalTo(44) + } + + completeButton.snp.makeConstraints { make in + make.top.equalTo(bottomSheetTextField.snp.bottom).offset(10) + make.height.equalTo(44) + make.leading.trailing.equalToSuperview().inset(16) + } + } +} + +// MARK: - @objc Function + +extension CustomBottomSheetVC { + @objc private func keyboardWillShow(_ sender: Notification) { + self.view.frame.origin.y = -241 + } + + @objc private func keyboardWillHide(_ sender: Notification) { + self.view.frame.origin.y = 0 + } + + @objc private func endEditing() { /// return 누를시 키보드 종료 + bottomSheetTextField.resignFirstResponder() + } + + @objc private func handleBackgroundTap() { + dismissBottomSheet() + } + + @objc private func textFieldTextDidChange() { + guard let text = bottomSheetTextField.text else { return } + + completeButton.isEnabled = !text.isEmpty + changeTextFieldLayerColor(!text.isEmpty) + + if text.count > titleNameMaxLength { + let index = text.index(text.startIndex, offsetBy: titleNameMaxLength) + let newString = text[text.startIndex.. Bool { + textField.resignFirstResponder() + return true + } + + private func changeTextFieldLayerColor(_ isEditing: Bool) { + bottomSheetTextField.layer.borderColor = isEditing ? UIColor.m1.cgColor : UIColor.g3.cgColor + } } From e4d747c06a6dfc0cac1b4bd6d123e53773f933e3 Mon Sep 17 00:00:00 2001 From: LeeMyeongJin Date: Sat, 21 Oct 2023 19:32:16 +0900 Subject: [PATCH 5/8] =?UTF-8?q?[Feat]=20#200=20-=20type=20=EC=97=90=20?= =?UTF-8?q?=EB=94=B0=EB=9D=BC=20=EC=BD=94=EB=93=9C=20=EB=B6=84=EB=A5=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UIComponents/CustomBottomSheetVC.swift | 97 +++++++++++++++++-- 1 file changed, 90 insertions(+), 7 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift index b3926b59..334d87d8 100644 --- a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift +++ b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift @@ -19,7 +19,7 @@ final class CustomBottomSheetVC: UIViewController { // MARK: - Properties private let backgroundView = UIView().then { - $0.backgroundColor = .black.withAlphaComponent(0.7) + $0.backgroundColor = .black.withAlphaComponent(0.65) } private let titleNameMaxLength = 20 private var BottomsheetType: SheetType! @@ -31,6 +31,11 @@ final class CustomBottomSheetVC: UIViewController { .map { _ in } .asDriver() } + // 바텀 시트 높이 + let bottomHeight: CGFloat = 241 + + // bottomSheet가 view의 상단에서 떨어진 거리 + private var bottomSheetViewTopConstraint: NSLayoutConstraint! // MARK: - UI Components @@ -46,6 +51,11 @@ final class CustomBottomSheetVC: UIViewController { $0.textColor = .g1 } + private let dismissIndicatorView = UIView().then { + $0.backgroundColor = .g3 + $0.layer.cornerRadius = 3 + } + private let completeButton = CustomButton(title: "완료").setColor(bgColor: .m1, disableColor: .g3).setEnabled(false) private let mainImageView = UIImageView().then { @@ -84,7 +94,10 @@ final class CustomBottomSheetVC: UIViewController { self.setDelegate() self.setTapGesture() self.setAddTarget() - + if BottomsheetType == .TextField { + showBottomSheet() + setupGestureRecognizer() + } } } @@ -121,7 +134,6 @@ extension CustomBottomSheetVC { private func dismissBottomSheet() { UIView.animate(withDuration: 0.25, delay: 0, options: .curveEaseOut, animations: { self.view.layoutIfNeeded() - self.backgroundTapAction?() }, completion: nil) } @@ -160,10 +172,10 @@ extension CustomBottomSheetVC { private func setLayout(_ type: SheetType) { switch type { - case .Image: - setImageLayout() case .TextField: setTextFieldLayout() + case .Image: + setImageLayout() } } @@ -197,11 +209,22 @@ extension CustomBottomSheetVC { private func setTextFieldLayout() { view.addSubviews(bottomSheetView) - bottomSheetView.addSubviews(contentsLabel, bottomSheetTextField, completeButton) + let topConstant = view.safeAreaInsets.bottom + view.safeAreaLayoutGuide.layoutFrame.height + bottomSheetViewTopConstraint = bottomSheetView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: topConstant) + bottomSheetView.addSubviews(contentsLabel, bottomSheetTextField, dismissIndicatorView, completeButton) bottomSheetView.snp.makeConstraints { make in make.leading.bottom.trailing.equalToSuperview() - make.height.equalTo(241) + make.height.equalTo(bottomHeight) + } + + NSLayoutConstraint.activate([bottomSheetViewTopConstraint]) + + dismissIndicatorView.snp.makeConstraints { make in + make.width.equalTo(102) + make.height.equalTo(7) + make.top.equalTo(bottomSheetView.snp.top).inset(12) + make.centerX.equalToSuperview() } contentsLabel.snp.makeConstraints { make in @@ -222,11 +245,54 @@ extension CustomBottomSheetVC { make.leading.trailing.equalToSuperview().inset(16) } } + + private func showBottomSheet() { + + let safeAreaHeight: CGFloat = view.safeAreaLayoutGuide.layoutFrame.height + let bottomPadding: CGFloat = view.safeAreaInsets.bottom + + bottomSheetViewTopConstraint.constant = (safeAreaHeight + bottomPadding) - bottomHeight + + UIView.animate(withDuration: 0.25, delay: 0, options: .curveEaseIn, animations: { + self.backgroundView.alpha = 0.65 + self.view.layoutIfNeeded() + }, completion: nil) + + } + + // 바텀 시트 사라지는 애니메이션 + private func hideBottomSheetAndGoBack() { + let safeAreaHeight = view.safeAreaLayoutGuide.layoutFrame.height + let bottomPadding = view.safeAreaInsets.bottom + bottomSheetViewTopConstraint.constant = safeAreaHeight + bottomPadding + UIView.animate(withDuration: 0.25, delay: 0, options: .curveEaseIn, animations: { + self.backgroundView.alpha = 0.0 + self.view.layoutIfNeeded() + }) { _ in + if self.presentingViewController != nil { + self.dismiss(animated: false, completion: nil) + } + } + } + + // GestureRecognizer 세팅 작업 + private func setupGestureRecognizer() { + // 흐린 부분 탭할 때, 바텀시트를 내리는 TapGesture + let dimmedTap = UITapGestureRecognizer(target: self, action: #selector(dimmedViewTapped(_:))) + backgroundView.addGestureRecognizer(dimmedTap) + backgroundView.isUserInteractionEnabled = true + + // 스와이프 했을 때, 바텀시트를 내리는 swipeGesture + let swipeGesture = UISwipeGestureRecognizer(target: self, action: #selector(panGesture)) + swipeGesture.direction = .down + view.addGestureRecognizer(swipeGesture) + } } // MARK: - @objc Function extension CustomBottomSheetVC { + @objc private func keyboardWillShow(_ sender: Notification) { self.view.frame.origin.y = -241 } @@ -256,6 +322,23 @@ extension CustomBottomSheetVC { self.showToast(message: "20자가 넘어갑니다") } } + + // UITapGestureRecognizer 연결 함수 부분 + @objc private func dimmedViewTapped(_ tapRecognizer: UITapGestureRecognizer) { + hideBottomSheetAndGoBack() + } + + // UISwipeGestureRecognizer 연결 함수 부분 + @objc func panGesture(_ recognizer: UISwipeGestureRecognizer) { + if recognizer.state == .ended { + switch recognizer.direction { + case .down: + hideBottomSheetAndGoBack() + default: + break + } + } + } } From 15e7e9f21a38a5ab0fc0f8dea1e20183f723c8b9 Mon Sep 17 00:00:00 2001 From: LeeMyeongJin Date: Mon, 6 Nov 2023 22:18:52 +0900 Subject: [PATCH 6/8] =?UTF-8?q?[Feat]=20#200=20-=20keyborad=20=EC=9C=84?= =?UTF-8?q?=EC=B9=98=20=EC=86=8D=EC=84=B1=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift index 334d87d8..2310896e 100644 --- a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift +++ b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift @@ -294,7 +294,7 @@ extension CustomBottomSheetVC { extension CustomBottomSheetVC { @objc private func keyboardWillShow(_ sender: Notification) { - self.view.frame.origin.y = -241 + self.view.frame.origin.y = -341 } @objc private func keyboardWillHide(_ sender: Notification) { From f003425ba0f08ecabf89309c36a966756e36e003 Mon Sep 17 00:00:00 2001 From: LeeMyeongJin Date: Mon, 6 Nov 2023 22:31:47 +0900 Subject: [PATCH 7/8] =?UTF-8?q?[Chore]=20#200=20-=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=9C=84=EC=B9=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj | 8 ++++---- .../Global/UIComponents/CustomBottomSheetVC.swift | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj index 47b9d4dc..6360f34f 100644 --- a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj +++ b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 0AEBD608F3973389E8E1C6D6 /* Pods_Runnect_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 015778D02D5CDE0838284CD7 /* Pods_Runnect_iOS.framework */; }; 712F661D2A7B7BAB00D9539B /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 712F661C2A7B7BAB00D9539B /* Config.swift */; }; + 7136BF8A2AF921A900679364 /* CustomBottomSheetVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7136BF892AF921A900679364 /* CustomBottomSheetVC.swift */; }; 71DBF23E2ABB255A0013415B /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 71DBF23D2ABB255A0013415B /* GoogleService-Info.plist */; }; A3305A97296EF58C000B1A10 /* GoalRewardInfoDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3305A96296EF58C000B1A10 /* GoalRewardInfoDto.swift */; }; A3BC2F2B2962C3D500198261 /* GoalRewardInfoVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3BC2F2A2962C3D500198261 /* GoalRewardInfoVC.swift */; }; @@ -43,7 +44,6 @@ CE102C4A29DBAD3D00E23E69 /* AuthInterceptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE102C4929DBAD3D00E23E69 /* AuthInterceptor.swift */; }; CE146770296568DC00DCEA1B /* RunTrackingVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE14676F296568DC00DCEA1B /* RunTrackingVC.swift */; }; CE14677829658C7200DCEA1B /* Stopwatch.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE14677729658C7200DCEA1B /* Stopwatch.swift */; }; - CE14677A2965A80700DCEA1B /* CustomBottomSheetVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1467792965A80700DCEA1B /* CustomBottomSheetVC.swift */; }; CE14677C2965C1B100DCEA1B /* RunningRecordVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE14677B2965C1B100DCEA1B /* RunningRecordVC.swift */; }; CE15F5A4296C932E0023827C /* RunningModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE15F5A3296C932E0023827C /* RunningModel.swift */; }; CE17F02D2961BBA100E1DED0 /* ColorLiterals.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE17F02C2961BBA100E1DED0 /* ColorLiterals.swift */; }; @@ -166,6 +166,7 @@ 3C3033C911343B5C57EB68E7 /* Pods-Runnect-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runnect-iOS.debug.xcconfig"; path = "Target Support Files/Pods-Runnect-iOS/Pods-Runnect-iOS.debug.xcconfig"; sourceTree = ""; }; 7110A6032AA337DD009A7E99 /* Runnect-iOSDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Runnect-iOSDebug.entitlements"; sourceTree = ""; }; 712F661C2A7B7BAB00D9539B /* Config.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = ""; }; + 7136BF892AF921A900679364 /* CustomBottomSheetVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomBottomSheetVC.swift; sourceTree = ""; }; 71DBF23D2ABB255A0013415B /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "../../../../Runnect-iOS/Runnect-iOS/Runnect-iOS/GoogleService-Info.plist"; sourceTree = ""; }; A3305A96296EF58C000B1A10 /* GoalRewardInfoDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoalRewardInfoDto.swift; sourceTree = ""; }; A3BC2F2A2962C3D500198261 /* GoalRewardInfoVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoalRewardInfoVC.swift; sourceTree = ""; }; @@ -206,7 +207,6 @@ CE102C4929DBAD3D00E23E69 /* AuthInterceptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthInterceptor.swift; sourceTree = ""; }; CE14676F296568DC00DCEA1B /* RunTrackingVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunTrackingVC.swift; sourceTree = ""; }; CE14677729658C7200DCEA1B /* Stopwatch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Stopwatch.swift; sourceTree = ""; }; - CE1467792965A80700DCEA1B /* CustomBottomSheetVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomBottomSheetVC.swift; sourceTree = ""; }; CE14677B2965C1B100DCEA1B /* RunningRecordVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunningRecordVC.swift; sourceTree = ""; }; CE15F5A3296C932E0023827C /* RunningModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunningModel.swift; sourceTree = ""; }; CE17F02C2961BBA100E1DED0 /* ColorLiterals.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorLiterals.swift; sourceTree = ""; }; @@ -1042,8 +1042,8 @@ CEC2A6882962ADB900160BF7 /* MapView */, CEEC6B4A2961D89700D00E1E /* CustomNavigationBar.swift */, CEC2A6842961F92C00160BF7 /* CustomButton.swift */, + 7136BF892AF921A900679364 /* CustomBottomSheetVC.swift */, CE0D9FD229648DA300CEB5CD /* CustomAlertVC.swift */, - CE1467792965A80700DCEA1B /* CustomBottomSheetVC.swift */, CE9291242965C9FB0010959C /* CourseDetailInfoView.swift */, CE9291262965D0ED0010959C /* StatsInfoView.swift */, CE6B63D729673450003F900F /* ListEmptyView.swift */, @@ -1378,6 +1378,7 @@ CE14677C2965C1B100DCEA1B /* RunningRecordVC.swift in Sources */, CE6B63D829673450003F900F /* ListEmptyView.swift in Sources */, CE6655F6295D90B600C64E12 /* addToolBar.swift in Sources */, + 7136BF8A2AF921A900679364 /* CustomBottomSheetVC.swift in Sources */, A3C2CAD529E4F85400EC525B /* PersonalInfoVC.swift in Sources */, DAD5A3DA296C6DA500C8166B /* TitleCollectionViewCell.swift in Sources */, CEC2A68A2962ADCD00160BF7 /* RNMapView.swift in Sources */, @@ -1446,7 +1447,6 @@ A3BC2F4129667A0D00198261 /* NicknameEditorVC.swift in Sources */, CE0C23742966D62A00B45063 /* PagedView.swift in Sources */, CE3A53C5296C6017003D518C /* KeychainManager.swift in Sources */, - CE14677A2965A80700DCEA1B /* CustomBottomSheetVC.swift in Sources */, CEEC6B4B2961D89700D00E1E /* CustomNavigationBar.swift in Sources */, CE09037D296E9ED900BEA710 /* ScrapCourseResponseDto.swift in Sources */, CED791B32A2626AF001BFCFB /* ShadowView.swift in Sources */, diff --git a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift index 2310896e..a6829c8a 100644 --- a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift +++ b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift @@ -2,7 +2,7 @@ // CustomBottomSheetVC.swift // Runnect-iOS // -// Created by sejin on 2023/01/04. +// Created by 이명진 on 11/6/23. // import UIKit From 46ec36d37cadcf4ecfce20cf938a2bc0617b8666 Mon Sep 17 00:00:00 2001 From: LeeMyeongJin Date: Mon, 13 Nov 2023 02:16:56 +0900 Subject: [PATCH 8/8] =?UTF-8?q?[Refactor]=20#200=20-=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EB=A6=AC=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UIComponents/CustomBottomSheetVC.swift | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift index a6829c8a..42069943 100644 --- a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift +++ b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomBottomSheetVC.swift @@ -32,10 +32,7 @@ final class CustomBottomSheetVC: UIViewController { .asDriver() } // 바텀 시트 높이 - let bottomHeight: CGFloat = 241 - - // bottomSheet가 view의 상단에서 떨어진 거리 - private var bottomSheetViewTopConstraint: NSLayoutConstraint! + let bottomHeight: CGFloat = 206 // MARK: - UI Components @@ -137,6 +134,7 @@ extension CustomBottomSheetVC { }, completion: nil) } + // 중복 작업 통일 필요 (1. 배경화면 누를시, 2.스와이프 할시) private func setTapGesture() { let tap = UITapGestureRecognizer(target: view, action: #selector(UIView.endEditing)) tap.cancelsTouchesInView = false @@ -209,17 +207,17 @@ extension CustomBottomSheetVC { private func setTextFieldLayout() { view.addSubviews(bottomSheetView) - let topConstant = view.safeAreaInsets.bottom + view.safeAreaLayoutGuide.layoutFrame.height - bottomSheetViewTopConstraint = bottomSheetView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: topConstant) + + let topConst = view.safeAreaInsets.bottom + view.safeAreaLayoutGuide.layoutFrame.height + bottomSheetView.addSubviews(contentsLabel, bottomSheetTextField, dismissIndicatorView, completeButton) bottomSheetView.snp.makeConstraints { make in make.leading.bottom.trailing.equalToSuperview() + make.top.equalTo(view.snp.top).offset(topConst) make.height.equalTo(bottomHeight) } - NSLayoutConstraint.activate([bottomSheetViewTopConstraint]) - dismissIndicatorView.snp.makeConstraints { make in make.width.equalTo(102) make.height.equalTo(7) @@ -251,7 +249,13 @@ extension CustomBottomSheetVC { let safeAreaHeight: CGFloat = view.safeAreaLayoutGuide.layoutFrame.height let bottomPadding: CGFloat = view.safeAreaInsets.bottom - bottomSheetViewTopConstraint.constant = (safeAreaHeight + bottomPadding) - bottomHeight + let topConst = (safeAreaHeight + bottomPadding) - bottomHeight + + bottomSheetView.snp.remakeConstraints { make in + make.leading.bottom.trailing.equalToSuperview() + make.top.equalTo(view.snp.top).offset(topConst) + make.height.equalTo(bottomHeight) + } UIView.animate(withDuration: 0.25, delay: 0, options: .curveEaseIn, animations: { self.backgroundView.alpha = 0.65 @@ -264,7 +268,15 @@ extension CustomBottomSheetVC { private func hideBottomSheetAndGoBack() { let safeAreaHeight = view.safeAreaLayoutGuide.layoutFrame.height let bottomPadding = view.safeAreaInsets.bottom - bottomSheetViewTopConstraint.constant = safeAreaHeight + bottomPadding + + let topConst = (safeAreaHeight + bottomPadding) + + bottomSheetView.snp.remakeConstraints { make in + make.leading.bottom.trailing.equalToSuperview() + make.top.equalTo(view.snp.top).offset(topConst) + make.height.equalTo(bottomHeight) + } + UIView.animate(withDuration: 0.25, delay: 0, options: .curveEaseIn, animations: { self.backgroundView.alpha = 0.0 self.view.layoutIfNeeded()