more changes.
This commit is contained in:
parent
f19d45b865
commit
8b5fe4a1f4
@ -8,12 +8,12 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@objc protocol DigitBoxDelegate {
|
@objc protocol DigitBoxProtocol {
|
||||||
@objc optional func digitFieldDidDelete(_ textField: UITextField?)
|
@objc optional func digitFieldDidDelete(_ textField: UITextField?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@objcMembers open class DigitBox: FormFieldContainer, UITextFieldDelegate {
|
@objcMembers open class DigitBox: FormFieldContainer, UITextFieldDelegate, TextFieldDidDeleteProtocol {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Outlets
|
// MARK: - Outlets
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -61,7 +61,7 @@ import UIKit
|
|||||||
// MARK: - Delegate
|
// MARK: - Delegate
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
weak var digitBoxDelegate: DigitBoxDelegate?
|
weak var digitBoxDelegate: DigitBoxProtocol?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Constraints
|
// MARK: - Constraints
|
||||||
@ -74,16 +74,16 @@ import UIKit
|
|||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public override init(frame: CGRect) {
|
@objc public override init(frame: CGRect) {
|
||||||
super.init(frame: frame)
|
super.init(frame: frame)
|
||||||
setup()
|
setup()
|
||||||
}
|
}
|
||||||
|
|
||||||
public convenience init() {
|
@objc public convenience init() {
|
||||||
self.init(frame: .zero)
|
self.init(frame: .zero)
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init?(coder: NSCoder) {
|
@objc required public init?(coder: NSCoder) {
|
||||||
super.init(coder: coder)
|
super.init(coder: coder)
|
||||||
fatalError("DigitBox does not support xibs.")
|
fatalError("DigitBox does not support xibs.")
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ import UIKit
|
|||||||
// MARK: - Lifecycle
|
// MARK: - Lifecycle
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private func setup() {
|
@objc private func setup() {
|
||||||
|
|
||||||
guard constraints.isEmpty else { return }
|
guard constraints.isEmpty else { return }
|
||||||
|
|
||||||
@ -101,6 +101,7 @@ import UIKit
|
|||||||
|
|
||||||
addSubview(digitField)
|
addSubview(digitField)
|
||||||
digitField.delegate = self
|
digitField.delegate = self
|
||||||
|
digitField.didDeleteDelegate = self
|
||||||
|
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
digitField.heightAnchor.constraint(equalToConstant: 24),
|
digitField.heightAnchor.constraint(equalToConstant: 24),
|
||||||
@ -120,21 +121,20 @@ import UIKit
|
|||||||
layer.addSublayer(bottomBar)
|
layer.addSublayer(bottomBar)
|
||||||
}
|
}
|
||||||
updateView(MVMCoreUISplitViewController.getDetailViewWidth())
|
updateView(MVMCoreUISplitViewController.getDetailViewWidth())
|
||||||
digitField.addTarget(self, action:#selector(textfieldChanged) , for: .valueChanged)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func textfieldChanged() {
|
@objc public func textFieldDidDelete() {
|
||||||
|
digitBoxDelegate?.digitFieldDidDelete?(digitField)
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func layoutSubviews() {
|
@objc open override func layoutSubviews() {
|
||||||
super.layoutSubviews()
|
super.layoutSubviews()
|
||||||
|
|
||||||
let barHeight: CGFloat = showError ? 4 : 1
|
let barHeight: CGFloat = showError ? 4 : 1
|
||||||
bottomBar?.frame = CGRect(x: 0, y: bounds.height - barHeight, width: bounds.width, height: barHeight)
|
bottomBar?.frame = CGRect(x: 0, y: bounds.height - barHeight, width: bounds.width, height: barHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func reset() {
|
@objc open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
|
||||||
digitField.text = nil
|
digitField.text = nil
|
||||||
@ -144,7 +144,7 @@ import UIKit
|
|||||||
// MARK: - Methods
|
// MARK: - Methods
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public override func updateView(_ size: CGFloat) {
|
@objc public override func updateView(_ size: CGFloat) {
|
||||||
super.updateView(size)
|
super.updateView(size)
|
||||||
|
|
||||||
DispatchQueue.main.async { [weak self] in
|
DispatchQueue.main.async { [weak self] in
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import UIKit
|
|||||||
/**
|
/**
|
||||||
* Subclass of TextEntryField as it is to use similar logic as a singular textField but appear separate..
|
* Subclass of TextEntryField as it is to use similar logic as a singular textField but appear separate..
|
||||||
*/
|
*/
|
||||||
@objcMembers open class DigitEntryField: TextEntryField, DigitBoxDelegate {
|
@objcMembers open class DigitEntryField: TextEntryField, DigitBoxProtocol {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -122,7 +122,7 @@ import UIKit
|
|||||||
// MARK: - Delegate
|
// MARK: - Delegate
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
/// Holds a reference to the delegating class so this class can internally influence the TextField behavior as well.
|
/// Holds a reference to the 'delegating' class so this class can internally influence the TextField behavior as well.
|
||||||
private weak var proprietorTextDelegate: UITextFieldDelegate?
|
private weak var proprietorTextDelegate: UITextFieldDelegate?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -140,6 +140,7 @@ import UIKit
|
|||||||
@objc public convenience init(numberOfDigits: Int) {
|
@objc public convenience init(numberOfDigits: Int) {
|
||||||
self.init(frame: .zero)
|
self.init(frame: .zero)
|
||||||
self.numberOfDigits = numberOfDigits
|
self.numberOfDigits = numberOfDigits
|
||||||
|
assembleDigitFieldsView(size: MVMCoreUISplitViewController.getDetailViewWidth())
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc required public init?(coder: NSCoder) {
|
@objc required public init?(coder: NSCoder) {
|
||||||
@ -156,7 +157,6 @@ import UIKit
|
|||||||
alignCenterHorizontal()
|
alignCenterHorizontal()
|
||||||
isAccessibilityElement = false
|
isAccessibilityElement = false
|
||||||
entryContainer.disableAllBorders = true
|
entryContainer.disableAllBorders = true
|
||||||
assembleDigitFieldsView(size: MVMCoreUISplitViewController.getDetailViewWidth())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func createDigitField() -> DigitBox {
|
@objc private func createDigitField() -> DigitBox {
|
||||||
@ -173,6 +173,8 @@ import UIKit
|
|||||||
|
|
||||||
var accessibleElements: [Any] = [titleLabel]
|
var accessibleElements: [Any] = [titleLabel]
|
||||||
|
|
||||||
|
digitBoxes.forEach { $0.removeFromSuperview() }
|
||||||
|
|
||||||
if numberOfDigits > 0 {
|
if numberOfDigits > 0 {
|
||||||
var digitBoxes = [DigitBox]()
|
var digitBoxes = [DigitBox]()
|
||||||
for _ in 0..<numberOfDigits {
|
for _ in 0..<numberOfDigits {
|
||||||
@ -233,8 +235,7 @@ import UIKit
|
|||||||
|
|
||||||
@objc open override func reset() {
|
@objc open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
|
||||||
entryContainer.disableAllBorders = false
|
|
||||||
digitBoxes.forEach { $0.reset() }
|
digitBoxes.forEach { $0.reset() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +270,7 @@ import UIKit
|
|||||||
|
|
||||||
var selectPreviousField = false
|
var selectPreviousField = false
|
||||||
|
|
||||||
for field in digitBoxes.reversed() {
|
for field in Array(digitBoxes.reversed()) {
|
||||||
|
|
||||||
if field.isSelected {
|
if field.isSelected {
|
||||||
selectPreviousField = true
|
selectPreviousField = true
|
||||||
@ -307,8 +308,8 @@ import UIKit
|
|||||||
if !clear {
|
if !clear {
|
||||||
switchFieldsAutomatically = true
|
switchFieldsAutomatically = true
|
||||||
}
|
}
|
||||||
field.isSelected = true
|
|
||||||
field.digitField.becomeFirstResponder()
|
field.digitField.becomeFirstResponder()
|
||||||
|
field.isSelected = true
|
||||||
switchFieldsAutomatically = false
|
switchFieldsAutomatically = false
|
||||||
|
|
||||||
UIAccessibility.post(notification: .layoutChanged, argument: field.digitField)
|
UIAccessibility.post(notification: .layoutChanged, argument: field.digitField)
|
||||||
@ -408,19 +409,27 @@ extension DigitEntryField {
|
|||||||
if digitBox.digitField == textField {
|
if digitBox.digitField == textField {
|
||||||
selectedDigitField = digitBox
|
selectedDigitField = digitBox
|
||||||
digitBox.isSelected = true
|
digitBox.isSelected = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !switchFieldsAutomatically {
|
// if !switchFieldsAutomatically {
|
||||||
textField.text = ""
|
// textField.text = ""
|
||||||
valueChanged()
|
// valueChanged()
|
||||||
}
|
// }
|
||||||
|
|
||||||
proprietorTextDelegate?.textFieldDidBeginEditing?(textField)
|
proprietorTextDelegate?.textFieldDidBeginEditing?(textField)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func textFieldDidEndEditing(_ textField: UITextField) {
|
@objc public func textFieldDidEndEditing(_ textField: UITextField) {
|
||||||
|
|
||||||
|
digitBoxes.forEach { box in
|
||||||
|
if box.digitField == textField {
|
||||||
|
box.isSelected = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
proprietorTextDelegate?.textFieldDidEndEditing?(textField)
|
proprietorTextDelegate?.textFieldDidEndEditing?(textField)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,14 +22,12 @@ import UIKit
|
|||||||
let label = Label()
|
let label = Label()
|
||||||
label.font = MFStyler.fontB3()
|
label.font = MFStyler.fontB3()
|
||||||
label.textColor = .mfBattleshipGrey()
|
label.textColor = .mfBattleshipGrey()
|
||||||
label.isAccessibilityElement = true
|
|
||||||
label.setContentCompressionResistancePriority(.required, for: .vertical)
|
label.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
return label
|
return label
|
||||||
}()
|
}()
|
||||||
|
|
||||||
public private(set) var entryContainer: FormFieldContainer = {
|
public private(set) var entryContainer: FormFieldContainer = {
|
||||||
let view = FormFieldContainer()
|
let view = FormFieldContainer()
|
||||||
view.isAccessibilityElement = false
|
|
||||||
return view
|
return view
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -37,7 +35,6 @@ import UIKit
|
|||||||
let label = Label()
|
let label = Label()
|
||||||
label.font = MFStyler.fontForTextFieldUnderLabel()
|
label.font = MFStyler.fontForTextFieldUnderLabel()
|
||||||
label.textColor = .black
|
label.textColor = .black
|
||||||
label.isAccessibilityElement = true
|
|
||||||
label.setContentCompressionResistancePriority(.required, for: .vertical)
|
label.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
return label
|
return label
|
||||||
}()
|
}()
|
||||||
|
|||||||
@ -52,6 +52,7 @@ open class ItemDropdownEntryField: BaseDropdownEntryField {
|
|||||||
|
|
||||||
pickerView = MVMCoreUICommonViewsUtility.addPicker(to: textField, delegate: self)
|
pickerView = MVMCoreUICommonViewsUtility.addPicker(to: textField, delegate: self)
|
||||||
textField.hideBlinkingCaret = true
|
textField.hideBlinkingCaret = true
|
||||||
|
textField.autocorrectionType = .no
|
||||||
uiTextFieldDelegate = self
|
uiTextFieldDelegate = self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -97,7 +97,7 @@ import MVMCore
|
|||||||
return MVMCoreUIUtility.validateInternationalMDNString(MDN)
|
return MVMCoreUIUtility.validateInternationalMDNString(MDN)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func validateAndColor() -> Bool {
|
@objc public func validate() -> Bool {
|
||||||
|
|
||||||
if !shouldValidateMDN {
|
if !shouldValidateMDN {
|
||||||
let isValid = hasValidMDN()
|
let isValid = hasValidMDN()
|
||||||
@ -116,7 +116,7 @@ import MVMCore
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func getContacts(_ sender: Any?) {
|
@objc public func getContacts(_ sender: Any?) {
|
||||||
|
|
||||||
let picker = CNContactPickerViewController()
|
let picker = CNContactPickerViewController()
|
||||||
picker.delegate = self
|
picker.delegate = self
|
||||||
@ -183,7 +183,7 @@ import MVMCore
|
|||||||
|
|
||||||
proprietorTextDelegate?.textFieldDidEndEditing?(textField)
|
proprietorTextDelegate?.textFieldDidEndEditing?(textField)
|
||||||
|
|
||||||
if validateAndColor() && isNationalMDN {
|
if validate() && isNationalMDN {
|
||||||
textField.text = MVMCoreUIUtility.formatMdn(textField.text)
|
textField.text = MVMCoreUIUtility.formatMdn(textField.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,12 +8,12 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
protocol TextFieldDelegate {
|
public protocol TextFieldDidDeleteProtocol: class {
|
||||||
func textFieldDidDelete()
|
func textFieldDidDelete()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
open class TextField: UITextField {
|
@objcMembers open class TextField: UITextField {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -30,7 +30,7 @@ open class TextField: UITextField {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
/// Holds a reference to the delegating class so this class can internally influence the TextField behavior as well.
|
/// Holds a reference to the delegating class so this class can internally influence the TextField behavior as well.
|
||||||
private weak var proprietorTextDelegate: UITextFieldDelegate?
|
public weak var didDeleteDelegate: TextFieldDidDeleteProtocol?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initialization
|
// MARK: - Initialization
|
||||||
@ -69,7 +69,7 @@ open class TextField: UITextField {
|
|||||||
|
|
||||||
open override func deleteBackward() {
|
open override func deleteBackward() {
|
||||||
super.deleteBackward()
|
super.deleteBackward()
|
||||||
// proprietorTextDelegate?.textFieldDidDelete()
|
didDeleteDelegate?.textFieldDidDelete()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -101,7 +101,7 @@ import UIKit
|
|||||||
_isLocked = false
|
_isLocked = false
|
||||||
_isEnabled = true
|
_isEnabled = true
|
||||||
_showError = false
|
_showError = false
|
||||||
|
|
||||||
fieldState = selected ? .selected : .original
|
fieldState = selected ? .selected : .original
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,6 +155,8 @@ import UIKit
|
|||||||
override open func setupView() {
|
override open func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
|
|
||||||
|
isAccessibilityElement = false
|
||||||
|
|
||||||
isOpaque = false
|
isOpaque = false
|
||||||
if let bottomBar = bottomBar {
|
if let bottomBar = bottomBar {
|
||||||
layer.addSublayer(bottomBar)
|
layer.addSublayer(bottomBar)
|
||||||
|
|||||||
@ -208,12 +208,14 @@ import UIKit
|
|||||||
/// Adds the standard mvm style caret to the accessory view
|
/// Adds the standard mvm style caret to the accessory view
|
||||||
@objc public func addCaretViewAccessory() {
|
@objc public func addCaretViewAccessory() {
|
||||||
guard accessoryView == nil else { return }
|
guard accessoryView == nil else { return }
|
||||||
let width: CGFloat = 6
|
caretView = CaretView(lineWidth: 1)
|
||||||
let height: CGFloat = 10
|
caretView?.size = .small(.vertical)
|
||||||
caretView = CaretView(lineThickness: CaretView.thin)
|
caretView?.setConstraints()
|
||||||
caretView?.frame = CGRect(x: 0, y: 0, width: width, height: height)
|
|
||||||
caretViewWidthSizeObject = MFSizeObject(standardSize: width, standardiPadPortraitSize: 9)
|
if let size = caretView?.size?.dimensions() {
|
||||||
caretViewHeightSizeObject = MFSizeObject(standardSize: height, standardiPadPortraitSize: 16)
|
caretViewWidthSizeObject = MFSizeObject(standardSize: size.width, standardiPadPortraitSize: 9)
|
||||||
|
caretViewHeightSizeObject = MFSizeObject(standardSize: size.height, standardiPadPortraitSize: 16)
|
||||||
|
}
|
||||||
accessoryView = caretView
|
accessoryView = caretView
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user