Merge branch 'develop' into bugfix/moleculename_encoding

This commit is contained in:
Lekshmi S 2021-03-24 21:47:56 +05:30
commit aba2d5b373
11 changed files with 33 additions and 31 deletions

View File

@ -200,6 +200,7 @@ import UIKit
open override func reset() { open override func reset() {
super.reset() super.reset()
textField.isSecureTextEntry = false
textField.font = Styler.Font.RegularBodyLarge.getFont() textField.font = Styler.Font.RegularBodyLarge.getFont()
} }
@ -365,6 +366,12 @@ import UIKit
setupTextFieldToolbar() setupTextFieldToolbar()
if isSelected { startEditing() } if isSelected { startEditing() }
//Added to override text when view is reloaded.
if let text = model.text, !text.isEmpty {
regexTextFieldOutputIfAvailable()
}
} }
} }

View File

@ -624,9 +624,6 @@ public typealias ActionBlock = () -> ()
} else if !MVMCoreGetterUtility.fequal(a: Float(standardFontSize), b: 0.0), let sizeObject = sizeObject ?? MFStyler.sizeObjectGeneric(forCurrentDevice: standardFontSize) { } else if !MVMCoreGetterUtility.fequal(a: Float(standardFontSize), b: 0.0), let sizeObject = sizeObject ?? MFStyler.sizeObjectGeneric(forCurrentDevice: standardFontSize) {
font = font.updateSize(sizeObject.getValueBased(onSize: size)) font = font.updateSize(sizeObject.getValueBased(onSize: size))
} }
// Provide the label additional size information to help calculate its intrinsic content.
preferredMaxLayoutWidth = Styler.maxAvailableLayoutWidth(size: size)
} }
@objc public func setFont(_ font: UIFont, scale: Bool) { @objc public func setFont(_ font: UIFont, scale: Bool) {
@ -688,7 +685,7 @@ public typealias ActionBlock = () -> ()
static func getTextAttachmentImage(name: String = "externalLink", dimension: CGFloat) -> NSTextAttachment { static func getTextAttachmentImage(name: String = "externalLink", dimension: CGFloat) -> NSTextAttachment {
let imageAttachment = NSTextAttachment() let imageAttachment = NSTextAttachment()
imageAttachment.image = MVMCoreUIUtility.imageNamed(name) imageAttachment.image = MVMCoreCache.shared()?.getImageFromRegisteredBundles(name)
imageAttachment.bounds = CGRect(x: 0, y: 0, width: dimension, height: dimension) imageAttachment.bounds = CGRect(x: 0, y: 0, width: dimension, height: dimension)
return imageAttachment return imageAttachment

View File

@ -16,8 +16,8 @@ import WebKit
var webviewModel: WebViewModel? { var webviewModel: WebViewModel? {
return model as? WebViewModel return model as? WebViewModel
} }
var webView: WKWebView? open var webView: WKWebView?
var overLayer = MVMCoreUICommonViewsUtility.commonView() open var overLayer = MVMCoreUICommonViewsUtility.commonView()
public let loadingSpinner = MFLoadingSpinner(frame: .zero) public let loadingSpinner = MFLoadingSpinner(frame: .zero)
var delegateObject: MVMCoreUIDelegateObject? var delegateObject: MVMCoreUIDelegateObject?
var webViewHeight: NSLayoutConstraint? var webViewHeight: NSLayoutConstraint?

View File

@ -9,9 +9,6 @@
import Foundation import Foundation
@objcMembers public class MoleculeObjectMapping: NSObject { @objcMembers public class MoleculeObjectMapping: NSObject {
public var moleculeMapping: [String: MoleculeViewProtocol.Type] = [:]
/// Returns the mapping object stored in the singleton /// Returns the mapping object stored in the singleton
public static func shared() -> Self? { public static func shared() -> Self? {
return MVMCoreActionUtility.initializerClassCheck(CoreUIObject.sharedInstance()?.moleculeMap, classToVerify: self) as? Self return MVMCoreActionUtility.initializerClassCheck(CoreUIObject.sharedInstance()?.moleculeMap, classToVerify: self) as? Self
@ -19,18 +16,17 @@ import Foundation
/// Registers the model with the model registry and the view with the mapper. /// Registers the model with the model registry and the view with the mapper.
public func register<M: ModelProtocol, V: MoleculeViewProtocol>(viewClass: V.Type, viewModelClass: M.Type) { public func register<M: ModelProtocol, V: MoleculeViewProtocol>(viewClass: V.Type, viewModelClass: M.Type) {
try? ModelRegistry.register(viewModelClass) try? ModelRegistry.register(handler: viewClass, for: viewModelClass)
moleculeMapping.updateValue(viewClass, forKey: viewModelClass.identifier)
} }
/// Returns the type of molecule view for the given model /// Returns the type of molecule view for the given model
public func getMoleculeClass(_ model: MoleculeModelProtocol) -> MoleculeViewProtocol.Type? { public func getMoleculeClass(_ model: MoleculeModelProtocol) -> MoleculeViewProtocol.Type? {
return moleculeMapping[model.moleculeName] return ModelRegistry.getHandler(model) as? MoleculeViewProtocol.Type
} }
/// Creates a molecule with the given model. /// Creates a molecule with the given model.
public func createMolecule(_ model: MoleculeModelProtocol, delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> MoleculeViewProtocol? { public func createMolecule(_ model: MoleculeModelProtocol, delegateObject: MVMCoreUIDelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) -> MoleculeViewProtocol? {
guard let type = moleculeMapping[model.moleculeName] else { return nil } guard let type = getMoleculeClass(model) else { return nil }
return type.init(model: model, delegateObject, additionalData) return type.init(model: model, delegateObject, additionalData)
} }
@ -286,3 +282,4 @@ import Foundation
} }
} }
} }

View File

@ -12,7 +12,7 @@
//-------------------------------------------------- //--------------------------------------------------
public let leftImage = LoadImageView(pinnedEdges: .all) public let leftImage = LoadImageView(pinnedEdges: .all)
public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink() public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(spacing: 2.0)
public let rightLabel = Label(fontStyle: .RegularBodySmall) public let rightLabel = Label(fontStyle: .RegularBodySmall)
public lazy var rightLabelStackItem: StackItem = { public lazy var rightLabelStackItem: StackItem = {

View File

@ -22,6 +22,16 @@
get { return model as? EyebrowHeadlineBodyLinkModel } get { return model as? EyebrowHeadlineBodyLinkModel }
} }
//--------------------------------------------------
// MARK: - Initialization
//--------------------------------------------------
public convenience init(spacing: CGFloat) {
self.init(frame: .zero)
stack.stackModel?.spacing = spacing
stack.restack()
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - MFViewProtocol // MARK: - MFViewProtocol
//-------------------------------------------------- //--------------------------------------------------

View File

@ -199,7 +199,7 @@ open class Stack<T>: Container where T: (StackModelProtocol & MoleculeModelProto
} }
var name = "stack<" var name = "stack<"
for case let item in model.molecules { for case let item in model.molecules {
if let moleculeClass = MoleculeObjectMapping.shared()?.moleculeMapping[item.moleculeName], if let moleculeClass = MoleculeObjectMapping.shared()?.getMoleculeClass(item),
let nameForReuse = moleculeClass.nameForReuse(with: item, delegateObject) { let nameForReuse = moleculeClass.nameForReuse(with: item, delegateObject) {
name.append(nameForReuse + ",") name.append(nameForReuse + ",")
} else { } else {

View File

@ -9,7 +9,7 @@
import UIKit import UIKit
import MVMCore.MVMCoreViewProtocol import MVMCore.MVMCoreViewProtocol
public protocol MoleculeViewProtocol: UIView { public protocol MoleculeViewProtocol: UIView, ModelHandlerProtocol {
/// Initializes the view with the model /// Initializes the view with the model
init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?)
@ -31,6 +31,7 @@ public protocol MoleculeViewProtocol: UIView {
} }
extension MoleculeViewProtocol { extension MoleculeViewProtocol {
/// Calls set with model /// Calls set with model
public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
self.init(frame: .zero) self.init(frame: .zero)

View File

@ -461,7 +461,7 @@ import UIKit
open func handleOpenPage(for requestParameters: MVMCoreRequestParameters, actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) { open func handleOpenPage(for requestParameters: MVMCoreRequestParameters, actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) {
addFormParams(requestParameters) addFormParams(requestParameters)
requestParameters.parentPageType = loadObject?.pageJSON?.optionalStringForKey("parentPageType") requestParameters.parentPageType = loadObject?.pageJSON?.optionalStringForKey("parentPageType")
MVMCoreActionHandler.defaultHandleOpenPage(for: requestParameters, additionalData: additionalData, delegateObject: delegateObject()) MVMCoreActionHandler.defaultHandleOpenPage(for: requestParameters, actionInformation: actionInformation, additionalData: additionalData, delegateObject: delegateObject())
} }
open func logAction(withActionInformation actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) { open func logAction(withActionInformation actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) {

View File

@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Getters #pragma mark - Getters
//Returns localized imageName // Returns localized imageName
+ (nullable NSString *)localizedImageName:(nullable NSString *)imageName; + (nullable NSString *)localizedImageName:(nullable NSString *)imageName;
// The bundle for this framework // The bundle for this framework

View File

@ -23,24 +23,14 @@
return [NSBundle bundleWithIdentifier:@"com.vzw.MVMCoreUI"]; return [NSBundle bundleWithIdentifier:@"com.vzw.MVMCoreUI"];
} }
+ (BOOL)userPrefersSpanish {
// This should be enough for us to look at what the user prefers.
NSString *preference = [[[[NSLocale preferredLanguages] objectAtIndex:0] substringToIndex:2] lowercaseString];
return [preference isEqualToString:@"es"] || [preference isEqualToString:@"es-mx"];
}
+ (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key { + (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key {
// If the app language is not english... force load from the english file anyway. // Redirect key with relevant module.
if ([MVMCoreUIUtility userPrefersSpanish]) { return [MVMCoreGetterUtility hardcodedStringWithKey:key bundle:[MVMCoreUIUtility bundleForMVMCoreUI]];
return [[NSBundle bundleWithPath:[[MVMCoreUIUtility bundleForMVMCoreUI] pathForResource:@"es" ofType:@"lproj"]] localizedStringForKey:key value:@"" table:nil];
} else {
return [[NSBundle bundleWithPath:[[MVMCoreUIUtility bundleForMVMCoreUI] pathForResource:@"en" ofType:@"lproj"]] localizedStringForKey:key value:@"" table:nil];
}
} }
+ (nullable NSString *)localizedImageName:(nullable NSString *)imageName { + (nullable NSString *)localizedImageName:(nullable NSString *)imageName {
if (imageName.length > 0) { if (imageName.length > 0) {
if ([MVMCoreUIUtility userPrefersSpanish]) { if ([MVMCoreGetterUtility userPrefersSpanish]) {
imageName = [NSString stringWithFormat:@"%@_es", imageName]; imageName = [NSString stringWithFormat:@"%@_es", imageName];
} else { } else {
imageName = [NSString stringWithFormat:@"%@_en", imageName]; imageName = [NSString stringWithFormat:@"%@_en", imageName];