Container protocol
Doughnut chart model Break stack into regular and dynamic components
This commit is contained in:
parent
a318b19410
commit
db0d9f4353
@ -105,10 +105,10 @@
|
|||||||
94C661D923CCF4B400D9FE5B /* LeftRightLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */; };
|
94C661D923CCF4B400D9FE5B /* LeftRightLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */; };
|
||||||
94C661DA23CCF4FB00D9FE5B /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */; };
|
94C661DA23CCF4FB00D9FE5B /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */; };
|
||||||
C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; };
|
C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; };
|
||||||
C7192E7D23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */; };
|
|
||||||
C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69323C9909000BFB94E /* DoughnutChartModel.swift */; };
|
C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69323C9909000BFB94E /* DoughnutChartModel.swift */; };
|
||||||
C695A69623C990BC00BFB94E /* DoughnutChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69523C990BC00BFB94E /* DoughnutChart.swift */; };
|
C695A69623C990BC00BFB94E /* DoughnutChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69523C990BC00BFB94E /* DoughnutChart.swift */; };
|
||||||
C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69723C990C200BFB94E /* DoughnutChartView.swift */; };
|
C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69723C990C200BFB94E /* DoughnutChartView.swift */; };
|
||||||
|
C7192E7D23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */; };
|
||||||
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; };
|
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; };
|
||||||
D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; };
|
D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; };
|
||||||
D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */; };
|
D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */; };
|
||||||
@ -128,10 +128,17 @@
|
|||||||
D243859923A16B1800332775 /* Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = D243859823A16B1800332775 /* Container.swift */; };
|
D243859923A16B1800332775 /* Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = D243859823A16B1800332775 /* Container.swift */; };
|
||||||
D260105323CEA61600764D80 /* ToggleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105223CEA61600764D80 /* ToggleModel.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 */; };
|
D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105423CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift */; };
|
||||||
|
D260105923D0A92900764D80 /* ContainerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105823D0A92900764D80 /* ContainerProtocol.swift */; };
|
||||||
|
D260105B23D0BB7100764D80 /* StackModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105A23D0BB7100764D80 /* StackModelProtocol.swift */; };
|
||||||
|
D260105D23D0BCD400764D80 /* Stack.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105C23D0BCD400764D80 /* Stack.swift */; };
|
||||||
|
D260105F23D0BFFC00764D80 /* StackItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105E23D0BFFC00764D80 /* StackItem.swift */; };
|
||||||
|
D260106123D0C02A00764D80 /* StackItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260106023D0C02A00764D80 /* StackItemModelProtocol.swift */; };
|
||||||
|
D260106323D0C05000764D80 /* StackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260106223D0C05000764D80 /* StackItemModel.swift */; };
|
||||||
|
D260106523D0CEA700764D80 /* StackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260106423D0CEA700764D80 /* StackModel.swift */; };
|
||||||
D260D7B122D65BDD007E7233 /* MVMCoreUIPageControl.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
D260D7B122D65BDD007E7233 /* MVMCoreUIPageControl.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */; };
|
D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */; };
|
||||||
D260D7B622D68514007E7233 /* MVMCoreUIPagingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
D260D7B622D68514007E7233 /* MVMCoreUIPagingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
D268C70C2386DFFD007F2C1C /* StackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* StackItemModel.swift */; };
|
D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; };
|
||||||
D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; };
|
D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; };
|
||||||
D268C712238D6699007F2C1C /* DropDown.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C711238D6699007F2C1C /* DropDown.swift */; };
|
D268C712238D6699007F2C1C /* DropDown.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C711238D6699007F2C1C /* DropDown.swift */; };
|
||||||
D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* StandardFooterView.swift */; };
|
D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* StandardFooterView.swift */; };
|
||||||
@ -282,7 +289,7 @@
|
|||||||
D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */; };
|
D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */; };
|
||||||
D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */; };
|
D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */; };
|
||||||
D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */; };
|
D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */; };
|
||||||
D2FB151D23A40F1500C20E10 /* StackItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151C23A40F1500C20E10 /* StackItem.swift */; };
|
D2FB151D23A40F1500C20E10 /* MoleculeStackItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151C23A40F1500C20E10 /* MoleculeStackItem.swift */; };
|
||||||
DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */; };
|
DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */; };
|
||||||
DBC4391822442197001AB423 /* CaretView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391622442196001AB423 /* CaretView.swift */; };
|
DBC4391822442197001AB423 /* CaretView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391622442196001AB423 /* CaretView.swift */; };
|
||||||
DBC4391922442197001AB423 /* DashLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391722442197001AB423 /* DashLine.swift */; };
|
DBC4391922442197001AB423 /* DashLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391722442197001AB423 /* DashLine.swift */; };
|
||||||
@ -338,7 +345,7 @@
|
|||||||
01EB3683236097C0006832FA /* MoleculeProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeProtocol.swift; sourceTree = "<group>"; };
|
01EB3683236097C0006832FA /* MoleculeProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeProtocol.swift; sourceTree = "<group>"; };
|
||||||
01EB368823609801006832FA /* LabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelModel.swift; sourceTree = "<group>"; };
|
01EB368823609801006832FA /* LabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelModel.swift; sourceTree = "<group>"; };
|
||||||
01EB368923609801006832FA /* ListItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListItemModel.swift; sourceTree = "<group>"; };
|
01EB368923609801006832FA /* ListItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListItemModel.swift; sourceTree = "<group>"; };
|
||||||
01EB368A23609801006832FA /* StackItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StackItemModel.swift; sourceTree = "<group>"; };
|
01EB368A23609801006832FA /* MoleculeStackItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeStackItemModel.swift; sourceTree = "<group>"; };
|
||||||
01EB368B23609801006832FA /* MoleculeStackModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeStackModel.swift; sourceTree = "<group>"; };
|
01EB368B23609801006832FA /* MoleculeStackModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeStackModel.swift; sourceTree = "<group>"; };
|
||||||
01EB368C23609801006832FA /* HeaderModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderModel.swift; sourceTree = "<group>"; };
|
01EB368C23609801006832FA /* HeaderModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderModel.swift; sourceTree = "<group>"; };
|
||||||
01EB368D23609801006832FA /* HeadlineBodyModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeadlineBodyModel.swift; sourceTree = "<group>"; };
|
01EB368D23609801006832FA /* HeadlineBodyModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeadlineBodyModel.swift; sourceTree = "<group>"; };
|
||||||
@ -380,10 +387,10 @@
|
|||||||
94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeImageModel.swift; sourceTree = "<group>"; };
|
94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeImageModel.swift; sourceTree = "<group>"; };
|
||||||
94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeActionModel.swift; sourceTree = "<group>"; };
|
94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeActionModel.swift; sourceTree = "<group>"; };
|
||||||
C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = "<group>"; };
|
C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = "<group>"; };
|
||||||
C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadLineBodyCaretLinkImage.swift; sourceTree = "<group>"; };
|
|
||||||
C695A69323C9909000BFB94E /* DoughnutChartModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartModel.swift; sourceTree = "<group>"; };
|
C695A69323C9909000BFB94E /* DoughnutChartModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartModel.swift; sourceTree = "<group>"; };
|
||||||
C695A69523C990BC00BFB94E /* DoughnutChart.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChart.swift; sourceTree = "<group>"; };
|
C695A69523C990BC00BFB94E /* DoughnutChart.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChart.swift; sourceTree = "<group>"; };
|
||||||
C695A69723C990C200BFB94E /* DoughnutChartView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartView.swift; sourceTree = "<group>"; };
|
C695A69723C990C200BFB94E /* DoughnutChartView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartView.swift; sourceTree = "<group>"; };
|
||||||
|
C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadLineBodyCaretLinkImage.swift; sourceTree = "<group>"; };
|
||||||
D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = "<group>"; };
|
D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = "<group>"; };
|
||||||
D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = "<group>"; };
|
D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = "<group>"; };
|
||||||
D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSLayoutConstraintAxis+Extension.swift"; sourceTree = "<group>"; };
|
D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSLayoutConstraintAxis+Extension.swift"; sourceTree = "<group>"; };
|
||||||
@ -403,6 +410,13 @@
|
|||||||
D243859823A16B1800332775 /* Container.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Container.swift; sourceTree = "<group>"; };
|
D243859823A16B1800332775 /* Container.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Container.swift; sourceTree = "<group>"; };
|
||||||
D260105223CEA61600764D80 /* ToggleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleModel.swift; sourceTree = "<group>"; };
|
D260105223CEA61600764D80 /* ToggleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleModel.swift; sourceTree = "<group>"; };
|
||||||
D260105423CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUISwitch+Model.swift"; sourceTree = "<group>"; };
|
D260105423CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUISwitch+Model.swift"; sourceTree = "<group>"; };
|
||||||
|
D260105823D0A92900764D80 /* ContainerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerProtocol.swift; sourceTree = "<group>"; };
|
||||||
|
D260105A23D0BB7100764D80 /* StackModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackModelProtocol.swift; sourceTree = "<group>"; };
|
||||||
|
D260105C23D0BCD400764D80 /* Stack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Stack.swift; sourceTree = "<group>"; };
|
||||||
|
D260105E23D0BFFC00764D80 /* StackItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackItem.swift; sourceTree = "<group>"; };
|
||||||
|
D260106023D0C02A00764D80 /* StackItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackItemModelProtocol.swift; sourceTree = "<group>"; };
|
||||||
|
D260106223D0C05000764D80 /* StackItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackItemModel.swift; sourceTree = "<group>"; };
|
||||||
|
D260106423D0CEA700764D80 /* StackModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackModel.swift; sourceTree = "<group>"; };
|
||||||
D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPageControl.h; sourceTree = "<group>"; };
|
D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPageControl.h; sourceTree = "<group>"; };
|
||||||
D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIPageControl.m; sourceTree = "<group>"; };
|
D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIPageControl.m; sourceTree = "<group>"; };
|
||||||
D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPagingProtocol.h; sourceTree = "<group>"; };
|
D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPagingProtocol.h; sourceTree = "<group>"; };
|
||||||
@ -572,7 +586,7 @@
|
|||||||
D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeListTemplate.swift; sourceTree = "<group>"; };
|
D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeListTemplate.swift; sourceTree = "<group>"; };
|
||||||
D2F4DDE52371A4CB00CD28BB /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
|
D2F4DDE52371A4CB00CD28BB /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
|
||||||
D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeContainer.swift; sourceTree = "<group>"; };
|
D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeContainer.swift; sourceTree = "<group>"; };
|
||||||
D2FB151C23A40F1500C20E10 /* StackItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackItem.swift; sourceTree = "<group>"; };
|
D2FB151C23A40F1500C20E10 /* MoleculeStackItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeStackItem.swift; sourceTree = "<group>"; };
|
||||||
DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LeftRightLabelView.swift; sourceTree = "<group>"; };
|
DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LeftRightLabelView.swift; sourceTree = "<group>"; };
|
||||||
DB891E822253FA8500022516 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = "<group>"; };
|
DB891E822253FA8500022516 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = "<group>"; };
|
||||||
DBC4391622442196001AB423 /* CaretView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretView.swift; sourceTree = "<group>"; };
|
DBC4391622442196001AB423 /* CaretView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretView.swift; sourceTree = "<group>"; };
|
||||||
@ -665,10 +679,6 @@
|
|||||||
01EB368723609801006832FA /* Molecules */ = {
|
01EB368723609801006832FA /* Molecules */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
C695A69323C9909000BFB94E /* DoughnutChartModel.swift */,
|
|
||||||
01EB368923609801006832FA /* ListItemModel.swift */,
|
|
||||||
01EB368A23609801006832FA /* MoleculeStackItemModel.swift */,
|
|
||||||
01EB368B23609801006832FA /* MoleculeStackModel.swift */,
|
|
||||||
011B58F323A2CCC80085F53C /* DropDownModel.swift */,
|
011B58F323A2CCC80085F53C /* DropDownModel.swift */,
|
||||||
01EB368C23609801006832FA /* HeaderModel.swift */,
|
01EB368C23609801006832FA /* HeaderModel.swift */,
|
||||||
012A88EB238F084D00FE3DA1 /* FooterModel.swift */,
|
012A88EB238F084D00FE3DA1 /* FooterModel.swift */,
|
||||||
@ -806,6 +816,9 @@
|
|||||||
D22479902316A9CB003FCCF9 /* Organisms */ = {
|
D22479902316A9CB003FCCF9 /* Organisms */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
D260105A23D0BB7100764D80 /* StackModelProtocol.swift */,
|
||||||
|
D260106423D0CEA700764D80 /* StackModel.swift */,
|
||||||
|
D260105C23D0BCD400764D80 /* Stack.swift */,
|
||||||
01EB368B23609801006832FA /* MoleculeStackModel.swift */,
|
01EB368B23609801006832FA /* MoleculeStackModel.swift */,
|
||||||
D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */,
|
D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */,
|
||||||
D2A6390022CBB1820052ED1F /* Carousel.swift */,
|
D2A6390022CBB1820052ED1F /* Carousel.swift */,
|
||||||
@ -826,8 +839,11 @@
|
|||||||
D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */,
|
D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */,
|
||||||
011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */,
|
011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */,
|
||||||
D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */,
|
D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */,
|
||||||
01EB368A23609801006832FA /* StackItemModel.swift */,
|
D260106023D0C02A00764D80 /* StackItemModelProtocol.swift */,
|
||||||
D2FB151C23A40F1500C20E10 /* StackItem.swift */,
|
D260106223D0C05000764D80 /* StackItemModel.swift */,
|
||||||
|
D260105E23D0BFFC00764D80 /* StackItem.swift */,
|
||||||
|
01EB368A23609801006832FA /* MoleculeStackItemModel.swift */,
|
||||||
|
D2FB151C23A40F1500C20E10 /* MoleculeStackItem.swift */,
|
||||||
);
|
);
|
||||||
path = Items;
|
path = Items;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -841,6 +857,16 @@
|
|||||||
path = Legacy;
|
path = Legacy;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
D260105723CF9CC500764D80 /* Doughnut */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
C695A69323C9909000BFB94E /* DoughnutChartModel.swift */,
|
||||||
|
C695A69523C990BC00BFB94E /* DoughnutChart.swift */,
|
||||||
|
C695A69723C990C200BFB94E /* DoughnutChartView.swift */,
|
||||||
|
);
|
||||||
|
path = Doughnut;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
D29DF0C221E404D4003B2FB9 = {
|
D29DF0C221E404D4003B2FB9 = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@ -937,8 +963,7 @@
|
|||||||
D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */,
|
D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */,
|
||||||
017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */,
|
017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */,
|
||||||
017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */,
|
017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */,
|
||||||
C695A69523C990BC00BFB94E /* DoughnutChart.swift */,
|
D260105723CF9CC500764D80 /* Doughnut */,
|
||||||
C695A69723C990C200BFB94E /* DoughnutChartView.swift */,
|
|
||||||
);
|
);
|
||||||
path = Molecules;
|
path = Molecules;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -986,6 +1011,7 @@
|
|||||||
D29DF2B721E7BE79003B2FB9 /* TabBarController */,
|
D29DF2B721E7BE79003B2FB9 /* TabBarController */,
|
||||||
D29DF2B621E7BE66003B2FB9 /* SplitViewController */,
|
D29DF2B621E7BE66003B2FB9 /* SplitViewController */,
|
||||||
D2B18B93236214AD00A9AEDC /* NavigationController.swift */,
|
D2B18B93236214AD00A9AEDC /* NavigationController.swift */,
|
||||||
|
D260105823D0A92900764D80 /* ContainerProtocol.swift */,
|
||||||
D243859823A16B1800332775 /* Container.swift */,
|
D243859823A16B1800332775 /* Container.swift */,
|
||||||
);
|
);
|
||||||
path = Containers;
|
path = Containers;
|
||||||
@ -1424,7 +1450,7 @@
|
|||||||
94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */,
|
94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */,
|
||||||
DBC4391922442197001AB423 /* DashLine.swift in Sources */,
|
DBC4391922442197001AB423 /* DashLine.swift in Sources */,
|
||||||
0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */,
|
0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */,
|
||||||
D2FB151D23A40F1500C20E10 /* StackItem.swift in Sources */,
|
D2FB151D23A40F1500C20E10 /* MoleculeStackItem.swift in Sources */,
|
||||||
D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */,
|
D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */,
|
||||||
0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */,
|
0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */,
|
||||||
017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */,
|
017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */,
|
||||||
@ -1449,6 +1475,7 @@
|
|||||||
D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */,
|
D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */,
|
||||||
012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */,
|
012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */,
|
||||||
D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */,
|
D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */,
|
||||||
|
D260106323D0C05000764D80 /* StackItemModel.swift in Sources */,
|
||||||
01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */,
|
01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */,
|
||||||
0A21DB7F235DECC500C160A2 /* EntryField.swift in Sources */,
|
0A21DB7F235DECC500C160A2 /* EntryField.swift in Sources */,
|
||||||
D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */,
|
D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */,
|
||||||
@ -1465,6 +1492,7 @@
|
|||||||
D28A838723CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift in Sources */,
|
D28A838723CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift in Sources */,
|
||||||
C695A69623C990BC00BFB94E /* DoughnutChart.swift in Sources */,
|
C695A69623C990BC00BFB94E /* DoughnutChart.swift in Sources */,
|
||||||
014AA72D23C5059B006F3E93 /* StackPageTemplateModel.swift in Sources */,
|
014AA72D23C5059B006F3E93 /* StackPageTemplateModel.swift in Sources */,
|
||||||
|
D260106123D0C02A00764D80 /* StackItemModelProtocol.swift in Sources */,
|
||||||
012A88C4238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift in Sources */,
|
012A88C4238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift in Sources */,
|
||||||
94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */,
|
94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */,
|
||||||
014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */,
|
014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */,
|
||||||
@ -1486,7 +1514,7 @@
|
|||||||
D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */,
|
D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */,
|
||||||
01EB369023609801006832FA /* ListItemModel.swift in Sources */,
|
01EB369023609801006832FA /* ListItemModel.swift in Sources */,
|
||||||
D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */,
|
D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */,
|
||||||
D268C70C2386DFFD007F2C1C /* StackItemModel.swift in Sources */,
|
D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */,
|
||||||
DBEFFA04225A829700230692 /* Label.swift in Sources */,
|
DBEFFA04225A829700230692 /* Label.swift in Sources */,
|
||||||
D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */,
|
D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */,
|
||||||
01509D952327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift in Sources */,
|
01509D952327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift in Sources */,
|
||||||
@ -1504,6 +1532,7 @@
|
|||||||
D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */,
|
D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */,
|
||||||
D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */,
|
D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */,
|
||||||
D282AACB2243C61700C46919 /* ButtonView.swift in Sources */,
|
D282AACB2243C61700C46919 /* ButtonView.swift in Sources */,
|
||||||
|
D260105D23D0BCD400764D80 /* Stack.swift in Sources */,
|
||||||
D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */,
|
D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */,
|
||||||
01EB368F23609801006832FA /* LabelModel.swift in Sources */,
|
01EB368F23609801006832FA /* LabelModel.swift in Sources */,
|
||||||
0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */,
|
0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */,
|
||||||
@ -1559,9 +1588,11 @@
|
|||||||
D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */,
|
D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */,
|
||||||
0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */,
|
0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */,
|
||||||
D243859923A16B1800332775 /* Container.swift in Sources */,
|
D243859923A16B1800332775 /* Container.swift in Sources */,
|
||||||
|
D260105B23D0BB7100764D80 /* StackModelProtocol.swift in Sources */,
|
||||||
D29DF29821E7ADB8003B2FB9 /* MFScrollingViewController.m in Sources */,
|
D29DF29821E7ADB8003B2FB9 /* MFScrollingViewController.m in Sources */,
|
||||||
D28A839323CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift in Sources */,
|
D28A839323CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift in Sources */,
|
||||||
D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */,
|
D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */,
|
||||||
|
D260105F23D0BFFC00764D80 /* StackItem.swift in Sources */,
|
||||||
01EB369323609801006832FA /* HeaderModel.swift in Sources */,
|
01EB369323609801006832FA /* HeaderModel.swift in Sources */,
|
||||||
D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */,
|
D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */,
|
||||||
0A21DB83235DFBC500C160A2 /* MdnEntryField.swift in Sources */,
|
0A21DB83235DFBC500C160A2 /* MdnEntryField.swift in Sources */,
|
||||||
@ -1601,6 +1632,7 @@
|
|||||||
014AA72E23C5059B006F3E93 /* StackCenteredPageTemplateModel.swift in Sources */,
|
014AA72E23C5059B006F3E93 /* StackCenteredPageTemplateModel.swift in Sources */,
|
||||||
0ABD136B237B193A0081388D /* EntryFieldContainer.swift in Sources */,
|
0ABD136B237B193A0081388D /* EntryFieldContainer.swift in Sources */,
|
||||||
D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */,
|
D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */,
|
||||||
|
D260105923D0A92900764D80 /* ContainerProtocol.swift in Sources */,
|
||||||
C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */,
|
C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */,
|
||||||
D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */,
|
D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */,
|
||||||
012A88C2238D7BCA00FE3DA1 /* CarouselItemModel.swift in Sources */,
|
012A88C2238D7BCA00FE3DA1 /* CarouselItemModel.swift in Sources */,
|
||||||
@ -1616,6 +1648,7 @@
|
|||||||
D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */,
|
D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */,
|
||||||
946EE1BA237B66D80036751F /* MoleculeModelHelper.swift in Sources */,
|
946EE1BA237B66D80036751F /* MoleculeModelHelper.swift in Sources */,
|
||||||
01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */,
|
01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */,
|
||||||
|
D260106523D0CEA700764D80 /* StackModel.swift in Sources */,
|
||||||
D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */,
|
D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
|||||||
@ -196,7 +196,7 @@ public class ContainerHelper: NSObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open class Container: View {
|
open class Container: View, ContainerProtocol {
|
||||||
var view: UIView?
|
var view: UIView?
|
||||||
let containerHelper = ContainerHelper()
|
let containerHelper = ContainerHelper()
|
||||||
var containerModel: ContainerModelProtocol? {
|
var containerModel: ContainerModelProtocol? {
|
||||||
@ -208,6 +208,19 @@ open class Container: View {
|
|||||||
guard let containerModel = model as? ContainerModelProtocol else { return }
|
guard let containerModel = model as? ContainerModelProtocol else { return }
|
||||||
containerHelper.set(with: containerModel, for: view as? MVMCoreUIViewConstrainingProtocol)
|
containerHelper.set(with: containerModel, for: view as? MVMCoreUIViewConstrainingProtocol)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK:- ContainerProtocol
|
||||||
|
public func alignHorizontal(_ alignment: UIStackView.Alignment) {
|
||||||
|
containerHelper.alignHorizontal(alignment)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func alignVertical(_ alignment: UIStackView.Alignment) {
|
||||||
|
containerHelper.alignVertical(alignment)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func constrainView(_ view: UIView) {
|
||||||
|
containerHelper.constrainView(view)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - MVMCoreViewProtocol
|
// MARK: - MVMCoreViewProtocol
|
||||||
|
|||||||
15
MVMCoreUI/Containers/ContainerProtocol.swift
Normal file
15
MVMCoreUI/Containers/ContainerProtocol.swift
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
//
|
||||||
|
// ContainerProtocol.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Scott Pfeil on 1/16/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public protocol ContainerProtocol {
|
||||||
|
func alignHorizontal(_ alignment: UIStackView.Alignment)
|
||||||
|
func alignVertical(_ alignment: UIStackView.Alignment)
|
||||||
|
func constrainView(_ view: UIView)
|
||||||
|
}
|
||||||
@ -8,21 +8,23 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol {
|
open class DoughnutChart: View {
|
||||||
|
var doughnutLayer = CALayer()
|
||||||
var containerView = MVMCoreUICommonViewsUtility.commonView()
|
|
||||||
var containerLayer = CALayer()
|
|
||||||
var titleLabel = Label.commonLabelH3(true)
|
var titleLabel = Label.commonLabelH3(true)
|
||||||
var subTitleLabel = Label.commonLabelB2(true)
|
var subTitleLabel = Label.commonLabelB2(true)
|
||||||
var doughnutChartModel: DoughnutChartModel? {
|
var doughnutChartModel: DoughnutChartModel? {
|
||||||
get { return model as? DoughnutChartModel }
|
get { return model as? DoughnutChartModel }
|
||||||
}
|
}
|
||||||
var labelContainer = ViewConstrainingView.empty()
|
var labelContainer = MVMCoreUICommonViewsUtility.commonView()
|
||||||
|
var labelContainerLeftConstraint: NSLayoutConstraint?
|
||||||
|
var labelContainerTopConstraint: NSLayoutConstraint?
|
||||||
|
var labelContainerBottomConstraint: NSLayoutConstraint?
|
||||||
|
var labelContainerRightConstraint: NSLayoutConstraint?
|
||||||
var heightConstraint: NSLayoutConstraint?
|
var heightConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: 150)!
|
static let heightConstant: CGFloat = 150
|
||||||
|
private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: heightConstant)!
|
||||||
var height: CGFloat = 150 {
|
var height: CGFloat = heightConstant {
|
||||||
didSet {
|
didSet {
|
||||||
if height != oldValue {
|
if height != oldValue {
|
||||||
sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: height)!
|
sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: height)!
|
||||||
@ -47,17 +49,16 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol {
|
|||||||
clearLayers()
|
clearLayers()
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func setAsMolecule() {
|
public override func setAsMolecule() {
|
||||||
titleLabel.setAsMolecule()
|
titleLabel.setAsMolecule()
|
||||||
subTitleLabel.setAsMolecule()
|
subTitleLabel.setAsMolecule()
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func setupView() {
|
open override func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
guard containerView.superview == nil else {
|
guard labelContainer.superview == nil else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
addSubview(containerView)
|
|
||||||
addSubview(labelContainer)
|
addSubview(labelContainer)
|
||||||
|
|
||||||
labelContainer.addSubview(titleLabel)
|
labelContainer.addSubview(titleLabel)
|
||||||
@ -68,36 +69,35 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol {
|
|||||||
//Make label font size to adjust width if label content is high
|
//Make label font size to adjust width if label content is high
|
||||||
titleLabel.numberOfLines = 1
|
titleLabel.numberOfLines = 1
|
||||||
titleLabel.adjustsFontSizeToFitWidth = true
|
titleLabel.adjustsFontSizeToFitWidth = true
|
||||||
|
|
||||||
containerView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
|
layer.addSublayer(doughnutLayer)
|
||||||
containerView.topAnchor.constraint(equalTo: topAnchor).isActive = true
|
heightConstraint = heightAnchor.constraint(equalToConstant:
|
||||||
bottomAnchor.constraint(equalTo: containerView.bottomAnchor).isActive = true
|
|
||||||
trailingAnchor.constraint(equalTo: containerView.trailingAnchor).isActive = true
|
|
||||||
containerView.layer.addSublayer(containerLayer)
|
|
||||||
heightConstraint = containerView.heightAnchor.constraint(equalToConstant:
|
|
||||||
sizeObject.getValueBasedOnApplicationWidth())
|
sizeObject.getValueBasedOnApplicationWidth())
|
||||||
heightConstraint?.isActive = true
|
heightConstraint?.isActive = true
|
||||||
containerView.widthAnchor.constraint(equalTo: containerView.heightAnchor).isActive = true
|
widthAnchor.constraint(equalTo: heightAnchor).isActive = true
|
||||||
|
|
||||||
labelContainer.leftPin = labelContainer.leftAnchor.constraint(greaterThanOrEqualTo: containerView.leftAnchor, constant: lineWidth())
|
labelContainerLeftConstraint = labelContainer.leftAnchor.constraint(greaterThanOrEqualTo: leftAnchor, constant: lineWidth())
|
||||||
labelContainer.leftPin?.isActive = true
|
labelContainerLeftConstraint?.isActive = true
|
||||||
labelContainer.topPin = labelContainer.topAnchor.constraint(greaterThanOrEqualTo: containerView.topAnchor, constant: lineWidth())
|
labelContainerTopConstraint = labelContainer.topAnchor.constraint(greaterThanOrEqualTo: topAnchor, constant: lineWidth())
|
||||||
labelContainer.topPin?.isActive = true
|
labelContainerTopConstraint?.isActive = true
|
||||||
labelContainer.centerYAnchor.constraint(equalTo: containerView.centerYAnchor).isActive = true
|
labelContainerRightConstraint = rightAnchor.constraint(greaterThanOrEqualTo: labelContainer.rightAnchor, constant: lineWidth())
|
||||||
labelContainer.centerXAnchor.constraint(equalTo: containerView.centerXAnchor).isActive = true
|
labelContainerRightConstraint?.isActive = true
|
||||||
|
labelContainerBottomConstraint = bottomAnchor.constraint(greaterThanOrEqualTo: labelContainer.bottomAnchor, constant: lineWidth())
|
||||||
|
labelContainerBottomConstraint?.isActive = true
|
||||||
|
labelContainer.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
|
||||||
|
labelContainer.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
|
||||||
|
|
||||||
NSLayoutConstraint.constraintPinSubview(titleLabel, pinTop: true, pinBottom: false, pinLeft: true, pinRight: true)
|
NSLayoutConstraint.constraintPinSubview(titleLabel, pinTop: true, pinBottom: false, pinLeft: true, pinRight: true)
|
||||||
NSLayoutConstraint.constraintPinSubview(subTitleLabel, pinTop: false, pinBottom: true, pinLeft: true, pinRight: true)
|
NSLayoutConstraint.constraintPinSubview(subTitleLabel, pinTop: false, pinBottom: true, pinLeft: true, pinRight: true)
|
||||||
_ = NSLayoutConstraint(pinFirstView: titleLabel, toSecondView: subTitleLabel, withConstant: 0, directionVertical: true)
|
_ = NSLayoutConstraint(pinFirstView: titleLabel, toSecondView: subTitleLabel, withConstant: 0, directionVertical: true)
|
||||||
//Rotate view for initial draw
|
//Rotate view for initial draw
|
||||||
containerLayer.transform = CATransform3DMakeRotation(1 * .pi, 0.0, 0.0, 1.0)
|
doughnutLayer.transform = CATransform3DMakeRotation(1 * .pi, 0.0, 0.0, 1.0)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||||
super.setWithModel(model, delegateObject, additionalData)
|
super.setWithModel(model, delegateObject, additionalData)
|
||||||
clearLayers()
|
clearLayers()
|
||||||
guard let doughnutChartModel = model as? DoughnutChartModel else {
|
guard let doughnutChartModel = doughnutChartModel else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
titleLabel.setWithModel(doughnutChartModel.title, delegateObject, additionalData)
|
titleLabel.setWithModel(doughnutChartModel.title, delegateObject, additionalData)
|
||||||
@ -111,7 +111,7 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol {
|
|||||||
func drawGraph() {
|
func drawGraph() {
|
||||||
clearLayers()
|
clearLayers()
|
||||||
let widthHeight = sizeObject.getValueBasedOnApplicationWidth()
|
let widthHeight = sizeObject.getValueBasedOnApplicationWidth()
|
||||||
containerLayer.frame = CGRect(x: 0, y: 0,
|
doughnutLayer.frame = CGRect(x: 0, y: 0,
|
||||||
width: widthHeight,
|
width: widthHeight,
|
||||||
height: widthHeight)
|
height: widthHeight)
|
||||||
if let doughnutChart = doughnutChartModel {
|
if let doughnutChart = doughnutChartModel {
|
||||||
@ -122,17 +122,16 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func drawBar(_ chartModel: ChartItemModel, _ prevPercent: CGFloat) -> CGFloat {
|
func drawBar(_ chartModel: DoughnutChartItemModel, _ prevPercent: CGFloat) -> CGFloat {
|
||||||
|
|
||||||
let shapeLayer = CAShapeLayer()
|
let shapeLayer = CAShapeLayer()
|
||||||
shapeLayer.frame = containerLayer.frame
|
shapeLayer.frame = doughnutLayer.frame
|
||||||
shapeLayer.lineWidth = lineWidth()
|
shapeLayer.lineWidth = lineWidth()
|
||||||
shapeLayer.fillColor = nil
|
shapeLayer.fillColor = nil
|
||||||
shapeLayer.strokeColor = UIColor.mfGet(forHex: chartModel.color).cgColor
|
shapeLayer.strokeColor = chartModel.color.uiColor.cgColor
|
||||||
|
|
||||||
let arcCenter = shapeLayer.position
|
let arcCenter = shapeLayer.position
|
||||||
let radius = shapeLayer.bounds.size.width / 2.0 - lineWidth()/2.0
|
let radius = shapeLayer.bounds.size.width / 2.0 - lineWidth()/2.0
|
||||||
//lineSizeObject.getValueBasedOnApplicationWidth() / 2.0
|
|
||||||
let clockwise = true
|
let clockwise = true
|
||||||
|
|
||||||
let value: CGFloat = chartModel.percent
|
let value: CGFloat = chartModel.percent
|
||||||
@ -146,12 +145,12 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol {
|
|||||||
clockwise: clockwise)
|
clockwise: clockwise)
|
||||||
|
|
||||||
shapeLayer.path = circlePath.cgPath
|
shapeLayer.path = circlePath.cgPath
|
||||||
containerLayer.addSublayer(shapeLayer)
|
doughnutLayer.addSublayer(shapeLayer)
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
func clearLayers() {
|
func clearLayers() {
|
||||||
containerLayer.sublayers?.forEach({ $0.removeFromSuperlayer() })
|
doughnutLayer.sublayers?.forEach({ $0.removeFromSuperlayer() })
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateContainer() {
|
func updateContainer() {
|
||||||
@ -161,7 +160,7 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func lineWidth() -> CGFloat {
|
func lineWidth() -> CGFloat {
|
||||||
return doughnutChartModel?.lineWidth ?? 30
|
return 30
|
||||||
}
|
}
|
||||||
|
|
||||||
func lineGap() -> CGFloat {
|
func lineGap() -> CGFloat {
|
||||||
@ -174,9 +173,10 @@ open class DoughnutChart: View, MVMCoreUIViewConstrainingProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func updateLabelContainer() {
|
func updateLabelContainer() {
|
||||||
labelContainer.leftPin?.constant = lineWidth()
|
labelContainerLeftConstraint?.constant = lineWidth()
|
||||||
labelContainer.topPin?.constant = lineWidth()
|
labelContainerTopConstraint?.constant = lineWidth()
|
||||||
|
labelContainerRightConstraint?.constant = lineWidth()
|
||||||
|
labelContainerBottomConstraint?.constant = lineWidth()
|
||||||
labelContainer.setNeedsDisplay()
|
labelContainer.setNeedsDisplay()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -13,16 +13,24 @@ import Foundation
|
|||||||
public static var identifier: String = "doughnutChart"
|
public static var identifier: String = "doughnutChart"
|
||||||
public var title: LabelModel?
|
public var title: LabelModel?
|
||||||
public var subtitle: LabelModel?
|
public var subtitle: LabelModel?
|
||||||
public var sections: [ChartItemModel]
|
public var sections: [DoughnutChartItemModel]
|
||||||
public var lineWidth: CGFloat?
|
|
||||||
public var spaceRequired: Bool?
|
public var spaceRequired: Bool?
|
||||||
|
|
||||||
|
public init(sections: [DoughnutChartItemModel]) {
|
||||||
|
self.sections = sections
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objcMembers public class DoughnutChartItemModel: MoleculeProtocol {
|
||||||
@objcMembers public class ChartItemModel: MoleculeProtocol {
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
|
public static var identifier: String = "doughnutChartItem"
|
||||||
public var label: LabelModel
|
public var label: LabelModel
|
||||||
public var percent: CGFloat
|
@Percent public var percent: CGFloat
|
||||||
public var color: String
|
public var color: Color
|
||||||
public static var identifier: String = "chartItem"
|
|
||||||
|
public init(percent: CGFloat, color: Color, label: LabelModel) {
|
||||||
|
self.percent = percent
|
||||||
|
self.color = color
|
||||||
|
self.label = label
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -9,54 +9,48 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@objcMembers open class DoughnutChartView: View {
|
@objcMembers open class DoughnutChartView: View {
|
||||||
|
|
||||||
var doughnutChart = DoughnutChart(frame: CGRect.zero)
|
var doughnutChart = DoughnutChart(frame: CGRect.zero)
|
||||||
var colorLablesStack = ColorViewLabelsStack()
|
var colorLablesStack = ColorViewLabelsStack()
|
||||||
var container = MVMCoreUICommonViewsUtility.commonView()
|
|
||||||
var doughnutChartModel: DoughnutChartModel? {
|
var doughnutChartModel: DoughnutChartModel? {
|
||||||
get { return model as? DoughnutChartModel }
|
get { return model as? DoughnutChartModel }
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func setupView() {
|
open override func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
guard container.superview == nil else {
|
guard doughnutChart.superview == nil else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
addSubview(container)
|
|
||||||
doughnutChart.translatesAutoresizingMaskIntoConstraints = false
|
doughnutChart.translatesAutoresizingMaskIntoConstraints = false
|
||||||
container.addSubview(doughnutChart)
|
addSubview(doughnutChart)
|
||||||
colorLablesStack.translatesAutoresizingMaskIntoConstraints = false
|
colorLablesStack.translatesAutoresizingMaskIntoConstraints = false
|
||||||
container.addSubview(colorLablesStack)
|
addSubview(colorLablesStack)
|
||||||
|
|
||||||
NSLayoutConstraint.constraintPinSubview(container, pinTop: true, pinBottom: true, pinLeft: true, pinRight: true)
|
doughnutChart.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
|
||||||
doughnutChart.leadingAnchor.constraint(equalTo: container.leadingAnchor).isActive = true
|
doughnutChart.topAnchor.constraint(equalTo: topAnchor, constant: PaddingFour).isActive = true
|
||||||
doughnutChart.topAnchor.constraint(equalTo: container.topAnchor, constant: PaddingFour).isActive = true
|
bottomAnchor.constraint(greaterThanOrEqualTo: doughnutChart.bottomAnchor).isActive = true
|
||||||
container.bottomAnchor.constraint(greaterThanOrEqualTo: doughnutChart.bottomAnchor).isActive = true
|
|
||||||
|
|
||||||
let containerBottomAnchor = container.bottomAnchor.constraint(equalTo: doughnutChart.bottomAnchor)
|
let doughnutBottomAnchor = bottomAnchor.constraint(equalTo: doughnutChart.bottomAnchor)
|
||||||
containerBottomAnchor.priority = UILayoutPriority(rawValue: 200)
|
doughnutBottomAnchor.priority = UILayoutPriority(rawValue: 200)
|
||||||
containerBottomAnchor.isActive = true
|
doughnutBottomAnchor.isActive = true
|
||||||
|
|
||||||
let colorLablesBottomAnchor = container.bottomAnchor.constraint(equalTo: colorLablesStack.bottomAnchor)
|
let colorLablesBottomAnchor = bottomAnchor.constraint(equalTo: colorLablesStack.bottomAnchor)
|
||||||
colorLablesBottomAnchor.priority = UILayoutPriority(rawValue: 204)
|
colorLablesBottomAnchor.priority = UILayoutPriority(rawValue: 204)
|
||||||
colorLablesBottomAnchor.isActive = true
|
colorLablesBottomAnchor.isActive = true
|
||||||
|
|
||||||
let colorLablesTopAnchor = colorLablesStack.topAnchor.constraint(equalTo: doughnutChart.topAnchor)
|
let colorLablesTopAnchor = colorLablesStack.topAnchor.constraint(equalTo: doughnutChart.topAnchor)
|
||||||
colorLablesTopAnchor.priority = UILayoutPriority(rawValue: 204)
|
colorLablesTopAnchor.priority = .defaultLow
|
||||||
colorLablesTopAnchor.isActive = true
|
colorLablesTopAnchor.isActive = true
|
||||||
|
|
||||||
colorLablesStack.topAnchor.constraint(greaterThanOrEqualTo: doughnutChart.topAnchor).isActive = true
|
colorLablesStack.topAnchor.constraint(greaterThanOrEqualTo: doughnutChart.topAnchor).isActive = true
|
||||||
container.bottomAnchor.constraint(greaterThanOrEqualTo: colorLablesStack.bottomAnchor).isActive = true
|
bottomAnchor.constraint(greaterThanOrEqualTo: colorLablesStack.bottomAnchor).isActive = true
|
||||||
container.trailingAnchor.constraint(greaterThanOrEqualTo: colorLablesStack.trailingAnchor).isActive = true
|
trailingAnchor.constraint(equalTo: colorLablesStack.trailingAnchor).isActive = true
|
||||||
|
|
||||||
let centerY = colorLablesStack.centerYAnchor.constraint(equalTo: doughnutChart.centerYAnchor)
|
let centerY = colorLablesStack.centerYAnchor.constraint(equalTo: doughnutChart.centerYAnchor)
|
||||||
centerY.priority = .defaultLow
|
centerY.priority = UILayoutPriority(rawValue: 500)
|
||||||
centerY.isActive = true
|
centerY.isActive = true
|
||||||
|
|
||||||
colorLablesStack.leadingAnchor.constraint(equalTo: doughnutChart.trailingAnchor, constant: PaddingThree).isActive = true
|
colorLablesStack.leadingAnchor.constraint(equalTo: doughnutChart.trailingAnchor, constant: PaddingThree).isActive = true
|
||||||
colorLablesStack.backgroundColor = UIColor.clear
|
colorLablesStack.backgroundColor = UIColor.clear
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func updateView(_ size: CGFloat) {
|
open override func updateView(_ size: CGFloat) {
|
||||||
@ -67,56 +61,51 @@ import Foundation
|
|||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
doughnutChart.reset()
|
||||||
colorLablesStack.reset()
|
colorLablesStack.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||||
super.setWithModel(model, delegateObject, additionalData)
|
super.setWithModel(model, delegateObject, additionalData)
|
||||||
doughnutChart.clearLayers()
|
|
||||||
colorLablesStack.removeAllItemViews()
|
guard let model = doughnutChartModel else { return }
|
||||||
doughnutChart.setWithModel(model, delegateObject, additionalData)
|
doughnutChart.setWithModel(model, delegateObject, additionalData)
|
||||||
colorLablesStack.setWithModel(model, delegateObject, additionalData)
|
|
||||||
|
// Create the stack model
|
||||||
|
var stackItems: [MoleculeStackItemModel] = []
|
||||||
|
for item in model.sections {
|
||||||
|
stackItems.append(MoleculeStackItemModel(with: item))
|
||||||
|
}
|
||||||
|
let stack = MoleculeStackModel(molecules: stackItems)
|
||||||
|
stack.verticalAlignment = .fill
|
||||||
|
colorLablesStack.setWithModel(stack, delegateObject, additionalData)
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||||
if model == nil {
|
guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: DoughnutChartModel.self) else { return }
|
||||||
let data = try! JSONSerialization.data(withJSONObject: json!)
|
setWithModel(model, delegateObject, additionalData)
|
||||||
let decoder = JSONDecoder()
|
}
|
||||||
let model = try! decoder.decode(DoughnutChartModel.self, from: data)
|
}
|
||||||
setWithModel(model, delegateObject, additionalData as? [String : AnyHashable])
|
|
||||||
} else {
|
extension DoughnutChartView: MVMCoreUIViewConstrainingProtocol {
|
||||||
setWithModel(model, delegateObject, additionalData as? [String : AnyHashable])
|
open func horizontalAlignment() -> UIStackView.Alignment {
|
||||||
}
|
return .leading
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ColorViewLabelsStack: MoleculeStackView {
|
class ColorViewLabelsStack: MoleculeStackView {
|
||||||
|
override func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) {
|
||||||
var dougnutChartModel: DoughnutChartModel?
|
guard let stackItemModels = stackModel?.molecules else { return }
|
||||||
override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
for model in stackItemModels {
|
||||||
let previousModel = self.dougnutChartModel
|
let view = ColorViewWithLabel()
|
||||||
removeAllItemViews()
|
let stackItem = MoleculeStackItem(andContain: view)
|
||||||
guard let dougnutChartModel = model as? DoughnutChartModel else {
|
stackItem.setWithModel(model, delegate, nil)
|
||||||
return
|
stackItems.append(stackItem)
|
||||||
}
|
}
|
||||||
var items: [StackItem]?
|
|
||||||
if previousModel?.sections.count == dougnutChartModel.sections.count {
|
|
||||||
items = stackItems
|
|
||||||
}
|
|
||||||
stackItems = []
|
|
||||||
self.model = MoleculeStackModel(molecules: [])
|
|
||||||
for (index, chartItemModel) in dougnutChartModel.sections.enumerated() {
|
|
||||||
let colorViewWithLabel = items?[index].view as? ColorViewWithLabel ?? ColorViewWithLabel()
|
|
||||||
colorViewWithLabel.setWithModel(chartItemModel, delegateObject, additionalData)
|
|
||||||
addView(colorViewWithLabel, lastItem: index == dougnutChartModel.sections.count - 1)
|
|
||||||
}
|
|
||||||
self.dougnutChartModel = dougnutChartModel
|
|
||||||
restack()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ColorViewWithLabel: View, MVMCoreUIViewConstrainingProtocol {
|
class ColorViewWithLabel: View {
|
||||||
|
|
||||||
var label = Label.commonLabelB2(true)
|
var label = Label.commonLabelB2(true)
|
||||||
var colorView = MVMCoreUICommonViewsUtility.commonView()
|
var colorView = MVMCoreUICommonViewsUtility.commonView()
|
||||||
@ -140,9 +129,8 @@ class ColorViewWithLabel: View, MVMCoreUIViewConstrainingProtocol {
|
|||||||
|
|
||||||
label.leadingAnchor.constraint(equalTo: colorView.trailingAnchor, constant: PaddingOne).isActive = true
|
label.leadingAnchor.constraint(equalTo: colorView.trailingAnchor, constant: PaddingOne).isActive = true
|
||||||
label.topAnchor.constraint(equalTo: topAnchor).isActive = true
|
label.topAnchor.constraint(equalTo: topAnchor).isActive = true
|
||||||
trailingAnchor.constraint(greaterThanOrEqualTo: label.trailingAnchor).isActive = true
|
trailingAnchor.constraint(equalTo: label.trailingAnchor).isActive = true
|
||||||
bottomAnchor.constraint(equalTo: label.bottomAnchor).isActive = true
|
bottomAnchor.constraint(equalTo: label.bottomAnchor).isActive = true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func updateView(_ size: CGFloat) {
|
override func updateView(_ size: CGFloat) {
|
||||||
@ -163,11 +151,10 @@ class ColorViewWithLabel: View, MVMCoreUIViewConstrainingProtocol {
|
|||||||
|
|
||||||
override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||||
super.setWithModel(model, delegateObject, additionalData)
|
super.setWithModel(model, delegateObject, additionalData)
|
||||||
guard let chartItemModel = model as? ChartItemModel else {
|
guard let chartItemModel = model as? DoughnutChartItemModel else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
label.setWithModel(chartItemModel.label, delegateObject, additionalData)
|
label.setWithModel(chartItemModel.label, delegateObject, additionalData)
|
||||||
colorView.backgroundColor = UIColor.mfGet(forHex: chartItemModel.color)
|
colorView.backgroundColor = chartItemModel.color.uiColor
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
16
MVMCoreUI/Molecules/Items/MoleculeStackItem.swift
Normal file
16
MVMCoreUI/Molecules/Items/MoleculeStackItem.swift
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// StackItem.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Scott Pfeil on 12/13/19.
|
||||||
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
// A list item that contains a molecule
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
open class MoleculeStackItem: MoleculeContainer {
|
||||||
|
var stackItemModel: StackItemModel? {
|
||||||
|
get { return model as? StackItemModel }
|
||||||
|
}
|
||||||
|
}
|
||||||
45
MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift
Normal file
45
MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
//
|
||||||
|
// MoleculeStackItem.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Suresh, Kamlesh on 10/4/19.
|
||||||
|
// Copyright © 2019 Suresh, Kamlesh. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
@objcMembers public class MoleculeStackItemModel: MoleculeContainerModel, MoleculeProtocol, StackItemModelProtocol {
|
||||||
|
public static var identifier: String = "stackItem"
|
||||||
|
public var backgroundColor: Color?
|
||||||
|
public var spacing: CGFloat?
|
||||||
|
public var percent: Int?
|
||||||
|
public var gone: Bool = false
|
||||||
|
|
||||||
|
enum MoleculeStackItemCodingKeys: String, CodingKey {
|
||||||
|
case spacing
|
||||||
|
case percent
|
||||||
|
case gone
|
||||||
|
}
|
||||||
|
|
||||||
|
public override init(with moleculeModel: MoleculeProtocol) {
|
||||||
|
super.init(with: moleculeModel)
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
let typeContainer = try decoder.container(keyedBy: MoleculeStackItemCodingKeys.self)
|
||||||
|
spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing)
|
||||||
|
percent = try typeContainer.decodeIfPresent(Int.self, forKey: .percent)
|
||||||
|
if let gone = try typeContainer.decodeIfPresent(Bool.self, forKey: .gone) {
|
||||||
|
self.gone = gone
|
||||||
|
}
|
||||||
|
try super.init(from: decoder)
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func encode(to encoder: Encoder) throws {
|
||||||
|
try super.encode(to: encoder)
|
||||||
|
var container = encoder.container(keyedBy: MoleculeStackItemCodingKeys.self)
|
||||||
|
try container.encodeIfPresent(spacing, forKey: .spacing)
|
||||||
|
try container.encodeIfPresent(percent, forKey: .percent)
|
||||||
|
try container.encode(gone, forKey: .gone)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,13 +2,13 @@
|
|||||||
// StackItem.swift
|
// StackItem.swift
|
||||||
// MVMCoreUI
|
// MVMCoreUI
|
||||||
//
|
//
|
||||||
// Created by Scott Pfeil on 12/13/19.
|
// Created by Scott Pfeil on 1/16/20.
|
||||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
import Foundation
|
||||||
|
|
||||||
open class StackItem: MoleculeContainer {
|
open class StackItem: Container {
|
||||||
var stackItemModel: StackItemModel? {
|
var stackItemModel: StackItemModel? {
|
||||||
get { return model as? StackItemModel }
|
get { return model as? StackItemModel }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,45 +1,20 @@
|
|||||||
//
|
//
|
||||||
// MoleculeStackItem.swift
|
// StackItemModel.swift
|
||||||
// MVMCoreUI
|
// MVMCoreUI
|
||||||
//
|
//
|
||||||
// Created by Suresh, Kamlesh on 10/4/19.
|
// Created by Scott Pfeil on 1/16/20.
|
||||||
// Copyright © 2019 Suresh, Kamlesh. All rights reserved.
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@objcMembers public class StackItemModel: MoleculeContainerModel, MoleculeProtocol {
|
@objcMembers public class StackItemModel: StackItemModelProtocol, Codable {
|
||||||
public static var identifier: String = "stackItem"
|
|
||||||
public var backgroundColor: Color?
|
|
||||||
public var spacing: CGFloat?
|
public var spacing: CGFloat?
|
||||||
public var percent: Int?
|
public var percent: Int?
|
||||||
public var gone: Bool = false
|
public var gone: Bool = false
|
||||||
|
|
||||||
enum MoleculeStackItemCodingKeys: String, CodingKey {
|
public convenience init(gone: Bool) {
|
||||||
case spacing
|
self.init()
|
||||||
case percent
|
self.gone = gone
|
||||||
case gone
|
|
||||||
}
|
|
||||||
|
|
||||||
public override init(with moleculeModel: MoleculeProtocol) {
|
|
||||||
super.init(with: moleculeModel)
|
|
||||||
}
|
|
||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
|
||||||
let typeContainer = try decoder.container(keyedBy: MoleculeStackItemCodingKeys.self)
|
|
||||||
spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing)
|
|
||||||
percent = try typeContainer.decodeIfPresent(Int.self, forKey: .percent)
|
|
||||||
if let gone = try typeContainer.decodeIfPresent(Bool.self, forKey: .gone) {
|
|
||||||
self.gone = gone
|
|
||||||
}
|
|
||||||
try super.init(from: decoder)
|
|
||||||
}
|
|
||||||
|
|
||||||
public override func encode(to encoder: Encoder) throws {
|
|
||||||
try super.encode(to: encoder)
|
|
||||||
var container = encoder.container(keyedBy: MoleculeStackItemCodingKeys.self)
|
|
||||||
try container.encodeIfPresent(spacing, forKey: .spacing)
|
|
||||||
try container.encodeIfPresent(percent, forKey: .percent)
|
|
||||||
try container.encode(gone, forKey: .gone)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
15
MVMCoreUI/Molecules/Items/StackItemModelProtocol.swift
Normal file
15
MVMCoreUI/Molecules/Items/StackItemModelProtocol.swift
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
//
|
||||||
|
// StackItemModelProtocol.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Scott Pfeil on 1/16/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public protocol StackItemModelProtocol {
|
||||||
|
var spacing: CGFloat? { get set }
|
||||||
|
var percent: Int? { get set }
|
||||||
|
var gone: Bool { get set }
|
||||||
|
}
|
||||||
@ -19,7 +19,7 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objcMembers open class EyebrowHeadlineBodyLink: Container {
|
@objcMembers open class EyebrowHeadlineBodyLink: Container {
|
||||||
let stack = MoleculeStackView(frame: .zero)
|
let stack = Stack<StackModel>(frame: .zero)
|
||||||
let eyebrow = Label.commonLabelB3(true)
|
let eyebrow = Label.commonLabelB3(true)
|
||||||
let headline = Label.commonLabelB1(true)
|
let headline = Label.commonLabelB1(true)
|
||||||
let body = Label.commonLabelB2(true)
|
let body = Label.commonLabelB2(true)
|
||||||
@ -34,19 +34,7 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol {
|
|||||||
guard stack.superview == nil else {
|
guard stack.superview == nil else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let eyebrowStackItem = StackItemModel(with: casteModel!.eyeBrow!)
|
|
||||||
let headlineStackItem = StackItemModel(with: casteModel!.headline!)
|
|
||||||
let bodyStackItem = StackItemModel(with: casteModel!.body!)
|
|
||||||
let linkStackItem = StackItemModel(with: casteModel!.link!)
|
|
||||||
|
|
||||||
// To visually take into account the extra padding in the intrinsic content of a button.
|
|
||||||
linkStackItem.spacing = -6
|
|
||||||
|
|
||||||
let stackModel = MoleculeStackModel(molecules: [eyebrowStackItem,headlineStackItem,bodyStackItem,linkStackItem])
|
|
||||||
stackModel.spacing = 0
|
|
||||||
stack.model = stackModel
|
|
||||||
stack.stackItems = [StackItem(andContain: eyebrow),StackItem(andContain: headline),StackItem(andContain: body),StackItem(andContain: link)]
|
stack.stackItems = [StackItem(andContain: eyebrow),StackItem(andContain: headline),StackItem(andContain: body),StackItem(andContain: link)]
|
||||||
|
|
||||||
addSubview(stack)
|
addSubview(stack)
|
||||||
NSLayoutConstraint.constraintPinSubview(toSuperview: stack)
|
NSLayoutConstraint.constraintPinSubview(toSuperview: stack)
|
||||||
}
|
}
|
||||||
@ -64,13 +52,14 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol {
|
|||||||
headline.setWithModel(casteModel?.headline, delegateObject, additionalData)
|
headline.setWithModel(casteModel?.headline, delegateObject, additionalData)
|
||||||
body.setWithModel(casteModel?.body, delegateObject, additionalData)
|
body.setWithModel(casteModel?.body, delegateObject, additionalData)
|
||||||
link.setWithModel(casteModel?.link, delegateObject, additionalData)
|
link.setWithModel(casteModel?.link, delegateObject, additionalData)
|
||||||
|
|
||||||
(stack.stackItems[0].model as? StackItemModel)?.gone = !eyebrow.hasText
|
// Create a stack model to use for the internal stack.
|
||||||
(stack.stackItems[1].model as? StackItemModel)?.gone = !headline.hasText
|
let stackModel = StackModel(molecules: [StackItemModel(gone: !eyebrow.hasText),StackItemModel(gone: !headline.hasText),StackItemModel(gone: !body.hasText),StackItemModel(gone: (link.titleLabel?.text?.count ?? 0) == 0)])
|
||||||
(stack.stackItems[2].model as? StackItemModel)?.gone = !body.hasText
|
stackModel.spacing = 0
|
||||||
(stack.stackItems[3].model as? StackItemModel)?.gone = ((link.titleLabel?.text?.count) ?? 0) == 0
|
stack.model = stackModel
|
||||||
stack.restack()
|
stack.restack()
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||||
guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: EyebrowHeadlineBodyLinkModel.self) else { return }
|
guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: EyebrowHeadlineBodyLinkModel.self) else { return }
|
||||||
setWithModel(model, delegateObject, additionalData)
|
setWithModel(model, delegateObject, additionalData)
|
||||||
|
|||||||
@ -5,17 +5,19 @@
|
|||||||
// Created by Suresh, Kamlesh on 10/3/19.
|
// Created by Suresh, Kamlesh on 10/3/19.
|
||||||
// Copyright © 2019 Suresh, Kamlesh. All rights reserved.
|
// Copyright © 2019 Suresh, Kamlesh. All rights reserved.
|
||||||
//
|
//
|
||||||
|
// A stack that has a list molecule stack items.
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@objcMembers public class MoleculeStackModel: ContainerModel, MoleculeProtocol {
|
@objcMembers public class MoleculeStackModel: ContainerModel, MoleculeProtocol, StackModelProtocol {
|
||||||
public static var identifier: String = "stack"
|
public static var identifier: String = "stack"
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var molecules: [StackItemModel]
|
public var molecules: [MoleculeStackItemModel]
|
||||||
public var axis: NSLayoutConstraint.Axis = .vertical
|
public var axis: NSLayoutConstraint.Axis = .vertical
|
||||||
public var spacing: CGFloat = 16.0
|
public var spacing: CGFloat = 16.0
|
||||||
|
public var useStackSpacingBeforeFirstItem = false
|
||||||
|
|
||||||
public init(molecules: [StackItemModel]) {
|
public init(molecules: [MoleculeStackItemModel]) {
|
||||||
self.molecules = molecules
|
self.molecules = molecules
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
@ -29,7 +31,7 @@ import Foundation
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: StackCodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: StackCodingKeys.self)
|
||||||
molecules = try typeContainer.decode([StackItemModel].self, forKey: .molecules)
|
molecules = try typeContainer.decode([MoleculeStackItemModel].self, forKey: .molecules)
|
||||||
if let axisString = try typeContainer.decodeIfPresent(String.self, forKey: .axis), let optionalAxis = NSLayoutConstraint.Axis(rawValue: axisString) {
|
if let axisString = try typeContainer.decodeIfPresent(String.self, forKey: .axis), let optionalAxis = NSLayoutConstraint.Axis(rawValue: axisString) {
|
||||||
axis = optionalAxis
|
axis = optionalAxis
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,193 +8,22 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
open class MoleculeStackView: Container {
|
open class MoleculeStackView: Stack<MoleculeStackModel> {
|
||||||
var contentView: UIView = MVMCoreUICommonViewsUtility.commonView()
|
override var stackModel: MoleculeStackModel? {
|
||||||
var useStackSpacingBeforeFirstItem = false
|
|
||||||
var stackModel: MoleculeStackModel? {
|
|
||||||
get { return model as? MoleculeStackModel }
|
get { return model as? MoleculeStackModel }
|
||||||
}
|
}
|
||||||
var stackItems: [StackItem] = []
|
|
||||||
|
|
||||||
var moleculesShouldSetHorizontalMargins = false
|
/// Convenience function, adds a molecule to a MoleculeStackItem to the MoleculeStack
|
||||||
var moleculesShouldSetVerticalMargins = false
|
func addMolecule(_ view: View, lastItem: Bool) {
|
||||||
|
guard let model = view.model else { return }
|
||||||
// MARK: - Helpers
|
let stackItemModel = MoleculeStackItemModel(with: model)
|
||||||
public func pinView(_ view: UIView, toView: UIView, attribute: NSLayoutConstraint.Attribute, relation: NSLayoutConstraint.Relation, priority: UILayoutPriority, constant: CGFloat) {
|
let stackItem = MoleculeStackItem(andContain: view)
|
||||||
let constraint = NSLayoutConstraint(item: view, attribute: attribute, relatedBy: relation, toItem: toView, attribute: attribute, multiplier: 1.0, constant: constant)
|
addView(stackItem, stackItemModel, lastItem: lastItem)
|
||||||
constraint.priority = priority
|
|
||||||
constraint.isActive = true
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Restacks the existing items.
|
|
||||||
func restack() {
|
|
||||||
removeAllItemViews()
|
|
||||||
let stackItems = self.stackItems
|
|
||||||
self.stackItems = []
|
|
||||||
let lastItem = stackItems.last(where: { (item) -> Bool in
|
|
||||||
return !item.stackItemModel!.gone
|
|
||||||
})
|
|
||||||
for item in stackItems {
|
|
||||||
addStackItem(item, lastItem: item === lastItem)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Removes all stack items views from the view.
|
|
||||||
func removeAllItemViews() {
|
|
||||||
for item in stackItems {
|
|
||||||
item.removeFromSuperview()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Inits
|
|
||||||
public override init(frame: CGRect) {
|
|
||||||
super.init(frame: frame)
|
|
||||||
}
|
|
||||||
|
|
||||||
public init(withJSON json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
|
||||||
super.init(frame: CGRect.zero)
|
|
||||||
setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
|
||||||
}
|
|
||||||
|
|
||||||
public required init?(coder aDecoder: NSCoder) {
|
|
||||||
fatalError("init(coder:) has not been implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - MFViewProtocol
|
|
||||||
public override func setupView() {
|
|
||||||
super.setupView()
|
|
||||||
guard contentView.superview == nil else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
MVMCoreUIUtility.setMarginsFor(contentView, leading: 0, top: 0, trailing: 0, bottom: 0)
|
|
||||||
translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
backgroundColor = .clear
|
|
||||||
addSubview(contentView)
|
|
||||||
containerHelper.constrainView(contentView)
|
|
||||||
contentView.setContentHuggingPriority(.defaultHigh, for: .vertical)
|
|
||||||
contentView.setContentHuggingPriority(.defaultHigh, for: .horizontal)
|
|
||||||
}
|
|
||||||
|
|
||||||
public override func updateView(_ size: CGFloat) {
|
|
||||||
super.updateView(size)
|
|
||||||
for item in stackItems {
|
|
||||||
item.updateView(size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
|
||||||
public override func reset() {
|
|
||||||
super.reset()
|
|
||||||
backgroundColor = .clear
|
|
||||||
for item in stackItems {
|
|
||||||
item.reset()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
|
||||||
let previousModel = stackModel
|
|
||||||
super.setWithModel(model, delegateObject, additionalData)
|
|
||||||
removeAllItemViews()
|
|
||||||
|
|
||||||
// If the items in the stack are different, clear them, create new ones.
|
|
||||||
if (previousModel == nil) || MoleculeStackView.nameForReuse(previousModel, delegateObject) != MoleculeStackView.nameForReuse(model, delegateObject) {
|
|
||||||
stackItems = []
|
|
||||||
createStackItemsFromModel(with: delegateObject)
|
|
||||||
} else if let models = stackModel?.molecules {
|
|
||||||
for (index, element) in models.enumerated() {
|
|
||||||
stackItems[index].setWithModel(element, delegateObject, additionalData)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
restack()
|
|
||||||
stackModel?.useHorizontalMargins = moleculesShouldSetHorizontalMargins
|
|
||||||
stackModel?.useVerticalMargins = moleculesShouldSetVerticalMargins
|
|
||||||
}
|
|
||||||
|
|
||||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
|
||||||
if model == nil {
|
|
||||||
let data = try! JSONSerialization.data(withJSONObject: json!)
|
|
||||||
let decoder = JSONDecoder()
|
|
||||||
let model = try! decoder.decode(MoleculeStackModel.self, from: data)
|
|
||||||
setWithModel(model, delegateObject, additionalData)
|
|
||||||
} else {
|
|
||||||
setWithModel(model, delegateObject, additionalData)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
|
|
||||||
// This will aggregate names of molecules to make an id.
|
|
||||||
guard let model = model as? MoleculeStackModel else {
|
|
||||||
return "stack<>"
|
|
||||||
}
|
|
||||||
var name = "stack<"
|
|
||||||
for case let item in model.molecules {
|
|
||||||
if let moleculeName = item.molecule.moleculeName {
|
|
||||||
if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[moleculeName] as? ModelMoleculeViewProtocol.Type,
|
|
||||||
let nameForReuse = moleculeClass.nameForReuse(item.molecule, delegateObject) {
|
|
||||||
name.append(nameForReuse + ",")
|
|
||||||
} else {
|
|
||||||
name.append(moleculeName + ",")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
name.append(">")
|
|
||||||
return name
|
|
||||||
}
|
|
||||||
|
|
||||||
public class func name(forReuse molecule: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? {
|
|
||||||
// This will aggregate names of molecules to make an id.
|
|
||||||
guard let molecules = molecule?.optionalArrayForKey(KeyMolecules) else {
|
|
||||||
return "stack<>"
|
|
||||||
}
|
|
||||||
var name = "stack<"
|
|
||||||
for case let item as [AnyHashable: Any] in molecules {
|
|
||||||
if let molecule = item.optionalDictionaryForKey(KeyMolecule), let moleculeName = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: molecule)?.name?(forReuse: molecule, delegateObject: delegateObject) ?? molecule.optionalStringForKey(KeyMoleculeName) {
|
|
||||||
name.append(moleculeName + ",")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
name.append(">")
|
|
||||||
return name
|
|
||||||
}
|
|
||||||
|
|
||||||
public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
|
||||||
guard let items = json?.optionalArrayForKey(KeyMolecules) else {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
let horizontal = json?.optionalStringForKey("axis") == "horizontal"
|
|
||||||
var estimatedHeight: CGFloat = 0
|
|
||||||
for case let item as [AnyHashable: AnyHashable] in items {
|
|
||||||
if let molecule = item.optionalDictionaryForKey(KeyMolecule) {
|
|
||||||
let height = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: molecule)?.estimatedHeight?(forRow: molecule, delegateObject: delegateObject)
|
|
||||||
if !horizontal {
|
|
||||||
// Vertical stack aggregates the items
|
|
||||||
let spacing = item.optionalCGFloatForKey("spacing") ?? (estimatedHeight != 0 ? (json?.optionalCGFloatForKey("spacing") ?? 16) : 0)
|
|
||||||
estimatedHeight += ((height ?? 0) + spacing)
|
|
||||||
} else if let height = height {
|
|
||||||
// Horizontal stack takes the tallest item.
|
|
||||||
estimatedHeight = max(estimatedHeight, height)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return estimatedHeight
|
|
||||||
}
|
|
||||||
|
|
||||||
public class func requiredModules(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
|
|
||||||
guard let items = json?.optionalArrayForKey(KeyMolecules) else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
var modules: [String] = []
|
|
||||||
for case let item as [AnyHashable: AnyHashable] in items {
|
|
||||||
if let molecule = item.optionalDictionaryForKey(KeyMolecule), let modulesForMolecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: molecule)?.requiredModules?(molecule, delegateObject: delegateObject, error: error) {
|
|
||||||
modules += modulesForMolecule
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return modules.count > 0 ? modules : nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Adding to stack
|
// MARK: - Adding to stack
|
||||||
/// Creates all of the stackItems for the stackItemModels
|
/// Creates all of the stackItems for the stackItemModels
|
||||||
func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) {
|
override func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) {
|
||||||
guard let stackItemModels = stackModel?.molecules else { return }
|
guard let stackItemModels = stackModel?.molecules else { return }
|
||||||
for model in stackItemModels {
|
for model in stackItemModels {
|
||||||
if let stackItem = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model, delegate) as? StackItem {
|
if let stackItem = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model, delegate) as? StackItem {
|
||||||
@ -202,67 +31,4 @@ open class MoleculeStackView: Container {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds the view to the stack.
|
|
||||||
func addView(_ view: View, lastItem: Bool) {
|
|
||||||
guard let model = view.model else { return }
|
|
||||||
let stackItem = StackItem(andContain: view)
|
|
||||||
stackItem.model = StackItemModel(with: model)
|
|
||||||
addStackItem(stackItem, lastItem: lastItem)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Adds the stack item view
|
|
||||||
private func addStackItem(_ stackItem: StackItem, lastItem: Bool) {
|
|
||||||
let stackModel = self.stackModel!
|
|
||||||
let model = stackItem.stackItemModel!
|
|
||||||
guard !model.gone else {
|
|
||||||
// Gone views do not show
|
|
||||||
return
|
|
||||||
}
|
|
||||||
contentView.addSubview(stackItem)
|
|
||||||
stackItem.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
|
|
||||||
let spacing = model.spacing ?? stackModel.spacing
|
|
||||||
let verticalAlignment = model.verticalAlignment ?? (stackItem.view as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() ?? (model.percent == nil && stackModel.axis == .vertical ? .fill : (stackModel.axis == .vertical ? .leading : .center))
|
|
||||||
let horizontalAlignment = model.horizontalAlignment ?? (stackItem.view as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() ?? (stackModel.axis == .vertical || model.percent == nil ? .fill : .leading)
|
|
||||||
stackItem.containerHelper.alignHorizontal(horizontalAlignment)
|
|
||||||
stackItem.containerHelper.alignVertical(verticalAlignment)
|
|
||||||
|
|
||||||
let first = stackItems.first { !($0.stackItemModel?.gone ?? false) } == nil
|
|
||||||
if stackModel.axis == .vertical {
|
|
||||||
if first {
|
|
||||||
pinView(stackItem, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: useStackSpacingBeforeFirstItem ? spacing : model.spacing ?? 0)
|
|
||||||
} else if let previousView = stackItems.last(where: { item in
|
|
||||||
return !item.stackItemModel!.gone
|
|
||||||
}) {
|
|
||||||
stackItem.topAnchor.constraint(equalTo: previousView.bottomAnchor, constant: spacing).isActive = true
|
|
||||||
}
|
|
||||||
pinView(stackItem, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: 0)
|
|
||||||
pinView(contentView, toView: stackItem, attribute: .trailing, relation: .equal, priority: .required, constant: 0)
|
|
||||||
if let percent = model.percent {
|
|
||||||
stackItem.heightAnchor.constraint(equalTo: contentView.heightAnchor, multiplier: CGFloat(percent)/100.0).isActive = true
|
|
||||||
}
|
|
||||||
if lastItem {
|
|
||||||
pinView(contentView, toView: stackItem, attribute: .bottom, relation: .equal, priority: .required, constant: 0)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if first {
|
|
||||||
// First horizontal item has no spacing by default unless told otherwise.
|
|
||||||
pinView(stackItem, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: useStackSpacingBeforeFirstItem ? spacing : model.spacing ?? 0)
|
|
||||||
} else if let previousView = stackItems.last(where: { item in
|
|
||||||
return !item.stackItemModel!.gone
|
|
||||||
}) {
|
|
||||||
stackItem.leftAnchor.constraint(equalTo: previousView.rightAnchor, constant: spacing).isActive = true
|
|
||||||
}
|
|
||||||
pinView(stackItem, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: 0)
|
|
||||||
pinView(contentView, toView: stackItem, attribute: .bottom, relation: .equal, priority: .required, constant: 0)
|
|
||||||
if let percent = model.percent {
|
|
||||||
stackItem.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: CGFloat(percent)/100.0).isActive = true
|
|
||||||
}
|
|
||||||
if lastItem {
|
|
||||||
pinView(contentView, toView: stackItem, attribute: .right, relation: .equal, priority: .required, constant: 0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stackItems.append(stackItem)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
239
MVMCoreUI/Organisms/Stack.swift
Normal file
239
MVMCoreUI/Organisms/Stack.swift
Normal file
@ -0,0 +1,239 @@
|
|||||||
|
//
|
||||||
|
// Stack.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Scott Pfeil on 1/16/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
open class Stack<T>: Container where T: StackModelProtocol {
|
||||||
|
var contentView: UIView = MVMCoreUICommonViewsUtility.commonView()
|
||||||
|
var stackModel: T? {
|
||||||
|
get { return model as? T }
|
||||||
|
}
|
||||||
|
var stackItems: [UIView] = []
|
||||||
|
|
||||||
|
// MARK: - Helpers
|
||||||
|
public func pinView(_ view: UIView, toView: UIView, attribute: NSLayoutConstraint.Attribute, relation: NSLayoutConstraint.Relation, priority: UILayoutPriority, constant: CGFloat) {
|
||||||
|
let constraint = NSLayoutConstraint(item: view, attribute: attribute, relatedBy: relation, toItem: toView, attribute: attribute, multiplier: 1.0, constant: constant)
|
||||||
|
constraint.priority = priority
|
||||||
|
constraint.isActive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Restacks the existing items.
|
||||||
|
func restack() {
|
||||||
|
removeAllItemViews()
|
||||||
|
guard let stackModel = stackModel else { return }
|
||||||
|
let stackItems = self.stackItems
|
||||||
|
self.stackItems = []
|
||||||
|
let lastItemIndex = stackModel.molecules.lastIndex(where: { (item) -> Bool in
|
||||||
|
return !item.gone
|
||||||
|
})
|
||||||
|
for (index, view) in stackItems.enumerated() {
|
||||||
|
addView(view, stackModel.molecules[index], lastItem: lastItemIndex == index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Removes all stack items views from the view.
|
||||||
|
func removeAllItemViews() {
|
||||||
|
for item in stackItems {
|
||||||
|
item.removeFromSuperview()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Inits
|
||||||
|
public override init(frame: CGRect) {
|
||||||
|
super.init(frame: frame)
|
||||||
|
}
|
||||||
|
|
||||||
|
public init(withJSON json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||||
|
super.init(frame: CGRect.zero)
|
||||||
|
setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
}
|
||||||
|
|
||||||
|
public required init?(coder aDecoder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - MFViewProtocol
|
||||||
|
public override func setupView() {
|
||||||
|
super.setupView()
|
||||||
|
guard contentView.superview == nil else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
MVMCoreUIUtility.setMarginsFor(contentView, leading: 0, top: 0, trailing: 0, bottom: 0)
|
||||||
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
backgroundColor = .clear
|
||||||
|
addSubview(contentView)
|
||||||
|
containerHelper.constrainView(contentView)
|
||||||
|
contentView.setContentHuggingPriority(.defaultHigh, for: .vertical)
|
||||||
|
contentView.setContentHuggingPriority(.defaultHigh, for: .horizontal)
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func updateView(_ size: CGFloat) {
|
||||||
|
super.updateView(size)
|
||||||
|
for item in stackItems {
|
||||||
|
(item as? MVMCoreViewProtocol)?.updateView(size)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||||
|
public override func reset() {
|
||||||
|
super.reset()
|
||||||
|
backgroundColor = .clear
|
||||||
|
for item in stackItems {
|
||||||
|
(item as? MoleculeViewProtocol)?.reset?()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||||
|
let previousModel = self.model
|
||||||
|
super.setWithModel(model, delegateObject, additionalData)
|
||||||
|
removeAllItemViews()
|
||||||
|
|
||||||
|
// If the items in the stack are different, clear them, create new ones.
|
||||||
|
if (previousModel == nil) || MoleculeStackView.nameForReuse(previousModel, delegateObject) != MoleculeStackView.nameForReuse(model, delegateObject) {
|
||||||
|
stackItems = []
|
||||||
|
createStackItemsFromModel(with: delegateObject)
|
||||||
|
} else if let models = stackModel?.molecules {
|
||||||
|
for (index, element) in models.enumerated() {
|
||||||
|
(stackItems[index] as? ModelMoleculeViewProtocol)?.setWithModel(element as? MoleculeProtocol, delegateObject, additionalData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
restack()
|
||||||
|
}
|
||||||
|
|
||||||
|
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
|
if model == nil {
|
||||||
|
let data = try! JSONSerialization.data(withJSONObject: json!)
|
||||||
|
let decoder = JSONDecoder()
|
||||||
|
let model = try! decoder.decode(MoleculeStackModel.self, from: data)
|
||||||
|
setWithModel(model, delegateObject, additionalData)
|
||||||
|
} else {
|
||||||
|
setWithModel(model, delegateObject, additionalData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
|
||||||
|
// This will aggregate names of molecules to make an id.
|
||||||
|
guard let model = model as? MoleculeStackModel else {
|
||||||
|
return "stack<>"
|
||||||
|
}
|
||||||
|
var name = "stack<"
|
||||||
|
for case let item in model.molecules {
|
||||||
|
if let moleculeName = item.molecule.moleculeName {
|
||||||
|
if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[moleculeName] as? ModelMoleculeViewProtocol.Type,
|
||||||
|
let nameForReuse = moleculeClass.nameForReuse(item.molecule, delegateObject) {
|
||||||
|
name.append(nameForReuse + ",")
|
||||||
|
} else {
|
||||||
|
name.append(moleculeName + ",")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
name.append(">")
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
|
||||||
|
// Need to update to take into account first spacing flag
|
||||||
|
public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||||
|
guard let model = molecule as? MoleculeStackModel else { return 0 }
|
||||||
|
let horizontal = model.axis == .horizontal
|
||||||
|
var estimatedHeight: CGFloat = 0
|
||||||
|
for case let item in model.molecules {
|
||||||
|
if item.gone { continue }
|
||||||
|
let height = (MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(item) as? ModelMoleculeViewProtocol.Type)?.estimatedHeight(forRow: item, delegateObject: delegateObject) ?? 0
|
||||||
|
if !horizontal {
|
||||||
|
// Vertical stack aggregates the items
|
||||||
|
let spacing = item.spacing ?? model.spacing
|
||||||
|
estimatedHeight += (height + spacing)
|
||||||
|
} else {
|
||||||
|
// Horizontal stack takes the tallest item.
|
||||||
|
estimatedHeight = max(estimatedHeight, height)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return estimatedHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
public override class func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
|
||||||
|
guard let model = molecule as? MoleculeStackModel else { return nil }
|
||||||
|
var modules: [String] = []
|
||||||
|
for case let item in model.molecules {
|
||||||
|
if let modulesForMolecule = (MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(item) as? ModelMoleculeViewProtocol.Type)?.requiredModules(item, delegateObject: delegateObject, error: error) {
|
||||||
|
modules += modulesForMolecule
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modules.count > 0 ? modules : nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Adding to stack
|
||||||
|
/// Can be subclassed to create views when we get stack item models and have no views yet
|
||||||
|
func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convenience function, adds a view to a StackItem to the Stack
|
||||||
|
func addViewToItemToStack(_ view: UIView, lastItem: Bool) {
|
||||||
|
let stackItemModel = StackItemModel()
|
||||||
|
let stackItem = StackItem(andContain: view)
|
||||||
|
addView(stackItem, stackItemModel, lastItem: lastItem)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Adds the stack item view
|
||||||
|
func addView(_ view: UIView,_ model: StackItemModelProtocol, lastItem: Bool) {
|
||||||
|
let stackModel = self.stackModel!
|
||||||
|
guard !model.gone else {
|
||||||
|
// Gone views do not show
|
||||||
|
stackItems.append(view)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
contentView.addSubview(view)
|
||||||
|
view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
|
||||||
|
let spacing = model.spacing ?? stackModel.spacing
|
||||||
|
if let container = view as? ContainerProtocol {
|
||||||
|
let verticalAlignment = (model as? ContainerModelProtocol)?.verticalAlignment ?? (view as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() ?? (model.percent == nil && stackModel.axis == .vertical ? .fill : (stackModel.axis == .vertical ? .leading : .center))
|
||||||
|
let horizontalAlignment = (model as? ContainerModelProtocol)?.horizontalAlignment ?? (view as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() ?? (stackModel.axis == .vertical || model.percent == nil ? .fill : .leading)
|
||||||
|
container.alignHorizontal(horizontalAlignment)
|
||||||
|
container.alignVertical(verticalAlignment)
|
||||||
|
}
|
||||||
|
|
||||||
|
let first = contentView.subviews.count == 1
|
||||||
|
if stackModel.axis == .vertical {
|
||||||
|
if first {
|
||||||
|
pinView(view, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: stackModel.useStackSpacingBeforeFirstItem ? spacing : model.spacing ?? 0)
|
||||||
|
} else if let previousView = stackItems.last(where: { item in
|
||||||
|
return !model.gone
|
||||||
|
}) {
|
||||||
|
view.topAnchor.constraint(equalTo: previousView.bottomAnchor, constant: spacing).isActive = true
|
||||||
|
}
|
||||||
|
pinView(view, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: 0)
|
||||||
|
pinView(contentView, toView: view, attribute: .trailing, relation: .equal, priority: .required, constant: 0)
|
||||||
|
if let percent = model.percent {
|
||||||
|
view.heightAnchor.constraint(equalTo: contentView.heightAnchor, multiplier: CGFloat(percent)/100.0).isActive = true
|
||||||
|
}
|
||||||
|
if lastItem {
|
||||||
|
pinView(contentView, toView: view, attribute: .bottom, relation: .equal, priority: .required, constant: 0)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if first {
|
||||||
|
// First horizontal item has no spacing by default unless told otherwise.
|
||||||
|
pinView(view, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: stackModel.useStackSpacingBeforeFirstItem ? spacing : model.spacing ?? 0)
|
||||||
|
} else if let previousView = stackItems.last(where: { item in
|
||||||
|
return !model.gone
|
||||||
|
}) {
|
||||||
|
view.leftAnchor.constraint(equalTo: previousView.rightAnchor, constant: spacing).isActive = true
|
||||||
|
}
|
||||||
|
pinView(view, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: 0)
|
||||||
|
pinView(contentView, toView: view, attribute: .bottom, relation: .equal, priority: .required, constant: 0)
|
||||||
|
if let percent = model.percent {
|
||||||
|
view.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: CGFloat(percent)/100.0).isActive = true
|
||||||
|
}
|
||||||
|
if lastItem {
|
||||||
|
pinView(contentView, toView: view, attribute: .right, relation: .equal, priority: .required, constant: 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stackItems.append(view)
|
||||||
|
}
|
||||||
|
}
|
||||||
22
MVMCoreUI/Organisms/StackModel.swift
Normal file
22
MVMCoreUI/Organisms/StackModel.swift
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
//
|
||||||
|
// StackModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Scott Pfeil on 1/16/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
@objcMembers public class StackModel: StackModelProtocol, MoleculeProtocol {
|
||||||
|
public static var identifier: String = "simpleStack"
|
||||||
|
public var backgroundColor: Color?
|
||||||
|
public var molecules: [StackItemModel]
|
||||||
|
@Axis public var axis: NSLayoutConstraint.Axis = .vertical
|
||||||
|
public var spacing: CGFloat = 16.0
|
||||||
|
public var useStackSpacingBeforeFirstItem = false
|
||||||
|
|
||||||
|
public init(molecules: [StackItemModel]) {
|
||||||
|
self.molecules = molecules
|
||||||
|
}
|
||||||
|
}
|
||||||
18
MVMCoreUI/Organisms/StackModelProtocol.swift
Normal file
18
MVMCoreUI/Organisms/StackModelProtocol.swift
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
//
|
||||||
|
// StackModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Scott Pfeil on 1/16/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public protocol StackModelProtocol {
|
||||||
|
associatedtype AnyStackItemModel: StackItemModelProtocol
|
||||||
|
|
||||||
|
var molecules: [AnyStackItemModel] { get set }
|
||||||
|
var axis: NSLayoutConstraint.Axis { get set }
|
||||||
|
var spacing: CGFloat { get set }
|
||||||
|
var useStackSpacingBeforeFirstItem: Bool { get set }
|
||||||
|
}
|
||||||
@ -31,7 +31,6 @@
|
|||||||
@"button": PrimaryButton.class,
|
@"button": PrimaryButton.class,
|
||||||
@"link": MFTextButton.class,
|
@"link": MFTextButton.class,
|
||||||
@"header": StandardHeaderView.class,
|
@"header": StandardHeaderView.class,
|
||||||
@"stack": MoleculeStackView.class,
|
|
||||||
@"twoButtonView": TwoButtonView.class,
|
@"twoButtonView": TwoButtonView.class,
|
||||||
@"footer": StandardFooterView.class,
|
@"footer": StandardFooterView.class,
|
||||||
@"caretView": CaretView.class,
|
@"caretView": CaretView.class,
|
||||||
|
|||||||
@ -10,11 +10,13 @@ import Foundation
|
|||||||
|
|
||||||
@objcMembers public class MoleculeObjectMapping: NSObject {
|
@objcMembers public class MoleculeObjectMapping: NSObject {
|
||||||
public static func registerObjects() {
|
public static func registerObjects() {
|
||||||
|
MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(MoleculeStackView.self, forKey: "stack" as NSString)
|
||||||
|
|
||||||
ModelRegistry.register(LabelModel.self)
|
ModelRegistry.register(LabelModel.self)
|
||||||
ModelRegistry.register(HeaderModel.self)
|
ModelRegistry.register(HeaderModel.self)
|
||||||
ModelRegistry.register(HeadlineBodyModel.self)
|
ModelRegistry.register(HeadlineBodyModel.self)
|
||||||
ModelRegistry.register(MoleculeStackModel.self)
|
ModelRegistry.register(MoleculeStackModel.self)
|
||||||
ModelRegistry.register(StackItemModel.self)
|
ModelRegistry.register(MoleculeStackItemModel.self)
|
||||||
ModelRegistry.register(TextFieldModel.self)
|
ModelRegistry.register(TextFieldModel.self)
|
||||||
ModelRegistry.register(ProgressBarModel.self)
|
ModelRegistry.register(ProgressBarModel.self)
|
||||||
ModelRegistry.register(MultiProgressBarModel.self)
|
ModelRegistry.register(MultiProgressBarModel.self)
|
||||||
|
|||||||
@ -49,8 +49,8 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let stack = MoleculeStackView(frame: .zero)
|
let stack = MoleculeStackView(frame: .zero)
|
||||||
stack.useStackSpacingBeforeFirstItem = true
|
moleculeStackModel.useStackSpacingBeforeFirstItem = true
|
||||||
stack.moleculesShouldSetHorizontalMargins = true
|
moleculeStackModel.useHorizontalMargins = true
|
||||||
stack.setWithModel(moleculeStackModel, delegateObject() as? MVMCoreUIDelegateObject, nil)
|
stack.setWithModel(moleculeStackModel, delegateObject() as? MVMCoreUIDelegateObject, nil)
|
||||||
return stack
|
return stack
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,11 @@ import Foundation
|
|||||||
try container.encode(axis.rawValueString, forKey: .axis)
|
try container.encode(axis.rawValueString, forKey: .axis)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
enum AxisError: Error {
|
||||||
|
case notAnAxis
|
||||||
|
}
|
||||||
|
|
||||||
extension NSLayoutConstraint.Axis: RawRepresentable {
|
extension NSLayoutConstraint.Axis: RawRepresentable {
|
||||||
|
|
||||||
init?(rawValue: String) {
|
init?(rawValue: String) {
|
||||||
@ -54,3 +59,29 @@ extension NSLayoutConstraint.Axis: RawRepresentable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@propertyWrapper
|
||||||
|
public struct Axis {
|
||||||
|
public var wrappedValue: NSLayoutConstraint.Axis
|
||||||
|
|
||||||
|
public init(wrappedValue value: NSLayoutConstraint.Axis) {
|
||||||
|
self.wrappedValue = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Axis: Codable {
|
||||||
|
public init(from decoder: Decoder) throws {
|
||||||
|
let typeContainer = try decoder.singleValueContainer()
|
||||||
|
let string = try typeContainer.decode(String.self)
|
||||||
|
guard let axis = NSLayoutConstraint.Axis(rawValue: string) else {
|
||||||
|
throw AxisError.notAnAxis
|
||||||
|
}
|
||||||
|
wrappedValue = axis
|
||||||
|
}
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
let string = wrappedValue.rawValueString
|
||||||
|
var container = encoder.singleValueContainer()
|
||||||
|
try container.encode(string)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user