Commit 2973e931ecea536913162ea95c9246ead91854c8

Authored by Dmitriy Tymofyeyev
1 parent 88b9a880

add CustomUI + TextFieldWithPadding

... ... @@ -23,8 +23,8 @@ class Checkbox: UIButton {
23 23 override var isSelected: Bool {
24 24 didSet {
25 25 checkBoxLabel.textColor = isSelected ?
26   - UIColor(red: 50/255, green: 55/255, blue: 85/255, alpha: 1) :
27   - UIColor(red: 185/255, green: 185/255, blue: 185/255, alpha: 1)
  26 + .TextColor.darkBlue :
  27 + .TextColor.lightGrey
28 28 checkboxImageView.image = isSelected ?
29 29 UIImage(named: "OnIndicator") :
30 30 UIImage(named: "OffIndicator")
... ...
... ... @@ -5,4 +5,61 @@
5 5 // Created by Дмитрий Тимофеев on 17.06.2022.
6 6 //
7 7
8   -import Foundation
  8 +import UIKit
  9 +class SquereCheckbox: UIButton {
  10 + private let checkboxImageView: UIImageView = {
  11 + let obj = UIImageView()
  12 + return obj
  13 + }()
  14 +
  15 + private let checkBoxLabel: UILabel = {
  16 + let obj = UILabel()
  17 + obj.font = .skModernist(type: .regular, ofSize: 14)
  18 + return obj
  19 + }()
  20 +
  21 + override var isSelected: Bool {
  22 + didSet {
  23 + checkBoxLabel.textColor = isSelected ?
  24 + .TextColor.darkBlue :
  25 + .TextColor.lightGrey
  26 + checkboxImageView.image = isSelected ?
  27 + UIImage(named: "FullSquere") :
  28 + UIImage(named: "EmptySquere")
  29 + }
  30 + }
  31 +
  32 + var checkboxTitle: String = "" {
  33 + didSet {
  34 + checkBoxLabel.text = checkboxTitle
  35 + }
  36 + }
  37 +
  38 + override init(frame: CGRect) {
  39 + super.init(frame: frame)
  40 + setup()
  41 + }
  42 +
  43 + required init?(coder: NSCoder) {
  44 + super.init(coder: coder)
  45 + setup()
  46 + }
  47 +
  48 + private func setup() {
  49 + isSelected = false
  50 +
  51 + addSubview(checkboxImageView)
  52 + addSubview(checkBoxLabel)
  53 +
  54 + checkboxImageView.snp.makeConstraints { make in
  55 + make.leading.equalToSuperview()
  56 + make.top.bottom.equalToSuperview()
  57 + }
  58 +
  59 + checkBoxLabel.snp.makeConstraints { make in
  60 + make.top.bottom.equalToSuperview()
  61 + make.trailing.equalToSuperview()
  62 + make.leading.equalTo(checkboxImageView.snp.trailing).offset(10)
  63 + }
  64 + }
  65 +}
... ...
... ... @@ -8,20 +8,19 @@
8 8 import UIKit
9 9
10 10 class TextFieldWithPadding: UITextField {
11   - var textPaddingForPhone = UIEdgeInsets(
  11 + var textPadding = UIEdgeInsets(
12 12 top: 0,
13   - left: 78,
  13 + left: 0,
14 14 bottom: 0,
15   - right: 22
16   - )
  15 + right: 0)
17 16
18 17 override func textRect(forBounds bounds: CGRect) -> CGRect {
19 18 let rect = super.textRect(forBounds: bounds)
20   - return rect.inset(by: textPaddingForPhone)
  19 + return rect.inset(by: textPadding)
21 20 }
22 21
23 22 override func editingRect(forBounds bounds: CGRect) -> CGRect {
24 23 let rect = super.editingRect(forBounds: bounds)
25   - return rect.inset(by: textPaddingForPhone)
  24 + return rect.inset(by: textPadding)
26 25 }
27 26 }
... ...
Please register or login to post a comment