Showing
7 changed files
with
308 additions
and
218 deletions
| 1 | +// | ||
| 2 | +// SettingsModel.swift | ||
| 3 | +// InterQR-Internship | ||
| 4 | +// | ||
| 5 | +// Created by Leyter on 09.06.2022. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | +import UIKit | ||
| 10 | +enum SettingsModel: CaseIterable { | ||
| 11 | + case displayName | ||
| 12 | + case doNotDisturb | ||
| 13 | + case ringtone | ||
| 14 | + case editResidents | ||
| 15 | + case widgetLock | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + func getTitle() -> String { | ||
| 20 | + switch self { | ||
| 21 | + case .displayName : | ||
| 22 | + return "Your display name" | ||
| 23 | + case .doNotDisturb : | ||
| 24 | + return "Do not disturb" | ||
| 25 | + case .editResidents : | ||
| 26 | + return "Edit residents" | ||
| 27 | + case .widgetLock: | ||
| 28 | + return "Widget lock" | ||
| 29 | + case .ringtone: | ||
| 30 | + return "Rringtone" | ||
| 31 | + } | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + func getIcon() -> UIImage? { | ||
| 35 | + switch self { | ||
| 36 | + case .displayName: | ||
| 37 | + return UIImage(named: "Profile") | ||
| 38 | + case .doNotDisturb: | ||
| 39 | + return UIImage(named: "Notification") | ||
| 40 | + case .editResidents: | ||
| 41 | + return UIImage(named: "Password") | ||
| 42 | + case .widgetLock: | ||
| 43 | + return UIImage(named: "Profile") | ||
| 44 | + case .ringtone: | ||
| 45 | + return UIImage(named: "Volume") | ||
| 46 | + } | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + func getDescription() -> String { | ||
| 50 | + switch self { | ||
| 51 | + case .displayName : | ||
| 52 | + return "This name will be dispayed everywhere" | ||
| 53 | + case .doNotDisturb : | ||
| 54 | + return "This name will be dispayed everywhere" | ||
| 55 | + case .editResidents : | ||
| 56 | + return "This name will be dispayed everywhere" | ||
| 57 | + case .widgetLock: | ||
| 58 | + return "This name will be dispayed everywhere" | ||
| 59 | + case .ringtone: | ||
| 60 | + return "This name will be dispayed everywhere" | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | +} |
| 1 | // | 1 | // |
| 2 | -// ProfileView.swift | 2 | +// DisplayNameCell.swift |
| 3 | // InterQR-Internship | 3 | // InterQR-Internship |
| 4 | // | 4 | // |
| 5 | -// Created by Дмитрий Тимофеев on 08.06.2022. | 5 | +// Created by Leyter on 09.06.2022. |
| 6 | // | 6 | // |
| 7 | 7 | ||
| 8 | +import Foundation | ||
| 8 | import UIKit | 9 | import UIKit |
| 9 | -import SnapKit | ||
| 10 | - | ||
| 11 | -class ProfileView: UIView { | ||
| 12 | - | ||
| 13 | - var profileImage: UIImageView = { | 10 | +class DisplayNameCell: UITableViewCell, Reusable { |
| 11 | + var settingsIcon: UIImageView = { | ||
| 14 | var obj = UIImageView() | 12 | var obj = UIImageView() |
| 15 | obj.image = UIImage(named: "Profile") | 13 | obj.image = UIImage(named: "Profile") |
| 16 | return obj | 14 | return obj |
| @@ -29,58 +27,52 @@ class ProfileView: UIView { | @@ -29,58 +27,52 @@ class ProfileView: UIView { | ||
| 29 | obj.textColor = UIColor(red: 0.725, green: 0.725, blue: 0.725, alpha: 1) | 27 | obj.textColor = UIColor(red: 0.725, green: 0.725, blue: 0.725, alpha: 1) |
| 30 | return obj | 28 | return obj |
| 31 | }() | 29 | }() |
| 32 | - var displayNameLabel: UILabel = { | ||
| 33 | - var obj = UILabel() | 30 | + var displayNameTextField: UITextField = { |
| 31 | + var obj = UITextField() | ||
| 34 | obj.text = "John Doe" | 32 | obj.text = "John Doe" |
| 33 | + obj.returnKeyType = .done | ||
| 35 | obj.backgroundColor = UIColor(red: 0.971, green: 0.967, blue: 0.967, alpha: 1) | 34 | obj.backgroundColor = UIColor(red: 0.971, green: 0.967, blue: 0.967, alpha: 1) |
| 36 | obj.clipsToBounds = true | 35 | obj.clipsToBounds = true |
| 37 | obj.layer.cornerRadius = 15 | 36 | obj.layer.cornerRadius = 15 |
| 38 | return obj | 37 | return obj |
| 39 | }() | 38 | }() |
| 40 | - var dividingLineView: UIView = { | ||
| 41 | - var view = UIView() | ||
| 42 | - view.backgroundColor = UIColor(red: 246/255, green: 246/255, blue: 246/255, alpha: 1) | ||
| 43 | - return view | ||
| 44 | - }() | ||
| 45 | 39 | ||
| 46 | - override init(frame: CGRect) { | ||
| 47 | - super.init(frame: frame) | ||
| 48 | - layout() | 40 | + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { |
| 41 | + super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
| 42 | + setup() | ||
| 49 | } | 43 | } |
| 50 | 44 | ||
| 51 | required init?(coder: NSCoder) { | 45 | required init?(coder: NSCoder) { |
| 52 | - fatalError("init(coder:) has not been implemented") | 46 | + super.init(coder: coder) |
| 47 | + setup() | ||
| 53 | } | 48 | } |
| 54 | 49 | ||
| 55 | - func layout() { | ||
| 56 | - addSubview(profileImage) | ||
| 57 | - addSubview(titleLabel) | ||
| 58 | - addSubview(descriptionLabel) | ||
| 59 | - addSubview(displayNameLabel) | ||
| 60 | - addSubview(dividingLineView) | 50 | + private func setup() { |
| 51 | + selectionStyle = .none | ||
| 52 | + contentView.addSubview(settingsIcon) | ||
| 53 | + contentView.addSubview(titleLabel) | ||
| 54 | + contentView.addSubview(descriptionLabel) | ||
| 55 | + contentView.addSubview(displayNameTextField) | ||
| 61 | 56 | ||
| 62 | - profileImage.snp.makeConstraints { | ||
| 63 | - $0.top.equalTo(snp.top) | ||
| 64 | - $0.leading.equalTo(snp.leading).offset(32) | ||
| 65 | - } | ||
| 66 | - titleLabel.snp.makeConstraints { | ||
| 67 | - $0.top.equalTo(profileImage.snp.top) | ||
| 68 | - $0.leading.equalTo(profileImage.snp.trailing).offset(18) | 57 | + settingsIcon.snp.makeConstraints { make in |
| 58 | + make.top.equalToSuperview() | ||
| 59 | + make.leading.equalTo(snp.leading).offset(32) | ||
| 69 | } | 60 | } |
| 70 | - descriptionLabel.snp.makeConstraints { | ||
| 71 | - $0.top.equalTo(titleLabel.snp.bottom).offset(5) | ||
| 72 | - $0.leading.equalTo(titleLabel.snp.leading) | 61 | + titleLabel.snp.makeConstraints { make in |
| 62 | + make.top.equalTo(settingsIcon.snp.top) | ||
| 63 | + make.leading.equalTo(settingsIcon.snp.trailing).offset(18) | ||
| 73 | } | 64 | } |
| 74 | - displayNameLabel.snp.makeConstraints { | ||
| 75 | - $0.top.equalTo(descriptionLabel.snp.bottom).offset(20) | ||
| 76 | - $0.leading.equalTo(snp.leading).offset(66) | ||
| 77 | - $0.trailing.equalTo(snp.trailing).offset(-28) | ||
| 78 | - $0.height.equalTo(47) | 65 | + descriptionLabel.snp.makeConstraints { make in |
| 66 | + make.top.equalTo(titleLabel.snp.bottom).offset(5) | ||
| 67 | + make.leading.equalTo(titleLabel.snp.leading) | ||
| 79 | } | 68 | } |
| 80 | - dividingLineView.snp.makeConstraints { | ||
| 81 | - $0.leading.trailing.equalToSuperview() | ||
| 82 | - $0.height.equalTo(1) | ||
| 83 | - $0.top.equalTo(displayNameLabel.snp.bottom).offset(30) | 69 | + displayNameTextField.snp.makeConstraints { make in |
| 70 | + make.top.equalTo(descriptionLabel.snp.bottom).offset(20) | ||
| 71 | + make.leading.equalTo(snp.leading).offset(66) | ||
| 72 | + make.trailing.equalTo(snp.trailing).offset(-28) | ||
| 73 | + make.height.equalTo(47) | ||
| 74 | + make.bottom.equalToSuperview().offset(-30) | ||
| 84 | } | 75 | } |
| 76 | + | ||
| 85 | } | 77 | } |
| 86 | } | 78 | } |
| 1 | +// | ||
| 2 | +// SetingsSwitchCell.swift | ||
| 3 | +// InterQR-Internship | ||
| 4 | +// | ||
| 5 | +// Created by Leyter on 09.06.2022. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | +import UIKit | ||
| 10 | +class SettingsSwitchCell: UITableViewCell, Reusable { | ||
| 11 | + | ||
| 12 | + var settingsIcon: UIImageView = { | ||
| 13 | + var obj = UIImageView() | ||
| 14 | + obj.image = UIImage(named: "Notification") | ||
| 15 | + return obj | ||
| 16 | + }() | ||
| 17 | + | ||
| 18 | + var titleLabel: UILabel = { | ||
| 19 | + var obj = UILabel() | ||
| 20 | + obj.text = "Do not disturb" | ||
| 21 | + obj.textColor = UIColor(red: 0.196, green: 0.216, blue: 0.333, alpha: 1) | ||
| 22 | + obj.font = .skModernist(type: .bold, ofSize: 16) | ||
| 23 | + return obj | ||
| 24 | + }() | ||
| 25 | + | ||
| 26 | + var descriptionLabel: UILabel = { | ||
| 27 | + var obj = UILabel() | ||
| 28 | + obj.text = "You will not be notified of any calls for one day. Auto reset at midnight" | ||
| 29 | + obj.textColor = UIColor(red: 0.725, green: 0.725, blue: 0.725, alpha: 1) | ||
| 30 | + obj.font = .skModernist(type: .regular, ofSize: 14) | ||
| 31 | + obj.numberOfLines = 0 | ||
| 32 | + return obj | ||
| 33 | + }() | ||
| 34 | + | ||
| 35 | + var notificationSwitch: UISwitch = { | ||
| 36 | + var obj = UISwitch() | ||
| 37 | + obj.isOn = false | ||
| 38 | + obj.clipsToBounds = true | ||
| 39 | + return obj | ||
| 40 | + }() | ||
| 41 | + | ||
| 42 | + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
| 43 | + super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
| 44 | + setup() | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + required init?(coder: NSCoder) { | ||
| 48 | + super.init(coder: coder) | ||
| 49 | + setup() | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + func setup() { | ||
| 53 | + selectionStyle = .none | ||
| 54 | + contentView.addSubview(settingsIcon) | ||
| 55 | + contentView.addSubview(titleLabel) | ||
| 56 | + contentView.addSubview(descriptionLabel) | ||
| 57 | + contentView.addSubview(notificationSwitch) | ||
| 58 | + | ||
| 59 | + settingsIcon.snp.makeConstraints { make in | ||
| 60 | + make.leading.equalToSuperview().offset(31) | ||
| 61 | + make.top.equalToSuperview().offset(38) | ||
| 62 | + } | ||
| 63 | + titleLabel.snp.makeConstraints { make in | ||
| 64 | + make.leading.equalTo(settingsIcon.snp.trailing).offset(17.5) | ||
| 65 | + make.top.equalToSuperview().offset(38) | ||
| 66 | + } | ||
| 67 | + descriptionLabel.snp.makeConstraints { make in | ||
| 68 | + make.top.equalTo(titleLabel.snp.bottom).offset(5) | ||
| 69 | + make.leading.equalTo(titleLabel.snp.leading) | ||
| 70 | + make.bottom.equalToSuperview().offset(-22) | ||
| 71 | + } | ||
| 72 | + notificationSwitch.snp.makeConstraints { make in | ||
| 73 | + make.top.equalTo(snp.top).offset(36) | ||
| 74 | + make.trailing.equalTo(snp.trailing).offset(-28) | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | +} |
| 1 | +// | ||
| 2 | +// SettingsTableViewCell.swift | ||
| 3 | +// InterQR-Internship | ||
| 4 | +// | ||
| 5 | +// Created by Leyter on 09.06.2022. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | +import UIKit | ||
| 10 | +class SettingsTableViewCell: UITableViewCell, Reusable { | ||
| 11 | + | ||
| 12 | + var settingsIcon: UIImageView = { | ||
| 13 | + var obj = UIImageView() | ||
| 14 | + obj.image = UIImage(named: "Edit") | ||
| 15 | + obj.contentMode = .scaleAspectFill | ||
| 16 | + return obj | ||
| 17 | + }() | ||
| 18 | + | ||
| 19 | + var titleLabel: UILabel = { | ||
| 20 | + var obj = UILabel() | ||
| 21 | + obj.text = "Edit residents" | ||
| 22 | + obj.textColor = UIColor(red: 0.196, green: 0.216, blue: 0.333, alpha: 1) | ||
| 23 | + obj.font = .skModernist(type: .bold, ofSize: 16) | ||
| 24 | + return obj | ||
| 25 | + }() | ||
| 26 | + var descriptionLabel: UILabel = { | ||
| 27 | + var obj = UILabel() | ||
| 28 | + obj.text = "Edit the residents and their information" | ||
| 29 | + obj.textColor = UIColor(red: 0.725, green: 0.725, blue: 0.725, alpha: 1) | ||
| 30 | + obj.font = .skModernist(type: .regular, ofSize: 14) | ||
| 31 | + return obj | ||
| 32 | + }() | ||
| 33 | + var arrowImageView: UIImageView = { | ||
| 34 | + var obj = UIImageView() | ||
| 35 | + obj.image = UIImage(named: "NextPointer") | ||
| 36 | + return obj | ||
| 37 | + }() | ||
| 38 | + | ||
| 39 | + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
| 40 | + super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
| 41 | + setup() | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + required init?(coder: NSCoder) { | ||
| 45 | + super.init(coder: coder) | ||
| 46 | + setup() | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + func setup() { | ||
| 50 | + selectionStyle = .none | ||
| 51 | + contentView.addSubview(settingsIcon) | ||
| 52 | + contentView.addSubview(titleLabel) | ||
| 53 | + contentView.addSubview(descriptionLabel) | ||
| 54 | + contentView.addSubview(arrowImageView) | ||
| 55 | + | ||
| 56 | + settingsIcon.snp.makeConstraints { make in | ||
| 57 | + make.top.equalToSuperview().offset(26) | ||
| 58 | + make.leading.equalToSuperview().offset(32) | ||
| 59 | + make.height.width.equalTo(18) | ||
| 60 | + } | ||
| 61 | + titleLabel.snp.makeConstraints { make in | ||
| 62 | + make.top.equalToSuperview().offset(26) | ||
| 63 | + make.leading.equalTo(settingsIcon.snp.trailing).offset(15) | ||
| 64 | + } | ||
| 65 | + descriptionLabel.snp.makeConstraints { make in | ||
| 66 | + make.top.equalTo(titleLabel.snp.bottom).offset(5) | ||
| 67 | + make.leading.equalTo(titleLabel.snp.leading) | ||
| 68 | + make.bottom.equalToSuperview().offset(-22) | ||
| 69 | + } | ||
| 70 | + arrowImageView.snp.makeConstraints { make in | ||
| 71 | + make.centerY.equalToSuperview() | ||
| 72 | + make.trailing.equalTo(snp.trailing).offset(-28) | ||
| 73 | + } | ||
| 74 | + } | ||
| 75 | +} |
| 1 | -// | ||
| 2 | -// EditInfoView.swift | ||
| 3 | -// InterQR-Internship | ||
| 4 | -// | ||
| 5 | -// Created by Дмитрий Тимофеев on 08.06.2022. | ||
| 6 | -// | ||
| 7 | - | ||
| 8 | -import UIKit | ||
| 9 | - | ||
| 10 | -class EditInfoView: UIView { | ||
| 11 | - | ||
| 12 | - var editImage: UIImageView = { | ||
| 13 | - var obj = UIImageView() | ||
| 14 | - obj.image = UIImage(named: "Edit") | ||
| 15 | - obj.contentMode = .scaleAspectFill | ||
| 16 | - return obj | ||
| 17 | - }() | ||
| 18 | - var titleLabel: UILabel = { | ||
| 19 | - var obj = UILabel() | ||
| 20 | - obj.text = "Edit residents" | ||
| 21 | - obj.textColor = UIColor(red: 0.196, green: 0.216, blue: 0.333, alpha: 1) | ||
| 22 | - obj.font = .skModernist(type: .bold, ofSize: 16) | ||
| 23 | - return obj | ||
| 24 | - }() | ||
| 25 | - var descriptionLabel: UILabel = { | ||
| 26 | - var obj = UILabel() | ||
| 27 | - obj.text = "Edit the residents and their information" | ||
| 28 | - obj.textColor = UIColor(red: 0.725, green: 0.725, blue: 0.725, alpha: 1) | ||
| 29 | - obj.font = .skModernist(type: .regular, ofSize: 14) | ||
| 30 | - return obj | ||
| 31 | - }() | ||
| 32 | - var editButton: UIButton = { | ||
| 33 | - var obj = UIButton() | ||
| 34 | - obj.setImage(UIImage(named: "NextPointer"), for: .normal) | ||
| 35 | - return obj | ||
| 36 | - }() | ||
| 37 | - var dividingLineView: UIView = { | ||
| 38 | - var view = UIView() | ||
| 39 | - view.backgroundColor = UIColor(red: 246/255, green: 246/255, blue: 246/255, alpha: 1) | ||
| 40 | - return view | ||
| 41 | - }() | ||
| 42 | - | ||
| 43 | - override init(frame: CGRect) { | ||
| 44 | - super.init(frame: frame) | ||
| 45 | - layout() | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | - required init?(coder: NSCoder) { | ||
| 49 | - fatalError("init(coder:) has not been implemented") | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | - func layout() { | ||
| 53 | - addSubview(editImage) | ||
| 54 | - addSubview(titleLabel) | ||
| 55 | - addSubview(descriptionLabel) | ||
| 56 | - addSubview(editButton) | ||
| 57 | - addSubview(dividingLineView) | ||
| 58 | - | ||
| 59 | - editImage.snp.makeConstraints { | ||
| 60 | - $0.top.equalTo(snp.top).offset(26) | ||
| 61 | - $0.leading.equalTo(snp.leading).offset(32) | ||
| 62 | - $0.height.width.equalTo(18) | ||
| 63 | - } | ||
| 64 | - titleLabel.snp.makeConstraints { | ||
| 65 | - $0.top.equalTo(snp.top).offset(26) | ||
| 66 | - $0.leading.equalTo(editImage.snp.trailing).offset(15) | ||
| 67 | - } | ||
| 68 | - descriptionLabel.snp.makeConstraints { | ||
| 69 | - $0.top.equalTo(titleLabel.snp.bottom).offset(5) | ||
| 70 | - $0.leading.equalTo(titleLabel.snp.leading) | ||
| 71 | - } | ||
| 72 | - editButton.snp.makeConstraints { | ||
| 73 | - $0.top.equalTo(snp.top).offset(38) | ||
| 74 | - $0.trailing.equalTo(snp.trailing).offset(-28) | ||
| 75 | - } | ||
| 76 | - dividingLineView.snp.makeConstraints { | ||
| 77 | - $0.height.equalTo(1) | ||
| 78 | - $0.top.equalTo(descriptionLabel.snp.bottom).offset(22) | ||
| 79 | - $0.trailing.leading.equalToSuperview().inset(32) | ||
| 80 | - } | ||
| 81 | - } | ||
| 82 | -} |
| 1 | -// | ||
| 2 | -// NotificationsView.swift | ||
| 3 | -// InterQR-Internship | ||
| 4 | -// | ||
| 5 | -// Created by Дмитрий Тимофеев on 08.06.2022. | ||
| 6 | -// | ||
| 7 | - | ||
| 8 | -import UIKit | ||
| 9 | - | ||
| 10 | -class NotificationsView: UIView { | ||
| 11 | - | ||
| 12 | - var notificationImage: UIImageView = { | ||
| 13 | - var obj = UIImageView() | ||
| 14 | - obj.image = UIImage(named: "Notification") | ||
| 15 | - return obj | ||
| 16 | - }() | ||
| 17 | - var titleLabel: UILabel = { | ||
| 18 | - var obj = UILabel() | ||
| 19 | - obj.text = "Do not disturb" | ||
| 20 | - obj.textColor = UIColor(red: 0.196, green: 0.216, blue: 0.333, alpha: 1) | ||
| 21 | - obj.font = .skModernist(type: .bold, ofSize: 16) | ||
| 22 | - return obj | ||
| 23 | - }() | ||
| 24 | - var descriptionLabel: UILabel = { | ||
| 25 | - var obj = UILabel() | ||
| 26 | - obj.text = "You will not be notified of any\ncalls for one day. Auto reset at\nmidnight" | ||
| 27 | - obj.textColor = UIColor(red: 0.725, green: 0.725, blue: 0.725, alpha: 1) | ||
| 28 | - obj.font = .skModernist(type: .regular, ofSize: 14) | ||
| 29 | - obj.numberOfLines = 3 | ||
| 30 | - return obj | ||
| 31 | - }() | ||
| 32 | - var notificationSwitch: UISwitch = { | ||
| 33 | - var obj = UISwitch() | ||
| 34 | - obj.isOn = true | ||
| 35 | - obj.clipsToBounds = true | ||
| 36 | - return obj | ||
| 37 | - }() | ||
| 38 | - var volumeImage: UIImageView = { | ||
| 39 | - var obj = UIImageView() | ||
| 40 | - obj.image = UIImage(named: "Volume") | ||
| 41 | - return obj | ||
| 42 | - }() | ||
| 43 | - var dividingLineView: UIView = { | ||
| 44 | - var view = UIView() | ||
| 45 | - view.backgroundColor = UIColor(red: 246/255, green: 246/255, blue: 246/255, alpha: 1) | ||
| 46 | - return view | ||
| 47 | - }() | ||
| 48 | - | ||
| 49 | - override init(frame: CGRect) { | ||
| 50 | - super.init(frame: frame) | ||
| 51 | - layout() | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - required init?(coder: NSCoder) { | ||
| 55 | - fatalError("init(coder:) has not been implemented") | ||
| 56 | - } | ||
| 57 | - | ||
| 58 | - func layout() { | ||
| 59 | - addSubview(notificationImage) | ||
| 60 | - addSubview(titleLabel) | ||
| 61 | - addSubview(descriptionLabel) | ||
| 62 | - addSubview(notificationSwitch) | ||
| 63 | - addSubview(volumeImage) | ||
| 64 | - addSubview(dividingLineView) | ||
| 65 | - | ||
| 66 | - notificationImage.snp.makeConstraints { | ||
| 67 | - $0.leading.equalTo(snp.leading).offset(31) | ||
| 68 | - $0.top.equalTo(snp.top).offset(38) | ||
| 69 | - } | ||
| 70 | - titleLabel.snp.makeConstraints { | ||
| 71 | - $0.leading.equalTo(notificationImage.snp.trailing).offset(17.5) | ||
| 72 | - $0.top.equalTo(snp.top).offset(38) | ||
| 73 | - } | ||
| 74 | - descriptionLabel.snp.makeConstraints { | ||
| 75 | - $0.top.equalTo(titleLabel.snp.bottom).offset(5) | ||
| 76 | - $0.leading.equalTo(titleLabel.snp.leading) | ||
| 77 | - } | ||
| 78 | - notificationSwitch.snp.makeConstraints { | ||
| 79 | - $0.top.equalTo(snp.top).offset(36) | ||
| 80 | - $0.trailing.equalTo(snp.trailing).offset(-28) | ||
| 81 | - } | ||
| 82 | - volumeImage.snp.makeConstraints { | ||
| 83 | - $0.leading.equalTo(snp.leading).offset(29.5) | ||
| 84 | - $0.top.equalTo(titleLabel.snp.bottom).offset(53) | ||
| 85 | - } | ||
| 86 | - dividingLineView.snp.makeConstraints { | ||
| 87 | - $0.height.equalTo(1) | ||
| 88 | - $0.top.equalTo(volumeImage.snp.bottom).offset(17) | ||
| 89 | - $0.leading.equalTo(snp.leading).offset(32) | ||
| 90 | - $0.trailing.equalTo(snp.trailing).offset(-32) | ||
| 91 | - } | ||
| 92 | - } | ||
| 93 | -} |
InterQR-Internship/Reusable+cell.swift
0 → 100644
| 1 | +// | ||
| 2 | +// Reusable+cell.swift | ||
| 3 | +// InterQR-Internship | ||
| 4 | +// | ||
| 5 | +// Created by Leyter on 09.06.2022. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | +import UIKit | ||
| 10 | + | ||
| 11 | +protocol Reusable: class { | ||
| 12 | + static var reuseIdentifier: String { get } | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +extension Reusable { | ||
| 16 | + static var reuseIdentifier: String { | ||
| 17 | + return String(describing: Self.self) | ||
| 18 | + } | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +// swiftlint:disable force_cast | ||
| 22 | + | ||
| 23 | +extension UICollectionView { | ||
| 24 | + func registerReusableCell<T: UICollectionViewCell>(_: T.Type) where T: Reusable { | ||
| 25 | + self.register(T.self, forCellWithReuseIdentifier: T.reuseIdentifier) | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + func dequeueReusableCell<T: UICollectionViewCell>(for indexPath: IndexPath) -> T where T: Reusable { | ||
| 29 | + return self.dequeueReusableCell(withReuseIdentifier: T.reuseIdentifier, for: indexPath) as! T | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + func registerReusableSupplementaryView<T: UICollectionReusableView>(elementKind: String, _: T.Type) where T: Reusable { | ||
| 33 | + self.register(T.self, forSupplementaryViewOfKind: elementKind, withReuseIdentifier: T.reuseIdentifier) | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + func dequeueReusableSupplementaryView<T: UICollectionReusableView>(ofKind elementKind: String, for indexPath: IndexPath) -> T where T: Reusable { | ||
| 37 | + return self.dequeueReusableSupplementaryView(ofKind: elementKind, withReuseIdentifier: T.reuseIdentifier, for: indexPath) as! T | ||
| 38 | + } | ||
| 39 | +} | ||
| 40 | + | ||
| 41 | +extension UITableView { | ||
| 42 | + func registerReusableCell<T: UITableViewCell>(_: T.Type) where T: Reusable { | ||
| 43 | + self.register(T.self, forCellReuseIdentifier: T.reuseIdentifier) | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + func registerReusableView<T: UITableViewHeaderFooterView>(_: T.Type) where T: Reusable { | ||
| 47 | + self.register(T.self, forHeaderFooterViewReuseIdentifier: T.reuseIdentifier) | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + func dequeueReusableCell<T: UITableViewCell>(for indexPath: IndexPath) -> T where T: Reusable { | ||
| 51 | + return self.dequeueReusableCell(withIdentifier: T.reuseIdentifier, for: indexPath) as! T | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + func dequeueReusableView<T: UITableViewHeaderFooterView>() -> T where T: Reusable { | ||
| 55 | + return self.dequeueReusableHeaderFooterView(withIdentifier: T.reuseIdentifier) as! T | ||
| 56 | + } | ||
| 57 | +} |
Please
register
or
login
to post a comment