Merge branch 'develop' into feature/viewInRoomArAtomicTemplate
This commit is contained in:
commit
163aebd6f3
@ -71,13 +71,17 @@ import UIKit
|
|||||||
public var showError: Bool {
|
public var showError: Bool {
|
||||||
get { return entryFieldContainer.showError }
|
get { return entryFieldContainer.showError }
|
||||||
set (error) {
|
set (error) {
|
||||||
self.feedback = error ? entryFieldModel?.errorMessage : entryFieldModel?.feedback
|
self.feedback = error ? errorMessage : entryFieldModel?.feedback
|
||||||
self.feedbackLabel.textColor = error ? entryFieldModel?.errorTextColor?.uiColor ?? .mvmBlack : .mvmBlack
|
self.feedbackLabel.textColor = error ? entryFieldModel?.errorTextColor?.uiColor ?? .mvmBlack : .mvmBlack
|
||||||
self.entryFieldContainer.showError = error
|
self.entryFieldContainer.showError = error
|
||||||
self.entryFieldModel?.showError = error
|
self.entryFieldModel?.showError = error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var errorMessage: String? {
|
||||||
|
entryFieldModel?.dynamicErrorMessage ?? entryFieldModel?.errorMessage
|
||||||
|
}
|
||||||
|
|
||||||
/// Toggles original or locked UI.
|
/// Toggles original or locked UI.
|
||||||
public var isLocked: Bool {
|
public var isLocked: Bool {
|
||||||
get { return entryFieldContainer.isLocked }
|
get { return entryFieldContainer.isLocked }
|
||||||
@ -306,16 +310,30 @@ import UIKit
|
|||||||
|
|
||||||
if self.isSelected {
|
if self.isSelected {
|
||||||
self.updateValidation(model.isValid ?? true)
|
self.updateValidation(model.isValid ?? true)
|
||||||
|
|
||||||
} else if model.isValid ?? true && self.showError {
|
} else if model.isValid ?? true && self.showError {
|
||||||
self.showError = false
|
self.showError = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model.updateUIDynamicError = { [weak self] in
|
||||||
|
MVMCoreDispatchUtility.performBlock(onMainThread: {
|
||||||
|
guard let self = self else { return }
|
||||||
|
let validState = model.isValid ?? false
|
||||||
|
self.updateValidation(validState)
|
||||||
|
if !validState && model.shouldClearText {
|
||||||
|
self.text = ""
|
||||||
|
model.shouldClearText = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
title = model.title
|
title = model.title
|
||||||
feedback = model.feedback
|
feedback = model.feedback
|
||||||
isEnabled = model.enabled
|
isEnabled = model.enabled
|
||||||
entryFieldContainer.disableAllBorders = model.hideBorders
|
entryFieldContainer.disableAllBorders = model.hideBorders
|
||||||
|
accessibilityIdentifier = model.accessibilityIdentifier ?? model.fieldKey
|
||||||
|
|
||||||
if let isLocked = model.locked {
|
if let isLocked = model.locked {
|
||||||
self.isLocked = isLocked
|
self.isLocked = isLocked
|
||||||
|
|||||||
@ -19,8 +19,16 @@ import Foundation
|
|||||||
}
|
}
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
|
public var accessibilityIdentifier: String?
|
||||||
public var title: String?
|
public var title: String?
|
||||||
public var feedback: String?
|
public var feedback: String?
|
||||||
|
public var shouldClearText: Bool = false
|
||||||
|
public var dynamicErrorMessage: String? {
|
||||||
|
didSet {
|
||||||
|
isValid = dynamicErrorMessage?.isEmpty ?? true
|
||||||
|
updateUIDynamicError?()
|
||||||
|
}
|
||||||
|
}
|
||||||
public var errorMessage: String?
|
public var errorMessage: String?
|
||||||
public var errorTextColor: Color?
|
public var errorTextColor: Color?
|
||||||
public var enabled: Bool = true
|
public var enabled: Bool = true
|
||||||
@ -41,6 +49,9 @@ import Foundation
|
|||||||
/// Temporary binding mechanism for the view to update on enable changes.
|
/// Temporary binding mechanism for the view to update on enable changes.
|
||||||
public var updateUI: ActionBlock?
|
public var updateUI: ActionBlock?
|
||||||
|
|
||||||
|
// TODO: Remove once updateUI is fixed with isSelected
|
||||||
|
public var updateUIDynamicError: ActionBlock?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Keys
|
// MARK: - Keys
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -48,6 +59,7 @@ import Foundation
|
|||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
|
case accessibilityIdentifier
|
||||||
case title
|
case title
|
||||||
case enabled
|
case enabled
|
||||||
case feedback
|
case feedback
|
||||||
@ -67,6 +79,9 @@ import Foundation
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public func formFieldValue() -> AnyHashable? {
|
public func formFieldValue() -> AnyHashable? {
|
||||||
|
if dynamicErrorMessage != nil {
|
||||||
|
dynamicErrorMessage = nil
|
||||||
|
}
|
||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,6 +111,7 @@ import Foundation
|
|||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
|
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
||||||
title = try typeContainer.decodeIfPresent(String.self, forKey: .title)
|
title = try typeContainer.decodeIfPresent(String.self, forKey: .title)
|
||||||
feedback = try typeContainer.decodeIfPresent(String.self, forKey: .feedback)
|
feedback = try typeContainer.decodeIfPresent(String.self, forKey: .feedback)
|
||||||
errorMessage = try typeContainer.decodeIfPresent(String.self, forKey: .errorMessage)
|
errorMessage = try typeContainer.decodeIfPresent(String.self, forKey: .errorMessage)
|
||||||
@ -117,6 +133,7 @@ import Foundation
|
|||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(moleculeName, forKey: .moleculeName)
|
try container.encodeIfPresent(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
|
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
|
||||||
try container.encodeIfPresent(title, forKey: .title)
|
try container.encodeIfPresent(title, forKey: .title)
|
||||||
try container.encodeIfPresent(feedback, forKey: .feedback)
|
try container.encodeIfPresent(feedback, forKey: .feedback)
|
||||||
try container.encodeIfPresent(text, forKey: .text)
|
try container.encodeIfPresent(text, forKey: .text)
|
||||||
|
|||||||
@ -18,12 +18,8 @@ import UIKit
|
|||||||
@objc public var loadObject: MVMCoreLoadObject?
|
@objc public var loadObject: MVMCoreLoadObject?
|
||||||
public var model: MVMControllerModelProtocol?
|
public var model: MVMControllerModelProtocol?
|
||||||
public var pageModel: PageModelProtocol? {
|
public var pageModel: PageModelProtocol? {
|
||||||
get {
|
get { model }
|
||||||
return model
|
set { model = newValue as? MVMControllerModelProtocol }
|
||||||
}
|
|
||||||
set {
|
|
||||||
model = newValue as? MVMControllerModelProtocol
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set if this page is containted in a manager.
|
/// Set if this page is containted in a manager.
|
||||||
@ -31,12 +27,10 @@ import UIKit
|
|||||||
|
|
||||||
/// A temporary iVar backer for delegateObject() until we change the protocol
|
/// A temporary iVar backer for delegateObject() until we change the protocol
|
||||||
public lazy var delegateObjectIVar: MVMCoreUIDelegateObject = {
|
public lazy var delegateObjectIVar: MVMCoreUIDelegateObject = {
|
||||||
return MVMCoreUIDelegateObject.create(withDelegateForAll: self)
|
MVMCoreUIDelegateObject.create(withDelegateForAll: self)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
public func delegateObject() -> DelegateObject? {
|
public func delegateObject() -> DelegateObject? { delegateObjectIVar }
|
||||||
return delegateObjectIVar
|
|
||||||
}
|
|
||||||
|
|
||||||
public var formValidator: FormValidator?
|
public var formValidator: FormValidator?
|
||||||
|
|
||||||
@ -52,7 +46,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)
|
!MVMCoreGetterUtility.cgfequalwiththreshold(previousScreenSize.width, view.bounds.size.width, 0.1)
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -80,7 +74,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
open func modulesToListenFor() -> [String]? {
|
open func modulesToListenFor() -> [String]? {
|
||||||
return loadObject?.requestParameters?.modules as? [String]
|
loadObject?.requestParameters?.modules as? [String]
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc open func responseJSONUpdated(notification: Notification) {
|
@objc open func responseJSONUpdated(notification: Notification) {
|
||||||
@ -405,7 +399,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
open override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
|
open override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
|
||||||
return MVMCoreGetterUtility.isOnIPad() ? UIInterfaceOrientationMask.all : UIInterfaceOrientationMask.portrait
|
MVMCoreGetterUtility.isOnIPad() ? UIInterfaceOrientationMask.all : UIInterfaceOrientationMask.portrait
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
||||||
@ -424,6 +418,7 @@ import UIKit
|
|||||||
open func viewControllerReady(inManager manager: UIViewController & MVMCoreViewManagerProtocol) {
|
open func viewControllerReady(inManager manager: UIViewController & MVMCoreViewManagerProtocol) {
|
||||||
pageShown()
|
pageShown()
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - MVMCoreLoadDelegateProtocol
|
// MARK: - MVMCoreLoadDelegateProtocol
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -444,6 +439,21 @@ import UIKit
|
|||||||
open func addFormParams(_ requestParameters: MVMCoreRequestParameters) {
|
open func addFormParams(_ requestParameters: MVMCoreRequestParameters) {
|
||||||
formValidator?.addFormParams(requestParameters: requestParameters)
|
formValidator?.addFormParams(requestParameters: requestParameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func handleFieldErrors(_ fieldErrors: [Any]?, loadObject: MVMCoreLoadObject) {
|
||||||
|
|
||||||
|
for case let fieldError as [AnyHashable: Any] in fieldErrors ?? [] {
|
||||||
|
|
||||||
|
guard let fieldName = fieldError["fieldName"] as? String,
|
||||||
|
let userError = fieldError["userMessage"] as? String,
|
||||||
|
let entryFieldModel = formValidator?.fields[fieldName] as? EntryFieldModel
|
||||||
|
else { continue }
|
||||||
|
|
||||||
|
entryFieldModel.shouldClearText = fieldError["clearText"] as? Bool ?? true
|
||||||
|
entryFieldModel.dynamicErrorMessage = userError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - MVMCoreActionDelegateProtocol
|
// MARK: - MVMCoreActionDelegateProtocol
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -484,7 +494,7 @@ import UIKit
|
|||||||
|
|
||||||
// Needed otherwise when subclassed, the extension gets called.
|
// Needed otherwise when subclassed, the extension gets called.
|
||||||
open func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) { }
|
open func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) { }
|
||||||
open func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? { return nil }
|
open func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? { nil }
|
||||||
open func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation) { }
|
open func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation) { }
|
||||||
open func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) { }
|
open func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) { }
|
||||||
|
|
||||||
@ -514,7 +524,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
open func showRightPanelForScreenBeforeLaunchApp() -> Bool {
|
open func showRightPanelForScreenBeforeLaunchApp() -> Bool {
|
||||||
return loadObject?.pageJSON?.lenientBoolForKey("showRightPanel") ?? false
|
loadObject?.pageJSON?.lenientBoolForKey("showRightPanel") ?? false
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make molecular
|
// TODO: make molecular
|
||||||
@ -610,6 +620,6 @@ import UIKit
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
func executeBehaviors<T>(_ behaviorBlock:(_ behavior:T)->Void) {
|
func executeBehaviors<T>(_ behaviorBlock:(_ behavior:T)->Void) {
|
||||||
model?.behaviors?.compactMap({ $0 as? T }).forEach { behaviorBlock($0) }
|
model?.behaviors?.compactMap { $0 as? T }.forEach { behaviorBlock($0) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,6 @@ public protocol FormFieldProtocol: FormItemProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension FormFieldProtocol {
|
extension FormFieldProtocol {
|
||||||
var baseValue: AnyHashable? {
|
|
||||||
return nil
|
var baseValue: AnyHashable? { nil }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user