-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDatePickerView.swift
More file actions
72 lines (62 loc) · 2.46 KB
/
Copy pathDatePickerView.swift
File metadata and controls
72 lines (62 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//
// DatePickerViewController.swift
// Presentation
//
// Created by 이동현 on 7/27/25.
//
import SnapKit
import UIKit
protocol DatePickerViewDelegate: AnyObject {
func datePickerView(_ pickerView: DatePickerView, didSelectTime time: Date)
}
final class DatePickerView: UIViewController {
private enum Layout {
static let datePickerHeight: CGFloat = 195
static let horizontalSpacing: CGFloat = 20
static let registerButtonHeight: CGFloat = 54
static let registerButtonVerticalSpacing: CGFloat = 14
}
private let datePicker = UIDatePicker()
private let registerButton = UIButton()
weak var delegate: DatePickerViewDelegate?
override func viewDidLoad() {
super.viewDidLoad()
configureAttribute()
configureLayout()
}
private func configureAttribute() {
datePicker.preferredDatePickerStyle = .wheels
datePicker.datePickerMode = .time
datePicker.locale = Locale(identifier: "en_US")
datePicker.backgroundColor = .white
datePicker.tintColor = .black
registerButton.layer.cornerRadius = 12
registerButton.layer.masksToBounds = true
registerButton.backgroundColor = BitnagilColor.navy500
registerButton.titleLabel?.font = BitnagilFont.init(style: .body1, weight: .semiBold).font
registerButton.setTitle("등록하기", for: .normal)
registerButton.setTitleColor(.white, for: .normal)
registerButton.addAction(
UIAction { [weak self] _ in
guard let self else { return }
self.delegate?.datePickerView(self, didSelectTime: datePicker.date)
dismiss(animated: true)
},
for: .touchUpInside)
}
private func configureLayout() {
let safeArea = view.safeAreaLayoutGuide
view.addSubview(datePicker)
view.addSubview(registerButton)
datePicker.snp.makeConstraints { make in
make.top.horizontalEdges.equalToSuperview()
make.height.equalTo(Layout.datePickerHeight)
}
registerButton.snp.makeConstraints { make in
make.horizontalEdges.equalToSuperview().inset(Layout.horizontalSpacing)
make.top.equalTo(datePicker.snp.bottom).offset(Layout.registerButtonVerticalSpacing)
make.bottom.equalTo(safeArea.snp.bottom).offset(-Layout.registerButtonVerticalSpacing)
make.height.equalTo(Layout.registerButtonHeight)
}
}
}