Showing
12 changed files
with
136 additions
and
42 deletions
... | ... | @@ -20,9 +20,8 @@ extension UIColor { |
20 | 20 | static let error = UIColor(named: "ErrorTextField") |
21 | 21 | } |
22 | 22 | |
23 | - enum GradientBlue { | |
24 | - static let left = UIColor(named: "Left") | |
25 | - static let right = UIColor(named: "Right") | |
23 | + enum Background { | |
24 | + static let lightGrey = UIColor(named: "LightGreyBackground") | |
26 | 25 | } |
27 | 26 | |
28 | 27 | } |
... | ... | @@ -31,4 +30,9 @@ extension CGColor { |
31 | 30 | static let lightGrey = UIColor(named: "LightGreyBorderColor")?.cgColor |
32 | 31 | static let lightBlue = UIColor(named: "LightBlueBorderColor")?.cgColor |
33 | 32 | } |
33 | + | |
34 | + enum GradientBlue { | |
35 | + static let left = UIColor(named: "Left")?.cgColor | |
36 | + static let right = UIColor(named: "Right")?.cgColor | |
37 | + } | |
34 | 38 | } | ... | ... |
... | ... | @@ -20,5 +20,21 @@ |
20 | 20 | landmarkType = "7"> |
21 | 21 | </BreakpointContent> |
22 | 22 | </BreakpointProxy> |
23 | + <BreakpointProxy | |
24 | + BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> | |
25 | + <BreakpointContent | |
26 | + uuid = "A1E9762E-4F4B-4248-80A0-963D32FF79F7" | |
27 | + shouldBeEnabled = "Yes" | |
28 | + ignoreCount = "0" | |
29 | + continueAfterRunningActions = "No" | |
30 | + filePath = "InterQR-Internship/Modules/ContactPickerScreen/ViewController/ContactPickerViewController.swift" | |
31 | + startingColumnNumber = "9223372036854775807" | |
32 | + endingColumnNumber = "9223372036854775807" | |
33 | + startingLineNumber = "22" | |
34 | + endingLineNumber = "22" | |
35 | + landmarkName = "contactPicker(_:didSelect:)" | |
36 | + landmarkType = "7"> | |
37 | + </BreakpointContent> | |
38 | + </BreakpointProxy> | |
23 | 39 | </Breakpoints> |
24 | 40 | </Bucket> | ... | ... |
InterQR-Internship/Assets.xcassets/UIColors/Background/LightGreyBackground.colorset/Contents.json
0 → 100644
1 | +{ | |
2 | + "colors" : [ | |
3 | + { | |
4 | + "color" : { | |
5 | + "color-space" : "srgb", | |
6 | + "components" : { | |
7 | + "alpha" : "1.000", | |
8 | + "blue" : "234", | |
9 | + "green" : "234", | |
10 | + "red" : "227" | |
11 | + } | |
12 | + }, | |
13 | + "idiom" : "universal" | |
14 | + }, | |
15 | + { | |
16 | + "appearances" : [ | |
17 | + { | |
18 | + "appearance" : "luminosity", | |
19 | + "value" : "dark" | |
20 | + } | |
21 | + ], | |
22 | + "color" : { | |
23 | + "color-space" : "srgb", | |
24 | + "components" : { | |
25 | + "alpha" : "1.000", | |
26 | + "blue" : "1.000", | |
27 | + "green" : "1.000", | |
28 | + "red" : "1.000" | |
29 | + } | |
30 | + }, | |
31 | + "idiom" : "universal" | |
32 | + } | |
33 | + ], | |
34 | + "info" : { | |
35 | + "author" : "xcode", | |
36 | + "version" : 1 | |
37 | + } | |
38 | +} | ... | ... |
... | ... | @@ -54,7 +54,7 @@ class AddResidentsView: UIView { |
54 | 54 | |
55 | 55 | var dividingLineView: UIView = { |
56 | 56 | var view = UIView() |
57 | - view.backgroundColor = .systemGray | |
57 | + view.backgroundColor = .Background.lightGrey | |
58 | 58 | return view |
59 | 59 | }() |
60 | 60 | |
... | ... | @@ -123,8 +123,9 @@ class AddResidentsView: UIView { |
123 | 123 | |
124 | 124 | var gradientBG: CAGradientLayer = { |
125 | 125 | let obj = CAGradientLayer() |
126 | - var leftColor = UIColor(red: 0/255, green: 68/255, blue: 139/255, alpha: 1).cgColor | |
127 | - var rightColor = UIColor(red: 0/255, green: 122/255, blue: 191/255, alpha: 1).cgColor | |
126 | + var leftColor = CGColor.GradientBlue.left | |
127 | + | |
128 | + var rightColor = CGColor.GradientBlue.right | |
128 | 129 | obj.colors = [leftColor, rightColor] |
129 | 130 | obj.startPoint = CGPoint(x: 0, y: 0.5) |
130 | 131 | obj.endPoint = CGPoint(x: 1, y: 0.5) |
... | ... | @@ -134,7 +135,7 @@ class AddResidentsView: UIView { |
134 | 135 | var addResidentButton: UIButton = { |
135 | 136 | var obj = UIButton() |
136 | 137 | obj.setTitle("Add resident", for: .normal) |
137 | - obj.setTitleColor(UIColor(red: 1, green: 1, blue: 1, alpha: 1), for: .normal) | |
138 | + obj.setTitleColor(.white, for: .normal) | |
138 | 139 | obj.titleLabel?.font = .skModernist(type: .bold, ofSize: 16) |
139 | 140 | obj.clipsToBounds = true |
140 | 141 | obj.layer.masksToBounds = true | ... | ... |
... | ... | @@ -42,7 +42,7 @@ class AddResidentsViewController: UIViewController { |
42 | 42 | mainView.heartButton.addTarget(self, action: #selector(didTapOnChangeableButtons(_:)), for: .touchUpInside) |
43 | 43 | mainView.addResidentButton.addTarget(self, action: #selector(didTapResidentButton), for: .touchUpInside) |
44 | 44 | mainView.contactListButton.addTarget(self, action: #selector(didTapContactListButton), for: .touchUpInside) |
45 | - | |
45 | + | |
46 | 46 | NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil) |
47 | 47 | NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: UIResponder.keyboardWillHideNotification, object: nil) |
48 | 48 | } |
... | ... | @@ -69,18 +69,24 @@ class AddResidentsViewController: UIViewController { |
69 | 69 | |
70 | 70 | func didReceiveData() { |
71 | 71 | guard let name = mainView.nameTextField.text, |
72 | - let mobileNumber = mainView.mobileNumberTextField.text | |
72 | + let mobileNumber = mainView.mobileNumberTextField.text | |
73 | 73 | else { |
74 | 74 | return |
75 | 75 | } |
76 | - | |
77 | - let model = ResidentModel(name: name, | |
78 | - mobileNumber: mobileNumber, | |
79 | - manager: mainView.managerButton.isSelected, | |
80 | - hidden: mainView.hiddenButton.isSelected, | |
81 | - heart: mainView.heartButton.isSelected) | |
82 | - | |
83 | - delegate?.save(model) | |
76 | + let model = [ResidentModel(name: name, | |
77 | + mobileNumber: mobileNumber, | |
78 | + manager: mainView.managerButton.isSelected, | |
79 | + hidden: mainView.hiddenButton.isSelected, | |
80 | + heart: mainView.heartButton.isSelected)] | |
81 | + savedResidents.append(contentsOf: model) | |
82 | + delegate?.save(savedResidents) | |
83 | +// ??????????????????????????????? | |
84 | + mainView.nameTextField.text = "" //??? | |
85 | + mainView.mobileNumberTextField.text = "" //??? | |
86 | + mainView.managerButton.isSelected = false //??? | |
87 | + mainView.hiddenButton.isSelected = false //??? | |
88 | + mainView.heartButton.isSelected = false //??? | |
89 | +// ??????????????????????????????? | |
84 | 90 | } |
85 | 91 | |
86 | 92 | @objc private func didTapOnChangeableButtons(_ sender: SquereCheckbox) { |
... | ... | @@ -114,6 +120,7 @@ class AddResidentsViewController: UIViewController { |
114 | 120 | |
115 | 121 | func presentContactPickerVC() { |
116 | 122 | let viewController = ContactPickerViewController() |
123 | + viewController.delegate = self | |
117 | 124 | present(viewController, animated: true) |
118 | 125 | } |
119 | 126 | } |
... | ... | @@ -150,5 +157,13 @@ extension AddResidentsViewController { |
150 | 157 | } |
151 | 158 | } |
152 | 159 | } |
153 | - | |
160 | +//MARK: - Contact picker delegate | |
161 | +extension AddResidentsViewController: CNContactPickerDelegate { | |
162 | + func contactPicker(_ picker: CNContactPickerViewController, didSelect contact: CNContact) { | |
163 | + let userPhoneNumbers:[CNLabeledValue<CNPhoneNumber>] = contact.phoneNumbers | |
164 | + let firstPhoneNumber:CNPhoneNumber = userPhoneNumbers[0].value | |
165 | + | |
166 | + mainView.mobileNumberTextField.text = firstPhoneNumber.stringValue | |
167 | + } | |
168 | +} | |
154 | 169 | ... | ... |
... | ... | @@ -13,13 +13,13 @@ class ContactPickerViewController: CNContactPickerViewController { |
13 | 13 | var phoneNumber = "" |
14 | 14 | |
15 | 15 | override func viewDidLoad() { |
16 | - delegate = self | |
16 | +// delegate = self | |
17 | 17 | } |
18 | 18 | } |
19 | 19 | //MARK: - Contact picker delegate |
20 | 20 | extension ContactPickerViewController: CNContactPickerDelegate { |
21 | 21 | func contactPicker(_ picker: CNContactPickerViewController, didSelect contact: CNContact) { |
22 | - phoneNumber = "\(contact.familyName)" | |
22 | + phoneNumber = "\(contact.phoneNumbers)" | |
23 | 23 | |
24 | 24 | } |
25 | 25 | } | ... | ... |
... | ... | @@ -20,8 +20,8 @@ class ResidentTableViewCell: UITableViewCell { |
20 | 20 | |
21 | 21 | var serialNumberView: UIImageView = { |
22 | 22 | let obj = UIImageView() |
23 | + obj.clipsToBounds = true | |
23 | 24 | obj.layer.cornerRadius = 21.5 |
24 | - obj.backgroundColor = .blue | |
25 | 25 | return obj |
26 | 26 | }() |
27 | 27 | |
... | ... | @@ -69,7 +69,7 @@ class ResidentTableViewCell: UITableViewCell { |
69 | 69 | var heartButton: UIButton = { |
70 | 70 | var obj = UIButton() |
71 | 71 | obj.setImage(UIImage(named: "Heart"), for: .normal) |
72 | - obj.setImage(UIImage(named: "RedHeart"), for: .selected) | |
72 | + obj.setImage(UIImage(named: "HeartRed"), for: .selected) | |
73 | 73 | return obj |
74 | 74 | }() |
75 | 75 | |
... | ... | @@ -79,6 +79,16 @@ class ResidentTableViewCell: UITableViewCell { |
79 | 79 | return obj |
80 | 80 | }() |
81 | 81 | |
82 | + var gradientBG: CAGradientLayer = { | |
83 | + let obj = CAGradientLayer() | |
84 | + var leftColor = UIColor(red: 0/255, green: 68/255, blue: 139/255, alpha: 1).cgColor | |
85 | + var rightColor = UIColor(red: 0/255, green: 122/255, blue: 191/255, alpha: 1).cgColor | |
86 | + obj.colors = [leftColor, rightColor] | |
87 | + obj.startPoint = CGPoint(x: 0, y: 0.5) | |
88 | + obj.endPoint = CGPoint(x: 1, y: 0.5) | |
89 | + return obj | |
90 | + }() | |
91 | + | |
82 | 92 | override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { |
83 | 93 | super.init(style: style, reuseIdentifier: reuseIdentifier) |
84 | 94 | layout() |
... | ... | @@ -90,6 +100,7 @@ class ResidentTableViewCell: UITableViewCell { |
90 | 100 | |
91 | 101 | func layout() { |
92 | 102 | selectionStyle = .none |
103 | + serialNumberView.layer.insertSublayer(gradientBG, at: 0) | |
93 | 104 | |
94 | 105 | contentView.addSubview(containerView) |
95 | 106 | containerView.addSubview(serialNumberView) |
... | ... | @@ -150,4 +161,9 @@ class ResidentTableViewCell: UITableViewCell { |
150 | 161 | $0.trailing.equalToSuperview().offset(-22) |
151 | 162 | } |
152 | 163 | } |
164 | + | |
165 | + override func layoutSubviews() { | |
166 | + super.layoutSubviews() | |
167 | + gradientBG.frame = serialNumberView.bounds | |
168 | + } | |
153 | 169 | } | ... | ... |
... | ... | @@ -8,9 +8,12 @@ |
8 | 8 | import UIKit |
9 | 9 | |
10 | 10 | class ResidentsViewController: UIViewController { |
11 | - var myData: ResidentModel? | |
11 | + var myData: [ResidentModel] = [] | |
12 | + | |
13 | + let addResidentsVC = AddResidentsViewController() | |
14 | + | |
12 | 15 | var mainView = ResidentsView() |
13 | - var addResidents = AddResidentsViewController() | |
16 | + | |
14 | 17 | override func loadView() { |
15 | 18 | view = mainView |
16 | 19 | } |
... | ... | @@ -26,9 +29,6 @@ class ResidentsViewController: UIViewController { |
26 | 29 | |
27 | 30 | mainView.backButton.addTarget(self, action: #selector(didShowChooseApartVC), for: .touchUpInside) |
28 | 31 | mainView.addResidentsButton.addTarget(self, action: #selector(willShowAddResidentVC), for: .touchUpInside) |
29 | - | |
30 | - addResidents.delegate = self | |
31 | - addResidents.didReceiveData() | |
32 | 32 | } |
33 | 33 | |
34 | 34 | @objc func didShowChooseApartVC() { |
... | ... | @@ -36,37 +36,35 @@ class ResidentsViewController: UIViewController { |
36 | 36 | } |
37 | 37 | |
38 | 38 | @objc func willShowAddResidentVC() { |
39 | -// UIView.animate(withDuration: 0.5) { | |
40 | -// self.mainView.addResidentView.isHidden = false | |
41 | -// } | |
42 | - let vc = AddResidentsViewController() | |
43 | - vc.modalPresentationStyle = .overCurrentContext | |
44 | - vc.modalTransitionStyle = .crossDissolve | |
45 | - present(vc, animated: true) | |
39 | + addResidentsVC.modalPresentationStyle = .overCurrentContext | |
40 | + addResidentsVC.modalTransitionStyle = .crossDissolve | |
41 | + addResidentsVC.delegate = self | |
42 | + present(addResidentsVC, animated: true) | |
46 | 43 | } |
47 | - | |
48 | 44 | } |
49 | 45 | |
50 | 46 | //MARK: - TableView delegate & data source |
51 | 47 | extension ResidentsViewController: UITableViewDelegate, UITableViewDataSource { |
52 | 48 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
53 | - 10 | |
49 | + addResidentsVC.savedResidents.count | |
54 | 50 | } |
55 | 51 | |
56 | 52 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
57 | 53 | guard let cell = tableView.dequeueReusableCell(withIdentifier: ResidentTableViewCell.id, for: indexPath) as? ResidentTableViewCell else { return UITableViewCell() } |
58 | 54 | // cell.configureWithItem(doors[indexPath.row]) |
59 | 55 | cell.serialNumberLabel.text = "\(indexPath.row + 1)" |
60 | -// cell.nameLabel.text = myData?.name | |
61 | -// cell.phoneNumberLabel.text = myData?.mobileNumber | |
56 | + cell.nameLabel.text = myData[indexPath.row].name | |
57 | + cell.phoneNumberLabel.text = myData[indexPath.row].mobileNumber | |
58 | + cell.managerButton.isSelected = myData[indexPath.row].manager | |
59 | + cell.hiddenButton.isSelected = myData[indexPath.row].hidden | |
60 | + cell.heartButton.isSelected = myData[indexPath.row].heart | |
62 | 61 | return cell |
63 | 62 | } |
64 | 63 | } |
65 | 64 | //MARK: - Protocol delegate |
66 | 65 | extension ResidentsViewController: ResidentSavable { |
67 | - func save(_ data: ResidentModel) { | |
68 | -// mainView.residentsLabel.text = data.name | |
69 | - mainView.residentsLabel.reloadInputViews() | |
66 | + func save(_ data: [ResidentModel]) { | |
67 | + self.myData = data | |
70 | 68 | mainView.tableView.reloadData() |
71 | 69 | } |
72 | 70 | } | ... | ... |
Please
register
or
login
to post a comment