Merge branch 'develop'

This commit is contained in:
Kevin G Christiano 2020-03-25 11:19:09 -04:00
commit 5c4be8c2a6
7 changed files with 35 additions and 22 deletions

View File

@ -207,7 +207,7 @@ import UIKit
let digitBox = DigitBox() let digitBox = DigitBox()
digitBox.isAccessibilityElement = true digitBox.isAccessibilityElement = true
MVMCoreUICommonViewsUtility.addDismissToolbar(digitBox.digitField, delegate: self) digitBox.digitField.inputAccessoryView = MVMCoreUICommonViewsUtility.getToolbarWithDoneButton(delegate: self)
digitBox.digitField.delegate = self digitBox.digitField.delegate = self
digitBox.digitBoxDelegate = self digitBox.digitBoxDelegate = self
return digitBox return digitBox
@ -329,12 +329,10 @@ import UIKit
} }
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
guard let model = model as? DigitEntryFieldModel else { return } guard let model = model as? DigitEntryFieldModel else { return }
numberOfDigits = model.digits numberOfDigits = model.digits
setAsSecureTextEntry(model.secureEntry) setAsSecureTextEntry(model.secureEntry)
for digitBox in digitBoxes { for digitBox in digitBoxes {

View File

@ -116,8 +116,7 @@ import UIKit
set (newFeedback) { set (newFeedback) {
feedbackLabel.text = newFeedback feedbackLabel.text = newFeedback
feedbackLabel.accessibilityElementsHidden = feedbackLabel.text?.isEmpty ?? true feedbackLabel.accessibilityElementsHidden = feedbackLabel.text?.isEmpty ?? true
entryFieldContainer.refreshUI() entryFieldContainer.refreshUI(updateMoleculeLayout: true)
delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self)
} }
} }

View File

@ -49,6 +49,10 @@ import UIKit
/// Validate when user resigns editing. Default: true /// Validate when user resigns editing. Default: true
public var validateWhenDoneEditing: Bool = true public var validateWhenDoneEditing: Bool = true
public var textEntryFieldModel: TextEntryFieldModel? {
return model as? TextEntryFieldModel
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Computed Properties // MARK: - Computed Properties
@ -87,7 +91,7 @@ import UIKit
get { return textField.text } get { return textField.text }
set { set {
textField.text = newValue textField.text = newValue
(model as? TextEntryFieldModel)?.text = newValue textEntryFieldModel?.text = newValue
} }
} }
@ -167,7 +171,8 @@ import UIKit
textField.heightAnchor.constraint(equalToConstant: 24), textField.heightAnchor.constraint(equalToConstant: 24),
textField.topAnchor.constraint(equalTo: container.topAnchor, constant: 12), textField.topAnchor.constraint(equalTo: container.topAnchor, constant: 12),
textField.leadingAnchor.constraint(equalTo: container.leadingAnchor, constant: 16), textField.leadingAnchor.constraint(equalTo: container.leadingAnchor, constant: 16),
container.bottomAnchor.constraint(equalTo: textField.bottomAnchor, constant: 12)]) container.bottomAnchor.constraint(equalTo: textField.bottomAnchor, constant: 12)
])
textFieldTrailingConstraint = container.trailingAnchor.constraint(equalTo: textField.trailingAnchor, constant: 16) textFieldTrailingConstraint = container.trailingAnchor.constraint(equalTo: textField.trailingAnchor, constant: 16)
textFieldTrailingConstraint?.isActive = true textFieldTrailingConstraint?.isActive = true
@ -366,7 +371,6 @@ extension TextEntryField {
defaultValidationBlock() defaultValidationBlock()
} }
uiTextFieldDelegate = delegateObject.uiTextFieldDelegate uiTextFieldDelegate = delegateObject.uiTextFieldDelegate
observingTextFieldDelegate = delegateObject.observingTextFieldDelegate observingTextFieldDelegate = delegateObject.observingTextFieldDelegate
MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: uiTextFieldDelegate) MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: uiTextFieldDelegate)

View File

@ -36,7 +36,7 @@ import UIKit
/// Checks if the screen width has changed /// Checks if the screen width has changed
open func screenSizeChanged() -> Bool { open func screenSizeChanged() -> Bool {
return MVMCoreGetterUtility.cgfequalwiththreshold(previousScreenSize.width, view.bounds.size.width, 0.1) return !MVMCoreGetterUtility.cgfequalwiththreshold(previousScreenSize.width, view.bounds.size.width, 0.1)
} }
// MARK: - Response handling // MARK: - Response handling
@ -276,17 +276,18 @@ import UIKit
open override func viewDidLayoutSubviews() { open override func viewDidLayoutSubviews() {
// Add to fix a constraint bug where the width is zero and things get messed up. // Add to fix a constraint bug where the width is zero and things get messed up.
guard isViewLoaded, guard isViewLoaded, view.bounds.width > 1 else {
view.bounds.width > 1 else { super.viewDidLayoutSubviews()
super.viewDidLayoutSubviews() return
return
} }
if needsUpdateUI || screenSizeChanged() { if needsUpdateUI || screenSizeChanged() {
updateViews() updateViews()
needsUpdateUI = false needsUpdateUI = false
} }
previousScreenSize = view.bounds.size; previousScreenSize = view.bounds.size;
super.viewDidLayoutSubviews() super.viewDidLayoutSubviews()
} }

