Skip to content

Commit

Permalink
Merge pull request #81 from KCY-Fit-a-Pet/feat/80
Browse files Browse the repository at this point in the history
🎨 일정 등록 VC UI 구현
  • Loading branch information
psychology50 authored Jan 29, 2024
2 parents c89a2f5 + 1e0b330 commit 9cac36f
Show file tree
Hide file tree
Showing 38 changed files with 828 additions and 89 deletions.
30 changes: 29 additions & 1 deletion fit-a-pet-client/fit-a-pet-client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
4A8B9B4E2AD443FA009236EC /* MySearchRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A8B9B4D2AD443FA009236EC /* MySearchRouter.swift */; };
4A8B9B502AD444D0009236EC /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A8B9B4F2AD444D0009236EC /* Constants.swift */; };
4A9088772AC1681B000C7878 /* MainPetCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A9088752AC1681B000C7878 /* MainPetCollectionViewCell.swift */; };
4A9936522B64230600B7B21A /* CalendarHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A9936512B64230600B7B21A /* CalendarHeaderView.swift */; };
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 /* 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 @@ -145,6 +150,11 @@
4A8B9B4D2AD443FA009236EC /* MySearchRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MySearchRouter.swift; sourceTree = "<group>"; };
4A8B9B4F2AD444D0009236EC /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
4A9088752AC1681B000C7878 /* MainPetCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainPetCollectionViewCell.swift; sourceTree = "<group>"; };
4A9936512B64230600B7B21A /* CalendarHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarHeaderView.swift; sourceTree = "<group>"; };
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 /* 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 @@ -260,6 +270,16 @@
path = Manager;
sourceTree = "<group>";
};
4A9936502B64223D00B7B21A /* CalendarVCView */ = {
isa = PBXGroup;
children = (
4A9936512B64230600B7B21A /* CalendarHeaderView.swift */,
4A9936532B64231B00B7B21A /* CalendarView.swift */,
4A9936592B65309F00B7B21A /* CalendarDateView.swift */,
);
path = CalendarVCView;
sourceTree = "<group>";
};
4AA999852A8485A500E495FA = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -309,17 +329,19 @@
4ACDD49A2AD9A9F600CD8F1A /* FindAccountVC */,
4AD354232AAF7EB6004A47B3 /* TabBarVC */,
4A15F20C2AA8B3FB0098F2F7 /* SignUpVC */,
4AA999952A8485A500E495FA /* FirstVC.swift */,
4AD354142AACD390004A47B3 /* LoginVC.swift */,
4AA999952A8485A500E495FA /* FirstVC.swift */,
4AC579862B2E004400735252 /* CustomAlarmPopupVC.swift */,
4A828D8E2B619447006AE70A /* CustomCheckPopupVC.swift */,
4A9936552B642A0800B7B21A /* CalendarPanModalVC.swift */,
);
path = ViewControllers;
sourceTree = "<group>";
};
4ABE58592A85E8C100E22C5F /* View */ = {
isa = PBXGroup;
children = (
4A9936502B64223D00B7B21A /* CalendarVCView */,
4A0C7EFD2B5C28E10097D753 /* MainVCView */,
4A54A0B72B584CDD0024B940 /* PetVCView */,
4A40561D2B52FE3500A95891 /* PetCareCell */,
Expand All @@ -329,6 +351,7 @@
4AF0C8532B24E1A800A45EEE /* MyInfoTableViewCell.swift */,
4AC579842B2DFF7500735252 /* CustomAlarmPopupView.swift */,
4A828D8C2B619432006AE70A /* CustomCheckPopupView.swift */,
4A9936572B642B7E00B7B21A /* CustomVerticalView.swift */,
);
path = View;
sourceTree = "<group>";
Expand Down Expand Up @@ -595,6 +618,7 @@
4AD3542D2AAF7F83004A47B3 /* SettingVC.swift in Sources */,
4A80E4D42B49BA7800CD5D05 /* AnonymousAlamofire.swift in Sources */,
4AF0C8502B24765400A45EEE /* ResetPwVC.swift in Sources */,
4A9936562B642A0800B7B21A /* CalendarPanModalVC.swift in Sources */,
4A15F2122AA8B4880098F2F7 /* InputIdVC.swift in Sources */,
4A037FF22AED62E30073BB56 /* KeyChainHelper.swift in Sources */,
4A0750D42B0892B900281A4C /* CustomNavigationBar.swift in Sources */,
Expand Down Expand Up @@ -631,8 +655,10 @@
4AB6178E2B1CFAF300CED98E /* FindIdCheckVC.swift in Sources */,
4A0750D82B0D130F00281A4C /* PetRegistrationManager.swift in Sources */,
4AA999922A8485A500E495FA /* AppDelegate.swift in Sources */,
4A9936582B642B7E00B7B21A /* CustomVerticalView.swift in Sources */,
4ABE53002B5AD92F000EA41D /* PetDataManager.swift in Sources */,
4A88D6172B53ABD2003A2D0F /* PetCareRegistrationManager.swift in Sources */,
4A9936542B64231B00B7B21A /* CalendarView.swift in Sources */,
4ACDD4A92ADAFFD100CD8F1A /* InputPetBirthVC.swift in Sources */,
4A15F2142AA8B4A50098F2F7 /* InputPwVC.swift in Sources */,
4AA999942A8485A500E495FA /* SceneDelegate.swift in Sources */,
Expand All @@ -642,6 +668,7 @@
4A15F2072AA641910098F2F7 /* CustomNextBtn.swift in Sources */,
4AF0C8562B25A93500A45EEE /* AlarmTableViewCell.swift in Sources */,
4A0C7F012B5C3A690097D753 /* MainPetCareCollectionViewCell.swift in Sources */,
4A9936522B64230600B7B21A /* CalendarHeaderView.swift in Sources */,
4A8B9B482AD443D5009236EC /* BaseInterceptor.swift in Sources */,
4A3D7C012B51BB1F00E3BBF8 /* CareDateTableViewCell.swift in Sources */,
4AD354272AAF7EF5004A47B3 /* CalendarVC.swift in Sources */,
Expand All @@ -652,6 +679,7 @@
4AD354202AAF7CD6004A47B3 /* MainVC.swift in Sources */,
4A0C7EFF2B5C29090097D753 /* MainPetListView.swift in Sources */,
4A2440712B374C0F0086D2AB /* CryptoHelpers.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
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "calendar_add.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "calendar_left.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "calendar_right.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class PetCareCollectionViewMethod: NSObject, UICollectionViewDataSource, UIColle
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "MainPetCareCollectionViewCell", for: indexPath) as! MainPetCareCollectionViewCell

if let careCategory = petCareData[3]?[indexPath.section] {
if let careCategory = petCareData[selectedPet]?[indexPath.section] {
let care = careCategory.cares[indexPath.item]
let data = care.careName

Expand Down
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
14 changes: 14 additions & 0 deletions fit-a-pet-client/fit-a-pet-client/Utils/DateFormatterUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,26 @@ class DateFormatterUtils {
static func formatTime(_ timeString: String, from format: String = "HH:mm:ss", to newFormat: String = "a h:mm") -> String? {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = format
dateFormatter.locale = Locale(identifier: "ko_KR")

if let date = dateFormatter.date(from: timeString) {
dateFormatter.dateFormat = newFormat
return dateFormatter.string(from: date)
}
return nil
}

static func formatFullDate(_ dateString: String, from format: String = "yyyy.MM.dd", to newFormat: String = "yyyy.MM.dd (E)") -> String? {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = format
dateFormatter.locale = Locale(identifier: "ko_KR")

if let date = dateFormatter.date(from: dateString) {
dateFormatter.dateFormat = newFormat
let formattedDate = dateFormatter.string(from: date)
return formattedDate
}
return nil
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import UIKit
import SnapKit

class CalendarDateView: UIView {

private let dateLabel = UILabel()
let labelStackView = UIStackView()
let datePickerBtn = UIButton()
let timePickerBtn = UIButton()
var isDatePickerSelected = false
var isTimePickerSelected = false

private var selectedButton: UIButton?
weak var delegate: CalendarDateViewDelegate?

override init(frame: CGRect) {
super.init(frame: frame)
setupViews()
setupActions()
}

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupViews()
setupActions()
}

private func setupViews() {

let currentDate = Date()

let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
let currentDateAsString = dateFormatter.string(from: currentDate)

if let formattedTime = DateFormatterUtils.formatTime(currentDateAsString, from: "yyyy-MM-dd HH:mm:ss", to: "a h:mm") {
timePickerBtn.setTitle(formattedTime, for: .normal)
}
if let formattedFullDate = DateFormatterUtils.formatFullDate(currentDateAsString, from: "yyyy-MM-dd HH:mm:ss", to: "yyyy.MM.dd (E)") {
datePickerBtn.setTitle(formattedFullDate, for: .normal)
}


labelStackView.addArrangedSubview(datePickerBtn)
labelStackView.addArrangedSubview(timePickerBtn)

addSubview(dateLabel)
addSubview(labelStackView)

labelStackView.axis = .horizontal
labelStackView.alignment = .leading
labelStackView.distribution = .fill
labelStackView.spacing = 8

dateLabel.text = "날짜"
dateLabel.font = .boldSystemFont(ofSize: 18)

datePickerBtn.layer.borderWidth = 1
datePickerBtn.layer.borderColor = UIColor(named: "Gray3")?.cgColor
datePickerBtn.layer.cornerRadius = 8
datePickerBtn.setTitleColor(.black, for: .normal)
datePickerBtn.titleLabel?.font = UIFont.systemFont(ofSize: 14)

timePickerBtn.layer.borderWidth = 1
timePickerBtn.layer.borderColor = UIColor(named: "Gray3")?.cgColor
timePickerBtn.layer.cornerRadius = 8
timePickerBtn.setTitleColor(.black, for: .normal)
timePickerBtn.titleLabel?.font = UIFont.systemFont(ofSize: 14)


dateLabel.snp.makeConstraints { make in
make.top.equalToSuperview().offset(10)
make.height.equalTo(25)
}

labelStackView.snp.makeConstraints { make in
make.top.equalTo(dateLabel.snp.bottom).offset(8)
make.height.equalTo(56)
}

datePickerBtn.snp.makeConstraints { make in
make.height.equalTo(56)
make.width.equalTo(130)
}

timePickerBtn.snp.makeConstraints { make in
make.height.equalTo(56)
make.width.equalTo(90)
}
}

private func setupActions() {

datePickerBtn.addTarget(self, action: #selector(datePickerTapped), for: .touchUpInside)
timePickerBtn.addTarget(self, action: #selector(timePickerTapped), for: .touchUpInside)
}

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

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

}

private func deselectOtherButton() {
let otherButton = selectedButton
if otherButton == datePickerBtn {
datePickerBtn.setTitleColor(.black, for: .normal)
}else{
timePickerBtn.setTitleColor(.black, for: .normal)
}
}
}

protocol CalendarDateViewDelegate: AnyObject {
func datePickerButtonTapped()
func timePickerButtonTapped()
}
Loading

0 comments on commit 9cac36f

Please sign in to comment.