improvements made to digit field
This commit is contained in:
parent
6036415d6e
commit
ac1c856124
@ -24,7 +24,7 @@ import UIKit
|
||||
textField.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
textField.setContentCompressionResistancePriority(.required, for: .horizontal)
|
||||
textField.textAlignment = .center
|
||||
textField.font = MFStyler.fontForTextField()
|
||||
textField.font = Styler.Font.RegularBodyLarge.getFont()
|
||||
textField.keyboardType = .numberPad
|
||||
return textField
|
||||
}()
|
||||
@ -48,11 +48,11 @@ import UIKit
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
guard let self = self else { return }
|
||||
|
||||
self.borderStrokeColor = error ? .mfPumpkin() : .mfSilver()
|
||||
self.borderStrokeColor = error ? .mvmOrange : .mvmCoolGray3
|
||||
|
||||
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?.backgroundColor = self.showError ? UIColor.mfPumpkin().cgColor : UIColor.black.cgColor
|
||||
self.bottomBar?.backgroundColor = self.showError ? UIColor.mvmOrange.cgColor : UIColor.mvmBlack.cgColor
|
||||
|
||||
self.setNeedsDisplay()
|
||||
self.layoutIfNeeded()
|
||||
@ -97,29 +97,24 @@ import UIKit
|
||||
|
||||
open override func setupView() {
|
||||
super.setupView()
|
||||
|
||||
guard constraints.isEmpty else { return }
|
||||
|
||||
translatesAutoresizingMaskIntoConstraints = false
|
||||
backgroundColor = .clear
|
||||
|
||||
|
||||
addSubview(digitField)
|
||||
digitField.delegate = 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?.isActive = true
|
||||
heightConstraint = heightAnchor.constraint(equalToConstant: DigitBox.size.height)
|
||||
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 {
|
||||
layer.addSublayer(bottomBar)
|
||||
}
|
||||
@ -146,7 +141,7 @@ import UIKit
|
||||
super.reset()
|
||||
|
||||
backgroundColor = .clear
|
||||
digitField.font = MFStyler.fontForTextField()
|
||||
digitField.font = Styler.Font.RegularBodyLarge.getFont()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -186,7 +181,7 @@ import UIKit
|
||||
sizeObject?.performBlockBase(onSize: size)
|
||||
widthConstraint?.constant = width
|
||||
heightConstraint?.constant = height
|
||||
digitField.font = MFFonts.mfFont55Rg(pointSize)
|
||||
digitField.font = MFFonts.mfFontDSRegular(pointSize)
|
||||
previousSize = size
|
||||
}
|
||||
|
||||
|
||||
@ -228,14 +228,14 @@ import UIKit
|
||||
//--------------------------------------------------
|
||||
|
||||
@objc open override func updateView(_ size: CGFloat) {
|
||||
super.updateView(size)
|
||||
|
||||
|
||||
entryFieldContainer.disableAllBorders = true
|
||||
|
||||
if !self.digitBoxes.isEmpty {
|
||||
self.digitBoxes.forEach { $0.updateView(size) }
|
||||
}
|
||||
layoutIfNeeded()
|
||||
|
||||
super.updateView(size)
|
||||
}
|
||||
|
||||
public override func reset() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user