View File

@ -260,13 +260,21 @@ import UIKit
refreshUI(bottomBarSize: 1) refreshUI(bottomBarSize: 1)
} }
open func refreshUI(bottomBarSize: CGFloat? = nil) { open func refreshUI(bottomBarSize: CGFloat? = nil, updateMoleculeLayout: Bool = false) {
if !disableAllBorders { if !disableAllBorders {
let size: CGFloat = bottomBarSize ?? (showError ? 4 : 1) let size: CGFloat = bottomBarSize ?? (showError ? 4 : 1)
var heightChanged = false
if let bottomHeight = bottomBar?.bounds.height {
heightChanged = size != bottomHeight
}
bottomBar?.frame = CGRect(x: 0, y: bounds.height - size, width: bounds.width, height: size) bottomBar?.frame = CGRect(x: 0, y: bounds.height - size, width: bounds.width, height: size)
delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) if updateMoleculeLayout || heightChanged {
delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self)
}
setNeedsDisplay() setNeedsDisplay()
layoutIfNeeded() layoutIfNeeded()
} }

View File

@ -9,12 +9,15 @@
import Foundation import Foundation
public extension MVMCoreUICommonViewsUtility { public extension MVMCoreUICommonViewsUtility {
static func getToolbarWithDoneButton(delegate: ObservingTextFieldDelegate) -> UIToolbar { static func getToolbarWithDoneButton(delegate: ObservingTextFieldDelegate) -> UIToolbar {
let toolbar = self.makeEmptyToolbar() let toolbar = self.makeEmptyToolbar()
let space = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) let space = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
let button = UIBarButtonItem(barButtonSystemItem: .done, target: delegate, action: #selector(ObservingTextFieldDelegate.dismissFieldInput(sender:))) let button = UIBarButtonItem(barButtonSystemItem: .done, target: delegate, action: #selector(ObservingTextFieldDelegate.dismissFieldInput(sender:)))
button.tintColor = .black button.tintColor = .black
toolbar.setItems([space, button], animated: false) toolbar.setItems([space, button], animated: false)
return toolbar return toolbar
} }
} }

View File

@ -260,15 +260,15 @@ static const CGFloat VertialShadowOffset = 6;
UIBezierPath *shadowPath = [UIBezierPath bezierPath]; UIBezierPath *shadowPath = [UIBezierPath bezierPath];
//get the variables for frame //get the variables for frame
CGFloat x = 0; CGFloat x = rect.origin.x;
CGFloat y = 0; CGFloat y = rect.origin.y;
CGFloat width = CGRectGetWidth(rect); CGFloat width = CGRectGetWidth(rect);
CGFloat height = CGRectGetHeight(rect); CGFloat height = CGRectGetHeight(rect);
[shadowPath moveToPoint:CGPointMake(x + HorizontalShadowInset, y)]; [shadowPath moveToPoint:CGPointMake(x + HorizontalShadowInset, y)];
[shadowPath addLineToPoint:CGPointMake(width - HorizontalShadowInset, y)]; [shadowPath addLineToPoint:CGPointMake(x + width - HorizontalShadowInset, y)];
[shadowPath addLineToPoint:CGPointMake(width - HorizontalShadowInset, height-VertialShadowOffset/2)]; [shadowPath addLineToPoint:CGPointMake(x + width - HorizontalShadowInset, height-VertialShadowOffset/2)];
[shadowPath addQuadCurveToPoint:CGPointMake(x + HorizontalShadowInset, height - VertialShadowOffset/2) controlPoint:CGPointMake(width/2.f, height - VertialShadowOffset * 1.5)]; [shadowPath addQuadCurveToPoint:CGPointMake(x + HorizontalShadowInset, height - VertialShadowOffset/2) controlPoint:CGPointMake((x + width)/2.f, height - VertialShadowOffset * 1.5)];
[shadowPath addLineToPoint:CGPointMake(x + HorizontalShadowInset, y)]; [shadowPath addLineToPoint:CGPointMake(x + HorizontalShadowInset, y)];
[shadowPath closePath]; [shadowPath closePath];