From e79c1d763752a3df3a4291bfc5413e6f57ad4ad7 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 26 Aug 2024 16:13:05 -0500 Subject: [PATCH 1/7] added breadcrumbs/model Signed-off-by: Matt Bruce --- MVMCoreUI.xcodeproj/project.pbxproj | 16 +++ .../Molecules/Breadcrumbs/Breadcrumbs.swift | 71 +++++++++++ .../Breadcrumbs/BreadcrumbsModel.swift | 111 ++++++++++++++++++ 3 files changed, 198 insertions(+) create mode 100644 MVMCoreUI/Atomic/Molecules/Breadcrumbs/Breadcrumbs.swift create mode 100644 MVMCoreUI/Atomic/Molecules/Breadcrumbs/BreadcrumbsModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index fbb120aa..21144926 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -602,6 +602,8 @@ EA7AE5512C74EB4500107C74 /* CalendarViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7AE5502C74EB4500107C74 /* CalendarViewModel.swift */; }; EA7AE5532C74F1F600107C74 /* DatePickerEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7AE5522C74F1F600107C74 /* DatePickerEntryField.swift */; }; EA7AE5552C74F20600107C74 /* DatePickerEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7AE5542C74F20600107C74 /* DatePickerEntryFieldModel.swift */; }; + EA7AE55C2C7D18A100107C74 /* BreadcrumbsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7AE55B2C7D18A100107C74 /* BreadcrumbsModel.swift */; }; + EA7AE55E2C7D234500107C74 /* Breadcrumbs.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7AE55D2C7D234500107C74 /* Breadcrumbs.swift */; }; EA7D81602B2B6E6800D29F9E /* Icon.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7D815F2B2B6E6800D29F9E /* Icon.swift */; }; EA7D81622B2B6E7F00D29F9E /* IconModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7D81612B2B6E7F00D29F9E /* IconModel.swift */; }; EA7D81642B2BABCB00D29F9E /* TooltipModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7D81632B2BABCB00D29F9E /* TooltipModel.swift */; }; @@ -1239,6 +1241,8 @@ EA7AE5502C74EB4500107C74 /* CalendarViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarViewModel.swift; sourceTree = ""; }; EA7AE5522C74F1F600107C74 /* DatePickerEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatePickerEntryField.swift; sourceTree = ""; }; EA7AE5542C74F20600107C74 /* DatePickerEntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatePickerEntryFieldModel.swift; sourceTree = ""; }; + EA7AE55B2C7D18A100107C74 /* BreadcrumbsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BreadcrumbsModel.swift; sourceTree = ""; }; + EA7AE55D2C7D234500107C74 /* Breadcrumbs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Breadcrumbs.swift; sourceTree = ""; }; EA7D815F2B2B6E6800D29F9E /* Icon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Icon.swift; sourceTree = ""; }; EA7D81612B2B6E7F00D29F9E /* IconModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconModel.swift; sourceTree = ""; }; EA7D81632B2BABCB00D29F9E /* TooltipModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TooltipModel.swift; sourceTree = ""; }; @@ -2203,6 +2207,7 @@ D29DF10E21E67A77003B2FB9 /* Molecules */ = { isa = PBXGroup; children = ( + EA7AE55A2C7D188900107C74 /* Breadcrumbs */, D2EC7BD22527A1E400F540AF /* HeadersAndFooters */, D2CAC7C9251104CB00C75681 /* TopNotification */, D2509ED42472EE0B001BFB9D /* NavigationBar */, @@ -2641,6 +2646,15 @@ path = Alerts; sourceTree = ""; }; + EA7AE55A2C7D188900107C74 /* Breadcrumbs */ = { + isa = PBXGroup; + children = ( + EA7AE55B2C7D18A100107C74 /* BreadcrumbsModel.swift */, + EA7AE55D2C7D234500107C74 /* Breadcrumbs.swift */, + ); + path = Breadcrumbs; + sourceTree = ""; + }; EAA0CFAD275E7D5A00D65EB0 /* FormFieldEffect */ = { isa = PBXGroup; children = ( @@ -2968,6 +2982,7 @@ 525239C02407BCFF00454969 /* ListTwoColumnPriceDetailsModel.swift in Sources */, D2E2A99A23D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift in Sources */, D202AFE6242A6A9C00E5BEDF /* UICollectionViewScrollPosition+Extension.swift in Sources */, + EA7AE55C2C7D18A100107C74 /* BreadcrumbsModel.swift in Sources */, D20F3B44252E00E4004B3F56 /* PageProtocol.swift in Sources */, AA37CBD3251907200027344C /* StarsModel.swift in Sources */, 8D084AD22410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift in Sources */, @@ -2996,6 +3011,7 @@ AAE96FA525341F7D0037A989 /* ListStoreLocator.swift in Sources */, D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, 944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */, + EA7AE55E2C7D234500107C74 /* Breadcrumbs.swift in Sources */, D213347723843825008E41B3 /* Line.swift in Sources */, D2E2A99C23D8D975000B42E6 /* ImageHeadlineBodyModel.swift in Sources */, BB3BC1302550094500297977 /* ListLeftVariableIconWithRightCaretAllTextLinksModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Molecules/Breadcrumbs/Breadcrumbs.swift b/MVMCoreUI/Atomic/Molecules/Breadcrumbs/Breadcrumbs.swift new file mode 100644 index 00000000..6498ecb5 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/Breadcrumbs/Breadcrumbs.swift @@ -0,0 +1,71 @@ +// +// Breadcrumbs.swift +// MVMCoreUI +// +// Created by Matt Bruce on 8/26/24. +// Copyright © 2024 Verizon Wireless. All rights reserved. +// + +import Foundation +import VDS + +@objcMembers open class Breadcrumbs: VDS.Breadcrumbs, VDSMoleculeViewProtocol { + //------------------------------------------------------ + // MARK: - Properties + //------------------------------------------------------ + open var viewModel: BreadcrumbsModel! + open var delegateObject: MVMCoreUIDelegateObject? + open var additionalData: [AnyHashable : Any]? + + // Form Validation + open var fieldKey: String? + open var fieldValue: JSONValue? + open var groupName: String? + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + + override public init(frame: CGRect) { + super.init(frame: frame) + } + + /// There is currently no intention on using xib files. + required public init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + fatalError("xib file is not implemented for Checkbox.") + } + + public convenience required init() { + self.init(frame:.zero) + } + + open func viewModelDidUpdate() { + isEnabled = viewModel.enabled + surface = viewModel.surface + breadcrumbModels = viewModel.breadcrumbs.compactMap { [unowned self] breadcrumb in + var onClick: ((BreadcrumbItem) -> Void)? + if let action = breadcrumb.action { + onClick = { _ in + MVMCoreUIActionHandler.performActionUnstructured(with: action, + sourceModel: breadcrumb, + additionalData: self.additionalData, + delegateObject: self.delegateObject) + } + } + return .init(text: breadcrumb.text, + selected: breadcrumb.selected, + onClick: onClick) + } + } + + //-------------------------------------------------- + // MARK: - Actions + //-------------------------------------------------- + + //-------------------------------------------------- + // MARK: - MoleculeViewProtocol + //-------------------------------------------------- + public func updateView(_ size: CGFloat) {} + +} diff --git a/MVMCoreUI/Atomic/Molecules/Breadcrumbs/BreadcrumbsModel.swift b/MVMCoreUI/Atomic/Molecules/Breadcrumbs/BreadcrumbsModel.swift new file mode 100644 index 00000000..6c8ba47c --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/Breadcrumbs/BreadcrumbsModel.swift @@ -0,0 +1,111 @@ +// +// BreadCrumbs.swift +// MVMCoreUI +// +// Created by Matt Bruce on 8/26/24. +// Copyright © 2024 Verizon Wireless. All rights reserved. +// + +import Foundation +import VDS +import MVMCore + +open class BreadcrumbsModel: MoleculeModelProtocol { + + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + open class var identifier: String { "breadcrumbs" } + open var moleculeName: String { Self.identifier } + open var backgroundColor: Color? + open var id: String = UUID().uuidString + + open var breadcrumbs: [BreadcrumbModel] = [] + open var enabled: Bool = true + open var inverted: Bool = false + open var surface: Surface { inverted ? .dark : .light } + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case breadcrumbs + case enabled + case inverted + } + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + breadcrumbs = try container.decode([BreadcrumbModel].self, forKey: .breadcrumbs) + enabled = try container.decodeIfPresent(Bool.self, forKey: .enabled) ?? false + inverted = try container.decodeIfPresent(Bool.self, forKey: .inverted) ?? false + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(enabled, forKey: .enabled) + try container.encode(inverted, forKey: .inverted) + } + + public func isEqual(to model: any ModelComparisonProtocol) -> Bool { + guard let model = model as? Self else { return false } + return inverted == model.inverted + && enabled == model.enabled + && breadcrumbs == model.breadcrumbs + } +} + +open class BreadcrumbModel: MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + open class var identifier: String { "breadcrumb" } + open var moleculeName: String { Self.identifier } + open var backgroundColor: Color? + open var id: String = UUID().uuidString + + open var text: String = "" + open var selected: Bool = false + open var action: ActionModelProtocol? + + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case text + case selected + case action + } + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + text = try container.decode(String.self, forKey: .text) + selected = try container.decodeIfPresent(Bool.self, forKey: .selected) ?? false + action = try container.decodeModelIfPresent(codingKey: .action) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(text, forKey: .text) + try container.encode(selected, forKey: .selected) + try container.encodeModelIfPresent(action, forKey: .action) + } + + public func isEqual(to model: any ModelComparisonProtocol) -> Bool { + guard let model = model as? Self else { return false } + return text == model.text + && selected == model.selected + && action.isEqual(to: model.action) + } +} From 1c723c31dea4f7fdcc27468c916ecca08204f0d1 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 26 Aug 2024 16:13:16 -0500 Subject: [PATCH 2/7] registered in core Signed-off-by: Matt Bruce --- MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index 68494d90..da49a4a2 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -142,7 +142,9 @@ open class CoreUIModelMapping: ModelMapping { ModelRegistry.register(NavigationItemModel.self) ModelRegistry.register(NavigationImageButtonModel.self) ModelRegistry.register(NavigationLabelButtonModel.self) - + ModelRegistry.register(handler: Breadcrumbs.self, for: BreadcrumbsModel.self) + ModelRegistry.register(BreadcrumbModel.self) + // MARK:- Other Organisms ModelRegistry.register(handler: Carousel.self, for: CarouselModel.self) ModelRegistry.register(handler: BarsIndicatorView.self, for: BarsCarouselIndicatorModel.self) From 484b5785686430574aded0180d6e71eb1119cf7f Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 27 Aug 2024 14:30:39 -0500 Subject: [PATCH 3/7] added Pagination Signed-off-by: Matt Bruce --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++ MVMCoreUI/Atomic/Atoms/Views/Pagination.swift | 68 +++++++++++++++++++ .../Atomic/Atoms/Views/PaginationModel.swift | 67 ++++++++++++++++++ .../OtherHandlers/CoreUIModelMapping.swift | 1 + 4 files changed, 144 insertions(+) create mode 100644 MVMCoreUI/Atomic/Atoms/Views/Pagination.swift create mode 100644 MVMCoreUI/Atomic/Atoms/Views/PaginationModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 21144926..f3ba25ce 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -604,6 +604,8 @@ EA7AE5552C74F20600107C74 /* DatePickerEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7AE5542C74F20600107C74 /* DatePickerEntryFieldModel.swift */; }; EA7AE55C2C7D18A100107C74 /* BreadcrumbsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7AE55B2C7D18A100107C74 /* BreadcrumbsModel.swift */; }; EA7AE55E2C7D234500107C74 /* Breadcrumbs.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7AE55D2C7D234500107C74 /* Breadcrumbs.swift */; }; + EA7AE5602C7E554700107C74 /* PaginationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7AE55F2C7E554700107C74 /* PaginationModel.swift */; }; + EA7AE5622C7E555D00107C74 /* Pagination.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7AE5612C7E555D00107C74 /* Pagination.swift */; }; EA7D81602B2B6E6800D29F9E /* Icon.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7D815F2B2B6E6800D29F9E /* Icon.swift */; }; EA7D81622B2B6E7F00D29F9E /* IconModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7D81612B2B6E7F00D29F9E /* IconModel.swift */; }; EA7D81642B2BABCB00D29F9E /* TooltipModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7D81632B2BABCB00D29F9E /* TooltipModel.swift */; }; @@ -1243,6 +1245,8 @@ EA7AE5542C74F20600107C74 /* DatePickerEntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatePickerEntryFieldModel.swift; sourceTree = ""; }; EA7AE55B2C7D18A100107C74 /* BreadcrumbsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BreadcrumbsModel.swift; sourceTree = ""; }; EA7AE55D2C7D234500107C74 /* Breadcrumbs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Breadcrumbs.swift; sourceTree = ""; }; + EA7AE55F2C7E554700107C74 /* PaginationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaginationModel.swift; sourceTree = ""; }; + EA7AE5612C7E555D00107C74 /* Pagination.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Pagination.swift; sourceTree = ""; }; EA7D815F2B2B6E6800D29F9E /* Icon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Icon.swift; sourceTree = ""; }; EA7D81612B2B6E7F00D29F9E /* IconModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconModel.swift; sourceTree = ""; }; EA7D81632B2BABCB00D29F9E /* TooltipModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TooltipModel.swift; sourceTree = ""; }; @@ -2369,6 +2373,8 @@ D20492A524329CE200A5EED6 /* LoadImageView.swift */, 0A51F3E02475CB73002E08B6 /* LoadingSpinnerModel.swift */, 0A51F3E12475CB73002E08B6 /* LoadingSpinner.swift */, + EA7AE55F2C7E554700107C74 /* PaginationModel.swift */, + EA7AE5612C7E555D00107C74 /* Pagination.swift */, AA37CBD2251907200027344C /* StarsModel.swift */, AA37CBD42519072F0027344C /* Stars.swift */, AA07EA902510A442009A2AE3 /* StarModel.swift */, @@ -2957,6 +2963,7 @@ D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */, D28A837B23C928DA00DFE4FC /* MoleculeListCellProtocol.swift in Sources */, D28BA74D248589C800B75CB8 /* TabPageModelProtocol.swift in Sources */, + EA7AE5602C7E554700107C74 /* PaginationModel.swift in Sources */, 608211282AC6B57E00C3FC39 /* MVMCoreUILoggingHandler.swift in Sources */, 014AA72F23C5059B006F3E93 /* ThreeLayerPageTemplateModel.swift in Sources */, 0A21DB91235E0EDB00C160A2 /* DigitBox.swift in Sources */, @@ -2985,6 +2992,7 @@ EA7AE55C2C7D18A100107C74 /* BreadcrumbsModel.swift in Sources */, D20F3B44252E00E4004B3F56 /* PageProtocol.swift in Sources */, AA37CBD3251907200027344C /* StarsModel.swift in Sources */, + EA7AE5622C7E555D00107C74 /* Pagination.swift in Sources */, 8D084AD22410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift in Sources */, 94C0150C2421564A005811A9 /* ActionCollapseNotificationModel.swift in Sources */, D2CAC7CB251104E100C75681 /* NotificationXButtonModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/Views/Pagination.swift b/MVMCoreUI/Atomic/Atoms/Views/Pagination.swift new file mode 100644 index 00000000..a34ff0d0 --- /dev/null +++ b/MVMCoreUI/Atomic/Atoms/Views/Pagination.swift @@ -0,0 +1,68 @@ +// +// Pagination.swift +// MVMCoreUI +// +// Created by Matt Bruce on 8/27/24. +// Copyright © 2024 Verizon Wireless. All rights reserved. +// + +import Foundation +import VDS + +@objcMembers open class Pagination: VDS.Pagination, VDSMoleculeViewProtocol { + //------------------------------------------------------ + // MARK: - Properties + //------------------------------------------------------ + open var viewModel: PaginationModel! + open var delegateObject: MVMCoreUIDelegateObject? + open var additionalData: [AnyHashable : Any]? + + // Form Validation + open var fieldKey: String? + open var fieldValue: JSONValue? + open var groupName: String? + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + + override public init(frame: CGRect) { + super.init(frame: frame) + } + + /// There is currently no intention on using xib files. + required public init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + fatalError("xib file is not implemented for Checkbox.") + } + + public convenience required init() { + self.init(frame:.zero) + } + + open override func setup() { + super.setup() + pageChangedPublisher + .sink { [weak self] control in + guard let self else { return } + viewModel?.selectedPage = control.selectedPage + }.store(in: &subscribers) + } + + open func viewModelDidUpdate() { + isEnabled = viewModel.enabled + surface = viewModel.surface + total = viewModel.totalPages + selectedPage = viewModel.selectedPage + } + + //-------------------------------------------------- + // MARK: - Actions + //-------------------------------------------------- + + //-------------------------------------------------- + // MARK: - MoleculeViewProtocol + //-------------------------------------------------- + public func updateView(_ size: CGFloat) {} + +} diff --git a/MVMCoreUI/Atomic/Atoms/Views/PaginationModel.swift b/MVMCoreUI/Atomic/Atoms/Views/PaginationModel.swift new file mode 100644 index 00000000..7027c7bb --- /dev/null +++ b/MVMCoreUI/Atomic/Atoms/Views/PaginationModel.swift @@ -0,0 +1,67 @@ +// +// PaginationModel.swift +// MVMCoreUI +// +// Created by Matt Bruce on 8/27/24. +// Copyright © 2024 Verizon Wireless. All rights reserved. +// + +import Foundation +import VDS +import MVMCore + +open class PaginationModel: MoleculeModelProtocol { + + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + open class var identifier: String { "pagination" } + open var moleculeName: String { Self.identifier } + open var backgroundColor: Color? + open var id: String = UUID().uuidString + + open var totalPages: Int = 0 + open var selectedPage: Int = 0 + open var enabled: Bool = true + open var inverted: Bool = false + open var surface: Surface { inverted ? .dark : .light } + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case totalPages + case selectedPage + case enabled + case inverted + } + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + totalPages = try container.decode(Int.self, forKey: .totalPages) + selectedPage = try container.decodeIfPresent(Int.self, forKey: .selectedPage) ?? 0 + enabled = try container.decodeIfPresent(Bool.self, forKey: .enabled) ?? false + inverted = try container.decodeIfPresent(Bool.self, forKey: .inverted) ?? false + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(totalPages, forKey: .totalPages) + try container.encode(selectedPage, forKey: .selectedPage) + try container.encode(enabled, forKey: .enabled) + try container.encode(inverted, forKey: .inverted) + } + + public func isEqual(to model: any ModelComparisonProtocol) -> Bool { + guard let model = model as? Self else { return false } + return inverted == model.inverted + && enabled == model.enabled + && totalPages == model.totalPages + && selectedPage == model.selectedPage + } +} diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index da49a4a2..db0f9e6c 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -142,6 +142,7 @@ open class CoreUIModelMapping: ModelMapping { ModelRegistry.register(NavigationItemModel.self) ModelRegistry.register(NavigationImageButtonModel.self) ModelRegistry.register(NavigationLabelButtonModel.self) + ModelRegistry.register(handler: Pagination.self, for: PaginationModel.self) ModelRegistry.register(handler: Breadcrumbs.self, for: BreadcrumbsModel.self) ModelRegistry.register(BreadcrumbModel.self) From 61f9fb9946c617b093c8d9e3e5f7012e529c4bed Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 27 Aug 2024 16:38:17 -0500 Subject: [PATCH 4/7] enforce an action Signed-off-by: Matt Bruce --- .../Molecules/Breadcrumbs/Breadcrumbs.swift | 16 ++++++---------- .../Molecules/Breadcrumbs/BreadcrumbsModel.swift | 4 ++-- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/Breadcrumbs/Breadcrumbs.swift b/MVMCoreUI/Atomic/Molecules/Breadcrumbs/Breadcrumbs.swift index 6498ecb5..7faf54ce 100644 --- a/MVMCoreUI/Atomic/Molecules/Breadcrumbs/Breadcrumbs.swift +++ b/MVMCoreUI/Atomic/Molecules/Breadcrumbs/Breadcrumbs.swift @@ -44,18 +44,14 @@ import VDS isEnabled = viewModel.enabled surface = viewModel.surface breadcrumbModels = viewModel.breadcrumbs.compactMap { [unowned self] breadcrumb in - var onClick: ((BreadcrumbItem) -> Void)? - if let action = breadcrumb.action { - onClick = { _ in - MVMCoreUIActionHandler.performActionUnstructured(with: action, - sourceModel: breadcrumb, - additionalData: self.additionalData, - delegateObject: self.delegateObject) - } - } return .init(text: breadcrumb.text, selected: breadcrumb.selected, - onClick: onClick) + onClick: { _ in + MVMCoreUIActionHandler.performActionUnstructured(with: breadcrumb.action, + sourceModel: breadcrumb, + additionalData: self.additionalData, + delegateObject: self.delegateObject) + }) } } diff --git a/MVMCoreUI/Atomic/Molecules/Breadcrumbs/BreadcrumbsModel.swift b/MVMCoreUI/Atomic/Molecules/Breadcrumbs/BreadcrumbsModel.swift index 6c8ba47c..d987bb38 100644 --- a/MVMCoreUI/Atomic/Molecules/Breadcrumbs/BreadcrumbsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Breadcrumbs/BreadcrumbsModel.swift @@ -71,7 +71,7 @@ open class BreadcrumbModel: MoleculeModelProtocol { open var text: String = "" open var selected: Bool = false - open var action: ActionModelProtocol? + open var action: ActionModelProtocol //-------------------------------------------------- @@ -92,7 +92,7 @@ open class BreadcrumbModel: MoleculeModelProtocol { let container = try decoder.container(keyedBy: CodingKeys.self) text = try container.decode(String.self, forKey: .text) selected = try container.decodeIfPresent(Bool.self, forKey: .selected) ?? false - action = try container.decodeModelIfPresent(codingKey: .action) + action = try container.decodeModel(codingKey: .action) } public func encode(to encoder: Encoder) throws { From 5043ff35a0a9b4b85ed27bf189d6d1c4cdcb234e Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 20 Sep 2024 08:30:27 -0500 Subject: [PATCH 5/7] removed inits Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/Pagination.swift | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Pagination.swift b/MVMCoreUI/Atomic/Atoms/Views/Pagination.swift index a34ff0d0..7cb8c0c2 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Pagination.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Pagination.swift @@ -25,17 +25,6 @@ import VDS //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- - - override public init(frame: CGRect) { - super.init(frame: frame) - } - - /// There is currently no intention on using xib files. - required public init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - fatalError("xib file is not implemented for Checkbox.") - } - public convenience required init() { self.init(frame:.zero) } From 4f6b848e72c7097d02d46ca22d16a900e4ca5fde Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 20 Sep 2024 08:30:37 -0500 Subject: [PATCH 6/7] removed inits Signed-off-by: Matt Bruce --- .../Atomic/Molecules/Breadcrumbs/Breadcrumbs.swift | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/Breadcrumbs/Breadcrumbs.swift b/MVMCoreUI/Atomic/Molecules/Breadcrumbs/Breadcrumbs.swift index 7faf54ce..5793caa4 100644 --- a/MVMCoreUI/Atomic/Molecules/Breadcrumbs/Breadcrumbs.swift +++ b/MVMCoreUI/Atomic/Molecules/Breadcrumbs/Breadcrumbs.swift @@ -24,18 +24,7 @@ import VDS //-------------------------------------------------- // MARK: - Initializers - //-------------------------------------------------- - - override public init(frame: CGRect) { - super.init(frame: frame) - } - - /// There is currently no intention on using xib files. - required public init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - fatalError("xib file is not implemented for Checkbox.") - } - + //-------------------------------------------------- public convenience required init() { self.init(frame:.zero) } From 03a1bd0920949279e6592850df13e1a266244858 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 20 Sep 2024 08:30:51 -0500 Subject: [PATCH 7/7] made parentalmodelmolecule Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Molecules/Breadcrumbs/BreadcrumbsModel.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/Breadcrumbs/BreadcrumbsModel.swift b/MVMCoreUI/Atomic/Molecules/Breadcrumbs/BreadcrumbsModel.swift index d987bb38..d4982de6 100644 --- a/MVMCoreUI/Atomic/Molecules/Breadcrumbs/BreadcrumbsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Breadcrumbs/BreadcrumbsModel.swift @@ -10,7 +10,7 @@ import Foundation import VDS import MVMCore -open class BreadcrumbsModel: MoleculeModelProtocol { +open class BreadcrumbsModel: MoleculeModelProtocol, ParentMoleculeModelProtocol { //-------------------------------------------------- // MARK: - Properties @@ -19,6 +19,7 @@ open class BreadcrumbsModel: MoleculeModelProtocol { open var moleculeName: String { Self.identifier } open var backgroundColor: Color? open var id: String = UUID().uuidString + open var children: [any MoleculeModelProtocol] { breadcrumbs } open var breadcrumbs: [BreadcrumbModel] = [] open var enabled: Bool = true @@ -56,7 +57,6 @@ open class BreadcrumbsModel: MoleculeModelProtocol { guard let model = model as? Self else { return false } return inverted == model.inverted && enabled == model.enabled - && breadcrumbs == model.breadcrumbs } }