Skip to content

Commit

Permalink
feat: 스케줄 등록 VC 모달창에서 navigationController로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
heejinnn committed Jan 28, 2024
1 parent 69eedd0 commit 1e0b330
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 61 deletions.
10 changes: 5 additions & 5 deletions fit-a-pet-client/fit-a-pet-client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -154,7 +154,7 @@
4A9936532B64231B00B7B21A /* CalendarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarView.swift; sourceTree = "<group>"; };
4A9936552B642A0800B7B21A /* CalendarPanModalVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarPanModalVC.swift; sourceTree = "<group>"; };
4A9936572B642B7E00B7B21A /* CustomVerticalView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomVerticalView.swift; sourceTree = "<group>"; };
4A9936592B65309F00B7B21A /* PanModalDateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PanModalDateView.swift; sourceTree = "<group>"; };
4A9936592B65309F00B7B21A /* CalendarDateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarDateView.swift; sourceTree = "<group>"; };
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 = "<group>"; };
4AA999932A8485A500E495FA /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -275,7 +275,7 @@
children = (
4A9936512B64230600B7B21A /* CalendarHeaderView.swift */,
4A9936532B64231B00B7B21A /* CalendarView.swift */,
4A9936592B65309F00B7B21A /* PanModalDateView.swift */,
4A9936592B65309F00B7B21A /* CalendarDateView.swift */,
);
path = CalendarVCView;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import SnapKit

class PanModalDateView: UIView {
class CalendarDateView: UIView {

private let dateLabel = UILabel()
let labelStackView = UIStackView()
Expand All @@ -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)
Expand Down Expand Up @@ -126,7 +126,7 @@ class PanModalDateView: UIView {
}
}

protocol PanModalDateViewDelegate: AnyObject {
protocol CalendarDateViewDelegate: AnyObject {
func datePickerButtonTapped()
func timePickerButtonTapped()
}
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}
}

Expand Down

0 comments on commit 1e0b330

Please sign in to comment.