diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index fae40f0c..7c6f9ef6 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -206,6 +206,11 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat title = try typeContainer.decode(String.self, forKey: .title) action = try typeContainer.decodeModel(codingKey: .action) + if let style = decoder.context?.value(forKey: CodingKeys.style.stringValue) as? Styler.Button.Style{ + self.style = style + setFacade(by: style) + } + if let style = try typeContainer.decodeIfPresent(Styler.Button.Style.self, forKey: .style) { self.style = style setFacade(by: style) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index d4c4d26d..e36c8d23 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -49,16 +49,19 @@ import UIKit public init() { super.init(frame: .zero) model = LineModel(type: .secondary) + setStyle(.secondary) } public override init(frame: CGRect) { super.init(frame: frame) model = LineModel(type: .secondary) + setStyle(.secondary) } public required init?(coder: NSCoder) { super.init(coder: coder) model = LineModel(type: .secondary) + setStyle(.secondary) } public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift index e7096069..527ed054 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift @@ -58,11 +58,11 @@ import VDSColorTokens /// Sets the item colors. private func set(tabItemAppearance: UITabBarItemAppearance, model: TabBarModel) { tabItemAppearance.normal.iconColor = model.unSelectedColor.uiColor - tabItemAppearance.normal.titleTextAttributes = [NSAttributedString.Key.foregroundColor: model.unSelectedColor.uiColor, NSAttributedString.Key.font: MFFonts.mfFontTXRegular(10)] + tabItemAppearance.normal.titleTextAttributes = [NSAttributedString.Key.foregroundColor: model.unSelectedColor.uiColor, NSAttributedString.Key.font: MFFonts.mfFontTXBold(10)] tabItemAppearance.normal.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -3) tabItemAppearance.selected.iconColor = model.selectedColor.uiColor - tabItemAppearance.selected.titleTextAttributes = [NSAttributedString.Key.foregroundColor: model.selectedColor.uiColor, NSAttributedString.Key.font: MFFonts.mfFontTXRegular(10)] + tabItemAppearance.selected.titleTextAttributes = [NSAttributedString.Key.foregroundColor: model.selectedColor.uiColor, NSAttributedString.Key.font: MFFonts.mfFontTXBold(10)] tabItemAppearance.selected.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -3) } diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift index 4d843e6a..718cfc30 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift @@ -50,13 +50,17 @@ public class TwoButtonViewModel: ParentMoleculeModelProtocol { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - primaryButton = try typeContainer.decodeMoleculeIfPresent(codingKey: .primaryButton) - if primaryButton?.style == nil { - primaryButton?.style = .primary + + //set context value for 'primary' style to be set for the primaryButton in case the + //property is not returned in the JSON and once decoded, this value is removed from the context + try decoder.setContext(value: Styler.Button.Style.primary, for: "style") { + self.primaryButton = try typeContainer.decodeMoleculeIfPresent(codingKey: .primaryButton) } - secondaryButton = try typeContainer.decodeMoleculeIfPresent(codingKey: .secondaryButton) - if secondaryButton?.style == nil { - secondaryButton?.style = .secondary + + //set context value for 'secondary' style to be set for the primaryButton in case the + //property is not returned in the JSON and once decoded, this value is removed from the context + try decoder.setContext(value: Styler.Button.Style.secondary, for: "style") { + self.secondaryButton = try typeContainer.decodeMoleculeIfPresent(codingKey: .secondaryButton) } } diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index 523f6ea1..64b61480 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -61,7 +61,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc open var additionalLeftButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? open var additionalRightButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? open var titleView: MoleculeModelProtocol? - open var titleOffset: UIOffset? + open var titleOffset: UIOffset? = UIOffset(horizontal: -CGFloat.greatestFiniteMagnitude, vertical: 0) //-------------------------------------------------- // MARK: - Initializer @@ -114,7 +114,9 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc additionalRightButtons = try typeContainer.decodeModelsIfPresent(codingKey: .additionalRightButtons) titleView = try typeContainer.decodeModelIfPresent(codingKey: .titleView) style = try typeContainer.decodeIfPresent(NavigationItemStyle.self, forKey: .style) - titleOffset = try typeContainer.decodeIfPresent(UIOffset.self, forKey: .titleOffset) ?? UIOffset(horizontal: -CGFloat.greatestFiniteMagnitude, vertical: 0) + if let titleOffset = try typeContainer.decodeIfPresent(UIOffset.self, forKey: .titleOffset) { + self.titleOffset = titleOffset + } line?.inverted = style == .dark } diff --git a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift index 06660715..082f2da3 100644 --- a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift @@ -33,11 +33,7 @@ public extension TemplateProtocol { guard let pageJSON = json else { return } let delegateObject = (self as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject let data = try JSONSerialization.data(withJSONObject: pageJSON) - let decoder = JSONDecoder() - if let delegateObject = delegateObject { - // Add the delegate to access mid parsing if applicable. - try decoder.add(delegateObject: delegateObject) - } + let decoder = JSONDecoder.create(with: delegateObject) templateModel = try decodeTemplate(using: decoder, from: data) // Add additional required behaviors if applicable. diff --git a/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift b/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift index ee4d9587..a3be96f5 100644 --- a/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift +++ b/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift @@ -75,7 +75,7 @@ public class AddRemoveMoleculesBehavior: PageCustomActionHandlerBehavior, PageMo self.delegate = delegateObject } - public func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject) { + public func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) { guard let list = delegate?.moleculeListDelegate else { return } for case let model as (MoleculeModelProtocol & ListItemModelProtocol & AddMolecules) in rootMolecules { if let moleculesToAdd = model.getRecursiveMoleculesToAdd(), diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift index 76bc7f84..eadd5e4e 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift @@ -19,7 +19,7 @@ public protocol PageBehaviorProtocol: ModelHandlerProtocol { public protocol PageMoleculeTransformationBehavior: PageBehaviorProtocol { - func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject) + func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) } public protocol PageVisibilityBehavior: PageBehaviorProtocol { diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift index ea5003f4..e1c7f6a3 100644 --- a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -66,7 +66,7 @@ public extension UINavigationController { /// Convenience function for setting the navigation bar ui func setNavigationBarUI(with model: NavigationItemModelProtocol) { let navigationBar = navigationBar - let font = MFStyler.fontBoldBodySmall(false) + let font = MFStyler.fontBoldBodyLarge(false) let backgroundColor = model.backgroundColor?.uiColor let tint = model.tintColor.uiColor navigationBar.tintColor = tint diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index b3a142ba..f5c4023a 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -19,7 +19,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, /// Used to layout the ui. public lazy var stackView: UIStackView = { - let stackView = UIStackView(arrangedSubviews: [tabs, line, subNavigationController.view]) + let stackView = UIStackView(arrangedSubviews: [tabs, subNavigationController.view]) stackView.translatesAutoresizingMaskIntoConstraints = false stackView.isAccessibilityElement = false stackView.axis = .vertical @@ -33,10 +33,6 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, return tabs }() - public lazy var line: Line = { - return Line(model: LineModel(type: .secondary), delegateObjectIVar, nil) - }() - public lazy var subNavigationController: UINavigationController = { let subNavigationController = SubNavManagerNavigationController(rootViewController: viewController) subNavigationController.view.translatesAutoresizingMaskIntoConstraints = false diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m index fb7fe919..9425547c 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m @@ -125,8 +125,6 @@ - (void)openURLInSafariWebView:(nonnull NSURL *)url { SFSafariViewController *safariViewController = [[SFSafariViewController alloc] initWithURL:url]; - safariViewController.preferredBarTintColor = [UIColor whiteColor]; - safariViewController.preferredControlTintColor = [UIColor blackColor]; [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:safariViewController animated:YES]; } diff --git a/MVMCoreUI/TopAlert/TopNotificationModel.swift b/MVMCoreUI/TopAlert/TopNotificationModel.swift index 7c07c980..75300a3f 100644 --- a/MVMCoreUI/TopAlert/TopNotificationModel.swift +++ b/MVMCoreUI/TopAlert/TopNotificationModel.swift @@ -69,10 +69,7 @@ open class TopNotificationModel: Codable { /// Decodes the top alert json to a model. public static func decode(json: [AnyHashable: Any], delegateObject: MVMCoreUIDelegateObject?) throws -> Self { let data = try JSONSerialization.data(withJSONObject: json) - let decoder = JSONDecoder() - if let delegateObject = delegateObject { - try decoder.add(delegateObject: delegateObject) - } + let decoder = JSONDecoder.create(with: delegateObject) return try decoder.decode(self, from: data) }