improvements made to digit field

This commit is contained in:
Kevin G Christiano 2020-04-27 10:10:25 -04:00
parent 6036415d6e
commit ac1c856124
2 changed files with 17 additions and 22 deletions

View File

@ -24,7 +24,7 @@ import UIKit
textField.setContentCompressionResistancePriority(.required, for: .vertical) textField.setContentCompressionResistancePriority(.required, for: .vertical)
textField.setContentCompressionResistancePriority(.required, for: .horizontal) textField.setContentCompressionResistancePriority(.required, for: .horizontal)
textField.textAlignment = .center textField.textAlignment = .center
textField.font = MFStyler.fontForTextField() textField.font = Styler.Font.RegularBodyLarge.getFont()
textField.keyboardType = .numberPad textField.keyboardType = .numberPad
return textField return textField
}() }()
@ -48,11 +48,11 @@ import UIKit
DispatchQueue.main.async { [weak self] in DispatchQueue.main.async { [weak self] in
guard let self = self else { return } guard let self = self else { return }
self.borderStrokeColor = error ? .mfPumpkin() : .mfSilver() self.borderStrokeColor = error ? .mvmOrange : .mvmCoolGray3
let barHeight: CGFloat = self.showError ? 4 : 1 let barHeight: CGFloat = self.showError ? 4 : 1
self.bottomBar?.frame = CGRect(x: 0, y: self.bounds.height - barHeight, width: self.bounds.width, height: barHeight) self.bottomBar?.frame = CGRect(x: 0, y: self.bounds.height - barHeight, width: self.bounds.width, height: barHeight)
self.bottomBar?.backgroundColor = self.showError ? UIColor.mfPumpkin().cgColor : UIColor.black.cgColor self.bottomBar?.backgroundColor = self.showError ? UIColor.mvmOrange.cgColor : UIColor.mvmBlack.cgColor
self.setNeedsDisplay() self.setNeedsDisplay()
self.layoutIfNeeded() self.layoutIfNeeded()
@ -97,29 +97,24 @@ import UIKit
open override func setupView() { open override func setupView() {
super.setupView() super.setupView()
guard constraints.isEmpty else { return }
translatesAutoresizingMaskIntoConstraints = false
backgroundColor = .clear
addSubview(digitField) addSubview(digitField)
digitField.delegate = self digitField.delegate = self
digitField.didDeleteDelegate = self digitField.didDeleteDelegate = self
NSLayoutConstraint.activate([
digitField.topAnchor.constraint(equalTo: topAnchor, constant: PaddingOne),
digitField.leadingAnchor.constraint(equalTo: leadingAnchor, constant: PaddingOne),
bottomAnchor.constraint(equalTo: digitField.bottomAnchor, constant: PaddingOne),
trailingAnchor.constraint(equalTo: digitField.trailingAnchor, constant: PaddingOne),
digitField.centerYAnchor.constraint(equalTo: centerYAnchor),
digitField.centerXAnchor.constraint(equalTo: centerXAnchor)])
widthConstraint = widthAnchor.constraint(equalToConstant: DigitBox.size.width) widthConstraint = widthAnchor.constraint(equalToConstant: DigitBox.size.width)
widthConstraint?.isActive = true widthConstraint?.isActive = true
heightConstraint = heightAnchor.constraint(equalToConstant: DigitBox.size.height) heightConstraint = heightAnchor.constraint(equalToConstant: DigitBox.size.height)
heightConstraint?.isActive = true heightConstraint?.isActive = true
NSLayoutConstraint.activate([
digitField.topAnchor.constraint(equalTo: topAnchor, constant: Padding.Three),
digitField.leadingAnchor.constraint(equalTo: leadingAnchor),
bottomAnchor.constraint(equalTo: digitField.bottomAnchor, constant: Padding.Three),
trailingAnchor.constraint(equalTo: digitField.trailingAnchor),
digitField.centerYAnchor.constraint(equalTo: centerYAnchor)
])
if let bottomBar = bottomBar { if let bottomBar = bottomBar {
layer.addSublayer(bottomBar) layer.addSublayer(bottomBar)
} }
@ -146,7 +141,7 @@ import UIKit
super.reset() super.reset()
backgroundColor = .clear backgroundColor = .clear
digitField.font = MFStyler.fontForTextField() digitField.font = Styler.Font.RegularBodyLarge.getFont()
} }
//-------------------------------------------------- //--------------------------------------------------
@ -186,7 +181,7 @@ import UIKit
sizeObject?.performBlockBase(onSize: size) sizeObject?.performBlockBase(onSize: size)
widthConstraint?.constant = width widthConstraint?.constant = width
heightConstraint?.constant = height heightConstraint?.constant = height
digitField.font = MFFonts.mfFont55Rg(pointSize) digitField.font = MFFonts.mfFontDSRegular(pointSize)
previousSize = size previousSize = size
} }

View File

@ -228,14 +228,14 @@ import UIKit
//-------------------------------------------------- //--------------------------------------------------
@objc open override func updateView(_ size: CGFloat) { @objc open override func updateView(_ size: CGFloat) {
super.updateView(size)
entryFieldContainer.disableAllBorders = true entryFieldContainer.disableAllBorders = true
if !self.digitBoxes.isEmpty { if !self.digitBoxes.isEmpty {
self.digitBoxes.forEach { $0.updateView(size) } self.digitBoxes.forEach { $0.updateView(size) }
} }
layoutIfNeeded()
super.updateView(size)
} }
public override func reset() { public override func reset() {