Skip to content

Commit

Permalink
feat: calendarModalVC ui 완성
Browse files Browse the repository at this point in the history
  • Loading branch information
heejinnn committed Jan 28, 2024
1 parent 187f195 commit 69eedd0
Show file tree
Hide file tree
Showing 20 changed files with 127 additions and 70 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import UIKit
import SnapKit
import FSCalendar

class CalendarView: UIView {
class CalendarView: UIView, FSCalendarDelegateAppearance {
let calendar = FSCalendar()

override init(frame: CGRect) {
Expand Down Expand Up @@ -30,12 +30,16 @@ class CalendarView: UIView {
calendar.locale = Locale(identifier: "ko_KR")

calendar.appearance.titleTodayColor = UIColor(named: "PrimaryColor")
calendar.appearance.todayColor = .clear
calendar.appearance.todayColor = UIColor(named: "Secondary")


calendar.appearance.borderRadius = 0.5
calendar.appearance.todaySelectionColor = UIColor(named: "PrimaryColor")

calendar.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class PanModalDateView: UIView {
let labelStackView = UIStackView()
let datePickerBtn = UIButton()
let timePickerBtn = UIButton()
private var isDatePickerSelected = false
private var isTimePickerSelected = false
var isDatePickerSelected = false
var isTimePickerSelected = false

private var selectedButton: UIButton?
weak var delegate: PanModalDateViewDelegate?
Expand Down Expand Up @@ -96,19 +96,24 @@ class PanModalDateView: UIView {
}

@objc private func datePickerTapped() {
isDatePickerSelected.toggle()
deselectOtherButton()
selectedButton = datePickerBtn
datePickerBtn.setTitleColor(isDatePickerSelected ? UIColor(named: "PrimaryColor") : .black, for: .normal)
delegate?.datePickerButtonTapped()
if !isTimePickerSelected{
isDatePickerSelected.toggle()
deselectOtherButton()
selectedButton = datePickerBtn
datePickerBtn.setTitleColor(isDatePickerSelected ? UIColor(named: "PrimaryColor") : .black, for: .normal)
delegate?.datePickerButtonTapped()
}
}

@objc private func timePickerTapped() {
isTimePickerSelected.toggle()
deselectOtherButton()
selectedButton = timePickerBtn
timePickerBtn.setTitleColor(isDatePickerSelected ? UIColor(named: "PrimaryColor") : .black, for: .normal)
delegate?.timePickerButtonTapped()
if !isDatePickerSelected{
isTimePickerSelected.toggle()
deselectOtherButton()
selectedButton = timePickerBtn
timePickerBtn.setTitleColor(isTimePickerSelected ? UIColor(named: "PrimaryColor") : .black, for: .normal)
delegate?.timePickerButtonTapped()
}

}

private func deselectOtherButton() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class CalendarPanModalVC: UIViewController, PanModalDateViewDelegate {
let locationView = CustomVerticalView(labelText: "장소", placeholder: "장소")
let otherSettingView = OtherSettingsView()

let registrationBtn = CustomNextBtn(title: "등록하기")
let dateView = PanModalDateView()
let dateTimePicker = UIDatePicker()

Expand All @@ -21,15 +22,18 @@ class CalendarPanModalVC: UIViewController, PanModalDateViewDelegate {

private func setupViews() {
view.addSubview(scrollView)
view.addSubview(registrationBtn)

scrollView.snp.makeConstraints { make in
make.edges.equalToSuperview()
make.top.leading.trailing.equalToSuperview()
make.bottom.equalTo(registrationBtn.snp.top).offset(15)
}

dateView.delegate = self
scheduleView.textInputField.delegate = self
locationView.textInputField.delegate = self

dateTimePicker.isHidden = true

dateTimePicker.datePickerMode = .date
dateTimePicker.preferredDatePickerStyle = .inline

Expand Down Expand Up @@ -84,6 +88,12 @@ class CalendarPanModalVC: UIViewController, PanModalDateViewDelegate {
make.height.equalTo(400)
make.bottom.equalTo(scrollView.snp.bottom)
}

registrationBtn.snp.makeConstraints{make in
make.leading.equalTo(view.snp.leading).offset(16)
make.trailing.equalTo(view.snp.trailing).offset(-16)
make.bottom.equalTo(view.snp.bottom).offset(-50)
}
}

private func setupActions() {
Expand All @@ -104,47 +114,50 @@ class CalendarPanModalVC: UIViewController, PanModalDateViewDelegate {
func datePickerButtonTapped() {
dateTimePicker.datePickerMode = .date
dateTimePicker.preferredDatePickerStyle = .inline
if dateTimePicker.isHidden {

dateTimePicker.isHidden = false

dateTimePicker.snp.updateConstraints { make in
make.height.equalTo(300)
if !dateView.isTimePickerSelected{
if dateTimePicker.isHidden {
dateTimePicker.isHidden = false

dateTimePicker.snp.updateConstraints { make in
make.height.equalTo(300)
}

} else {
dateTimePicker.isHidden = true

dateTimePicker.snp.updateConstraints { make in
make.height.equalTo(0)
}
}

} else {
dateTimePicker.isHidden = true

dateTimePicker.snp.updateConstraints { make in
make.height.equalTo(0)
UIView.animate(withDuration: 0.3) {
self.view.layoutIfNeeded()
}
}
UIView.animate(withDuration: 0.3) {
self.view.layoutIfNeeded()
}

}

func timePickerButtonTapped() {
dateTimePicker.datePickerMode = .time
dateTimePicker.preferredDatePickerStyle = .wheels
if dateTimePicker.isHidden {

dateTimePicker.isHidden = false

dateTimePicker.snp.updateConstraints { make in
make.height.equalTo(250)
if !dateView.isDatePickerSelected{
if dateTimePicker.isHidden {
dateTimePicker.isHidden = false

dateTimePicker.snp.updateConstraints { make in
make.height.equalTo(250)
}

} else {
dateTimePicker.isHidden = true

dateTimePicker.snp.updateConstraints { make in
make.height.equalTo(0)
}
}

} else {
dateTimePicker.isHidden = true

dateTimePicker.snp.updateConstraints { make in
make.height.equalTo(0)
UIView.animate(withDuration: 0.3) {
self.view.layoutIfNeeded()
}
}
UIView.animate(withDuration: 0.3) {
self.view.layoutIfNeeded()
}
}
}

Expand All @@ -166,3 +179,26 @@ extension CalendarPanModalVC: PanModalPresentable {
}
}

extension CalendarPanModalVC: 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 locationText.isEmpty{
locationView.textInputField.layer.borderColor = UIColor(named: "Gray3")?.cgColor
}else{
locationView.textInputField.layer.borderColor = UIColor(named: "PrimaryColor")?.cgColor
}


return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class FindInputAuthNumVC: CustomNavigationBar{
}

nextIdCheckBtn.snp.makeConstraints{make in
make.bottom.equalTo(view.snp.bottom).offset(-65)
make.bottom.equalTo(view.snp.bottom).offset(-50)
make.left.equalTo(view.snp.left).offset(16)
make.right.equalTo(view.snp.right).offset(-16)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class FindInputPhoneNumVC: CustomNavigationBar{
}

nextInputAuthNumBtn.snp.makeConstraints{make in
make.bottom.equalTo(view.snp.bottom).offset(-65)
make.bottom.equalTo(view.snp.bottom).offset(-50)
make.left.equalTo(view.snp.left).offset(16)
make.right.equalTo(view.snp.right).offset(-16)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ResetPwVC: CustomNavigationBar{
}

resetPwCompleteBtn.snp.makeConstraints{make in
make.bottom.equalTo(view.snp.bottom).offset(-65)
make.bottom.equalTo(view.snp.bottom).offset(-50)
make.left.equalTo(view.snp.left).offset(16)
make.right.equalTo(view.snp.right).offset(-16)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ class LoginVC: UIViewController{
containerView.addSubview(loginBtn)
view.addSubview(containerView)

containerView.layer.borderWidth = 1

containerView.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.height.equalTo(350)
Expand Down Expand Up @@ -206,14 +204,14 @@ class LoginVC: UIViewController{
FindIdPwSwitch.findAuth = "아이디 찾기"
FindIdPwSwitch.findtype = "uid"
let findIdVC = FindInputPhoneNumVC(title: FindIdPwSwitch.findAuth)
self.navigationController?.pushViewController(findIdVC, animated: false)
self.navigationController?.pushViewController(findIdVC, animated: true)
}

@objc func changeFindPwVC(_ sender: UIButton){
FindIdPwSwitch.findAuth = "비밀번호 찾기"
FindIdPwSwitch.findtype = "password"
let findPwVC = FindInputIdVC(title: FindIdPwSwitch.findAuth)
self.navigationController?.pushViewController(findPwVC, animated: false)
self.navigationController?.pushViewController(findPwVC, animated: true)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class CheckCareVC : CustomNavigationBar {
}

nextUploadPetPhotoBtn.snp.makeConstraints{make in
make.bottom.equalTo(view.snp.bottom).offset(-65)
make.bottom.equalTo(view.snp.bottom).offset(-50)
make.left.equalTo(view.snp.left).offset(16)
make.right.equalTo(view.snp.right).offset(-16)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class InputGenderVC: CustomNavigationBar {
}

nextBirthBtn.snp.makeConstraints{make in
make.bottom.equalTo(view.snp.bottom).offset(-65)
make.bottom.equalTo(view.snp.bottom).offset(-50)
make.left.equalTo(view.snp.left).offset(16)
make.right.equalTo(view.snp.right).offset(-16)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class InputPetBirthVC : CustomNavigationBar {
}

nextCheckCareBtn.snp.makeConstraints{make in
make.bottom.equalTo(view.snp.bottom).offset(-65)
make.bottom.equalTo(view.snp.bottom).offset(-50)
make.left.equalTo(view.snp.left).offset(16)
make.right.equalTo(view.snp.right).offset(-16)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class InputPetNameVC: CustomNavigationBar {
}

nextGenderBtn.snp.makeConstraints{make in
make.bottom.equalTo(view.snp.bottom).offset(-65)
make.bottom.equalTo(view.snp.bottom).offset(-50)
make.left.equalTo(view.snp.left).offset(16)
make.right.equalTo(view.snp.right).offset(-16)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class InputSpeciesVC: CustomNavigationBar {
}

nextPetNameBtn.snp.makeConstraints{make in
make.bottom.equalTo(view.snp.bottom).offset(-65)
make.bottom.equalTo(view.snp.bottom).offset(-50)
make.left.equalTo(view.snp.left).offset(16)
make.right.equalTo(view.snp.right).offset(-16)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class UploadPetPhotoVC : CustomNavigationBar {
}

registCompleteBtn.snp.makeConstraints{make in
make.bottom.equalTo(view.snp.bottom).offset(-65)
make.bottom.equalTo(view.snp.bottom).offset(-50)
make.left.equalTo(view.snp.left).offset(16)
make.right.equalTo(view.snp.right).offset(-16)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class InputAuthNumVC : UIViewController{
}

nextIdBtn.snp.makeConstraints{make in
make.bottom.equalTo(view.snp.bottom).offset(-65)
make.bottom.equalTo(view.snp.bottom).offset(-50)
make.left.equalTo(view.snp.left).offset(16)
make.right.equalTo(view.snp.right).offset(-16)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class InputIdVC : UIViewController {
}

nextPwBtn.snp.makeConstraints{make in
make.bottom.equalTo(view.snp.bottom).offset(-65)
make.bottom.equalTo(view.snp.bottom).offset(-50)
make.left.equalTo(view.snp.left).offset(16)
make.right.equalTo(view.snp.right).offset(-16)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class InputNickVC : UIViewController {
}

completeSignUpBtn.snp.makeConstraints{make in
make.bottom.equalTo(view.snp.bottom).offset(-65)
make.bottom.equalTo(view.snp.bottom).offset(-50)
make.left.equalTo(view.snp.left).offset(16)
make.right.equalTo(view.snp.right).offset(-16)
}
Expand Down
Loading

0 comments on commit 69eedd0

Please sign in to comment.