diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 9643a16f..ba0db1dd 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -51,12 +51,9 @@ 017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */; }; 017BEB7B236763000024EF95 /* LineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7A236763000024EF95 /* LineModel.swift */; }; 017BEB7F23676E870024EF95 /* MoleculeObjectMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */; }; - 0189255C239AA7EB004E8AFF /* ModuleDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0189255B239AA7EB004E8AFF /* ModuleDelegateProtocol.swift */; }; 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0198F79E225679870066C936 /* FormValidationProtocol.swift */; }; 0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 0198F7A02256A80A0066C936 /* MFRadioButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0198F7A22256A80A0066C936 /* MFRadioButton.m */; }; - 01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */; }; - 01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */; }; 01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 01EB3684236097C0006832FA /* MoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3683236097C0006832FA /* MoleculeProtocol.swift */; }; 01EB368F23609801006832FA /* LabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368823609801006832FA /* LabelModel.swift */; }; @@ -69,6 +66,7 @@ 0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */; }; 0A209CD323A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */; }; 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */; }; + 0A5D59C223AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */; }; 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; }; 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */; }; 0AA33B34239813C50067DD0F /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */; }; @@ -122,7 +120,6 @@ D282AACB2243C61700C46919 /* ButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AACA2243C61700C46919 /* ButtonView.swift */; }; D28A837723C79FC600DFE4FC /* MFCustomButton+ActionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */; }; D296E13C229598BF0051EBE7 /* MoleculeListCellProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D296E1412295EBBA0051EBE7 /* MoleculeDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; }; D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -310,12 +307,9 @@ 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelMoleculeViewProtocol.swift; sourceTree = ""; }; 017BEB7A236763000024EF95 /* LineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineModel.swift; sourceTree = ""; }; 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeObjectMapping.swift; sourceTree = ""; }; - 0189255B239AA7EB004E8AFF /* ModuleDelegateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModuleDelegateProtocol.swift; sourceTree = ""; }; 0198F79E225679870066C936 /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = ""; }; 0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = ""; }; 0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = ""; }; - 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFTextFieldListView.swift; sourceTree = ""; }; - 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldListFormViewController.swift; sourceTree = ""; }; 01EB3683236097C0006832FA /* MoleculeProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeProtocol.swift; sourceTree = ""; }; 01EB368823609801006832FA /* LabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelModel.swift; sourceTree = ""; }; 01EB368923609801006832FA /* ListItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListItemModel.swift; sourceTree = ""; }; @@ -327,6 +321,7 @@ 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionDetailWithImage.swift; sourceTree = ""; }; 0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIStackViewAlignment+Extension.swift"; sourceTree = ""; }; 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CATransaction+Extension.swift"; sourceTree = ""; }; + 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleGuidelinesProtocol.swift; sourceTree = ""; }; 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = ""; }; 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = ""; }; 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxWithLabelView.swift; sourceTree = ""; }; @@ -380,7 +375,6 @@ D282AACA2243C61700C46919 /* ButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonView.swift; sourceTree = ""; }; D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFCustomButton+ActionModel.swift"; sourceTree = ""; }; D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeListCellProtocol.h; sourceTree = ""; }; - D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeDelegateProtocol.h; sourceTree = ""; }; D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = ""; }; D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = ""; }; D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsView.h; sourceTree = ""; }; @@ -559,13 +553,6 @@ path = ModelProtocols; sourceTree = ""; }; - 012A889A238898C600FE3DA1 /* Template */ = { - isa = PBXGroup; - children = ( - ); - path = Template; - sourceTree = ""; - }; 012A88EF23985E0100FE3DA1 /* Primitive Models */ = { isa = PBXGroup; children = ( @@ -602,7 +589,6 @@ 014AA72023C501E2006F3E93 /* Container */, 011B58EE23A2AA850085F53C /* ModelProtocols */, 012A88EF23985E0100FE3DA1 /* Primitive Models */, - 012A889A238898C600FE3DA1 /* Template */, 946EE1B5237B663A0036751F /* Extensions */, 01EB368723609801006832FA /* Molecules */, ); @@ -668,6 +654,14 @@ name = "Recovered References"; sourceTree = ""; }; + 0A5D59C323AD488600EFD9E9 /* Protocols */ = { + isa = PBXGroup; + children = ( + 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */, + ); + path = Protocols; + sourceTree = ""; + }; D213347423842FE3008E41B3 /* Controllers */ = { isa = PBXGroup; children = ( @@ -818,7 +812,6 @@ D29DF0DF21E418B2003B2FB9 /* Templates */ = { isa = PBXGroup; children = ( - 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */, D2A5146022121FBF00345BFB /* MoleculeStackTemplate.swift */, D2A514622213643100345BFB /* MoleculeStackCenteredTemplate.swift */, D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */, @@ -856,7 +849,6 @@ D224798D2316A988003FCCF9 /* VerticalCombinationViews */, D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */, 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */, - 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */, D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */, D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */, D2A514662213885800345BFB /* StandardHeaderView.swift */, @@ -1092,13 +1084,11 @@ D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */, D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */, D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */, - D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */, 012A88C7238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift */, D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */, D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */, 017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */, 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */, - 0189255B239AA7EB004E8AFF /* ModuleDelegateProtocol.swift */, ); path = OtherHandlers; sourceTree = ""; @@ -1165,6 +1155,7 @@ children = ( D2B18B7E2360913400A9AEDC /* Control.swift */, D2B18B802360945C00A9AEDC /* View.swift */, + 0A5D59C323AD488600EFD9E9 /* Protocols */, ); path = BaseClasses; sourceTree = ""; @@ -1228,7 +1219,6 @@ D29DF12D21E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.h in Headers */, D29DF24E21E6A177003B2FB9 /* MFDigitTextField.h in Headers */, D29770F321F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.h in Headers */, - D296E1412295EBBA0051EBE7 /* MoleculeDelegateProtocol.h in Headers */, D2C5001821F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h in Headers */, D29770FD21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h in Headers */, D29DF17421E69E1F003B2FB9 /* MFCustomButton.h in Headers */, @@ -1327,6 +1317,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 0A5D59C223AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift in Sources */, 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */, 012CA9E423888B1B003F810F /* (null) in Sources */, 9402C35023A2CEA3004B974C /* LeftRightLabelModel.swift in Sources */, @@ -1371,13 +1362,11 @@ D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */, 014AA72F23C5059B006F3E93 /* ThreeLayerPageTemplateModel.swift in Sources */, D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */, - 01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */, D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */, D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */, D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */, 014AA72D23C5059B006F3E93 /* StackPageTemplateModel.swift in Sources */, 012A88C4238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift in Sources */, - 0189255C239AA7EB004E8AFF /* ModuleDelegateProtocol.swift in Sources */, 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */, 014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */, 017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */, @@ -1435,7 +1424,6 @@ 94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */, 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */, D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, - 01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */, D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */, 012A88B1238C880100FE3DA1 /* PagingMoleculeProtocol.swift in Sources */, D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */, diff --git a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift index 95b00cd7..17515e71 100644 --- a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift +++ b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift @@ -289,7 +289,7 @@ import UIKit self?.addConstraints(width: width, height: height, size: image?.size) self?.loadingSpinnerHeightConstraint?.constant = 0 if layoutWillChange { - self?.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated?(self!) + self?.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self!) } completionHandler(image,data,isFallbackImage) })} diff --git a/MVMCoreUI/BaseClasses/Control.swift b/MVMCoreUI/BaseClasses/Control.swift index a633f4e1..769e7acb 100644 --- a/MVMCoreUI/BaseClasses/Control.swift +++ b/MVMCoreUI/BaseClasses/Control.swift @@ -56,17 +56,14 @@ import UIKit } } - //-------------------------------------------------- - // MARK: - UITouch - //-------------------------------------------------- - +} + +// MARK: - AppleGuidelinesProtocol +extension Control: AppleGuidelinesProtocol { + override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { - // If the control is smaller than 44pt by width or height, this will compensate. - let faultToleranceX: CGFloat = max((MinimumTappableArea - bounds.size.width) / 2.0, 0) - let faultToleranceY: CGFloat = max((MinimumTappableArea - bounds.size.height) / 2.0, 0) - let area = bounds.insetBy(dx: -faultToleranceX, dy: -faultToleranceY) - return area.contains(point) + return Self.acceptablyOutsideBounds(point: point, bounds: bounds) } } diff --git a/MVMCoreUI/BaseClasses/Protocols/AppleGuidelinesProtocol.swift b/MVMCoreUI/BaseClasses/Protocols/AppleGuidelinesProtocol.swift new file mode 100644 index 00000000..3498a274 --- /dev/null +++ b/MVMCoreUI/BaseClasses/Protocols/AppleGuidelinesProtocol.swift @@ -0,0 +1,32 @@ +// +// AppleGuidelinesProtocol.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 12/20/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + + +public protocol AppleGuidelinesProtocol { + static var minimumTappableArea: CGFloat { get } + static func acceptablyOutsideBounds(point: CGPoint, bounds: CGRect) -> Bool +} + +extension AppleGuidelinesProtocol { + + static public var minimumTappableArea: CGFloat { + return 44.0 + } + + // If the control is smaller than 44pt by width or height, this will compensate. + static public func acceptablyOutsideBounds(point: CGPoint, bounds: CGRect) -> Bool { + + let faultToleranceX: CGFloat = max((minimumTappableArea - bounds.size.width) / 2.0, 0) + let faultToleranceY: CGFloat = max((minimumTappableArea - bounds.size.height) / 2.0, 0) + let area = bounds.insetBy(dx: -faultToleranceX, dy: -faultToleranceY) + + return area.contains(point) + } +} diff --git a/MVMCoreUI/BaseControllers/MFViewController+Model.swift b/MVMCoreUI/BaseControllers/MFViewController+Model.swift index afc022f8..264592c0 100644 --- a/MVMCoreUI/BaseControllers/MFViewController+Model.swift +++ b/MVMCoreUI/BaseControllers/MFViewController+Model.swift @@ -8,7 +8,14 @@ import Foundation -extension MFViewController: ModuleDelegateProtocol { +extension MFViewController: MoleculeDelegateProtocol { + public func getModuleWithName(_ name: String?) -> [AnyHashable : Any]? { + guard let name = name else { + return nil + } + return loadObject?.modulesJSON?.optionalDictionaryForKey(name) + } + public func getModuleWithName(_ moduleName: String) -> Model? { guard let moduleJSON = loadObject?.modulesJSON?.optionalDictionaryForKey(moduleName), let moleculeName = moduleJSON.optionalStringForKey("moleculeName"), @@ -29,3 +36,5 @@ public extension MFViewController { (self as? TemplateProtocol)?.parseTemplateJSON() } } + +//MoleculeDelegateProtocol diff --git a/MVMCoreUI/BaseControllers/MFViewController.h b/MVMCoreUI/BaseControllers/MFViewController.h index c1415df4..cd96a07f 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.h +++ b/MVMCoreUI/BaseControllers/MFViewController.h @@ -27,14 +27,13 @@ #import #import #import -#import @class MainMenuViewController; @class MVMCoreUITabBarPageControlViewController; @class MVMAnimationManager; @class DelegateObject; -@interface MFViewController : UIViewController +@interface MFViewController : UIViewController // Stores the load object that this screen was loaded with. @property (nullable, strong, nonatomic) MVMCoreLoadObject *loadObject; diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index 153af17f..1d97efd9 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -834,15 +834,6 @@ } } -#pragma mark - MoleculeDelegateProtocol - -- (NSDictionary *)getModuleWithName:(NSString *)name { - if (!name) { - return nil; - } - return [self.loadObject.modulesJSON dict:name]; -} - #pragma mark - adobe analytics - (nullable NSArray *)additionalActionsToTrackWithMainActionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData { diff --git a/MVMCoreUI/MVMCoreUI.h b/MVMCoreUI/MVMCoreUI.h index 795298b3..ff9b4087 100644 --- a/MVMCoreUI/MVMCoreUI.h +++ b/MVMCoreUI/MVMCoreUI.h @@ -20,7 +20,6 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[]; #import #import #import -#import #import #import diff --git a/MVMCoreUI/Models/Molecules/DropDownModel.swift b/MVMCoreUI/Models/Molecules/DropDownModel.swift index c0320737..95caa2b6 100644 --- a/MVMCoreUI/Models/Molecules/DropDownModel.swift +++ b/MVMCoreUI/Models/Molecules/DropDownModel.swift @@ -14,4 +14,9 @@ import Foundation public var backgroundColor: Color? public var label: String public var options: [String] + + public init(label: String, options: [String]) { + self.label = label + self.options = options + } } diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index 2f824773..1e4ab9f2 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -10,19 +10,18 @@ import Foundation @objcMembers public class HeaderModel: MoleculeContainerModel, MoleculeProtocol { public static var identifier: String = "header" - public var moleculeName: String? public var backgroundColor: Color? public var line: LineModel? enum HeaderCodingKeys: String, CodingKey { case moleculeName case line + case backgroundColor } required public init(from decoder: Decoder) throws { try super.init(from: decoder) let typeContainer = try decoder.container(keyedBy: HeaderCodingKeys.self) - moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) // Default Values @@ -39,5 +38,6 @@ import Foundation var container = encoder.container(keyedBy: HeaderCodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(line, forKey: .line) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) } } diff --git a/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift b/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift index 35702824..56259942 100644 --- a/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift +++ b/MVMCoreUI/Models/Molecules/ModuleMoleculeModel.swift @@ -17,6 +17,10 @@ open class ModuleMoleculeModel: MoleculeProtocol { case moduleName } + public init(_ moduleName: String) { + self.moduleName = moduleName + } + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) moduleName = try typeContainer.decode(String.self, forKey:.moduleName) diff --git a/MVMCoreUI/Models/Primitive Models/Color.swift b/MVMCoreUI/Models/Primitive Models/Color.swift index 027b826e..e4c0e4fa 100644 --- a/MVMCoreUI/Models/Primitive Models/Color.swift +++ b/MVMCoreUI/Models/Primitive Models/Color.swift @@ -8,7 +8,11 @@ import UIKit - +/* + UIColor is not supported by Codable. This Color class + effectively turns UIColor into a primitive class like + Int and String and can be used the same. + */ public final class Color: Codable { //-------------------------------------------------- // MARK: - Properties diff --git a/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift index 075d33f1..d6a5e05d 100644 --- a/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/AccordionMoleculeTableViewCell.swift @@ -34,9 +34,9 @@ import UIKit } if accordionButton.isSelected { - delegateObject?.moleculeDelegate?.addMolecules?(molecules, sender: self, animation: .automatic) + delegateObject?.moleculeDelegate?.addMolecules(molecules, sender: self, animation: .automatic) } else { - delegateObject?.moleculeDelegate?.removeMolecules?(molecules, sender: self, animation: .automatic) + delegateObject?.moleculeDelegate?.removeMolecules(molecules, sender: self, animation: .automatic) } if (json?.boolForKey("hideSeparatorWhenExpanded") ?? false) && (self.bottomSeparatorView?.shouldBeVisible() ?? false) { diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index a9d9c360..a2ca4383 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -39,10 +39,10 @@ import UIKit if self.previousIndex != NSNotFound { let previousMolecules = moleculesArrays[self.previousIndex] - self.delegateObject?.moleculeDelegate?.removeMolecules?(previousMolecules, sender: self, animation: .fade) + self.delegateObject?.moleculeDelegate?.removeMolecules(previousMolecules, sender: self, animation: .fade) } let molecules = moleculesArrays[index] - self.delegateObject?.moleculeDelegate?.addMolecules?(molecules, sender: self, animation: .fade) + self.delegateObject?.moleculeDelegate?.addMolecules(molecules, sender: self, animation: .fade) self.previousIndex = index } } diff --git a/MVMCoreUI/Molecules/Items/TableViewCell.swift b/MVMCoreUI/Molecules/Items/TableViewCell.swift index 9fbad78b..bf616419 100644 --- a/MVMCoreUI/Molecules/Items/TableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TableViewCell.swift @@ -49,8 +49,10 @@ import UIKit switch styleString { case "standard": styleStandard() - case "header": - styleHeader() + case "shortDivider": + styleShortDivider() + case "tallDivider": + styleTallDivider() case "sectionFooter": styleFooter() case "none": @@ -66,13 +68,20 @@ import UIKit bottomSeparatorView?.setStyle(.standard) } - open func styleHeader() { + open func styleTallDivider() { topMarginPadding = 48 bottomMarginPadding = 16 topSeparatorView?.setStyle(.none) bottomSeparatorView?.setStyle(.thin) } + open func styleShortDivider() { + topMarginPadding = 32 + bottomMarginPadding = 16 + topSeparatorView?.style = .none + bottomSeparatorView?.style = .thin + } + open func styleFooter() { topMarginPadding = 24 bottomMarginPadding = 0 diff --git a/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift index b75f4600..d9626ae0 100644 --- a/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/TabsTableViewCell.swift @@ -58,7 +58,7 @@ extension TabsTableViewCell: TopTabbarDelegate { public func shouldSelectItem(at index: Int, topTabbar: TopTabbar) -> Bool { if let moleculesArrays = json?.arrayForKey(KeyMolecules), let molecules = moleculesArrays[topTabbar.selectedIndex] as? [[AnyHashable: Any]] { - delegateObject?.moleculeDelegate?.removeMolecules?(molecules, sender: self, animation: index < tabs.selectedIndex ? .right : .left) + delegateObject?.moleculeDelegate?.removeMolecules(molecules, sender: self, animation: index < tabs.selectedIndex ? .right : .left) } previousTabIndex = tabs.selectedIndex return true @@ -67,7 +67,7 @@ extension TabsTableViewCell: TopTabbarDelegate { public func topTabbar(_ topTabbar: TopTabbar, didSelectItemAt index: Int) { if let moleculesArrays = json?.arrayForKey(KeyMolecules), let molecules = moleculesArrays[index] as? [[AnyHashable: Any]] { - delegateObject?.moleculeDelegate?.addMolecules?(molecules, sender: self, animation: index < previousTabIndex ? .left : .right) + delegateObject?.moleculeDelegate?.addMolecules(molecules, sender: self, animation: index < previousTabIndex ? .left : .right) } } } diff --git a/MVMCoreUI/Molecules/MFTextFieldListView.swift b/MVMCoreUI/Molecules/MFTextFieldListView.swift deleted file mode 100644 index 6d24e19a..00000000 --- a/MVMCoreUI/Molecules/MFTextFieldListView.swift +++ /dev/null @@ -1,123 +0,0 @@ -// -// MFTextFieldListView.swift -// MobileFirstFramework -// -// Created by Suresh, Kamlesh on 9/21/18. -// Copyright © 2018 Verizon Wireless. All rights reserved. -// - -import UIKit -import MVMCore - - -public class MFTextFieldListView: ViewConstrainingView { - - public var textFieldMapList: [[String: Any]]? - public var parentViewContoller: MFViewController? - public var textFieldsToValidate: [MFTextField] = [] - public var textFields: [MFTextField] = [] - public var primaryButton: PrimaryButton? - - public init(textFieldMapList: [[String: Any]], parentViewContoller: MFViewController, primaryButton: PrimaryButton?) { - self.textFieldMapList = textFieldMapList - self.parentViewContoller = parentViewContoller - self.primaryButton = primaryButton - super.init(frame: .zero) - } - - public required init?(coder decoder: NSCoder) { - super.init(coder: decoder) - } - - public override func updateView(_ size: CGFloat) { - super.updateView(size) - for textField in textFields { - textField.updateView(size) - } - } - - public override func setupView() { - super.setupView() - self.translatesAutoresizingMaskIntoConstraints = false - - guard let textFieldMapList = textFieldMapList else { - return - } - var viewList: [UIView] = [] - - for textFieldMap in textFieldMapList { - if let textField = MFTextField(map: textFieldMap, bothDelegates: self) { - - if textFieldMap.boolForKey("required") { - textFieldsToValidate.append(textField) - } - - textFields.append(textField) - if let fieldKey = textField.fieldKey { - parentViewContoller?.register(textField, forErrorKey: fieldKey as String) - } - viewList.append(textField) - } - } - - StackableViewController.populateView(self, withUIArray: viewList) { (viewObject) -> UIEdgeInsets in - var edgeInsets = StackableViewController.standardSpaceAroundUIObject() - edgeInsets.left = 0 - edgeInsets.right = 0 - edgeInsets.top = 0 - return edgeInsets - } - - primaryButton?.handleEnabling(with: textFieldsToValidate) - } - - public func addParams(requestParameters: MVMCoreRequestParameters) { - requestParameters.add(getTextParamsList()) - } - - public func getTextParamsList() -> [String: Any] { - var extraParam: [String: Any] = [:] - for textField in textFields { - if let fieldKey = textField.fieldKey { - extraParam[fieldKey as String] = textField.text ?? "" - } - } - return extraParam - } -} - -extension MFTextFieldListView: UITextFieldDelegate, UITextViewDelegate, MFTextFieldDelegate { - @objc open func textFieldDidEndEditing(_ textField: UITextField) { - parentViewContoller?.textFieldDidEndEditing(textField) - primaryButton?.handleEnabling(with: textFieldsToValidate) - } - - @objc open func dismissFieldInput(_ sender: Any?) { - parentViewContoller?.dismissFieldInput(sender) - } - - @objc open func textFieldShouldReturn(_ textField: UITextField) -> Bool { - textField.resignFirstResponder() - return true - } - - @objc open func textFieldDidBeginEditing(_ textField: UITextField) { - parentViewContoller?.textFieldDidBeginEditing(textField) - } - - @objc open func entryIsValid(_ textfield: MFTextField?) { - DispatchQueue.main.async { - if self.parentViewContoller?.responds(to: #selector(MFTextFieldDelegate.entryIsValid(_:))) ?? false { - self.parentViewContoller?.entryIsValid(textfield) - } - } - } - - @objc open func entryIsInvalid(_ textfield: MFTextField?) { - DispatchQueue.main.async { - if self.parentViewContoller?.responds(to: #selector(MFTextFieldDelegate.entryIsInvalid(_:))) ?? false { - self.parentViewContoller?.entryIsInvalid(textfield) - } - } - } -} diff --git a/MVMCoreUI/Molecules/ModuleMolecule.swift b/MVMCoreUI/Molecules/ModuleMolecule.swift index f5d580de..863df271 100644 --- a/MVMCoreUI/Molecules/ModuleMolecule.swift +++ b/MVMCoreUI/Molecules/ModuleMolecule.swift @@ -20,11 +20,10 @@ open class ModuleMolecule: Container { } public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) { - #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.") - //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView. + super.setWithModel(model, delegateObject, additionalData) guard let moduleMoleculeModel = model as? ModuleMoleculeModel, - let moduleModel = delegateObject?.moduleProtocol?.getModuleWithName(moduleMoleculeModel.moduleName) as? MoleculeProtocol else { + let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMoleculeModel.moduleName) as? MoleculeProtocol else { // Critical error return } @@ -50,7 +49,7 @@ open class ModuleMolecule: Container { public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { guard let moduleMolecule = molecule as? ModuleMoleculeModel, - let moduleModel = delegateObject?.moduleProtocol?.getModuleWithName(moduleMolecule.moduleName) as? MoleculeProtocol, + let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMolecule.moduleName) as? MoleculeProtocol, let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol.Type, let height = classType.estimatedHeight(forRow: moduleModel, delegateObject: delegateObject)else { // Critical error @@ -61,7 +60,7 @@ open class ModuleMolecule: Container { public override func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { guard let moduleMolecule = model as? ModuleMoleculeModel, - let moduleModel = delegateObject?.moduleProtocol?.getModuleWithName(moduleMolecule.moduleName) as? MoleculeProtocol, + let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMolecule.moduleName) as? MoleculeProtocol, let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol, let name = classType.nameForReuse(moduleModel, delegateObject) else { // Critical error @@ -74,7 +73,7 @@ open class ModuleMolecule: Container { public static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { guard let moduleName = (molecule as? ModuleMoleculeModel)?.moduleName, - let _ = delegateObject?.moduleProtocol?.getModuleWithName(moduleName) else { + let _ = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else { if let errorObject = MVMCoreErrorObject(title: nil, message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), code: CoreUIErrorCode.ErrorCodeModuleMolecule.rawValue, domain: ErrorDomainNative, location: String(describing: self)) { error?.pointee = errorObject MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift index 6a7fbc05..f64162db 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift @@ -12,16 +12,14 @@ open class MVMCoreUIDelegateObject: DelegateObject { public weak var formValidationProtocol: FormValidationProtocol? public weak var buttonDelegate: ButtonDelegateProtocol? public weak var uiTextFieldDelegate: UITextFieldDelegate? - public weak var moleculeDelegate: MoleculeDelegateProtocol? - public var moduleProtocol: ModuleDelegateProtocol? - + public var moleculeDelegate: MoleculeDelegateProtocol? + open override func setAll(withDelegate delegate: Any) { super.setAll(withDelegate: delegate) formValidationProtocol = delegate as? FormValidationProtocol buttonDelegate = delegate as? ButtonDelegateProtocol uiTextFieldDelegate = delegate as? UITextFieldDelegate moleculeDelegate = delegate as? MoleculeDelegateProtocol - moduleProtocol = delegate as? ModuleDelegateProtocol } class func delegateObject(from controller: MVMCoreViewControllerProtocol?) -> MVMCoreUIDelegateObject? { diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m index e770ede5..2bc1a0dd 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m @@ -19,7 +19,6 @@ static NSMutableDictionary *viewControllerMapping; dispatch_once(&onceToken, ^{ viewControllerMapping = [@{ - @"textFieldListForm" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[TextFieldListFormViewController class]], @"moleculeStack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackTemplate class]], @"centerMoleculeStack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackCenteredTemplate class]], @"moleculeList" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeListTemplate class]], diff --git a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift index dd79ee3d..1ea4df38 100644 --- a/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift +++ b/MVMCoreUI/OtherHandlers/ModelMoleculeDelegateProtocol.swift @@ -8,7 +8,39 @@ import Foundation -public protocol ModelMoleculeDelegateProtocol { +public protocol MoleculeDelegateProtocol { + + /// returns a module for the corresponding module name. + func getModuleWithName(_ name: String?) -> [AnyHashable : Any]? + func getModuleWithName(_ moleculeName: String) -> Model? + + /// Notifies the delegate that the molecule layout update. Should be called when the layout may change due to an async method. + func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) //optional + + /// Asks the delegate to add or remove molecules. + //optional + func addMolecules(_ molecules: [[AnyHashable : Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) + func removeMolecules(_ molecules: [[AnyHashable : Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) + + //optional func addMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) func removeMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) } + +extension MoleculeDelegateProtocol { + public func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { + // Do Nothing + } + public func addMolecules(_ molecules: [[AnyHashable : Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { + // Do nothpublic ing + } + public func removeMolecules(_ molecules: [[AnyHashable : Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { + // Do nothing + } + public func addMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + // Do nothpublic ing + } + public func removeMolecules(_ molecules: [ListItemModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + // Do nothing + } +} diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 94c0d009..ecd55350 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -8,7 +8,7 @@ import UIKit -open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol, ModelMoleculeDelegateProtocol { +open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol { public var moleculesInfo: [(identifier: String, class: AnyClass, molecule: ListItemModelProtocol)]? var observer: NSKeyValueObservation? @@ -129,7 +129,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } // MARK: - MoleculeDelegateProtocol - open override func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { + open func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { if let tableView = tableView { let point = molecule.convert(molecule.bounds.origin, to: tableView) if let indexPath = tableView.indexPathForRow(at: point), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false { diff --git a/MVMCoreUI/Templates/TextFieldListFormViewController.swift b/MVMCoreUI/Templates/TextFieldListFormViewController.swift deleted file mode 100644 index bf3b0bea..00000000 --- a/MVMCoreUI/Templates/TextFieldListFormViewController.swift +++ /dev/null @@ -1,52 +0,0 @@ -// -// MVMCoreUITextFormViewController.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 1/24/19. -// Copyright © 2019 Verizon Wireless. All rights reserved. -// - -import UIKit - -public class TextFieldListFormViewController: TopLabelsAndBottomButtonsViewController { - - - public var textFieldListView: MFTextFieldListView? - - public override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view. - } - - public override func updateViews() { - super.updateViews() - } - - public override func newDataBuildScreen() { - super.newDataBuildScreen() - topLabelsView?.separatorView?.isHidden = true - } - - public override func buildViewsBetweenLabelsAndButtons() -> [UIView]? { - var viewList: [UIView] = [] - - if let textFieldsList = loadObject?.pageJSON?.arrayForKey("textFieldList") as? [[String: Any]] { - let textFieldListView = MFTextFieldListView(textFieldMapList: textFieldsList, - parentViewContoller: self, - primaryButton: self.primaryButton) - self.textFieldListView = textFieldListView - viewList.append(textFieldListView) - } - return viewList - } - - public override func handleOpenPage(for requestParameters: MVMCoreRequestParameters, actionInformation: [AnyHashable : Any]?, additionalData: [AnyHashable : Any]?) { - textFieldListView?.addParams(requestParameters: requestParameters) - super.handleOpenPage(for: requestParameters, actionInformation: actionInformation, additionalData: additionalData) - } - - public override func spaceAboveBetweenView() -> NSNumber? { - return PaddingFour as NSNumber - } - -}