diff --git a/fit-a-pet-client/fit-a-pet-client.xcodeproj/project.pbxproj b/fit-a-pet-client/fit-a-pet-client.xcodeproj/project.pbxproj index 15ae14eb..d8a1d16c 100644 --- a/fit-a-pet-client/fit-a-pet-client.xcodeproj/project.pbxproj +++ b/fit-a-pet-client/fit-a-pet-client.xcodeproj/project.pbxproj @@ -62,7 +62,7 @@ 4A9936542B64231B00B7B21A /* CalendarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A9936532B64231B00B7B21A /* CalendarView.swift */; }; 4A9936562B642A0800B7B21A /* CalendarPanModalVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A9936552B642A0800B7B21A /* CalendarPanModalVC.swift */; }; 4A9936582B642B7E00B7B21A /* CustomVerticalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A9936572B642B7E00B7B21A /* CustomVerticalView.swift */; }; - 4A99365A2B65309F00B7B21A /* PanModalDateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A9936592B65309F00B7B21A /* PanModalDateView.swift */; }; + 4A99365A2B65309F00B7B21A /* CalendarDateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A9936592B65309F00B7B21A /* CalendarDateView.swift */; }; 4AA999922A8485A500E495FA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AA999912A8485A500E495FA /* AppDelegate.swift */; }; 4AA999942A8485A500E495FA /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AA999932A8485A500E495FA /* SceneDelegate.swift */; }; 4AA999962A8485A500E495FA /* FirstVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AA999952A8485A500E495FA /* FirstVC.swift */; }; @@ -154,7 +154,7 @@ 4A9936532B64231B00B7B21A /* CalendarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarView.swift; sourceTree = ""; }; 4A9936552B642A0800B7B21A /* CalendarPanModalVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarPanModalVC.swift; sourceTree = ""; }; 4A9936572B642B7E00B7B21A /* CustomVerticalView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomVerticalView.swift; sourceTree = ""; }; - 4A9936592B65309F00B7B21A /* PanModalDateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PanModalDateView.swift; sourceTree = ""; }; + 4A9936592B65309F00B7B21A /* CalendarDateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarDateView.swift; sourceTree = ""; }; 4AA9998E2A8485A500E495FA /* fit-a-pet-client.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "fit-a-pet-client.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 4AA999912A8485A500E495FA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 4AA999932A8485A500E495FA /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -275,7 +275,7 @@ children = ( 4A9936512B64230600B7B21A /* CalendarHeaderView.swift */, 4A9936532B64231B00B7B21A /* CalendarView.swift */, - 4A9936592B65309F00B7B21A /* PanModalDateView.swift */, + 4A9936592B65309F00B7B21A /* CalendarDateView.swift */, ); path = CalendarVCView; sourceTree = ""; @@ -329,8 +329,8 @@ 4ACDD49A2AD9A9F600CD8F1A /* FindAccountVC */, 4AD354232AAF7EB6004A47B3 /* TabBarVC */, 4A15F20C2AA8B3FB0098F2F7 /* SignUpVC */, - 4AA999952A8485A500E495FA /* FirstVC.swift */, 4AD354142AACD390004A47B3 /* LoginVC.swift */, + 4AA999952A8485A500E495FA /* FirstVC.swift */, 4AC579862B2E004400735252 /* CustomAlarmPopupVC.swift */, 4A828D8E2B619447006AE70A /* CustomCheckPopupVC.swift */, 4A9936552B642A0800B7B21A /* CalendarPanModalVC.swift */, @@ -679,7 +679,7 @@ 4AD354202AAF7CD6004A47B3 /* MainVC.swift in Sources */, 4A0C7EFF2B5C29090097D753 /* MainPetListView.swift in Sources */, 4A2440712B374C0F0086D2AB /* CryptoHelpers.swift in Sources */, - 4A99365A2B65309F00B7B21A /* PanModalDateView.swift in Sources */, + 4A99365A2B65309F00B7B21A /* CalendarDateView.swift in Sources */, 4ACDD4A72AD9B3F600CD8F1A /* CheckCareVC.swift in Sources */, 4A8662D62B2629F500D8DDE8 /* EditUserNameVC.swift in Sources */, 4A40561F2B52FE7900A95891 /* TimeAttackPanModalTabelViewCell.swift in Sources */, diff --git a/fit-a-pet-client/fit-a-pet-client.xcworkspace/xcuserdata/maclove.xcuserdatad/UserInterfaceState.xcuserstate b/fit-a-pet-client/fit-a-pet-client.xcworkspace/xcuserdata/maclove.xcuserdatad/UserInterfaceState.xcuserstate index 76f8c439..ca833b92 100644 Binary files a/fit-a-pet-client/fit-a-pet-client.xcworkspace/xcuserdata/maclove.xcuserdatad/UserInterfaceState.xcuserstate and b/fit-a-pet-client/fit-a-pet-client.xcworkspace/xcuserdata/maclove.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/fit-a-pet-client/fit-a-pet-client/UIElement/CustomNavigationBar.swift b/fit-a-pet-client/fit-a-pet-client/UIElement/CustomNavigationBar.swift index d434b6fa..4d987aa0 100644 --- a/fit-a-pet-client/fit-a-pet-client/UIElement/CustomNavigationBar.swift +++ b/fit-a-pet-client/fit-a-pet-client/UIElement/CustomNavigationBar.swift @@ -37,7 +37,7 @@ class CustomNavigationBar: UIViewController { } @objc func closeButtonTapped() { - if currentTitle == "반려동물 등록하기" { + if currentTitle == "반려동물 등록하기" || currentTitle == "일정 등록하기" { navigationController?.popToRootViewController(animated: true) } else { if let loginVC = navigationController?.viewControllers.first(where: { $0 is LoginVC }) { @@ -51,7 +51,7 @@ class CustomNavigationBar: UIViewController { self.navigationController?.navigationBar.tintColor = .black - if currentTitle == "반려동물 등록하기" { + if currentTitle == "반려동물 등록하기"{ self.navigationItem.hidesBackButton = false } else { self.navigationItem.hidesBackButton = true diff --git a/fit-a-pet-client/fit-a-pet-client/View/CalendarVCView/PanModalDateView.swift b/fit-a-pet-client/fit-a-pet-client/View/CalendarVCView/CalendarDateView.swift similarity index 97% rename from fit-a-pet-client/fit-a-pet-client/View/CalendarVCView/PanModalDateView.swift rename to fit-a-pet-client/fit-a-pet-client/View/CalendarVCView/CalendarDateView.swift index 12e49416..8ccb5f37 100644 --- a/fit-a-pet-client/fit-a-pet-client/View/CalendarVCView/PanModalDateView.swift +++ b/fit-a-pet-client/fit-a-pet-client/View/CalendarVCView/CalendarDateView.swift @@ -1,7 +1,7 @@ import UIKit import SnapKit -class PanModalDateView: UIView { +class CalendarDateView: UIView { private let dateLabel = UILabel() let labelStackView = UIStackView() @@ -11,7 +11,7 @@ class PanModalDateView: UIView { var isTimePickerSelected = false private var selectedButton: UIButton? - weak var delegate: PanModalDateViewDelegate? + weak var delegate: CalendarDateViewDelegate? override init(frame: CGRect) { super.init(frame: frame) @@ -126,7 +126,7 @@ class PanModalDateView: UIView { } } -protocol PanModalDateViewDelegate: AnyObject { +protocol CalendarDateViewDelegate: AnyObject { func datePickerButtonTapped() func timePickerButtonTapped() } diff --git a/fit-a-pet-client/fit-a-pet-client/ViewControllers/CalendarPanModalVC.swift b/fit-a-pet-client/fit-a-pet-client/ViewControllers/CalendarPanModalVC.swift index 198c684d..b8e9fb84 100644 --- a/fit-a-pet-client/fit-a-pet-client/ViewControllers/CalendarPanModalVC.swift +++ b/fit-a-pet-client/fit-a-pet-client/ViewControllers/CalendarPanModalVC.swift @@ -1,28 +1,50 @@ import UIKit import SnapKit -import PanModal -class CalendarPanModalVC: UIViewController, PanModalDateViewDelegate { +class CalendarRegistrationVC: UIViewController, CalendarDateViewDelegate { private let scrollView = UIScrollView() private let titleLabel = UILabel() + private let closeBtn = UIButton() let scheduleView = CustomVerticalView(labelText: "일정 이름", placeholder: "일정 이름") let locationView = CustomVerticalView(labelText: "장소", placeholder: "장소") let otherSettingView = OtherSettingsView() let registrationBtn = CustomNextBtn(title: "등록하기") - let dateView = PanModalDateView() + let dateView = CalendarDateView() let dateTimePicker = UIDatePicker() override func viewDidLoad() { super.viewDidLoad() + setupNavigationBar() setupViews() setupActions() } + + private func setupNavigationBar() { + + navigationController?.navigationBar.tintColor = .black + navigationController?.navigationBar.topItem?.title = " " + + titleLabel.text = "일정 등록하기" + titleLabel.font = .boldSystemFont(ofSize: 18) + titleLabel.sizeToFit() + + let titleView = UIView(frame: CGRect(x: 0, y: 0, width: titleLabel.frame.width, height: titleLabel.frame.height)) + titleView.addSubview(titleLabel) + + navigationItem.titleView = titleView + + closeBtn.setImage(UIImage(named: "close_icon"), for: .normal) + closeBtn.addTarget(self, action: #selector(closeBtnTapped), for: .touchUpInside) + navigationItem.rightBarButtonItem = UIBarButtonItem(customView: closeBtn) + } private func setupViews() { + view.addSubview(scrollView) view.addSubview(registrationBtn) + view.backgroundColor = .white scrollView.snp.makeConstraints { make in make.top.leading.trailing.equalToSuperview() @@ -36,25 +58,15 @@ class CalendarPanModalVC: UIViewController, PanModalDateViewDelegate { dateTimePicker.isHidden = true dateTimePicker.datePickerMode = .date dateTimePicker.preferredDatePickerStyle = .inline - - scrollView.addSubview(titleLabel) + scrollView.addSubview(scheduleView) scrollView.addSubview(locationView) scrollView.addSubview(dateView) scrollView.addSubview(dateTimePicker) scrollView.addSubview(otherSettingView) - titleLabel.text = "일정 등록하기" - titleLabel.font = .boldSystemFont(ofSize: 18) - - titleLabel.snp.makeConstraints { make in - make.top.equalTo(scrollView.snp.top).offset(16) - make.centerX.equalToSuperview() - make.height.equalTo(40) - } - scheduleView.snp.makeConstraints { make in - make.top.equalTo(titleLabel.snp.bottom).offset(16) + make.top.equalTo(scrollView.snp.top).offset(16) make.leading.equalTo(view.snp.leading).offset(16) make.trailing.equalTo(view.snp.trailing).offset(-16) make.height.equalTo(88) @@ -110,6 +122,10 @@ class CalendarPanModalVC: UIViewController, PanModalDateViewDelegate { self.presentPanModal(timePanModalVC) } + @objc private func closeBtnTapped() { + + dismiss(animated: true, completion: nil) + } func datePickerButtonTapped() { dateTimePicker.datePickerMode = .date @@ -144,7 +160,7 @@ class CalendarPanModalVC: UIViewController, PanModalDateViewDelegate { dateTimePicker.isHidden = false dateTimePicker.snp.updateConstraints { make in - make.height.equalTo(250) + make.height.equalTo(200) } } else { @@ -161,44 +177,26 @@ class CalendarPanModalVC: UIViewController, PanModalDateViewDelegate { } } -extension CalendarPanModalVC: PanModalPresentable { - var panScrollable: UIScrollView? { - return scrollView - } - - var longFormHeight: PanModalHeight { - return .maxHeight - } - - var anchorModalToLongForm: Bool { - return false - } - - var panModalBackgroundColor: UIColor { - return UIColor.white - } -} - -extension CalendarPanModalVC: UITextFieldDelegate{ +extension CalendarRegistrationVC: UITextFieldDelegate{ func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { - - let scheduleText = (scheduleView.textInputField.text! as NSString).replacingCharacters(in: range, with: string) - let locationText = (locationView.textInputField.text! as NSString).replacingCharacters(in: range, with: string) - if scheduleText.isEmpty{ - scheduleView.textInputField.layer.borderColor = UIColor(named: "Gray3")?.cgColor - }else{ - scheduleView.textInputField.layer.borderColor = UIColor(named: "PrimaryColor")?.cgColor + if textField == scheduleView.textInputField { + handleTextChange(for: scheduleView, in: range, replacementString: string) + } else if textField == locationView.textInputField { + handleTextChange(for: locationView, in: range, replacementString: string) } - if locationText.isEmpty{ - locationView.textInputField.layer.borderColor = UIColor(named: "Gray3")?.cgColor - }else{ - locationView.textInputField.layer.borderColor = UIColor(named: "PrimaryColor")?.cgColor - } - - return true } + + private func handleTextChange(for customView: CustomVerticalView, in range: NSRange, replacementString string: String) { + let newText = (customView.textInputField.text! as NSString).replacingCharacters(in: range, with: string) + + if newText.isEmpty { + customView.textInputField.layer.borderColor = UIColor(named: "Gray3")?.cgColor + } else { + customView.textInputField.layer.borderColor = UIColor(named: "PrimaryColor")?.cgColor + } + } } diff --git a/fit-a-pet-client/fit-a-pet-client/ViewControllers/TabBarVC/CalendarVC.swift b/fit-a-pet-client/fit-a-pet-client/ViewControllers/TabBarVC/CalendarVC.swift index 810a8c8b..3e05e1d1 100644 --- a/fit-a-pet-client/fit-a-pet-client/ViewControllers/TabBarVC/CalendarVC.swift +++ b/fit-a-pet-client/fit-a-pet-client/ViewControllers/TabBarVC/CalendarVC.swift @@ -62,9 +62,11 @@ class CalendarVC: UIViewController { } @objc func didTapAddButton() { - let calendarPanModalVC = CalendarPanModalVC() + let calendarRegistrationVC = CalendarRegistrationVC() + let navigationController = UINavigationController(rootViewController: calendarRegistrationVC) - self.presentPanModal(calendarPanModalVC) + self.present(navigationController, animated: true) + } }