more changes.
This commit is contained in:
parent
6d7c1df7cc
commit
ce0ffeda29
@ -77,7 +77,7 @@ import UIKit
|
|||||||
backgroundColor = .white
|
backgroundColor = .white
|
||||||
textAlignment = .center
|
textAlignment = .center
|
||||||
keyboardType = .numberPad
|
keyboardType = .numberPad
|
||||||
layer.borderWidth = 1
|
// layer.borderWidth = 1
|
||||||
showErrorState(false)
|
showErrorState(false)
|
||||||
|
|
||||||
widthConstraint = widthAnchor.constraint(equalToConstant: 39)
|
widthConstraint = widthAnchor.constraint(equalToConstant: 39)
|
||||||
@ -157,10 +157,12 @@ import UIKit
|
|||||||
})
|
})
|
||||||
|
|
||||||
sizeObject?.performBlockBase(onSize: size)
|
sizeObject?.performBlockBase(onSize: size)
|
||||||
self.widthConstraint?.constant = digitWidth
|
// self.widthConstraint?.constant = digitWidth
|
||||||
self.heightConstraint?.constant = digitHeight
|
// self.heightConstraint?.constant = digitHeight
|
||||||
self.previousSize = size
|
self.previousSize = size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.setNeedsLayout()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import UIKit
|
|||||||
// MARK: - Outlets
|
// MARK: - Outlets
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
/// UI Container of digitFields
|
||||||
public private(set) var digitFieldsStack: UIStackView?
|
public private(set) var digitFieldsStack: UIStackView?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -29,7 +30,7 @@ import UIKit
|
|||||||
|
|
||||||
public override var isEnabled: Bool {
|
public override var isEnabled: Bool {
|
||||||
didSet {
|
didSet {
|
||||||
titleLabel.textColor = isEnabled ? .black : .black
|
titleLabel.textColor = isEnabled ? .black : .mfBattleshipGrey()
|
||||||
|
|
||||||
for digitBox in digitFields {
|
for digitBox in digitFields {
|
||||||
digitBox.isUserInteractionEnabled = isEnabled
|
digitBox.isUserInteractionEnabled = isEnabled
|
||||||
@ -65,11 +66,11 @@ import UIKit
|
|||||||
feedback = ""
|
feedback = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
if let feedback = feedback, !feedback.isEmpty {
|
// if let feedback = feedback, !feedback.isEmpty {
|
||||||
feedbackContainerDistance?.constant = 10
|
// feedbackContainerDistance?.constant = 10
|
||||||
} else {
|
// } else {
|
||||||
feedbackContainerDistance?.constant = 0
|
// feedbackContainerDistance?.constant = 0
|
||||||
}
|
// }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* adding missing accessibilityLabel value
|
* adding missing accessibilityLabel value
|
||||||
@ -109,7 +110,6 @@ import UIKit
|
|||||||
self.appearance = appearance
|
self.appearance = appearance
|
||||||
isUserInteractionEnabled = true
|
isUserInteractionEnabled = true
|
||||||
titleLabel.textColor = .mfBattleshipGrey()
|
titleLabel.textColor = .mfBattleshipGrey()
|
||||||
hideBorder = false
|
|
||||||
feedback = showError ? errorMessage : nil
|
feedback = showError ? errorMessage : nil
|
||||||
|
|
||||||
switch appearance {
|
switch appearance {
|
||||||
@ -127,7 +127,6 @@ import UIKit
|
|||||||
case .lock:
|
case .lock:
|
||||||
digitFields.forEach {
|
digitFields.forEach {
|
||||||
$0.isUserInteractionEnabled = false
|
$0.isUserInteractionEnabled = false
|
||||||
$0.hideBorder = true
|
|
||||||
$0.bottomBar.backgroundColor = UIColor.clear.cgColor
|
$0.bottomBar.backgroundColor = UIColor.clear.cgColor
|
||||||
}
|
}
|
||||||
case .select:
|
case .select:
|
||||||
@ -143,8 +142,6 @@ import UIKit
|
|||||||
}
|
}
|
||||||
titleLabel.textColor = self.isEnabled ? .mfBattleshipGrey() : .mfSilver()
|
titleLabel.textColor = self.isEnabled ? .mfBattleshipGrey() : .mfSilver()
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshBorderUI(bottomBarSize: appearance == .error ? 4 : 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -160,19 +157,18 @@ import UIKit
|
|||||||
self.init(frame: .zero)
|
self.init(frame: .zero)
|
||||||
}
|
}
|
||||||
|
|
||||||
public convenience init(numberOfDigits: Int) {
|
public init(numberOfDigits: Int) {
|
||||||
self.init(frame: .zero)
|
super.init(frame: .zero)
|
||||||
|
|
||||||
self.numberOfDigits = numberOfDigits
|
self.numberOfDigits = numberOfDigits
|
||||||
buildTextFieldsView(size: MVMCoreUISplitViewController.getDetailViewWidth())
|
setup()
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(numberOfDigits: Int, bothDelegates delegate: (UITextFieldDelegate & TextFieldDelegate)?, size: CGFloat? = nil) {
|
public init(numberOfDigits: Int, bothDelegates delegate: (UITextFieldDelegate & TextFieldDelegate)?, size: CGFloat? = nil) {
|
||||||
super.init(bothDelegates: delegate)
|
super.init(bothDelegates: delegate)
|
||||||
|
|
||||||
setup()
|
|
||||||
self.numberOfDigits = numberOfDigits
|
self.numberOfDigits = numberOfDigits
|
||||||
buildTextFieldsView(size: size ?? MVMCoreUISplitViewController.getDetailViewWidth())
|
setup()
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init?(coder: NSCoder) {
|
required public init?(coder: NSCoder) {
|
||||||
@ -186,19 +182,23 @@ import UIKit
|
|||||||
|
|
||||||
open func setup() {
|
open func setup() {
|
||||||
|
|
||||||
// Border for Field Container will not be shown.
|
|
||||||
hideBorder = true
|
|
||||||
alignCenterHorizontal()
|
alignCenterHorizontal()
|
||||||
isAccessibilityElement = false
|
isAccessibilityElement = false
|
||||||
|
hideBorder = true
|
||||||
|
bottomBar.backgroundColor = UIColor.clear.cgColor
|
||||||
|
bottomBar.frame = CGRect(x: 0, y: fieldContainer.bounds.height, width: 0, height: 0)
|
||||||
|
setupDigitFieldsView(size: MVMCoreUISplitViewController.getDetailViewWidth())
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func setupFieldContainerContent(_ container: UIView) {
|
open override func setupFieldContainerContent(_ container: UIView) {
|
||||||
|
|
||||||
|
// Will not be using textField.
|
||||||
|
// TODO: May subclass from FormEntry if minimal overriding.
|
||||||
textField.removeFromSuperview()
|
textField.removeFromSuperview()
|
||||||
setupTextFieldsView(forSize: CGFloat(numberOfDigits))
|
setupDigitFieldsView(size: MVMCoreUIUtility.getWidth())
|
||||||
}
|
}
|
||||||
|
|
||||||
func createDigitField() -> DigitBox {
|
private func createDigitField() -> DigitBox {
|
||||||
|
|
||||||
let textField = DigitBox()
|
let textField = DigitBox()
|
||||||
textField.isAccessibilityElement = true
|
textField.isAccessibilityElement = true
|
||||||
@ -207,26 +207,49 @@ import UIKit
|
|||||||
return textField
|
return textField
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildTextFieldsView(size: CGFloat) {
|
func setupDigitFieldsView(size: CGFloat) {
|
||||||
|
|
||||||
|
self.digitFieldsStack?.subviews.forEach { $0.removeFromSuperview() }
|
||||||
|
digitFieldsStack?.removeFromSuperview()
|
||||||
|
|
||||||
var accessibleElements: [Any] = [titleLabel]
|
var accessibleElements: [Any] = [titleLabel]
|
||||||
|
|
||||||
// Remove all current UI.
|
// Remove all current views in UI.
|
||||||
if !digitFields.isEmpty {
|
if let stackViews = digitFieldsStack?.subviews, !stackViews.isEmpty {
|
||||||
digitFieldsStack?.subviews.forEach { $0.removeFromSuperview() }
|
stackViews.forEach { $0.removeFromSuperview() }
|
||||||
}
|
}
|
||||||
|
|
||||||
if numberOfDigits > 0 {
|
if numberOfDigits > 0 {
|
||||||
let digitFields = [DigitBox](repeating: createDigitField(), count: numberOfDigits)
|
let digitFields = [DigitBox](repeating: createDigitField(), count: numberOfDigits)
|
||||||
|
|
||||||
digitFields.forEach {
|
|
||||||
$0.updateView(size)
|
|
||||||
accessibleElements.append($0)
|
|
||||||
}
|
|
||||||
|
|
||||||
self.digitFields = digitFields
|
self.digitFields = digitFields
|
||||||
setupTextFieldsView(forSize: size)
|
guard let space = MFSizeObject(standardSize: 5, smalliPhoneSize: 3)?.getValueBasedOnScreenSize() else { return }
|
||||||
|
|
||||||
|
var prevBox: DigitBox?
|
||||||
|
|
||||||
|
for (index, box) in digitFields.enumerated() {
|
||||||
|
// $0.updateView(size)
|
||||||
|
accessibleElements.append(box)
|
||||||
|
fieldContainer.addSubview(box)
|
||||||
|
|
||||||
|
box.widthAnchor.constraint(equalToConstant: 39).isActive = true
|
||||||
|
box.heightAnchor.constraint(equalToConstant: 44).isActive = true
|
||||||
|
|
||||||
|
box.topAnchor.constraint(equalTo: fieldContainer.topAnchor).isActive = true
|
||||||
|
fieldContainer.bottomAnchor.constraint(equalTo: box.bottomAnchor).isActive = true
|
||||||
|
|
||||||
|
if index == 0 {
|
||||||
|
box.leadingAnchor.constraint(equalTo: fieldContainer.leadingAnchor).isActive = true
|
||||||
|
|
||||||
|
} else if index == digitFields.count - 1 {
|
||||||
|
|
||||||
|
box.leadingAnchor.constraint(equalTo: prevBox!.trailingAnchor, constant: space).isActive = true
|
||||||
|
fieldContainer.trailingAnchor.constraint(greaterThanOrEqualTo: box.trailingAnchor).isActive = true
|
||||||
|
} else {
|
||||||
|
box.leadingAnchor.constraint(equalTo: prevBox!.trailingAnchor).isActive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
prevBox = box
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
digitFields = []
|
digitFields = []
|
||||||
}
|
}
|
||||||
@ -244,45 +267,37 @@ 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.titleLabel.updateView(size)
|
|
||||||
|
|
||||||
if !self.digitFields.isEmpty {
|
if !self.digitFields.isEmpty {
|
||||||
|
|
||||||
self.digitFieldsStack?.subviews.forEach { $0.removeFromSuperview() }
|
self.digitFieldsStack?.subviews.forEach { $0.removeFromSuperview() }
|
||||||
self.digitFields.forEach { $0.updateView(size) }
|
self.digitFields.forEach { $0.updateView(size) }
|
||||||
|
self.layoutIfNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Layout text boxes.
|
// Layout text boxes.
|
||||||
self.setupTextFieldsView(forSize: size)
|
// self.setupDigitFieldsView(size: size)
|
||||||
}
|
}
|
||||||
|
// hideBorder = true
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Methods
|
// MARK: - Methods
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
func removeError() {
|
|
||||||
|
|
||||||
DispatchQueue.main.async { [weak self] in
|
|
||||||
guard let self = self else { return }
|
|
||||||
|
|
||||||
self.digitFields.forEach { $0.showErrorState(false) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override func valueChanged() {
|
override func valueChanged() {
|
||||||
super.valueChanged()
|
super.valueChanged()
|
||||||
|
|
||||||
DispatchQueue.main.async { [weak self] in
|
// TODO: is feedbackContainerDistance needed?
|
||||||
guard let self = self else { return }
|
// DispatchQueue.main.async { [weak self] in
|
||||||
|
// guard let self = self else { return }
|
||||||
if let feedback = self.feedback, !feedback.isEmpty {
|
//
|
||||||
self.feedbackContainerDistance?.constant = 10
|
// if let feedback = self.feedback, !feedback.isEmpty {
|
||||||
|
// self.feedbackContainerDistance?.constant = 10
|
||||||
} else {
|
//
|
||||||
self.feedbackContainerDistance?.constant = 0
|
// } else {
|
||||||
}
|
// self.feedbackContainerDistance?.constant = 0
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
func setAsSecureTextEntry(_ secureEntry: Bool) {
|
func setAsSecureTextEntry(_ secureEntry: Bool) {
|
||||||
@ -299,17 +314,6 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupTextFieldsView(forSize size: CGFloat) {
|
|
||||||
|
|
||||||
guard let space = MFSizeObject(standardSize: 5, smalliPhoneSize: 3)?.getValueBasedOnScreenSize() else { return }
|
|
||||||
|
|
||||||
let stack = UIStackView(arrangedSubviews: digitFields)
|
|
||||||
self.digitFieldsStack = stack
|
|
||||||
textField.addSubview(stack)
|
|
||||||
stack.distribution = .equalSpacing
|
|
||||||
stack.spacing = space
|
|
||||||
}
|
|
||||||
|
|
||||||
public override func defaultValidationBlock() {
|
public override func defaultValidationBlock() {
|
||||||
|
|
||||||
validationBlock = { enteredValue in
|
validationBlock = { enteredValue in
|
||||||
@ -319,7 +323,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func selectPreviousTextField(_ currentTextField: UITextField?, clear: Bool) {
|
public func selectPreviousTextField(_ currentTextField: UITextField?, clear: Bool) {
|
||||||
|
|
||||||
var selectNextField = false
|
var selectNextField = false
|
||||||
|
|
||||||
@ -340,7 +344,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func selectNextTextField(_ currentTextField: UITextField?, clear: Bool) {
|
public func selectNextTextField(_ currentTextField: UITextField?, clear: Bool) {
|
||||||
|
|
||||||
var selectNextField = false
|
var selectNextField = false
|
||||||
|
|
||||||
@ -380,7 +384,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTextFieldsView(size: MVMCoreUIUtility.getWidth())
|
setupDigitFieldsView(size: MVMCoreUIUtility.getWidth())
|
||||||
}
|
}
|
||||||
|
|
||||||
open override class func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
open override class func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
||||||
|
|||||||
@ -16,10 +16,8 @@ import UIKit
|
|||||||
|
|
||||||
let dropDownCaretView: CaretView = {
|
let dropDownCaretView: CaretView = {
|
||||||
let caret = CaretView()
|
let caret = CaretView()
|
||||||
// caret.size = .medium
|
|
||||||
caret.direction = .down
|
caret.direction = .down
|
||||||
caret.lineWidth = 1.5
|
caret.lineWidth = 1.5
|
||||||
// caret.isHidden = true
|
|
||||||
caret.isUserInteractionEnabled = true
|
caret.isUserInteractionEnabled = true
|
||||||
caret.heightAnchor.constraint(equalToConstant: 9).isActive = true
|
caret.heightAnchor.constraint(equalToConstant: 9).isActive = true
|
||||||
caret.widthAnchor.constraint(equalToConstant: 16).isActive = true
|
caret.widthAnchor.constraint(equalToConstant: 16).isActive = true
|
||||||
@ -162,7 +160,7 @@ extension DropdownEntryField {
|
|||||||
if let calendar = calendar, calendar.isDate(fromDate, inSameDayAs: Date()) {
|
if let calendar = calendar, calendar.isDate(fromDate, inSameDayAs: Date()) {
|
||||||
text = MVMCoreUIUtility.hardcodedString(withKey: "textfield_today_string")
|
text = MVMCoreUIUtility.hardcodedString(withKey: "textfield_today_string")
|
||||||
} else {
|
} else {
|
||||||
self.text = formatter.string(from: fromDate)
|
text = formatter.string(from: fromDate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -174,7 +174,6 @@ import UIKit
|
|||||||
open func clearErrorState() {
|
open func clearErrorState() {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||||
self.separatorHeightConstraint.constant = 1;
|
self.separatorHeightConstraint.constant = 1;
|
||||||
self.separatorView.backgroundColor = [UIColor blackColor];
|
self.separatorView.backgroundColor = [UIColor blackColor];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user