From c6e6d28903e997b07c2b7546da0aa313346aef4a Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 6 Mar 2020 08:44:30 -0500 Subject: [PATCH] merge and cleanup --- MVMCoreUI.xcodeproj/project.pbxproj | 22 +++++----- MVMCoreUI/Molecules/Header.swift | 63 +++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 MVMCoreUI/Molecules/Header.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 4d3522e4..c5fecdef 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -180,6 +180,7 @@ D22D1F562204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D22D1F542204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D22D1F552204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m */; }; D243859923A16B1800332775 /* Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = D243859823A16B1800332775 /* Container.swift */; }; + D256E9932412880000360572 /* Header.swift in Sources */ = {isa = PBXBuildFile; fileRef = D256E9922412880000360572 /* Header.swift */; }; D260105323CEA61600764D80 /* ToggleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105223CEA61600764D80 /* ToggleModel.swift */; }; D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105423CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift */; }; D260105923D0A92900764D80 /* ContainerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105823D0A92900764D80 /* ContainerProtocol.swift */; }; @@ -526,6 +527,7 @@ D22D1F542204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIStackableViewController.h; sourceTree = ""; }; D22D1F552204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIStackableViewController.m; sourceTree = ""; }; D243859823A16B1800332775 /* Container.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Container.swift; sourceTree = ""; }; + D256E9922412880000360572 /* Header.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Header.swift; sourceTree = ""; }; D260105223CEA61600764D80 /* ToggleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleModel.swift; sourceTree = ""; }; D260105423CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUISwitch+Model.swift"; sourceTree = ""; }; D260105823D0A92900764D80 /* ContainerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerProtocol.swift; sourceTree = ""; }; @@ -817,15 +819,6 @@ path = OneColumn; sourceTree = ""; }; - 525239C32407FFCC00454969 /* LockUps */ = { - isa = PBXGroup; - children = ( - 525019DB2406430700EED91C /* ListProgressBarDataModel.swift */, - 525019DC2406430800EED91C /* ListProgressBarData.swift */, - ); - path = LockUps; - sourceTree = ""; - }; 525019E3240684E500EED91C /* FourColumn */ = { isa = PBXGroup; children = ( @@ -835,6 +828,15 @@ path = FourColumn; sourceTree = ""; }; + 525239C32407FFCC00454969 /* LockUps */ = { + isa = PBXGroup; + children = ( + 525019DB2406430700EED91C /* ListProgressBarDataModel.swift */, + 525019DC2406430800EED91C /* ListProgressBarData.swift */, + ); + path = LockUps; + sourceTree = ""; + }; 94C2D9822386F3E30006CF46 /* Label */ = { isa = PBXGroup; children = ( @@ -1197,6 +1199,7 @@ D224798E2316A995003FCCF9 /* HorizontalCombinationViews */, D224798D2316A988003FCCF9 /* VerticalCombinationViews */, 01EB368C23609801006832FA /* HeaderModel.swift */, + D256E9922412880000360572 /* Header.swift */, D2D90B41240463E100DD6EC9 /* MoleculeHeaderModel.swift */, D2A514662213885800345BFB /* MoleculeHeaderView.swift */, 012A88EB238F084D00FE3DA1 /* FooterModel.swift */, @@ -1847,6 +1850,7 @@ D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */, D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */, 017BEB7B236763000024EF95 /* LineModel.swift in Sources */, + D256E9932412880000360572 /* Header.swift in Sources */, 94C2D9A523872C350006CF46 /* LabelAttributeFontModel.swift in Sources */, 011D95AF2407266E000E3791 /* RadioButtonModel.swift in Sources */, 017BEB7F23676E870024EF95 /* MoleculeObjectMapping.swift in Sources */, diff --git a/MVMCoreUI/Molecules/Header.swift b/MVMCoreUI/Molecules/Header.swift new file mode 100644 index 00000000..c878c5ff --- /dev/null +++ b/MVMCoreUI/Molecules/Header.swift @@ -0,0 +1,63 @@ +// +// Header.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/6/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +open class HeaderView: Container { + public let line = Line() + + /// Convenience for doing some default setting + open var molecule: (UIView & MVMCoreUIMoleculeViewProtocol)? + + var headerModel: HeaderModel? { + get { return model as? HeaderModel } + } + + /// Convenience function to add a molecule to the view. + open func addMolecule(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { + addSubview(molecule) + containerHelper.constrainView(molecule) + self.molecule = molecule + } + + // MARK: - MVMCoreViewProtocol + open override func updateView(_ size: CGFloat) { + super.updateView(size) + line.updateView(size) + molecule?.updateView(size) + } + + public override func setupView() { + super.setupView() + line.setStyle(.heavy) + addSubview(line) + NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true + NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true + NSLayoutConstraint.pinViewRight(toSuperview: line, useMargins: true, constant: 0).isActive = true + } + + // MARK: - MVMCoreUIMoleculeViewProtocol + open override func reset() { + super.reset() + line.setStyle(.heavy) + molecule?.reset?() + } + + // MARK: - ModelMoleculeViewProtocol + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let headerModel = headerModel else { return } + if let lineModel = headerModel.line { + line.set(with: lineModel, delegateObject, additionalData) + } + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return PaddingDefaultVerticalSpacing + PaddingDefaultVerticalSpacing + } +}