-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from KCY-Fit-a-Pet/feat/80
🎨 일정 등록 VC UI 구현
- Loading branch information
Showing
38 changed files
with
828 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+13.5 KB
(110%)
...it-a-pet-client.xcworkspace/xcuserdata/maclove.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
21 changes: 21 additions & 0 deletions
21
fit-a-pet-client/fit-a-pet-client/Assets.xcassets/icon/calendar_add.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Binary file added
BIN
+305 Bytes
...nt/fit-a-pet-client/Assets.xcassets/icon/calendar_add.imageset/calendar_add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
fit-a-pet-client/fit-a-pet-client/Assets.xcassets/icon/calendar_left.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Binary file added
BIN
+229 Bytes
.../fit-a-pet-client/Assets.xcassets/icon/calendar_left.imageset/calendar_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
fit-a-pet-client/fit-a-pet-client/Assets.xcassets/icon/calendar_right.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Binary file added
BIN
+210 Bytes
...it-a-pet-client/Assets.xcassets/icon/calendar_right.imageset/calendar_right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
fit-a-pet-client/fit-a-pet-client/View/CalendarVCView/CalendarDateView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
Oops, something went wrong.