Merge branch 'develop' into bugfix/focusStuckIssue
This commit is contained in:
commit
bada7deb53
@ -0,0 +1,66 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "1500"
|
||||||
|
version = "1.7">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "D29DF0CB21E404D4003B2FB9"
|
||||||
|
BuildableName = "MVMCoreUI.framework"
|
||||||
|
BlueprintName = "MVMCoreUI"
|
||||||
|
ReferencedContainer = "container:MVMCoreUI.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
shouldAutocreateTestPlan = "YES">
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<MacroExpansion>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "D29DF0CB21E404D4003B2FB9"
|
||||||
|
BuildableName = "MVMCoreUI.framework"
|
||||||
|
BlueprintName = "MVMCoreUI"
|
||||||
|
ReferencedContainer = "container:MVMCoreUI.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</MacroExpansion>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
||||||
@ -51,30 +51,33 @@ public class AlertOperation: MVMCoreOperation {
|
|||||||
// Observe for when it is removed.
|
// Observe for when it is removed.
|
||||||
observeForCurrentAlertViewDismissal()
|
observeForCurrentAlertViewDismissal()
|
||||||
|
|
||||||
// Adds the presentation to the animation queue.
|
Task(priority: .high) {
|
||||||
let blockingOperation = MVMCoreOperation()
|
guard let viewControllerToPresentOn = await NavigationHandler.shared().getViewControllerToPresentOn() else {
|
||||||
self.blockingOperation = blockingOperation
|
markAsFinished()
|
||||||
Task { @MainActor in
|
return
|
||||||
MVMCoreNavigationHandler.shared()?.present(alertController, animated: true, delegate: nil) { [weak self] in
|
|
||||||
guard let self = self else {
|
|
||||||
blockingOperation.markAsFinished()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
Task {
|
|
||||||
// We finished but it was not displayed yet. It's possible that it was cancelled. Finish this task
|
|
||||||
if await !self.properties.getIsDisplayed() {
|
|
||||||
self.markAsFinished()
|
|
||||||
} else {
|
|
||||||
(CoreUIObject.sharedInstance()?.loggingDelegate as? MVMCoreUILoggingDelegateProtocol)?.logAlert(with: self.alertObject)
|
|
||||||
if self.isCancelled {
|
|
||||||
await self.dismissAlertView()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Block navigations until this alert is removed.
|
// Presents the alert.
|
||||||
MVMCoreNavigationHandler.shared()?.addNavigationOperation(blockingOperation)
|
let presentationOperation = await NavigationOperation(with: .present(viewController: alertController, onController: viewControllerToPresentOn), tryToReplace: false)
|
||||||
|
|
||||||
|
let blockingOperation = MVMCoreOperation()
|
||||||
|
blockingOperation.addDependency(presentationOperation)
|
||||||
|
self.blockingOperation = blockingOperation
|
||||||
|
|
||||||
|
// Block other navigation until this alert is removed.
|
||||||
|
NavigationHandler.shared().navigationQueue.addOperation(blockingOperation)
|
||||||
|
|
||||||
|
await NavigationHandler.shared().navigate(with: presentationOperation)
|
||||||
|
|
||||||
|
// We finished but it was not displayed yet. It's possible that it was cancelled. Finish this task
|
||||||
|
if await !self.properties.getIsDisplayed() {
|
||||||
|
self.markAsFinished()
|
||||||
|
} else {
|
||||||
|
(MVMCoreObject.sharedInstance()?.loggingDelegate as? MVMCoreUILoggingDelegateProtocol)?.logAlert(with: self.alertObject)
|
||||||
|
if self.isCancelled {
|
||||||
|
await self.dismissAlertView()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,10 +92,13 @@ public class AlertOperation: MVMCoreOperation {
|
|||||||
private func dismissAlertView() async {
|
private func dismissAlertView() async {
|
||||||
guard await properties.getIsDisplayed() else { return }
|
guard await properties.getIsDisplayed() else { return }
|
||||||
await withCheckedContinuation { continuation in
|
await withCheckedContinuation { continuation in
|
||||||
Task { @MainActor in
|
Task {
|
||||||
MVMCoreNavigationHandler.shared()?.dismiss(alertController, animated: true, delegate: nil) {
|
let dismissOperation = await NavigationOperation(with: .dismiss(viewController: alertController))
|
||||||
continuation.resume()
|
dismissOperation.queuePriority = .veryHigh
|
||||||
}
|
let task = Task(priority: .high) { await NavigationHandler.shared().navigate(with: dismissOperation) }
|
||||||
|
blockingOperation?.markAsFinished()
|
||||||
|
_ = await task.result
|
||||||
|
continuation.resume()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,8 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
//Making static property as class property so that subclasses can override getter function of the property
|
//Making static property as class property so that subclasses can override getter function of the property
|
||||||
open class var identifier: String { "button" }
|
open class var identifier: String { "button" }
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var accessibilityIdentifier: String?
|
public var accessibilityIdentifier: String?
|
||||||
public var accessibilityText: String?
|
public var accessibilityText: String?
|
||||||
public var title: String
|
public var title: String
|
||||||
@ -174,6 +176,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case accessibilityIdentifier
|
case accessibilityIdentifier
|
||||||
@ -201,6 +204,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat
|
|||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
||||||
accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
|
accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
|
||||||
title = try typeContainer.decode(String.self, forKey: .title)
|
title = try typeContainer.decode(String.self, forKey: .title)
|
||||||
@ -263,6 +267,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat
|
|||||||
|
|
||||||
open func encode(to encoder: Encoder) throws {
|
open func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(title, forKey: .title)
|
try container.encode(title, forKey: .title)
|
||||||
try container.encode(enabled, forKey: .enabled)
|
try container.encode(enabled, forKey: .enabled)
|
||||||
|
|||||||
@ -16,6 +16,7 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol, Enablea
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "caretLink"
|
public static var identifier: String = "caretLink"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var accessibilityIdentifier: String?
|
public var accessibilityIdentifier: String?
|
||||||
public var title: String
|
public var title: String
|
||||||
@ -41,6 +42,7 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol, Enablea
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case accessibilityIdentifier
|
case accessibilityIdentifier
|
||||||
case title
|
case title
|
||||||
@ -61,6 +63,7 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol, Enablea
|
|||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
||||||
title = try typeContainer.decode(String.self, forKey: .title)
|
title = try typeContainer.decode(String.self, forKey: .title)
|
||||||
@ -94,6 +97,7 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol, Enablea
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(title, forKey: .title)
|
try container.encode(title, forKey: .title)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
|
|||||||
@ -14,8 +14,9 @@ open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGro
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "imageButton"
|
public static var identifier: String = "imageButton"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
|
|
||||||
public var image: ImageViewModel?
|
public var image: ImageViewModel?
|
||||||
|
|
||||||
public var accessibilityText: String?
|
public var accessibilityText: String?
|
||||||
@ -34,6 +35,7 @@ open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGro
|
|||||||
}
|
}
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case image
|
case image
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
@ -52,6 +54,7 @@ open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGro
|
|||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
image = try typeContainer.decodeIfPresent(ImageViewModel.self, forKey: .image)
|
image = try typeContainer.decodeIfPresent(ImageViewModel.self, forKey: .image)
|
||||||
accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
|
accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
|
||||||
@ -77,6 +80,7 @@ open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGro
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(image, forKey: .image)
|
try container.encodeIfPresent(image, forKey: .image)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import VDSColorTokens
|
|||||||
else { return }
|
else { return }
|
||||||
|
|
||||||
// Set line to the same color as the text
|
// Set line to the same color as the text
|
||||||
if let color = titleLabel?.textColor?.cgColor {
|
if let color = titleColor(for: state)?.cgColor {
|
||||||
context.setStrokeColor(color)
|
context.setStrokeColor(color)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public class var identifier: String { "link" }
|
public class var identifier: String { "link" }
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var accessibilityIdentifier: String?
|
public var accessibilityIdentifier: String?
|
||||||
@ -48,6 +49,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case accessibilityIdentifier
|
case accessibilityIdentifier
|
||||||
@ -91,6 +93,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode
|
|||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
||||||
title = try typeContainer.decode(String.self, forKey: .title)
|
title = try typeContainer.decode(String.self, forKey: .title)
|
||||||
@ -137,6 +140,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(title, forKey: .title)
|
try container.encode(title, forKey: .title)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
|
|||||||
@ -11,11 +11,14 @@ import MVMCore
|
|||||||
|
|
||||||
@objcMembers public class TagModel: MoleculeModelProtocol {
|
@objcMembers public class TagModel: MoleculeModelProtocol {
|
||||||
public static var identifier: String = "tag"
|
public static var identifier: String = "tag"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var label: LabelModel
|
public var label: LabelModel
|
||||||
public var action: ActionModelProtocol?
|
public var action: ActionModelProtocol?
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case label
|
case label
|
||||||
case action
|
case action
|
||||||
@ -38,6 +41,7 @@ import MVMCore
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
label = try typeContainer.decode(LabelModel.self, forKey: .label)
|
label = try typeContainer.decode(LabelModel.self, forKey: .label)
|
||||||
action = try typeContainer.decodeModelIfPresent(codingKey: .action)
|
action = try typeContainer.decodeModelIfPresent(codingKey: .action)
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
@ -45,6 +49,7 @@ import MVMCore
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(label, forKey: .label)
|
try container.encode(label, forKey: .label)
|
||||||
try container.encodeModelIfPresent(action, forKey: .action)
|
try container.encodeModelIfPresent(action, forKey: .action)
|
||||||
|
|||||||
@ -11,10 +11,13 @@ import MVMCore
|
|||||||
|
|
||||||
@objcMembers public class TagsModel: MoleculeModelProtocol {
|
@objcMembers public class TagsModel: MoleculeModelProtocol {
|
||||||
public static var identifier: String = "tags"
|
public static var identifier: String = "tags"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var tags: [TagModel]
|
public var tags: [TagModel]
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case tags
|
case tags
|
||||||
@ -30,12 +33,14 @@ import MVMCore
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
tags = try typeContainer.decode([TagModel].self, forKey: .tags)
|
tags = try typeContainer.decode([TagModel].self, forKey: .tags)
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(tags, forKey: .tags)
|
try container.encode(tags, forKey: .tags)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import Foundation
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public class var identifier: String { "" }
|
public class var identifier: String { "" }
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var accessibilityIdentifier: String?
|
public var accessibilityIdentifier: String?
|
||||||
@ -63,6 +64,7 @@ import Foundation
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case accessibilityIdentifier
|
case accessibilityIdentifier
|
||||||
@ -138,6 +140,7 @@ import Foundation
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
||||||
title = try typeContainer.decodeIfPresent(String.self, forKey: .title)
|
title = try typeContainer.decodeIfPresent(String.self, forKey: .title)
|
||||||
@ -166,6 +169,7 @@ import Foundation
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encodeIfPresent(moleculeName, forKey: .moleculeName)
|
try container.encodeIfPresent(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
|
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
|
||||||
|
|||||||
@ -144,7 +144,9 @@ import MVMCore
|
|||||||
picker.displayedPropertyKeys = ["phoneNumbers"]
|
picker.displayedPropertyKeys = ["phoneNumbers"]
|
||||||
picker.predicateForEnablingContact = NSPredicate(format: "phoneNumbers.@count > 0")
|
picker.predicateForEnablingContact = NSPredicate(format: "phoneNumbers.@count > 0")
|
||||||
picker.predicateForSelectionOfProperty = NSPredicate(format: "key == 'phoneNumbers'")
|
picker.predicateForSelectionOfProperty = NSPredicate(format: "key == 'phoneNumbers'")
|
||||||
MVMCoreNavigationHandler.shared()?.present(picker, animated: true)
|
Task(priority: .userInitiated) {
|
||||||
|
await NavigationHandler.shared().present(viewController: picker, animated: true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "checkbox"
|
public static var identifier: String = "checkbox"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var accessibilityIdentifier: String?
|
public var accessibilityIdentifier: String?
|
||||||
public var selected: Bool = false
|
public var selected: Bool = false
|
||||||
@ -51,6 +52,7 @@
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case accessibilityIdentifier
|
case accessibilityIdentifier
|
||||||
case checked
|
case checked
|
||||||
@ -107,6 +109,8 @@
|
|||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
|
|
||||||
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
||||||
|
|
||||||
if let borderWidth = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .borderWidth) {
|
if let borderWidth = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .borderWidth) {
|
||||||
@ -180,6 +184,7 @@
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(groupName, forKey: .groupName)
|
try container.encodeIfPresent(groupName, forKey: .groupName)
|
||||||
try container.encodeIfPresent(fieldKey, forKey: .fieldKey)
|
try container.encodeIfPresent(fieldKey, forKey: .fieldKey)
|
||||||
|
|||||||
@ -14,6 +14,8 @@ open class HeartModel: MoleculeModelProtocol, EnableableModelProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "heart"
|
public static var identifier: String = "heart"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var accessibilityIdentifier: String?
|
public var accessibilityIdentifier: String?
|
||||||
public var isActive: Bool = false
|
public var isActive: Bool = false
|
||||||
@ -27,6 +29,7 @@ open class HeartModel: MoleculeModelProtocol, EnableableModelProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case accessibilityIdentifier
|
case accessibilityIdentifier
|
||||||
@ -49,6 +52,8 @@ open class HeartModel: MoleculeModelProtocol, EnableableModelProtocol {
|
|||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
|
|
||||||
if let isActive = try typeContainer.decodeIfPresent(Bool.self, forKey: .isActive) {
|
if let isActive = try typeContainer.decodeIfPresent(Bool.self, forKey: .isActive) {
|
||||||
self.isActive = isActive
|
self.isActive = isActive
|
||||||
}
|
}
|
||||||
@ -75,6 +80,7 @@ open class HeartModel: MoleculeModelProtocol, EnableableModelProtocol {
|
|||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
|
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(isActive, forKey: .isActive)
|
try container.encode(isActive, forKey: .isActive)
|
||||||
try container.encode(activeColor, forKey: .activeColor)
|
try container.encode(activeColor, forKey: .activeColor)
|
||||||
|
|||||||
@ -13,6 +13,8 @@ import MVMCore
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "radioBox"
|
public static var identifier: String = "radioBox"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var text: String
|
public var text: String
|
||||||
public var subText: String?
|
public var subText: String?
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
@ -30,6 +32,7 @@ import MVMCore
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case text
|
case text
|
||||||
case subText
|
case subText
|
||||||
@ -58,6 +61,8 @@ import MVMCore
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
text = try typeContainer.decode(String.self, forKey: .text)
|
text = try typeContainer.decode(String.self, forKey: .text)
|
||||||
subText = try typeContainer.decodeIfPresent(String.self, forKey: .subText)
|
subText = try typeContainer.decodeIfPresent(String.self, forKey: .subText)
|
||||||
selectedAccentColor = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedAccentColor)
|
selectedAccentColor = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedAccentColor)
|
||||||
@ -81,6 +86,7 @@ import MVMCore
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(text, forKey: .text)
|
try container.encode(text, forKey: .text)
|
||||||
try container.encodeIfPresent(subText, forKey: .subText)
|
try container.encodeIfPresent(subText, forKey: .subText)
|
||||||
|
|||||||
@ -13,6 +13,8 @@ import MVMCore
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "radioBoxes"
|
public static var identifier: String = "radioBoxes"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var boxes: [RadioBoxModel]
|
public var boxes: [RadioBoxModel]
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var accessibilityIdentifier: String?
|
public var accessibilityIdentifier: String?
|
||||||
@ -49,6 +51,7 @@ import MVMCore
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case enabled
|
case enabled
|
||||||
case readOnly
|
case readOnly
|
||||||
@ -75,6 +78,7 @@ import MVMCore
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
selectedAccentColor = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedAccentColor)
|
selectedAccentColor = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedAccentColor)
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
||||||
@ -91,6 +95,7 @@ import MVMCore
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(boxes, forKey: .boxes)
|
try container.encode(boxes, forKey: .boxes)
|
||||||
try container.encodeIfPresent(selectedAccentColor, forKey: .selectedAccentColor)
|
try container.encodeIfPresent(selectedAccentColor, forKey: .selectedAccentColor)
|
||||||
|
|||||||
@ -15,6 +15,8 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "radioButton"
|
public static var identifier: String = "radioButton"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var accessibilityIdentifier: String?
|
public var accessibilityIdentifier: String?
|
||||||
public var state: Bool = false
|
public var state: Bool = false
|
||||||
@ -35,6 +37,7 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case accessibilityIdentifier
|
case accessibilityIdentifier
|
||||||
@ -80,6 +83,8 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol {
|
|||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
|
|
||||||
if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) {
|
if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) {
|
||||||
self.state = state
|
self.state = state
|
||||||
}
|
}
|
||||||
@ -105,6 +110,7 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol {
|
|||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
|
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(state, forKey: .state)
|
try container.encode(state, forKey: .state)
|
||||||
try container.encode(enabled, forKey: .enabled)
|
try container.encode(enabled, forKey: .enabled)
|
||||||
|
|||||||
@ -13,6 +13,8 @@ import MVMCore
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "radioSwatch"
|
public static var identifier: String = "radioSwatch"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var accessibilityIdentifier: String?
|
public var accessibilityIdentifier: String?
|
||||||
public var color: Color = Color(uiColor: .mvmBlue)
|
public var color: Color = Color(uiColor: .mvmBlue)
|
||||||
@ -29,6 +31,7 @@ import MVMCore
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case accessibilityIdentifier
|
case accessibilityIdentifier
|
||||||
@ -54,6 +57,7 @@ import MVMCore
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
||||||
|
|
||||||
@ -79,6 +83,7 @@ import MVMCore
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
|
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
|
||||||
|
|||||||
@ -13,6 +13,8 @@ import MVMCore
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "radioSwatches"
|
public static var identifier: String = "radioSwatches"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var accessibilityIdentifier: String?
|
public var accessibilityIdentifier: String?
|
||||||
public var swatches: [RadioSwatchModel]
|
public var swatches: [RadioSwatchModel]
|
||||||
@ -43,6 +45,7 @@ import MVMCore
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case accessibilityIdentifier
|
case accessibilityIdentifier
|
||||||
@ -67,6 +70,7 @@ import MVMCore
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
||||||
swatches = try typeContainer.decode([RadioSwatchModel].self, forKey: .swatches)
|
swatches = try typeContainer.decode([RadioSwatchModel].self, forKey: .swatches)
|
||||||
@ -81,6 +85,7 @@ import MVMCore
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
|
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
|
||||||
|
|||||||
@ -13,6 +13,8 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "toggle"
|
public static var identifier: String = "toggle"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var accessibilityIdentifier: String?
|
public var accessibilityIdentifier: String?
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var selected: Bool = false
|
public var selected: Bool = false
|
||||||
@ -36,6 +38,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case state
|
case state
|
||||||
case animated
|
case animated
|
||||||
@ -86,6 +89,8 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol {
|
|||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
|
|
||||||
if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) {
|
if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) {
|
||||||
self.selected = state
|
self.selected = state
|
||||||
}
|
}
|
||||||
@ -128,6 +133,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol {
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
|
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
|
||||||
try container.encodeModelIfPresent(action, forKey: .action)
|
try container.encodeModelIfPresent(action, forKey: .action)
|
||||||
|
|||||||
@ -17,8 +17,9 @@ open class ArrowModel: MoleculeModelProtocol, EnableableModelProtocol {
|
|||||||
public static var identifier: String {
|
public static var identifier: String {
|
||||||
return "arrow"
|
return "arrow"
|
||||||
}
|
}
|
||||||
|
|
||||||
public var moleculeName: String?
|
public var moleculeName: String?
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var disabledColor: Color = Color(uiColor: .mvmCoolGray3)
|
public var disabledColor: Color = Color(uiColor: .mvmCoolGray3)
|
||||||
public var color: Color = Color(uiColor: .mvmBlack)
|
public var color: Color = Color(uiColor: .mvmBlack)
|
||||||
@ -57,6 +58,7 @@ open class ArrowModel: MoleculeModelProtocol, EnableableModelProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case disabledColor
|
case disabledColor
|
||||||
@ -75,7 +77,7 @@ open class ArrowModel: MoleculeModelProtocol, EnableableModelProtocol {
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
|
|
||||||
if let disabledColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledColor) {
|
if let disabledColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledColor) {
|
||||||
@ -113,6 +115,7 @@ open class ArrowModel: MoleculeModelProtocol, EnableableModelProtocol {
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(disabledColor, forKey: .disabledColor)
|
try container.encode(disabledColor, forKey: .disabledColor)
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import MVMCore
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "caretView"
|
public static var identifier: String = "caretView"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var strokeColor: Color = Color(uiColor: .mvmBlack)
|
public var strokeColor: Color = Color(uiColor: .mvmBlack)
|
||||||
public var strokeColor_inverted: Color = Color(uiColor: .mvmWhite)
|
public var strokeColor_inverted: Color = Color(uiColor: .mvmWhite)
|
||||||
@ -28,6 +29,7 @@ import MVMCore
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case strokeColor
|
case strokeColor
|
||||||
@ -51,6 +53,8 @@ import MVMCore
|
|||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
|
|
||||||
if let strokeColor = try typeContainer.decodeIfPresent(Color.self, forKey: .strokeColor) {
|
if let strokeColor = try typeContainer.decodeIfPresent(Color.self, forKey: .strokeColor) {
|
||||||
self.strokeColor = strokeColor
|
self.strokeColor = strokeColor
|
||||||
}
|
}
|
||||||
@ -78,6 +82,7 @@ import MVMCore
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(strokeColor, forKey: .strokeColor)
|
try container.encode(strokeColor, forKey: .strokeColor)
|
||||||
try container.encode(strokeColor_inverted, forKey: .strokeColor_inverted)
|
try container.encode(strokeColor_inverted, forKey: .strokeColor_inverted)
|
||||||
|
|||||||
@ -18,6 +18,7 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var moleculeName: String?
|
public var moleculeName: String?
|
||||||
public var numberOfPages: Int = 0
|
public var numberOfPages: Int = 0
|
||||||
@ -44,6 +45,7 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case currentIndex
|
case currentIndex
|
||||||
@ -66,6 +68,7 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName)
|
moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName)
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
|
|
||||||
@ -112,6 +115,7 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encodeIfPresent(moleculeName, forKey: .moleculeName)
|
try container.encodeIfPresent(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encode(numberOfPages, forKey: .numberOfPages)
|
try container.encode(numberOfPages, forKey: .numberOfPages)
|
||||||
|
|||||||
@ -18,6 +18,8 @@ public enum CheckboxPosition: String, Codable {
|
|||||||
@objcMembers open class CheckboxLabelModel: MoleculeModelProtocol {
|
@objcMembers open class CheckboxLabelModel: MoleculeModelProtocol {
|
||||||
open class var identifier: String { "checkboxLabel" }
|
open class var identifier: String { "checkboxLabel" }
|
||||||
public var moleculeName: String = CheckboxLabelModel.identifier
|
public var moleculeName: String = CheckboxLabelModel.identifier
|
||||||
|
@DecodableDefault.UUIDString public var id: String
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var checkboxAlignment: CheckboxPosition?
|
public var checkboxAlignment: CheckboxPosition?
|
||||||
public var checkbox: CheckboxModel
|
public var checkbox: CheckboxModel
|
||||||
|
|||||||
@ -15,6 +15,8 @@ import MVMCore
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "dashLine"
|
public static var identifier: String = "dashLine"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var accessibilityIdentifier: String?
|
public var accessibilityIdentifier: String?
|
||||||
public var dashColor: Color = Color(uiColor: .mvmCoolGray3)
|
public var dashColor: Color = Color(uiColor: .mvmCoolGray3)
|
||||||
@ -35,6 +37,7 @@ import MVMCore
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case accessibilityIdentifier
|
case accessibilityIdentifier
|
||||||
@ -56,6 +59,8 @@ import MVMCore
|
|||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
|
|
||||||
if let dashColor = try typeContainer.decodeIfPresent(Color.self, forKey: .dashColor) {
|
if let dashColor = try typeContainer.decodeIfPresent(Color.self, forKey: .dashColor) {
|
||||||
self.dashColor = dashColor
|
self.dashColor = dashColor
|
||||||
}
|
}
|
||||||
@ -74,6 +79,7 @@ import MVMCore
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(dashColor, forKey: .dashColor)
|
try container.encode(dashColor, forKey: .dashColor)
|
||||||
try container.encode(isHidden, forKey: .isHidden)
|
try container.encode(isHidden, forKey: .isHidden)
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
open class var identifier: String { "image" }
|
open class var identifier: String { "image" }
|
||||||
|
@DecodableDefault.UUIDString public var id: String
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var moleculeName: String = ImageViewModel.identifier
|
public var moleculeName: String = ImageViewModel.identifier
|
||||||
@ -45,6 +46,7 @@
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case image
|
case image
|
||||||
|
|||||||
@ -7,13 +7,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
@objcMembers open class LabelModel: MoleculeModelProtocol, Identifiable {
|
@objcMembers open class LabelModel: MoleculeModelProtocol {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
open class var identifier: String { "label" }
|
open class var identifier: String { "label" }
|
||||||
public var id: String
|
public var id: String
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var text: String
|
public var text: String
|
||||||
public var accessibilityText: String?
|
public var accessibilityText: String?
|
||||||
@ -35,8 +36,8 @@
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case moleculeName
|
|
||||||
case id
|
case id
|
||||||
|
case moleculeName
|
||||||
case text
|
case text
|
||||||
case accessibilityText
|
case accessibilityText
|
||||||
case textColor
|
case textColor
|
||||||
@ -110,7 +111,7 @@
|
|||||||
open func encode(to encoder: Encoder) throws {
|
open func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(moleculeName, forKey: .moleculeName)
|
try container.encodeIfPresent(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(id, forKey: .id)
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(text, forKey: .text)
|
try container.encode(text, forKey: .text)
|
||||||
try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText)
|
try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText)
|
||||||
try container.encodeIfPresent(textColor, forKey: .textColor)
|
try container.encodeIfPresent(textColor, forKey: .textColor)
|
||||||
|
|||||||
@ -15,6 +15,8 @@ import UIKit
|
|||||||
|
|
||||||
public static var identifier: String = "leftRightLabelView"
|
public static var identifier: String = "leftRightLabelView"
|
||||||
public var moleculeName: String = LeftRightLabelModel.identifier
|
public var moleculeName: String = LeftRightLabelModel.identifier
|
||||||
|
@DecodableDefault.UUIDString public var id: String
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var leftText: LabelModel
|
public var leftText: LabelModel
|
||||||
public var rightText: LabelModel?
|
public var rightText: LabelModel?
|
||||||
|
|||||||
@ -53,6 +53,8 @@ import VDSColorTokens
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "line"
|
public static var identifier: String = "line"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var type: Style = .secondary
|
public var type: Style = .secondary
|
||||||
public var frequency: Frequency? = .allExceptTop
|
public var frequency: Frequency? = .allExceptTop
|
||||||
|
|
||||||
@ -120,6 +122,7 @@ import VDSColorTokens
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case type
|
case type
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
@ -138,6 +141,8 @@ import VDSColorTokens
|
|||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
|
|
||||||
if let type = try typeContainer.decodeIfPresent(Style.self, forKey: .type) {
|
if let type = try typeContainer.decodeIfPresent(Style.self, forKey: .type) {
|
||||||
self.type = type
|
self.type = type
|
||||||
}
|
}
|
||||||
@ -158,6 +163,7 @@ import VDSColorTokens
|
|||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(type, forKey: .type)
|
try container.encode(type, forKey: .type)
|
||||||
try container.encode(inverted, forKey: .inverted)
|
try container.encode(inverted, forKey: .inverted)
|
||||||
try container.encodeIfPresent(frequency, forKey: .frequency)
|
try container.encodeIfPresent(frequency, forKey: .frequency)
|
||||||
|
|||||||
@ -13,9 +13,10 @@ open class LoadingSpinnerModel: MoleculeModelProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
|
||||||
public static var identifier: String = "loadingSpinner"
|
public static var identifier: String = "loadingSpinner"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
|
public var backgroundColor: Color?
|
||||||
public var strokeColor = Color(uiColor: .mvmBlack)
|
public var strokeColor = Color(uiColor: .mvmBlack)
|
||||||
public var lineWidth: CGFloat = 4
|
public var lineWidth: CGFloat = 4
|
||||||
public var diameter: CGFloat = 40
|
public var diameter: CGFloat = 40
|
||||||
@ -25,6 +26,7 @@ open class LoadingSpinnerModel: MoleculeModelProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case strokeColor
|
case strokeColor
|
||||||
@ -45,6 +47,7 @@ open class LoadingSpinnerModel: MoleculeModelProtocol {
|
|||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
|
|
||||||
if let diameter = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .diameter) {
|
if let diameter = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .diameter) {
|
||||||
@ -62,6 +65,7 @@ open class LoadingSpinnerModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encodeIfPresent(diameter, forKey: .diameter)
|
try container.encodeIfPresent(diameter, forKey: .diameter)
|
||||||
|
|||||||
@ -19,13 +19,17 @@ import Foundation
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objcMembers public class MultiProgressBarModel: MoleculeModelProtocol {
|
@objcMembers public class MultiProgressBarModel: MoleculeModelProtocol {
|
||||||
|
|
||||||
public static var identifier: String = "multiProgressBar"
|
public static var identifier: String = "multiProgressBar"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var progressList: [SingleProgressBarModel]
|
public var progressList: [SingleProgressBarModel]
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var thickness: CGFloat?
|
public var thickness: CGFloat?
|
||||||
public var roundedCorners: Bool?
|
public var roundedCorners: Bool?
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case progressList
|
case progressList
|
||||||
case thickness
|
case thickness
|
||||||
@ -39,6 +43,7 @@ import Foundation
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
progressList = try typeContainer.decode([SingleProgressBarModel].self, forKey: .progressList)
|
progressList = try typeContainer.decode([SingleProgressBarModel].self, forKey: .progressList)
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness)
|
thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness)
|
||||||
@ -47,6 +52,7 @@ import Foundation
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(progressList, forKey: .progressList)
|
try container.encode(progressList, forKey: .progressList)
|
||||||
try container.encodeIfPresent(thickness, forKey: .thickness)
|
try container.encodeIfPresent(thickness, forKey: .thickness)
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import Foundation
|
|||||||
|
|
||||||
@objcMembers public class ProgressBarModel: MoleculeModelProtocol {
|
@objcMembers public class ProgressBarModel: MoleculeModelProtocol {
|
||||||
public static var identifier: String = "progressBar"
|
public static var identifier: String = "progressBar"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
@Percent public var percent: CGFloat
|
@Percent public var percent: CGFloat
|
||||||
public var color: Color = Color(uiColor: .mfCerulean())
|
public var color: Color = Color(uiColor: .mfCerulean())
|
||||||
public var backgroundColor: Color? = Color(uiColor: .mfLightSilver())
|
public var backgroundColor: Color? = Color(uiColor: .mfLightSilver())
|
||||||
@ -17,6 +19,7 @@ import Foundation
|
|||||||
public var thickness: CGFloat?
|
public var thickness: CGFloat?
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case roundedCorners
|
case roundedCorners
|
||||||
case thickness
|
case thickness
|
||||||
@ -31,6 +34,7 @@ import Foundation
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
percent = try typeContainer.decode(CGFloat.self, forKey: .percent)
|
percent = try typeContainer.decode(CGFloat.self, forKey: .percent)
|
||||||
if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .color) {
|
if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .color) {
|
||||||
self.color = color
|
self.color = color
|
||||||
@ -44,6 +48,7 @@ import Foundation
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(percent, forKey: .percent)
|
try container.encode(percent, forKey: .percent)
|
||||||
try container.encode(color, forKey: .color)
|
try container.encode(color, forKey: .color)
|
||||||
|
|||||||
@ -13,6 +13,8 @@ open class StarModel: MoleculeModelProtocol {
|
|||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
public static var identifier: String = "star"
|
public static var identifier: String = "star"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
@Percent public var percent: CGFloat = 0
|
@Percent public var percent: CGFloat = 0
|
||||||
public var borderColor: Color?
|
public var borderColor: Color?
|
||||||
@ -23,6 +25,7 @@ open class StarModel: MoleculeModelProtocol {
|
|||||||
// MARK: - Keys
|
// MARK: - Keys
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case percent
|
case percent
|
||||||
@ -43,6 +46,7 @@ open class StarModel: MoleculeModelProtocol {
|
|||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
if let percent = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .percent) {
|
if let percent = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .percent) {
|
||||||
self.percent = percent
|
self.percent = percent
|
||||||
}
|
}
|
||||||
@ -56,6 +60,7 @@ open class StarModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(percent, forKey: .percent)
|
try container.encode(percent, forKey: .percent)
|
||||||
|
|||||||
@ -13,6 +13,8 @@ import MVMCore
|
|||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
public static var identifier: String = "stars"
|
public static var identifier: String = "stars"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var starBackgroundColor: Color?
|
public var starBackgroundColor: Color?
|
||||||
public var stars: [StarModel]
|
public var stars: [StarModel]
|
||||||
@ -25,6 +27,7 @@ import MVMCore
|
|||||||
// MARK: - Keys
|
// MARK: - Keys
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case starBackgroundColor
|
case starBackgroundColor
|
||||||
@ -48,6 +51,8 @@ import MVMCore
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
stars = try typeContainer.decode([StarModel].self, forKey: .stars)
|
stars = try typeContainer.decode([StarModel].self, forKey: .stars)
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
starBackgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .starBackgroundColor)
|
starBackgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .starBackgroundColor)
|
||||||
@ -63,6 +68,7 @@ import MVMCore
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(stars, forKey: .stars)
|
try container.encode(stars, forKey: .stars)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
|
|||||||
@ -37,8 +37,11 @@ open class Tilelet: VDS.Tilelet, VDSMoleculeViewProtocol{
|
|||||||
padding = viewModel.padding
|
padding = viewModel.padding
|
||||||
aspectRatio = viewModel.aspectRatio
|
aspectRatio = viewModel.aspectRatio
|
||||||
width = viewModel.width
|
width = viewModel.width
|
||||||
textWidth = viewModel.textWidth
|
if let value = viewModel.textWidth {
|
||||||
textPercentage = viewModel.textPercentage
|
textWidth = .value(value)
|
||||||
|
} else if let percentage = viewModel.textPercentage {
|
||||||
|
textWidth = .percentage(percentage)
|
||||||
|
}
|
||||||
titleModel = viewModel.titleModel(delegateObject: delegateObject, additionalData: additionalData)
|
titleModel = viewModel.titleModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||||
subTitleModel = viewModel.subTitleModel(delegateObject: delegateObject, additionalData: additionalData)
|
subTitleModel = viewModel.subTitleModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||||
badgeModel = viewModel.badge
|
badgeModel = viewModel.badge
|
||||||
|
|||||||
@ -15,6 +15,7 @@ open class TileletModel: MoleculeModelProtocol {
|
|||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
public static var identifier: String = "tilelet"
|
public static var identifier: String = "tilelet"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var color: TileContainer.BackgroundColor
|
public var color: TileContainer.BackgroundColor
|
||||||
public var padding: TileContainer.Padding
|
public var padding: TileContainer.Padding
|
||||||
@ -30,6 +31,7 @@ open class TileletModel: MoleculeModelProtocol {
|
|||||||
public var action: ActionModelProtocol?
|
public var action: ActionModelProtocol?
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case color
|
case color
|
||||||
@ -47,6 +49,7 @@ open class TileletModel: MoleculeModelProtocol {
|
|||||||
}
|
}
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
self.id = try container.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
self.backgroundColor = try container.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
self.backgroundColor = try container.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
self.color = try container.decodeIfPresent(TileContainer.BackgroundColor.self, forKey: .color) ?? TileContainer.BackgroundColor.black
|
self.color = try container.decodeIfPresent(TileContainer.BackgroundColor.self, forKey: .color) ?? TileContainer.BackgroundColor.black
|
||||||
self.padding = try container.decodeIfPresent(TileContainer.Padding.self, forKey: .padding) ?? TileContainer.Padding.padding4X
|
self.padding = try container.decodeIfPresent(TileContainer.Padding.self, forKey: .padding) ?? TileContainer.Padding.padding4X
|
||||||
@ -86,6 +89,7 @@ open class TileletModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encodeIfPresent(color, forKey: .color)
|
try container.encodeIfPresent(color, forKey: .color)
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import Foundation
|
|||||||
|
|
||||||
open class VideoModel: MoleculeModelProtocol, PageBehaviorProtocolRequirer {
|
open class VideoModel: MoleculeModelProtocol, PageBehaviorProtocolRequirer {
|
||||||
public static var identifier = "video"
|
public static var identifier = "video"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var video: String
|
public var video: String
|
||||||
public var showControls = false
|
public var showControls = false
|
||||||
@ -43,6 +44,7 @@ open class VideoModel: MoleculeModelProtocol, PageBehaviorProtocolRequirer {
|
|||||||
private var resignActiveListener: Any?
|
private var resignActiveListener: Any?
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case video
|
case video
|
||||||
case showControls
|
case showControls
|
||||||
@ -57,6 +59,7 @@ open class VideoModel: MoleculeModelProtocol, PageBehaviorProtocolRequirer {
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
video = try typeContainer.decode(String.self, forKey:.video)
|
video = try typeContainer.decode(String.self, forKey:.video)
|
||||||
if let showControls = try typeContainer.decodeIfPresent(Bool.self, forKey: .showControls) {
|
if let showControls = try typeContainer.decodeIfPresent(Bool.self, forKey: .showControls) {
|
||||||
self.showControls = showControls
|
self.showControls = showControls
|
||||||
@ -72,6 +75,7 @@ open class VideoModel: MoleculeModelProtocol, PageBehaviorProtocolRequirer {
|
|||||||
|
|
||||||
open func encode(to encoder: Encoder) throws {
|
open func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(video, forKey: .video)
|
try container.encode(video, forKey: .video)
|
||||||
try container.encode(showControls, forKey: .showControls)
|
try container.encode(showControls, forKey: .showControls)
|
||||||
|
|||||||
@ -12,6 +12,8 @@ import MVMCore
|
|||||||
@objcMembers public class WebViewModel: MoleculeModelProtocol {
|
@objcMembers public class WebViewModel: MoleculeModelProtocol {
|
||||||
public static var identifier: String = "webview"
|
public static var identifier: String = "webview"
|
||||||
public var moleculeName: String = WebViewModel.identifier
|
public var moleculeName: String = WebViewModel.identifier
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var url: URL?
|
public var url: URL?
|
||||||
public var htmlString: String?
|
public var htmlString: String?
|
||||||
@ -23,6 +25,7 @@ import MVMCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey{
|
private enum CodingKeys: String, CodingKey{
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case url
|
case url
|
||||||
@ -39,6 +42,7 @@ import MVMCore
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
url = try typeContainer.decodeIfPresent(URL.self, forKey: .url)
|
url = try typeContainer.decodeIfPresent(URL.self, forKey: .url)
|
||||||
htmlString = try typeContainer.decodeIfPresent(String.self, forKey: .htmlString)
|
htmlString = try typeContainer.decodeIfPresent(String.self, forKey: .htmlString)
|
||||||
@ -51,6 +55,7 @@ import MVMCore
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encodeIfPresent(url, forKey: .url)
|
try container.encodeIfPresent(url, forKey: .url)
|
||||||
|
|||||||
@ -19,6 +19,8 @@ public enum GraphStyle: String, Codable {
|
|||||||
public class WheelModel: MoleculeModelProtocol {
|
public class WheelModel: MoleculeModelProtocol {
|
||||||
|
|
||||||
public static var identifier: String = "wheel"
|
public static var identifier: String = "wheel"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var style: GraphStyle = .unlimited {
|
public var style: GraphStyle = .unlimited {
|
||||||
didSet {
|
didSet {
|
||||||
updateStyle()
|
updateStyle()
|
||||||
@ -43,6 +45,7 @@ public class WheelModel: MoleculeModelProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case style
|
case style
|
||||||
case size
|
case size
|
||||||
case diameter
|
case diameter
|
||||||
@ -56,6 +59,8 @@ public class WheelModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
|
|
||||||
if let style = try typeContainer.decodeIfPresent(GraphStyle.self, forKey: .style) {
|
if let style = try typeContainer.decodeIfPresent(GraphStyle.self, forKey: .style) {
|
||||||
self.style = style
|
self.style = style
|
||||||
}
|
}
|
||||||
@ -84,6 +89,7 @@ public class WheelModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(style, forKey: .style)
|
try container.encode(style, forKey: .style)
|
||||||
try container.encode(size, forKey: .size)
|
try container.encode(size, forKey: .size)
|
||||||
|
|||||||
@ -55,11 +55,11 @@ import Foundation
|
|||||||
isAccessibilityElement = true
|
isAccessibilityElement = true
|
||||||
var message = ""
|
var message = ""
|
||||||
|
|
||||||
if let headlineLabel = headlineBody.headlineLabel.text {
|
if let headlineLabel = headlineBody.headlineLabel.accessibilityLabel ?? headlineBody.headlineLabel.text {
|
||||||
message += headlineLabel + ", "
|
message += headlineLabel + ", "
|
||||||
}
|
}
|
||||||
|
|
||||||
if let messageLabel = headlineBody.messageLabel.text {
|
if let messageLabel = headlineBody.messageLabel.accessibilityLabel ?? headlineBody.messageLabel.text {
|
||||||
message += messageLabel
|
message += messageLabel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,8 @@ public class LockUpsPlanNamesModel: MoleculeModelProtocol {
|
|||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
public static var identifier: String = "planNamesLockup"
|
public static var identifier: String = "planNamesLockup"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var headline: LabelModel
|
public var headline: LabelModel
|
||||||
public var subHeadline: LabelModel
|
public var subHeadline: LabelModel
|
||||||
@ -31,6 +33,7 @@ public class LockUpsPlanNamesModel: MoleculeModelProtocol {
|
|||||||
// MARK: - Keys
|
// MARK: - Keys
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case headline
|
case headline
|
||||||
@ -43,6 +46,7 @@ public class LockUpsPlanNamesModel: MoleculeModelProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
headline = try typeContainer.decode(LabelModel.self, forKey: .headline)
|
headline = try typeContainer.decode(LabelModel.self, forKey: .headline)
|
||||||
subHeadline = try typeContainer.decode(LabelModel.self, forKey: .subHeadline)
|
subHeadline = try typeContainer.decode(LabelModel.self, forKey: .subHeadline)
|
||||||
@ -51,6 +55,7 @@ public class LockUpsPlanNamesModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encode(headline, forKey: .headline)
|
try container.encode(headline, forKey: .headline)
|
||||||
|
|||||||
@ -14,6 +14,8 @@ public class LockupsPlanSMLXLModel: MoleculeModelProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "planLockup"
|
public static var identifier: String = "planLockup"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var planLabel : LabelModel
|
public var planLabel : LabelModel
|
||||||
public var headline : LabelModel
|
public var headline : LabelModel
|
||||||
@ -43,6 +45,7 @@ public class LockupsPlanSMLXLModel: MoleculeModelProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case planLabel
|
case planLabel
|
||||||
@ -57,6 +60,7 @@ public class LockupsPlanSMLXLModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
planLabel = try typeContainer.decode(LabelModel.self, forKey: .planLabel)
|
planLabel = try typeContainer.decode(LabelModel.self, forKey: .planLabel)
|
||||||
headline = try typeContainer.decode(LabelModel.self, forKey: .headline)
|
headline = try typeContainer.decode(LabelModel.self, forKey: .headline)
|
||||||
@ -67,6 +71,7 @@ public class LockupsPlanSMLXLModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encode(planLabel, forKey: .planLabel)
|
try container.encode(planLabel, forKey: .planLabel)
|
||||||
|
|||||||
@ -16,6 +16,7 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
|
|||||||
|
|
||||||
public static var identifier: String = "titleLockup"
|
public static var identifier: String = "titleLockup"
|
||||||
public var moleculeName: String = TitleLockupModel.identifier
|
public var moleculeName: String = TitleLockupModel.identifier
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var eyebrow: LabelModel?
|
public var eyebrow: LabelModel?
|
||||||
public var title: LabelModel
|
public var title: LabelModel
|
||||||
@ -130,6 +131,7 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case eyebrow
|
case eyebrow
|
||||||
@ -145,6 +147,7 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
title = try typeContainer.decodeMolecule(codingKey: .title)
|
title = try typeContainer.decodeMolecule(codingKey: .title)
|
||||||
eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow)
|
eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow)
|
||||||
subTitle = try typeContainer.decodeMoleculeIfPresent(codingKey: .subTitle)
|
subTitle = try typeContainer.decodeMoleculeIfPresent(codingKey: .subTitle)
|
||||||
@ -164,6 +167,7 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(eyebrow, forKey: .eyebrow)
|
try container.encodeIfPresent(eyebrow, forKey: .eyebrow)
|
||||||
try container.encodeModel(title, forKey: .title)
|
try container.encodeModel(title, forKey: .title)
|
||||||
|
|||||||
@ -14,9 +14,11 @@ import Foundation
|
|||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
|
||||||
public static var identifier: String = "doughnutChartItem"
|
public static var identifier: String = "doughnutChartItem"
|
||||||
public var moleculeName: String = DoughnutChartItemModel.identifier
|
public var moleculeName: String = DoughnutChartItemModel.identifier
|
||||||
|
@DecodableDefault.UUIDString public var id: String
|
||||||
|
|
||||||
|
public var backgroundColor: Color?
|
||||||
public var label: LabelModel
|
public var label: LabelModel
|
||||||
@Percent public var percent: CGFloat
|
@Percent public var percent: CGFloat
|
||||||
public var color: Color
|
public var color: Color
|
||||||
|
|||||||
@ -14,9 +14,11 @@ import Foundation
|
|||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
|
||||||
public static var identifier: String = "doughnutChart"
|
public static var identifier: String = "doughnutChart"
|
||||||
public var moleculeName: String = DoughnutChartModel.identifier
|
public var moleculeName: String = DoughnutChartModel.identifier
|
||||||
|
@DecodableDefault.UUIDString public var id: String
|
||||||
|
|
||||||
|
public var backgroundColor: Color?
|
||||||
public var title: LabelModel?
|
public var title: LabelModel?
|
||||||
public var subtitle: LabelModel?
|
public var subtitle: LabelModel?
|
||||||
public var sections: [DoughnutChartItemModel]
|
public var sections: [DoughnutChartItemModel]
|
||||||
|
|||||||
@ -15,6 +15,8 @@ public class ImageHeadlineBodyModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
public static var identifier: String = "imageHeadlineBody"
|
public static var identifier: String = "imageHeadlineBody"
|
||||||
public var moleculeName: String = ImageHeadlineBodyModel.identifier
|
public var moleculeName: String = ImageHeadlineBodyModel.identifier
|
||||||
|
@DecodableDefault.UUIDString public var id: String
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var image: ImageViewModel
|
public var image: ImageViewModel
|
||||||
public var headlineBody: HeadlineBodyModel
|
public var headlineBody: HeadlineBodyModel
|
||||||
|
|||||||
@ -15,6 +15,8 @@ import MVMCore
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "radioButtonLabel"
|
public static var identifier: String = "radioButtonLabel"
|
||||||
|
@DecodableDefault.UUIDString public var id: String
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var moleculeName: String = RadioButtonLabelModel.identifier
|
public var moleculeName: String = RadioButtonLabelModel.identifier
|
||||||
public var radioButton: RadioButtonModel
|
public var radioButton: RadioButtonModel
|
||||||
|
|||||||
@ -11,6 +11,8 @@ import VDSColorTokens
|
|||||||
|
|
||||||
open class TabBarModel: MoleculeModelProtocol {
|
open class TabBarModel: MoleculeModelProtocol {
|
||||||
public static var identifier: String = "tabBar"
|
public static var identifier: String = "tabBar"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
open var tabs: [TabBarItemModel]
|
open var tabs: [TabBarItemModel]
|
||||||
|
|
||||||
private var _backgroundColor: Color?
|
private var _backgroundColor: Color?
|
||||||
@ -58,6 +60,7 @@ open class TabBarModel: MoleculeModelProtocol {
|
|||||||
open var selectedTab: Int = 0
|
open var selectedTab: Int = 0
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case tabs
|
case tabs
|
||||||
@ -73,6 +76,7 @@ open class TabBarModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
tabs = try typeContainer.decode([TabBarItemModel].self, forKey: .tabs)
|
tabs = try typeContainer.decode([TabBarItemModel].self, forKey: .tabs)
|
||||||
if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) {
|
if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) {
|
||||||
backgroundColor = color
|
backgroundColor = color
|
||||||
@ -93,6 +97,7 @@ open class TabBarModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
open func encode(to encoder: Encoder) throws {
|
open func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(tabs, forKey: .tabs)
|
try container.encode(tabs, forKey: .tabs)
|
||||||
try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor)
|
||||||
|
|||||||
@ -11,6 +11,8 @@ import VDSColorTokens
|
|||||||
|
|
||||||
open class TabsModel: MoleculeModelProtocol {
|
open class TabsModel: MoleculeModelProtocol {
|
||||||
public static var identifier: String = "tabs"
|
public static var identifier: String = "tabs"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
open var tabs: [TabItemModel]
|
open var tabs: [TabItemModel]
|
||||||
|
|
||||||
open var style: NavigationItemStyle?
|
open var style: NavigationItemStyle?
|
||||||
@ -71,6 +73,7 @@ open class TabsModel: MoleculeModelProtocol {
|
|||||||
open var selectedIndex: Int = 0
|
open var selectedIndex: Int = 0
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case tabs
|
case tabs
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
@ -87,6 +90,7 @@ open class TabsModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
tabs = try typeContainer.decode([TabItemModel].self, forKey: .tabs)
|
tabs = try typeContainer.decode([TabItemModel].self, forKey: .tabs)
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
_selectedColor = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedColor)
|
_selectedColor = try typeContainer.decodeIfPresent(Color.self, forKey: .selectedColor)
|
||||||
@ -100,6 +104,7 @@ open class TabsModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
open func encode(to encoder: Encoder) throws {
|
open func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(tabs, forKey: .tabs)
|
try container.encode(tabs, forKey: .tabs)
|
||||||
try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor)
|
||||||
|
|||||||
@ -15,6 +15,7 @@ public class TwoButtonViewModel: ParentMoleculeModelProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "twoButtonView"
|
public static var identifier: String = "twoButtonView"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var primaryButton: ButtonModel?
|
public var primaryButton: ButtonModel?
|
||||||
public var secondaryButton: ButtonModel?
|
public var secondaryButton: ButtonModel?
|
||||||
@ -28,6 +29,7 @@ public class TwoButtonViewModel: ParentMoleculeModelProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case primaryButton
|
case primaryButton
|
||||||
@ -49,6 +51,7 @@ public class TwoButtonViewModel: ParentMoleculeModelProtocol {
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
|
|
||||||
//set context value for 'primary' style to be set for the primaryButton in case the
|
//set context value for 'primary' style to be set for the primaryButton in case the
|
||||||
@ -66,6 +69,7 @@ public class TwoButtonViewModel: ParentMoleculeModelProtocol {
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encodeIfPresent(primaryButton, forKey: .primaryButton)
|
try container.encodeIfPresent(primaryButton, forKey: .primaryButton)
|
||||||
|
|||||||
@ -10,11 +10,14 @@ import Foundation
|
|||||||
|
|
||||||
public class TwoLinkViewModel: MoleculeModelProtocol {
|
public class TwoLinkViewModel: MoleculeModelProtocol {
|
||||||
public static var identifier: String = "twoLinkView"
|
public static var identifier: String = "twoLinkView"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var rightLink: LinkModel?
|
public var rightLink: LinkModel?
|
||||||
public var leftLink: LinkModel?
|
public var leftLink: LinkModel?
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case rightLink
|
case rightLink
|
||||||
@ -28,6 +31,7 @@ public class TwoLinkViewModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
rightLink = try typeContainer.decodeIfPresent(LinkModel.self, forKey: .rightLink)
|
rightLink = try typeContainer.decodeIfPresent(LinkModel.self, forKey: .rightLink)
|
||||||
leftLink = try typeContainer.decodeIfPresent(LinkModel.self, forKey: .leftLink)
|
leftLink = try typeContainer.decodeIfPresent(LinkModel.self, forKey: .leftLink)
|
||||||
@ -35,6 +39,7 @@ public class TwoLinkViewModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encodeIfPresent(rightLink, forKey: .rightLink)
|
try container.encodeIfPresent(rightLink, forKey: .rightLink)
|
||||||
|
|||||||
@ -11,6 +11,8 @@ import Foundation
|
|||||||
public class ActionDetailWithImageModel: MoleculeModelProtocol {
|
public class ActionDetailWithImageModel: MoleculeModelProtocol {
|
||||||
public static var identifier: String = "actionDetailWithImage"
|
public static var identifier: String = "actionDetailWithImage"
|
||||||
public var moleculeName: String = ActionDetailWithImageModel.identifier
|
public var moleculeName: String = ActionDetailWithImageModel.identifier
|
||||||
|
@DecodableDefault.UUIDString public var id: String
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var headlineBodyButton: HeadlineBodyButtonModel
|
public var headlineBodyButton: HeadlineBodyButtonModel
|
||||||
public var image: ImageViewModel
|
public var image: ImageViewModel
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import MVMCore
|
|||||||
|
|
||||||
public class CornerLabelsModel: ParentMoleculeModelProtocol {
|
public class CornerLabelsModel: ParentMoleculeModelProtocol {
|
||||||
public static var identifier: String = "cornerLabels"
|
public static var identifier: String = "cornerLabels"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var topLeftLabel: LabelModel?
|
public var topLeftLabel: LabelModel?
|
||||||
public var topRightLabel: LabelModel?
|
public var topRightLabel: LabelModel?
|
||||||
@ -26,6 +27,7 @@ public class CornerLabelsModel: ParentMoleculeModelProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case topLeftLabel
|
case topLeftLabel
|
||||||
case topRightLabel
|
case topRightLabel
|
||||||
@ -37,6 +39,7 @@ public class CornerLabelsModel: ParentMoleculeModelProtocol {
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
molecule = try typeContainer.decodeModelIfPresent(codingKey: .molecule)
|
molecule = try typeContainer.decodeModelIfPresent(codingKey: .molecule)
|
||||||
topLeftLabel = try typeContainer.decodeMoleculeIfPresent(codingKey: .topLeftLabel)
|
topLeftLabel = try typeContainer.decodeMoleculeIfPresent(codingKey: .topLeftLabel)
|
||||||
@ -47,6 +50,7 @@ public class CornerLabelsModel: ParentMoleculeModelProtocol {
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encodeModelIfPresent(molecule, forKey: .molecule)
|
try container.encodeModelIfPresent(molecule, forKey: .molecule)
|
||||||
try container.encodeModelIfPresent(topLeftLabel, forKey: .topLeftLabel)
|
try container.encodeModelIfPresent(topLeftLabel, forKey: .topLeftLabel)
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import Foundation
|
|||||||
public class HeadlineBodyLinkToggleModel: MoleculeModelProtocol {
|
public class HeadlineBodyLinkToggleModel: MoleculeModelProtocol {
|
||||||
public static var identifier: String = "headlineBodyLinkToggle"
|
public static var identifier: String = "headlineBodyLinkToggle"
|
||||||
public var moleculeName: String = HeadlineBodyLinkToggleModel.identifier
|
public var moleculeName: String = HeadlineBodyLinkToggleModel.identifier
|
||||||
|
@DecodableDefault.UUIDString public var id: String
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var headlineBodyLink: HeadlineBodyLinkModel
|
public var headlineBodyLink: HeadlineBodyLinkModel
|
||||||
public var toggle: ToggleModel
|
public var toggle: ToggleModel
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import Foundation
|
|||||||
open class HeadlineBodyToggleModel: MoleculeModelProtocol {
|
open class HeadlineBodyToggleModel: MoleculeModelProtocol {
|
||||||
public static var identifier: String = "headlineBodyToggle"
|
public static var identifier: String = "headlineBodyToggle"
|
||||||
public var moleculeName: String = HeadlineBodyToggleModel.identifier
|
public var moleculeName: String = HeadlineBodyToggleModel.identifier
|
||||||
|
@DecodableDefault.UUIDString public var id: String
|
||||||
open var backgroundColor: Color?
|
open var backgroundColor: Color?
|
||||||
open var headlineBody: HeadlineBodyModel
|
open var headlineBody: HeadlineBodyModel
|
||||||
open var toggle: ToggleModel
|
open var toggle: ToggleModel
|
||||||
|
|||||||
@ -12,6 +12,8 @@ import MVMCore
|
|||||||
public class LabelToggleModel: MoleculeModelProtocol {
|
public class LabelToggleModel: MoleculeModelProtocol {
|
||||||
public static var identifier: String = "labelToggle"
|
public static var identifier: String = "labelToggle"
|
||||||
public var moleculeName: String = LabelToggleModel.identifier
|
public var moleculeName: String = LabelToggleModel.identifier
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var label: LabelModel
|
public var label: LabelModel
|
||||||
public var toggle: ToggleModel
|
public var toggle: ToggleModel
|
||||||
@ -22,6 +24,7 @@ public class LabelToggleModel: MoleculeModelProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case label
|
case label
|
||||||
@ -30,6 +33,7 @@ public class LabelToggleModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey:.backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey:.backgroundColor)
|
||||||
label = try typeContainer.decode(LabelModel.self, forKey:.label)
|
label = try typeContainer.decode(LabelModel.self, forKey:.label)
|
||||||
toggle = try typeContainer.decode(ToggleModel.self, forKey:.toggle)
|
toggle = try typeContainer.decode(ToggleModel.self, forKey:.toggle)
|
||||||
@ -38,6 +42,7 @@ public class LabelToggleModel: MoleculeModelProtocol {
|
|||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encode(label, forKey: .label)
|
try container.encode(label, forKey: .label)
|
||||||
try container.encode(toggle, forKey: .toggle)
|
try container.encode(toggle, forKey: .toggle)
|
||||||
|
|||||||
@ -13,9 +13,11 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule
|
|||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
public static var identifier: String = "navigationImageButton"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var accessibilityIdentifier: String?
|
public var accessibilityIdentifier: String?
|
||||||
public static var identifier: String = "navigationImageButton"
|
|
||||||
public var image: String
|
public var image: String
|
||||||
public var action: ActionModelProtocol
|
public var action: ActionModelProtocol
|
||||||
public var accessibilityText: String?
|
public var accessibilityText: String?
|
||||||
@ -35,6 +37,7 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case image
|
case image
|
||||||
case action
|
case action
|
||||||
case accessibilityIdentifier
|
case accessibilityIdentifier
|
||||||
@ -49,6 +52,7 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
||||||
image = try typeContainer.decode(String.self, forKey: .image)
|
image = try typeContainer.decode(String.self, forKey: .image)
|
||||||
action = try typeContainer.decodeModel(codingKey: .action)
|
action = try typeContainer.decodeModel(codingKey: .action)
|
||||||
@ -60,6 +64,7 @@ public class NavigationImageButtonModel: NavigationButtonModelProtocol, Molecule
|
|||||||
|
|
||||||
open func encode(to encoder: Encoder) throws {
|
open func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(image, forKey: .image)
|
try container.encode(image, forKey: .image)
|
||||||
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
|
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
|
|||||||
@ -12,8 +12,10 @@ open class NavigationLabelButtonModel: NavigationButtonModelProtocol, MoleculeMo
|
|||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
open var backgroundColor: Color?
|
|
||||||
open class var identifier: String { "navigationLabelButton" }
|
open class var identifier: String { "navigationLabelButton" }
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
|
open var backgroundColor: Color?
|
||||||
open var accessibilityIdentifier: String?
|
open var accessibilityIdentifier: String?
|
||||||
open var title: String
|
open var title: String
|
||||||
open var action: ActionModelProtocol
|
open var action: ActionModelProtocol
|
||||||
@ -32,6 +34,7 @@ open class NavigationLabelButtonModel: NavigationButtonModelProtocol, MoleculeMo
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case accessibilityIdentifier
|
case accessibilityIdentifier
|
||||||
case title
|
case title
|
||||||
@ -44,6 +47,7 @@ open class NavigationLabelButtonModel: NavigationButtonModelProtocol, MoleculeMo
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
|
||||||
title = try typeContainer.decode(String.self, forKey: .title)
|
title = try typeContainer.decode(String.self, forKey: .title)
|
||||||
action = try typeContainer.decodeModel(codingKey: .action)
|
action = try typeContainer.decodeModel(codingKey: .action)
|
||||||
@ -51,6 +55,7 @@ open class NavigationLabelButtonModel: NavigationButtonModelProtocol, MoleculeMo
|
|||||||
|
|
||||||
open func encode(to encoder: Encoder) throws {
|
open func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
|
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
|
||||||
try container.encode(title, forKey: .title)
|
try container.encode(title, forKey: .title)
|
||||||
|
|||||||
@ -19,6 +19,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
open class var identifier: String { "navigationBar" }
|
open class var identifier: String { "navigationBar" }
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
private let defaultHidesSystemBackButton = true
|
private let defaultHidesSystemBackButton = true
|
||||||
|
|
||||||
@ -74,6 +75,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case title
|
case title
|
||||||
case hidden
|
case hidden
|
||||||
@ -96,6 +98,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
title = try typeContainer.decodeIfPresent(String.self, forKey: .title)
|
title = try typeContainer.decodeIfPresent(String.self, forKey: .title)
|
||||||
if let hidden = try typeContainer.decodeIfPresent(Bool.self, forKey: .hidden) {
|
if let hidden = try typeContainer.decodeIfPresent(Bool.self, forKey: .hidden) {
|
||||||
self.hidden = hidden
|
self.hidden = hidden
|
||||||
@ -122,6 +125,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc
|
|||||||
|
|
||||||
open func encode(to encoder: Encoder) throws {
|
open func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(title, forKey: .title)
|
try container.encodeIfPresent(title, forKey: .title)
|
||||||
try container.encode(hidden, forKey: .hidden)
|
try container.encode(hidden, forKey: .hidden)
|
||||||
|
|||||||
@ -9,11 +9,15 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
open class ModuleMoleculeModel: MoleculeModelProtocol {
|
open class ModuleMoleculeModel: MoleculeModelProtocol {
|
||||||
public var backgroundColor: Color?
|
|
||||||
public static var identifier: String = "moduleMolecule"
|
public static var identifier: String = "moduleMolecule"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
|
public var backgroundColor: Color?
|
||||||
public var moduleName: String
|
public var moduleName: String
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moduleName
|
case moduleName
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,11 +27,13 @@ open class ModuleMoleculeModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
moduleName = try typeContainer.decode(String.self, forKey:.moduleName)
|
moduleName = try typeContainer.decode(String.self, forKey:.moduleName)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moduleName, forKey: .moduleName)
|
try container.encode(moduleName, forKey: .moduleName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -114,7 +114,7 @@ import MVMCore
|
|||||||
|
|
||||||
open func performBlockOperation(with block: @escaping (MVMCoreBlockOperation) -> Void) {
|
open func performBlockOperation(with block: @escaping (MVMCoreBlockOperation) -> Void) {
|
||||||
let operation = MVMCoreBlockOperation(block: block)!
|
let operation = MVMCoreBlockOperation(block: block)!
|
||||||
MVMCoreNavigationHandler.shared()?.addNavigationOperation(operation)
|
NavigationHandler.shared().navigationQueue.addOperation(operation)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Collapses after a delay
|
/// Collapses after a delay
|
||||||
|
|||||||
@ -10,12 +10,16 @@ import Foundation
|
|||||||
import MVMCore
|
import MVMCore
|
||||||
|
|
||||||
public class NotificationXButtonModel: ButtonModelProtocol, MoleculeModelProtocol {
|
public class NotificationXButtonModel: ButtonModelProtocol, MoleculeModelProtocol {
|
||||||
|
|
||||||
public static var identifier: String = "notificationXButton"
|
public static var identifier: String = "notificationXButton"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var color: Color?
|
public var color: Color?
|
||||||
public var action: ActionModelProtocol = ActionNoopModel()
|
public var action: ActionModelProtocol = ActionNoopModel()
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case color
|
case color
|
||||||
case action
|
case action
|
||||||
@ -28,6 +32,7 @@ public class NotificationXButtonModel: ButtonModelProtocol, MoleculeModelProtoco
|
|||||||
|
|
||||||
public required init(from decoder: Decoder) throws {
|
public required init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
color = try typeContainer.decodeIfPresent(Color.self, forKey: .color)
|
color = try typeContainer.decodeIfPresent(Color.self, forKey: .color)
|
||||||
if let action: ActionModelProtocol = try typeContainer.decodeModelIfPresent(codingKey: .action) {
|
if let action: ActionModelProtocol = try typeContainer.decodeModelIfPresent(codingKey: .action) {
|
||||||
self.action = action
|
self.action = action
|
||||||
@ -36,6 +41,7 @@ public class NotificationXButtonModel: ButtonModelProtocol, MoleculeModelProtoco
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(color, forKey: .color)
|
try container.encodeIfPresent(color, forKey: .color)
|
||||||
try container.encodeModel(action, forKey: .action)
|
try container.encodeModel(action, forKey: .action)
|
||||||
|
|||||||
@ -13,6 +13,7 @@ public class EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol, ParentMolecule
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "eyebrowHeadlineBodyLink"
|
public static var identifier: String = "eyebrowHeadlineBodyLink"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
public var moleculeName: String = EyebrowHeadlineBodyLinkModel.identifier
|
public var moleculeName: String = EyebrowHeadlineBodyLinkModel.identifier
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var eyebrow: LabelModel?
|
public var eyebrow: LabelModel?
|
||||||
@ -56,6 +57,7 @@ public class EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol, ParentMolecule
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case eyebrow
|
case eyebrow
|
||||||
@ -70,6 +72,7 @@ public class EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol, ParentMolecule
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow)
|
eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow)
|
||||||
headline = try typeContainer.decodeMoleculeIfPresent(codingKey: .headline)
|
headline = try typeContainer.decodeMoleculeIfPresent(codingKey: .headline)
|
||||||
@ -84,6 +87,7 @@ public class EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol, ParentMolecule
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encodeIfPresent(eyebrow, forKey: .eyebrow)
|
try container.encodeIfPresent(eyebrow, forKey: .eyebrow)
|
||||||
|
|||||||
@ -14,6 +14,8 @@ public class HeadlineBodyButtonModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
public static var identifier: String = "headlineBodyButton"
|
public static var identifier: String = "headlineBodyButton"
|
||||||
public var moleculeName: String = HeadlineBodyButtonModel.identifier
|
public var moleculeName: String = HeadlineBodyButtonModel.identifier
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
|
|
||||||
public var headlineBody: HeadlineBodyModel
|
public var headlineBody: HeadlineBodyModel
|
||||||
@ -45,6 +47,7 @@ public class HeadlineBodyButtonModel: MoleculeModelProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case headlineBody
|
case headlineBody
|
||||||
@ -58,6 +61,7 @@ public class HeadlineBodyButtonModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody)
|
headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody)
|
||||||
button = try typeContainer.decode(ButtonModel.self, forKey: .button)
|
button = try typeContainer.decode(ButtonModel.self, forKey: .button)
|
||||||
@ -67,6 +71,7 @@ public class HeadlineBodyButtonModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encode(headlineBody, forKey: .headlineBody)
|
try container.encode(headlineBody, forKey: .headlineBody)
|
||||||
|
|||||||
@ -16,6 +16,8 @@ public class HeadlineBodyLinkModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
public static var identifier: String = "headlineBodyLink"
|
public static var identifier: String = "headlineBodyLink"
|
||||||
public var moleculeName: String = HeadlineBodyLinkModel.identifier
|
public var moleculeName: String = HeadlineBodyLinkModel.identifier
|
||||||
|
@DecodableDefault.UUIDString public var id: String
|
||||||
|
|
||||||
public var headlineBody: HeadlineBodyModel
|
public var headlineBody: HeadlineBodyModel
|
||||||
public var link: LinkModel
|
public var link: LinkModel
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
public static var identifier: String = "headlineBody"
|
public static var identifier: String = "headlineBody"
|
||||||
public var moleculeName: String = HeadlineBodyModel.identifier
|
public var moleculeName: String = HeadlineBodyModel.identifier
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
public var headline: LabelModel?
|
public var headline: LabelModel?
|
||||||
public var body: LabelModel?
|
public var body: LabelModel?
|
||||||
public var style: Style?
|
public var style: Style?
|
||||||
@ -23,6 +24,15 @@
|
|||||||
[headline, body].compactMap { $0 }
|
[headline, body].compactMap { $0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func replaceChildMolecule(with replacementMolecule: MoleculeModelProtocol) -> Bool {
|
||||||
|
return [
|
||||||
|
\HeadlineBodyModel.headline,
|
||||||
|
\HeadlineBodyModel.body,
|
||||||
|
].contains {
|
||||||
|
replaceChildMolecule(on: self, keyPath: $0, replacementMolecule: replacementMolecule)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Enum
|
// MARK: - Enum
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -57,6 +67,7 @@
|
|||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case headline
|
case headline
|
||||||
case body
|
case body
|
||||||
@ -66,6 +77,7 @@
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
headline = try typeContainer.decodeMoleculeIfPresent(codingKey: .headline)
|
headline = try typeContainer.decodeMoleculeIfPresent(codingKey: .headline)
|
||||||
body = try typeContainer.decodeMoleculeIfPresent(codingKey: .body)
|
body = try typeContainer.decodeMoleculeIfPresent(codingKey: .body)
|
||||||
style = try typeContainer.decodeIfPresent(Style.self, forKey: .style)
|
style = try typeContainer.decodeIfPresent(Style.self, forKey: .style)
|
||||||
@ -74,6 +86,7 @@
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(headline, forKey: .headline)
|
try container.encodeIfPresent(headline, forKey: .headline)
|
||||||
try container.encodeIfPresent(body, forKey: .body)
|
try container.encodeIfPresent(body, forKey: .body)
|
||||||
|
|||||||
@ -13,6 +13,8 @@ public class StringAndMoleculeModel: MoleculeModelProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "stringAndMoleculeModel"
|
public static var identifier: String = "stringAndMoleculeModel"
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var string: String
|
public var string: String
|
||||||
public var molecule: MoleculeModelProtocol
|
public var molecule: MoleculeModelProtocol
|
||||||
@ -33,6 +35,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case string
|
case string
|
||||||
@ -46,6 +49,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
public required init(from decoder: Decoder) throws {
|
public required init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
string = try typeContainer.decode(String.self, forKey: .string)
|
string = try typeContainer.decode(String.self, forKey: .string)
|
||||||
molecule = try typeContainer.decodeModel(codingKey: .molecule)
|
molecule = try typeContainer.decodeModel(codingKey: .molecule)
|
||||||
@ -54,6 +58,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encode(string, forKey: .string)
|
try container.encode(string, forKey: .string)
|
||||||
try container.encodeModel(molecule, forKey: .molecule)
|
try container.encodeModel(molecule, forKey: .molecule)
|
||||||
|
|||||||
@ -16,6 +16,8 @@ public class ThreeHeadlineBodyLinkModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
public static var identifier: String = "threeHeadlineBodyLink"
|
public static var identifier: String = "threeHeadlineBodyLink"
|
||||||
public var moleculeName: String = ThreeHeadlineBodyLinkModel.identifier
|
public var moleculeName: String = ThreeHeadlineBodyLinkModel.identifier
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
|
|
||||||
public var headline1: LabelModel
|
public var headline1: LabelModel
|
||||||
@ -41,6 +43,7 @@ public class ThreeHeadlineBodyLinkModel: MoleculeModelProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case headline1
|
case headline1
|
||||||
@ -56,6 +59,7 @@ public class ThreeHeadlineBodyLinkModel: MoleculeModelProtocol {
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
headline1 = try typeContainer.decode(LabelModel.self, forKey: .headline1)
|
headline1 = try typeContainer.decode(LabelModel.self, forKey: .headline1)
|
||||||
headline2 = try typeContainer.decode(LabelModel.self, forKey: .headline2)
|
headline2 = try typeContainer.decode(LabelModel.self, forKey: .headline2)
|
||||||
@ -67,6 +71,7 @@ public class ThreeHeadlineBodyLinkModel: MoleculeModelProtocol {
|
|||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encode(headline1, forKey: .headline1)
|
try container.encode(headline1, forKey: .headline1)
|
||||||
try container.encode(headline2, forKey: .headline2)
|
try container.encode(headline2, forKey: .headline2)
|
||||||
|
|||||||
@ -19,6 +19,8 @@ import UIKit
|
|||||||
return "carousel"
|
return "carousel"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol]
|
public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol]
|
||||||
public var index: Int = 0
|
public var index: Int = 0
|
||||||
@ -78,6 +80,7 @@ import UIKit
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case molecules
|
case molecules
|
||||||
@ -108,6 +111,7 @@ import UIKit
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
molecules = try typeContainer.decodeModels(codingKey: .molecules)
|
molecules = try typeContainer.decodeModels(codingKey: .molecules)
|
||||||
index = try typeContainer.decodeIfPresent(Int.self, forKey: .index) ?? 0
|
index = try typeContainer.decodeIfPresent(Int.self, forKey: .index) ?? 0
|
||||||
selectable = try typeContainer.decodeIfPresent(Bool.self, forKey: .selectable) ?? false
|
selectable = try typeContainer.decodeIfPresent(Bool.self, forKey: .selectable) ?? false
|
||||||
@ -144,6 +148,7 @@ import UIKit
|
|||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encodeModels(molecules, forKey: .molecules)
|
try container.encodeModels(molecules, forKey: .molecules)
|
||||||
|
|||||||
@ -25,6 +25,15 @@
|
|||||||
return molecules
|
return molecules
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func replaceChildMolecule(with replacementMolecule: MoleculeModelProtocol) -> Bool {
|
||||||
|
guard let replacementMolecule = replacementMolecule as? StackItemModelProtocol & MoleculeModelProtocol else { return false }
|
||||||
|
guard let matchingIndex = molecules.firstIndex(where: { molecule in
|
||||||
|
molecule.id == replacementMolecule.id
|
||||||
|
}) else { return false }
|
||||||
|
molecules[matchingIndex] = replacementMolecule
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializer
|
// MARK: - Initializer
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -5,10 +5,10 @@ public enum MolecularError: Swift.Error {
|
|||||||
case countImbalance(String)
|
case countImbalance(String)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public protocol MoleculeModelProtocol: ModelProtocol, AccessibilityModelProtocol, MoleculeTreeTraversalProtocol, MoleculeMaskingProtocol {
|
public protocol MoleculeModelProtocol: ModelProtocol, AccessibilityModelProtocol, MoleculeTreeTraversalProtocol, MoleculeMaskingProtocol {
|
||||||
var moleculeName: String { get }
|
var moleculeName: String { get }
|
||||||
var backgroundColor: Color? { get set }
|
var backgroundColor: Color? { get set }
|
||||||
|
var id: String { get }
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension MoleculeModelProtocol {
|
public extension MoleculeModelProtocol {
|
||||||
@ -20,7 +20,6 @@ public extension MoleculeModelProtocol {
|
|||||||
static var categoryCodingKey: String { "moleculeName" }
|
static var categoryCodingKey: String { "moleculeName" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Helpers made due to swift not able to reconcile which category.
|
// Helpers made due to swift not able to reconcile which category.
|
||||||
extension KeyedDecodingContainer where Key: CodingKey {
|
extension KeyedDecodingContainer where Key: CodingKey {
|
||||||
/// Decodes to a registered molecule based on the identifier
|
/// Decodes to a registered molecule based on the identifier
|
||||||
@ -53,8 +52,9 @@ public extension MoleculeModelProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Base case. No additional children to traverse.
|
// Base case. No additional children to traverse.
|
||||||
func depthFirstTraverse(options: TreeTraversalOptions, depth: Int, onVisit: (Int, MoleculeModelProtocol)->Void) {
|
func depthFirstTraverse(options: TreeTraversalOptions, depth: Int, onVisit: (Int, MoleculeModelProtocol, inout Bool)->Void) {
|
||||||
onVisit(depth, self)
|
var stop = false
|
||||||
|
onVisit(depth, self, &stop)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ public extension Array where Element == MoleculeModelProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func depthFirstTraverse(options: TreeTraversalOptions, depth: Int, onVisit: (Int, MoleculeModelProtocol)->Void) {
|
func depthFirstTraverse(options: TreeTraversalOptions, depth: Int, onVisit: (Int, MoleculeModelProtocol, inout Bool) -> Void) {
|
||||||
forEach { (molecule) in
|
forEach { (molecule) in
|
||||||
molecule.depthFirstTraverse(options: options, depth: depth, onVisit: onVisit)
|
molecule.depthFirstTraverse(options: options, depth: depth, onVisit: onVisit)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,10 +8,11 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public protocol ParentMoleculeModelProtocol: MoleculeModelProtocol {
|
public protocol ParentMoleculeModelProtocol: MoleculeModelProtocol, AnyObject {
|
||||||
|
|
||||||
var children: [MoleculeModelProtocol] { get }
|
var children: [MoleculeModelProtocol] { get }
|
||||||
|
|
||||||
|
func replaceChildMolecule(with molecule: MoleculeModelProtocol) -> Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension ParentMoleculeModelProtocol {
|
public extension ParentMoleculeModelProtocol {
|
||||||
@ -35,21 +36,44 @@ public extension ParentMoleculeModelProtocol {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func depthFirstTraverse(options: TreeTraversalOptions, depth: Int, onVisit: (Int, MoleculeModelProtocol)->Void) {
|
func depthFirstTraverse(options: TreeTraversalOptions, depth: Int, onVisit: (Int, MoleculeModelProtocol, inout Bool)->Void) {
|
||||||
|
var stop = false
|
||||||
if (options == .parentFirst) {
|
if (options == .parentFirst) {
|
||||||
onVisit(depth, self)
|
onVisit(depth, self, &stop)
|
||||||
|
guard !stop else { return }
|
||||||
}
|
}
|
||||||
children.forEach { (molecule) in
|
for child in children {
|
||||||
if let additionalParent = molecule as? ParentMoleculeModelProtocol {
|
if let additionalParent = child as? ParentMoleculeModelProtocol {
|
||||||
// Safety net to make sure the ParentMoleculeModelProtocol's method extension is called over the base MoleculeModelProtocol.
|
// Safety net to make sure the ParentMoleculeModelProtocol's method extension is called over the base MoleculeModelProtocol.
|
||||||
additionalParent.depthFirstTraverse(options: options, depth: depth + 1, onVisit: onVisit)
|
additionalParent.depthFirstTraverse(options: options, depth: depth + 1, onVisit: onVisit)
|
||||||
} else {
|
} else {
|
||||||
molecule.depthFirstTraverse(options: options, depth: depth + 1, onVisit: onVisit)
|
child.depthFirstTraverse(options: options, depth: depth + 1, onVisit: onVisit)
|
||||||
}
|
}
|
||||||
|
guard !stop else { return }
|
||||||
}
|
}
|
||||||
if (options == .childFirst) {
|
if (options == .childFirst) {
|
||||||
onVisit(depth, self)
|
onVisit(depth, self, &stop)
|
||||||
}
|
}
|
||||||
// if options == .leafOnly don't call on self.
|
// if options == .leafOnly don't call on self.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Top level test to replace child molecules. Each parent molecule should attempt to replace.
|
||||||
|
func replaceChildMolecule(with molecule: MoleculeModelProtocol) -> Bool { return false }
|
||||||
|
|
||||||
|
/// Helper function for replacing molecules on a path.
|
||||||
|
func replaceChildMolecule<P: ParentMoleculeModelProtocol, T: MoleculeModelProtocol>(on target: P, keyPath: ReferenceWritableKeyPath<P, T?>, replacementMolecule: MoleculeModelProtocol) -> Bool {
|
||||||
|
if let currentMolecule = target[keyPath: keyPath], currentMolecule.id == replacementMolecule.id, let newHeadline = replacementMolecule as? T {
|
||||||
|
target[keyPath: keyPath] = newHeadline
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func replaceChildMolecule<P: ParentMoleculeModelProtocol, T: MoleculeModelProtocol>(on target: P, keyPath: ReferenceWritableKeyPath<P, T>, replacementMolecule: MoleculeModelProtocol) -> Bool {
|
||||||
|
if target[keyPath: keyPath].id == replacementMolecule.id, let newHeadline = replacementMolecule as? T {
|
||||||
|
target[keyPath: keyPath] = newHeadline
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,7 @@ public extension TemplateModelProtocol {
|
|||||||
return rootMolecules.reduceDepthFirstTraverse(options: options, depth: depth, initialResult: initialResult, nextPartialResult: nextPartialResult)
|
return rootMolecules.reduceDepthFirstTraverse(options: options, depth: depth, initialResult: initialResult, nextPartialResult: nextPartialResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
func depthFirstTraverse(options: TreeTraversalOptions, depth: Int, onVisit: (Int, MoleculeModelProtocol) -> Void) {
|
func depthFirstTraverse(options: TreeTraversalOptions, depth: Int, onVisit: (Int, MoleculeModelProtocol, inout Bool) -> Void) {
|
||||||
return rootMolecules.depthFirstTraverse(options: options, depth: depth, onVisit: onVisit)
|
return rootMolecules.depthFirstTraverse(options: options, depth: depth, onVisit: onVisit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ public protocol MoleculeTreeTraversalProtocol {
|
|||||||
|
|
||||||
func reduceDepthFirstTraverse<Result>(options: TreeTraversalOptions, depth: Int, initialResult: Result, nextPartialResult: (Result, MoleculeModelProtocol, Int)->Result) -> Result
|
func reduceDepthFirstTraverse<Result>(options: TreeTraversalOptions, depth: Int, initialResult: Result, nextPartialResult: (Result, MoleculeModelProtocol, Int)->Result) -> Result
|
||||||
|
|
||||||
func depthFirstTraverse(options: TreeTraversalOptions, depth: Int, onVisit: (Int, MoleculeModelProtocol)->Void)
|
func depthFirstTraverse(options: TreeTraversalOptions, depth: Int, onVisit: (Int, MoleculeModelProtocol, inout Bool)->Void)
|
||||||
|
|
||||||
//func breadthFirstTraverse()
|
//func breadthFirstTraverse()
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ public extension MoleculeTreeTraversalProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func printMolecules(options: TreeTraversalOptions = .parentFirst) {
|
func printMolecules(options: TreeTraversalOptions = .parentFirst) {
|
||||||
depthFirstTraverse(options: options, depth: 1) { (depth, molecule) in
|
depthFirstTraverse(options: options, depth: 1) { depth, molecule, stop in
|
||||||
print("\(String(repeating: ">>", count: depth)) \"\(molecule.moleculeName)\" [\(molecule)]")
|
print("\(String(repeating: ">>", count: depth)) \"\(molecule.moleculeName)\" [\(molecule)]")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,4 +50,11 @@ public extension MoleculeTreeTraversalProtocol {
|
|||||||
return accumulator
|
return accumulator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func replaceMolecule(with replacementMolecule: MoleculeModelProtocol) {
|
||||||
|
depthFirstTraverse(options: .parentFirst, depth: 0) { depth, molecule, stop in
|
||||||
|
guard let parentMolecule = molecule as? ParentMoleculeModelProtocol else { return }
|
||||||
|
stop = parentMolecule.replaceChildMolecule(with: replacementMolecule)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -183,8 +183,12 @@
|
|||||||
// Returns a gradient lighter color;
|
// Returns a gradient lighter color;
|
||||||
+ (nonnull UIColor *)mfGradientColor:(nullable UIColor *)color;
|
+ (nonnull UIColor *)mfGradientColor:(nullable UIColor *)color;
|
||||||
|
|
||||||
|
// Returns if the color is dark or not
|
||||||
|
- (BOOL)isDark;
|
||||||
|
|
||||||
#pragma mark - Hex String
|
#pragma mark - Hex String
|
||||||
|
|
||||||
+ (nullable NSString *)hexStringForColor:(nonnull UIColor*)color;
|
+ (nullable NSString *)hexStringForColor:(nonnull UIColor*)color;
|
||||||
+ (nonnull UIColor *)mfGetColorForHexWithTransparency:(nonnull NSString *)hexString;
|
+ (nonnull UIColor *)mfGetColorForHexWithTransparency:(nonnull NSString *)hexString;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -389,6 +389,12 @@
|
|||||||
return [UIColor whiteColor];
|
return [UIColor whiteColor];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)isDark {
|
||||||
|
CGFloat greyScale = 0;
|
||||||
|
[self getWhite:&greyScale alpha:nil];
|
||||||
|
return greyScale < 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Hex String
|
#pragma mark - Hex String
|
||||||
|
|
||||||
+ (nullable NSString *)hexStringForColor:(nonnull UIColor*)color {
|
+ (nullable NSString *)hexStringForColor:(nonnull UIColor*)color {
|
||||||
|
|||||||
@ -7,9 +7,12 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
import MVMCore
|
||||||
|
import Combine
|
||||||
|
|
||||||
@objcMembers open class NavigationController: UINavigationController, MVMCoreViewManagerViewControllerProtocol {
|
@objcMembers open class NavigationController: UINavigationController, MVMCoreViewManagerViewControllerProtocol {
|
||||||
public weak var manager: (UIViewController & MVMCoreViewManagerProtocol)?
|
public weak var manager: (UIViewController & MVMCoreViewManagerProtocol)?
|
||||||
|
private var cancellables: Set<AnyCancellable> = []
|
||||||
|
|
||||||
/// Getter for the main navigation controller
|
/// Getter for the main navigation controller
|
||||||
public static func navigationController() -> Self? {
|
public static func navigationController() -> Self? {
|
||||||
@ -20,9 +23,9 @@ import UIKit
|
|||||||
public static func setupNavigationController() -> Self? {
|
public static func setupNavigationController() -> Self? {
|
||||||
let navigationController = self.init()
|
let navigationController = self.init()
|
||||||
MVMCoreUISession.sharedGlobal()?.navigationController = navigationController
|
MVMCoreUISession.sharedGlobal()?.navigationController = navigationController
|
||||||
MVMCoreNavigationHandler.shared()?.viewControllerToPresentOn = navigationController
|
NavigationHandler.shared().viewControllerToPresentOn = navigationController
|
||||||
MVMCoreNavigationHandler.shared()?.navigationController = navigationController
|
NavigationHandler.shared().navigationController = navigationController
|
||||||
MVMCoreNavigationHandler.shared()?.addDelegate(navigationController)
|
navigationController.subscribe()
|
||||||
navigationController.setNavigationBarUI(with: NavigationItemModel())
|
navigationController.setNavigationBarUI(with: NavigationItemModel())
|
||||||
return navigationController
|
return navigationController
|
||||||
}
|
}
|
||||||
@ -34,15 +37,45 @@ import UIKit
|
|||||||
return navigationController
|
return navigationController
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convenience function to return the navigation model of the lowest controller traversing managers if applicable.
|
/** Subscribes for events.
|
||||||
|
Updates the navigation item of the new view controller when one is pushed.
|
||||||
|
Based on ``NavigationItemModelProtocol`` of ``PageProtocol/pageModel``. Traverses the manager for the view controller if necessary.
|
||||||
|
*/
|
||||||
|
@MainActor
|
||||||
|
public func subscribe() {
|
||||||
|
NavigationHandler.shared().onNavigation.sink { [weak self] (event, operation) in
|
||||||
|
guard let self = self,
|
||||||
|
self == operation.navigationType.getNavigationController(),
|
||||||
|
let viewController = NavigationHandler.shared().getViewControllers(for: self).last,
|
||||||
|
let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return }
|
||||||
|
switch event {
|
||||||
|
case .willNavigate:
|
||||||
|
if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) {
|
||||||
|
MVMCoreViewManagerViewControllerProtocolHelper.helpSetManager(self, viewController: controller)
|
||||||
|
}
|
||||||
|
if let model = getNavigationModel(from: newViewController) {
|
||||||
|
self.setNavigationItem(with: model, for: viewController)
|
||||||
|
self.setNavigationBarUI(with: model)
|
||||||
|
}
|
||||||
|
self.manager?.willDisplay?(newViewController)
|
||||||
|
case .didNavigate:
|
||||||
|
self.manager?.displayedViewController?(newViewController)
|
||||||
|
if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) {
|
||||||
|
controller.viewControllerReady?(inManager: self)
|
||||||
|
}
|
||||||
|
@unknown default: break
|
||||||
|
}
|
||||||
|
}.store(in: &cancellables)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convenience function to return the navigation model of the view controller.
|
||||||
public func getNavigationModel(from viewController: UIViewController) -> NavigationItemModelProtocol? {
|
public func getNavigationModel(from viewController: UIViewController) -> NavigationItemModelProtocol? {
|
||||||
return (viewController as? PageProtocol)?.pageModel?.navigationBar
|
return (viewController as? PageProtocol)?.pageModel?.navigationBar
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Verifies the controller is the currently displayed controller.
|
/// Verifies the controller is the currently displayed controller.
|
||||||
public func isDisplayed(viewController: UIViewController) -> Bool {
|
public func isDisplayed(viewController: UIViewController) -> Bool {
|
||||||
guard let topViewController = topViewController,
|
guard viewController == getViewController() else {
|
||||||
viewController == MVMCoreUIUtility.getViewControllerTraversingManagers(topViewController) else {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@ -84,8 +117,10 @@ extension NavigationController: MVMCoreViewManagerProtocol {
|
|||||||
manager?.willDisplay?(viewController)
|
manager?.willDisplay?(viewController)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Updates the navigation item/bar of the current view controller based on the passed in model and view controller.
|
||||||
|
@MainActor
|
||||||
private func updateNavigationView(with model: NavigationItemModelProtocol, for viewController: UIViewController) {
|
private func updateNavigationView(with model: NavigationItemModelProtocol, for viewController: UIViewController) {
|
||||||
guard let topViewController = topViewController else { return }
|
guard let topViewController = NavigationHandler.shared().getViewControllers(for: self).last else { return }
|
||||||
|
|
||||||
setNavigationItem(with: model, for: topViewController, coordinatingWith: viewController as? PageBehaviorHandlerProtocol)
|
setNavigationItem(with: model, for: topViewController, coordinatingWith: viewController as? PageBehaviorHandlerProtocol)
|
||||||
setNavigationBarUI(with: model)
|
setNavigationBarUI(with: model)
|
||||||
@ -99,34 +134,6 @@ extension NavigationController: MVMCoreViewManagerProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension NavigationController: MVMCorePresentationDelegateProtocol {
|
|
||||||
public func navigationController(_ navigationController: UINavigationController, prepareDisplayFor viewController: UIViewController) {
|
|
||||||
if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) {
|
|
||||||
MVMCoreViewManagerViewControllerProtocolHelper.helpSetManager(self, viewController: controller)
|
|
||||||
}
|
|
||||||
guard self == navigationController,
|
|
||||||
let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController),
|
|
||||||
let model = getNavigationModel(from: newViewController) else { return }
|
|
||||||
setNavigationItem(with: model, for: viewController)
|
|
||||||
setNavigationBarUI(with: model)
|
|
||||||
}
|
|
||||||
|
|
||||||
public func navigationController(_ navigationController: UINavigationController, willDisplay viewController: UIViewController) {
|
|
||||||
guard self == navigationController,
|
|
||||||
let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return }
|
|
||||||
manager?.willDisplay?(newViewController)
|
|
||||||
}
|
|
||||||
|
|
||||||
public func navigationController(_ navigationController: UINavigationController, displayedViewController viewController: UIViewController) {
|
|
||||||
guard self == navigationController,
|
|
||||||
let newViewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) else { return }
|
|
||||||
manager?.displayedViewController?(newViewController)
|
|
||||||
if let controller = viewController as? (UIViewController & MVMCoreViewManagerViewControllerProtocol) {
|
|
||||||
controller.viewControllerReady?(inManager: self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension UIColor {
|
extension UIColor {
|
||||||
func image(_ size: CGSize = CGSize(width: 1, height: 1)) -> UIImage {
|
func image(_ size: CGSize = CGSize(width: 1, height: 1)) -> UIImage {
|
||||||
return UIGraphicsImageRenderer(size: size).image { rendererContext in
|
return UIGraphicsImageRenderer(size: size).image { rendererContext in
|
||||||
|
|||||||
@ -7,10 +7,12 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
import MVMCore
|
||||||
|
|
||||||
public extension UINavigationController {
|
public extension UINavigationController {
|
||||||
|
|
||||||
/// Convenience function for setting the navigation item.
|
/// Convenience function for setting the navigation item.
|
||||||
|
@MainActor
|
||||||
func setNavigationItem(with model: NavigationItemModelProtocol, for viewController: UIViewController, coordinatingWith pageBehaviorController: PageBehaviorHandlerProtocol? = nil) {
|
func setNavigationItem(with model: NavigationItemModelProtocol, for viewController: UIViewController, coordinatingWith pageBehaviorController: PageBehaviorHandlerProtocol? = nil) {
|
||||||
|
|
||||||
let behaviorHandler = pageBehaviorController ?? viewController as? PageBehaviorHandlerProtocol;
|
let behaviorHandler = pageBehaviorController ?? viewController as? PageBehaviorHandlerProtocol;
|
||||||
@ -32,13 +34,14 @@ public extension UINavigationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Convenience function for setting the navigation buttons.
|
/// Convenience function for setting the navigation buttons.
|
||||||
|
@MainActor
|
||||||
func setNavigationButtons(with model: NavigationItemModelProtocol, for viewController: UIViewController) {
|
func setNavigationButtons(with model: NavigationItemModelProtocol, for viewController: UIViewController) {
|
||||||
let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject
|
let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject
|
||||||
var leftItems: [UIBarButtonItem] = []
|
var leftItems: [UIBarButtonItem] = []
|
||||||
if model.hidesSystemBackButton,
|
if model.hidesSystemBackButton,
|
||||||
model.alwaysShowBackButton != false {
|
model.alwaysShowBackButton != false {
|
||||||
if let backButtonModel = model.backButton,
|
if let backButtonModel = model.backButton,
|
||||||
MVMCoreNavigationHandler.shared()?.getViewControllers(for: self)?.count ?? 0 > 1 || model.alwaysShowBackButton ?? false {
|
NavigationHandler.shared().getViewControllers(for: self).count > 1 || model.alwaysShowBackButton ?? false {
|
||||||
leftItems.append(backButtonModel.createNavigationItemButton(delegateObject: delegate, additionalData: nil))
|
leftItems.append(backButtonModel.createNavigationItemButton(delegateObject: delegate, additionalData: nil))
|
||||||
}
|
}
|
||||||
if let leftItemModels = model.additionalLeftButtons {
|
if let leftItemModels = model.additionalLeftButtons {
|
||||||
@ -59,6 +62,7 @@ public extension UINavigationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Convenience function for setting the navigation titleView.
|
/// Convenience function for setting the navigation titleView.
|
||||||
|
@MainActor
|
||||||
func setNavigationTitleView(with model: NavigationItemModelProtocol, for viewController: UIViewController, coordinatingWith pageBehaviorController: PageBehaviorHandlerProtocol? = nil) {
|
func setNavigationTitleView(with model: NavigationItemModelProtocol, for viewController: UIViewController, coordinatingWith pageBehaviorController: PageBehaviorHandlerProtocol? = nil) {
|
||||||
guard let titleViewModel = model.titleView else { return }
|
guard let titleViewModel = model.titleView else { return }
|
||||||
|
|
||||||
@ -86,6 +90,7 @@ public extension UINavigationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Convenience function for setting the navigation bar ui
|
/// Convenience function for setting the navigation bar ui
|
||||||
|
@MainActor
|
||||||
func setNavigationBarUI(with model: NavigationItemModelProtocol) {
|
func setNavigationBarUI(with model: NavigationItemModelProtocol) {
|
||||||
let navigationBar = navigationBar
|
let navigationBar = navigationBar
|
||||||
let font = Styler.Font.BoldTitleSmall.getFont(false)
|
let font = Styler.Font.BoldTitleSmall.getFont(false)
|
||||||
@ -113,4 +118,11 @@ public extension UINavigationController {
|
|||||||
|
|
||||||
setNavigationBarHidden(model.hidden, animated: true)
|
setNavigationBarHidden(model.hidden, animated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
func getViewController() -> UIViewController? {
|
||||||
|
guard let topViewController = getViewControllers().last,
|
||||||
|
let viewController = MVMCoreUIUtility.getViewControllerTraversingManagers(topViewController) else { return nil }
|
||||||
|
return viewController
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,8 @@ public protocol StatusBarUI {
|
|||||||
// Navigation bar update functions
|
// Navigation bar update functions
|
||||||
public extension MVMCoreUISplitViewController {
|
public extension MVMCoreUISplitViewController {
|
||||||
|
|
||||||
/// Updates the state for various controls (navigation, tab, progress) for the controller.
|
/// Updates the state for various controls (top navigation controller item, tab, progress) for the controller.
|
||||||
|
@MainActor
|
||||||
func updateState(with viewController: UIViewController) {
|
func updateState(with viewController: UIViewController) {
|
||||||
guard let navigationController = navigationController,
|
guard let navigationController = navigationController,
|
||||||
navigationController.isDisplayed(viewController: viewController) else { return }
|
navigationController.isDisplayed(viewController: viewController) else { return }
|
||||||
@ -30,7 +31,9 @@ public extension MVMCoreUISplitViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Progress Bar
|
// MARK: - Progress Bar
|
||||||
/// Updates the progress bar based on the page json for the view controller.
|
/** Updates the progress bar based on the page json for the view controller.
|
||||||
|
Uses a string value between 0 and 100 from key progressPercent in the MVMCoreViewControllerProtocol.loadObject.pageJSON.
|
||||||
|
*/
|
||||||
func updateProgressBar(for viewController: UIViewController) {
|
func updateProgressBar(for viewController: UIViewController) {
|
||||||
guard let viewController = viewController as? MVMCoreViewControllerProtocol else { return }
|
guard let viewController = viewController as? MVMCoreViewControllerProtocol else { return }
|
||||||
var progress: Float = 0.0
|
var progress: Float = 0.0
|
||||||
@ -42,12 +45,16 @@ public extension MVMCoreUISplitViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Tab Bar
|
// MARK: - Tab Bar
|
||||||
/// Updates the tab bar based on the page json for the view controller.
|
/** Updates the tab bar based on the page json for the view controller.
|
||||||
|
For the index: checks the view controller's pageModel (``PageProtocol``) property ``TabPageModelProtocol/tabBarIndex``, else tabBarIndex in action map that led to this page, else the previous tab bar index of this page.
|
||||||
|
For hidden: checks the view controller's pageModel (``PageProtocol``) property ``TabPageModelProtocol/tabBarHidden``, else tabBarHidden in action map that led to this page, else it is visibile.
|
||||||
|
*/
|
||||||
|
@MainActor
|
||||||
func updateTabBar(for viewController: UIViewController) {
|
func updateTabBar(for viewController: UIViewController) {
|
||||||
let mvmViewController = viewController as? MVMCoreViewControllerProtocol
|
let mvmViewController = viewController as? MVMCoreViewControllerProtocol
|
||||||
tabBar?.delegateObject = mvmViewController?.delegateObject?() as? MVMCoreUIDelegateObject
|
tabBar?.delegateObject = mvmViewController?.delegateObject?() as? MVMCoreUIDelegateObject
|
||||||
|
|
||||||
let navigationIndex = (MVMCoreNavigationHandler.shared()?.getViewControllers(for: navigationController)?.count ?? 1) - 1
|
let navigationIndex = (navigationController != nil ? NavigationHandler.shared().getViewControllers(for: navigationController!).count : 1) - 1
|
||||||
|
|
||||||
// Set the highlighted index. In terms of priority, Page > Action > Previous.
|
// Set the highlighted index. In terms of priority, Page > Action > Previous.
|
||||||
if let index = ((viewController as? PageProtocol)?.pageModel as? TabPageModelProtocol)?.tabBarIndex {
|
if let index = ((viewController as? PageProtocol)?.pageModel as? TabPageModelProtocol)?.tabBarIndex {
|
||||||
@ -80,10 +87,13 @@ public extension MVMCoreUISplitViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Navigation Bar
|
// MARK: - Navigation Bar
|
||||||
/// Convenience function. Sets the navigation and split view properties for the view controller. Panel access is determined if view controller is a detail view protocol.
|
/** Convenience function. Sets the navigation and split view properties for the view controller.
|
||||||
|
Panel access is determined if view controller is a ``MVMCoreUIDetailViewProtocol``
|
||||||
|
*/
|
||||||
|
@MainActor
|
||||||
func setNavigationBar(for viewController: UIViewController, navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol) {
|
func setNavigationBar(for viewController: UIViewController, navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol) {
|
||||||
guard navigationController == self.navigationController,
|
guard navigationController == self.navigationController,
|
||||||
viewController == getCurrentDetailViewController() else {
|
self.navigationController?.isDisplayed(viewController: viewController) == true else {
|
||||||
/// Not the split view navigation controller, skip split functions.
|
/// Not the split view navigation controller, skip split functions.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -97,9 +107,13 @@ public extension MVMCoreUISplitViewController {
|
|||||||
setNavigationIconColor(navigationItemModel.tintColor.uiColor)
|
setNavigationIconColor(navigationItemModel.tintColor.uiColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the left navigation items for the view controller based on model and splitview.
|
/** Sets the left navigation items for the top view controller based on the model and viewController.
|
||||||
|
Panel access is determined if view controller is a ``MVMCoreUIDetailViewProtocol``
|
||||||
|
*/
|
||||||
|
@MainActor
|
||||||
func setLeftNavigationButtons(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol?, viewController: UIViewController) {
|
func setLeftNavigationButtons(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol?, viewController: UIViewController) {
|
||||||
guard let topViewController = navigationController.topViewController else { return }
|
let viewControllers = NavigationHandler.shared().getViewControllers(for: navigationController)
|
||||||
|
guard let topViewController = viewControllers.last else { return }
|
||||||
|
|
||||||
var leftItems: [UIBarButtonItem] = []
|
var leftItems: [UIBarButtonItem] = []
|
||||||
let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject
|
let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject
|
||||||
@ -110,7 +124,7 @@ public extension MVMCoreUISplitViewController {
|
|||||||
if let forceBackButton = navigationItemModel?.alwaysShowBackButton {
|
if let forceBackButton = navigationItemModel?.alwaysShowBackButton {
|
||||||
showBackButton = forceBackButton
|
showBackButton = forceBackButton
|
||||||
} else {
|
} else {
|
||||||
showBackButton = MVMCoreNavigationHandler.shared()?.getViewControllers(for: navigationController)?.count ?? 0 > 1
|
showBackButton = viewControllers.count > 1
|
||||||
}
|
}
|
||||||
if showBackButton {
|
if showBackButton {
|
||||||
if let backButtonModel = navigationItemModel?.backButton {
|
if let backButtonModel = navigationItemModel?.backButton {
|
||||||
@ -144,9 +158,12 @@ public extension MVMCoreUISplitViewController {
|
|||||||
topViewController.navigationItem.setLeftBarButtonItems(leftItems.count > 0 ? leftItems : nil, animated: !DisableAnimations.boolValue)
|
topViewController.navigationItem.setLeftBarButtonItems(leftItems.count > 0 ? leftItems : nil, animated: !DisableAnimations.boolValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the right navigation items for the view controller based on model and splitview.
|
/** Sets the right navigation items for the top view controller based on the model and viewController.
|
||||||
|
Panel access is determined if view controller is a ``MVMCoreUIDetailViewProtocol``
|
||||||
|
*/
|
||||||
|
@MainActor
|
||||||
func setRightNavigationButtons(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol?, viewController: UIViewController) {
|
func setRightNavigationButtons(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol?, viewController: UIViewController) {
|
||||||
guard let topViewController = navigationController.topViewController else { return }
|
guard let topViewController = NavigationHandler.shared().getViewControllers(for: navigationController).last else { return }
|
||||||
|
|
||||||
let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject
|
let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject
|
||||||
var rightItems: [UIBarButtonItem] = []
|
var rightItems: [UIBarButtonItem] = []
|
||||||
@ -173,6 +190,9 @@ public extension MVMCoreUISplitViewController {
|
|||||||
topViewController.navigationItem.setRightBarButtonItems(rightItems.count > 0 ? rightItems : nil, animated: !DisableAnimations.boolValue)
|
topViewController.navigationItem.setRightBarButtonItems(rightItems.count > 0 ? rightItems : nil, animated: !DisableAnimations.boolValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** If the current detail view controller has a navigation model.
|
||||||
|
``NavigationController/getNavigationModel(from:)`` from ``getCurrentDetailViewController()``
|
||||||
|
*/
|
||||||
@objc func navigationBarModelExists() -> Bool {
|
@objc func navigationBarModelExists() -> Bool {
|
||||||
// Legacy Navigation
|
// Legacy Navigation
|
||||||
guard let currentViewController = getCurrentDetailViewController(),
|
guard let currentViewController = getCurrentDetailViewController(),
|
||||||
@ -180,8 +200,9 @@ public extension MVMCoreUISplitViewController {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convenience function to update the navigation bar if the controller is the current lowest controller.
|
/// Convenience function to update the navigation bar if the controller is the current detail controller.
|
||||||
@objc func updateNavigationBarFor(viewController: UIViewController) {
|
@MainActor @objc
|
||||||
|
func updateNavigationBarFor(viewController: UIViewController) {
|
||||||
guard let navigationController = navigationController,
|
guard let navigationController = navigationController,
|
||||||
navigationController.isDisplayed(viewController: viewController),
|
navigationController.isDisplayed(viewController: viewController),
|
||||||
let model = navigationController.getNavigationModel(from: viewController) else { return }
|
let model = navigationController.getNavigationModel(from: viewController) else { return }
|
||||||
@ -201,9 +222,13 @@ public extension MVMCoreUISplitViewController {
|
|||||||
return .default
|
return .default
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the status bar background color and style.
|
/** Updates the status bar background color and style for the passed view controller.
|
||||||
@objc func setStatusBarForCurrentViewController() {
|
The background color is fetched from ``MVMCoreUIDetailViewProtocol/defaultStatusBarBackgroundColor()``, else the current navigation bar background, else the current status bar background color.
|
||||||
let viewController = getCurrentViewController() as? MVMCoreUIDetailViewProtocol
|
The backgroundStytle is fetched from ``MVMCoreUIDetailViewProtocol/defaultStatusBarStyle()`` else ``getStatusBarStyle(for:)``
|
||||||
|
*/
|
||||||
|
@MainActor
|
||||||
|
func setStatusBar(for viewController: UIViewController?) {
|
||||||
|
let viewController = viewController as? MVMCoreUIDetailViewProtocol
|
||||||
let backgroundColor = viewController?.defaultStatusBarBackgroundColor?() ??
|
let backgroundColor = viewController?.defaultStatusBarBackgroundColor?() ??
|
||||||
navigationController?.navigationBar.standardAppearance.backgroundColor ??
|
navigationController?.navigationBar.standardAppearance.backgroundColor ??
|
||||||
statusBarView?.backgroundColor
|
statusBarView?.backgroundColor
|
||||||
@ -213,6 +238,14 @@ public extension MVMCoreUISplitViewController {
|
|||||||
|
|
||||||
setStatusBarBackgroundColor(backgroundColor, style: style)
|
setStatusBarBackgroundColor(backgroundColor, style: style)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Updates the status bar background color and style for the current view controller.
|
||||||
|
See ``setStatusBar(for:)``
|
||||||
|
*/
|
||||||
|
@MainActor
|
||||||
|
@objc func setStatusBarForCurrentViewController() {
|
||||||
|
setStatusBar(for: getCurrentViewController())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension MVMCoreUISplitViewController: MVMCoreViewManagerProtocol {
|
extension MVMCoreUISplitViewController: MVMCoreViewManagerProtocol {
|
||||||
@ -235,6 +268,17 @@ extension MVMCoreUISplitViewController: MVMCoreViewManagerProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc public extension MVMCoreUISplitViewController {
|
@objc public extension MVMCoreUISplitViewController {
|
||||||
|
@objc func goBack() {
|
||||||
|
Task(priority: .userInitiated) { @MainActor in
|
||||||
|
if let viewController = getCurrentDetailViewController() as? MVMCoreUIDetailViewProtocol,
|
||||||
|
let backButtonPressed = viewController.backButtonPressed {
|
||||||
|
backButtonPressed()
|
||||||
|
} else {
|
||||||
|
await NavigationHandler.shared().popTopViewController()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Subscribes for notification events.
|
/// Subscribes for notification events.
|
||||||
@objc func subscribeForNotifications() {
|
@objc func subscribeForNotifications() {
|
||||||
guard cancellables == nil else { return }
|
guard cancellables == nil else { return }
|
||||||
|
|||||||
@ -7,7 +7,6 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "MVMCoreUISplitViewController.h"
|
#import "MVMCoreUISplitViewController.h"
|
||||||
@import MVMCore.MVMCoreNavigationHandler;
|
|
||||||
@import MVMCore.MVMCoreDispatchUtility;
|
@import MVMCore.MVMCoreDispatchUtility;
|
||||||
@import MVMCore.MVMCoreViewManagerProtocol;
|
@import MVMCore.MVMCoreViewManagerProtocol;
|
||||||
@import MVMCore.MVMCoreActionUtility;
|
@import MVMCore.MVMCoreActionUtility;
|
||||||
@ -192,14 +191,7 @@ CGFloat const PanelAnimationDuration = 0.2;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)backButtonPressed:(id)sender {
|
- (IBAction)backButtonPressed:(id)sender {
|
||||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
[self goBack];
|
||||||
UIViewController *detailViewController = [self getCurrentDetailViewController];
|
|
||||||
if ([detailViewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)] && [detailViewController respondsToSelector:@selector(backButtonPressed)]) {
|
|
||||||
[((UIViewController <MVMCoreUIDetailViewProtocol> *)detailViewController) backButtonPressed];
|
|
||||||
} else {
|
|
||||||
[[MVMCoreNavigationHandler sharedNavigationHandler] popTopViewControllerAnimated:YES];
|
|
||||||
}
|
|
||||||
}];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)rightPanelButtonPressed:(id)sender {
|
- (IBAction)rightPanelButtonPressed:(id)sender {
|
||||||
@ -258,7 +250,7 @@ CGFloat const PanelAnimationDuration = 0.2;
|
|||||||
|
|
||||||
- (void)setLeftNavigationItemForViewController:(UIViewController * _Nonnull)viewController accessible:(BOOL)accessible extended:(BOOL)extended {
|
- (void)setLeftNavigationItemForViewController:(UIViewController * _Nonnull)viewController accessible:(BOOL)accessible extended:(BOOL)extended {
|
||||||
NSMutableArray *leftBarButtonItems = [NSMutableArray array];
|
NSMutableArray *leftBarButtonItems = [NSMutableArray array];
|
||||||
if (self.navigationController && [MVMCoreNavigationHandler.sharedNavigationHandler getViewControllersForNavigationController:self.navigationController].count > 1) {
|
if (self.navigationController && [self.navigationController getViewControllers].count > 1) {
|
||||||
[leftBarButtonItems addObject:self.backButton];
|
[leftBarButtonItems addObject:self.backButton];
|
||||||
}
|
}
|
||||||
if ((accessible && !extended) && self.leftPanelButton) {
|
if ((accessible && !extended) && self.leftPanelButton) {
|
||||||
@ -1074,7 +1066,7 @@ CGFloat const PanelAnimationDuration = 0.2;
|
|||||||
|
|
||||||
// Returns the desired view or falls back. Hot fix until we can get away from using these functions...
|
// Returns the desired view or falls back. Hot fix until we can get away from using these functions...
|
||||||
+ (CGRect)getBounds:(UIView *)desiredView {
|
+ (CGRect)getBounds:(UIView *)desiredView {
|
||||||
UIView *view = desiredView ?: [MVMCoreNavigationHandler sharedNavigationHandler].navigationController.view ?: [MVMCoreGetterUtility getKeyWindow].rootViewController.view;
|
UIView *view = desiredView ?: [self mainSplitViewController].navigationController.view ?: [MVMCoreGetterUtility getKeyWindow].rootViewController.view;
|
||||||
return view ? view.bounds : [UIScreen mainScreen].bounds;
|
return view ? view.bounds : [UIScreen mainScreen].bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1099,17 +1091,7 @@ CGFloat const PanelAnimationDuration = 0.2;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (UIViewController *)getCurrentVisibleController {
|
- (UIViewController *)getCurrentVisibleController {
|
||||||
UIViewController *baseViewController = [MVMCoreNavigationHandler sharedNavigationHandler].viewControllerToPresentOn ?: [MVMCoreGetterUtility getKeyWindow].rootViewController;
|
return [MVMCoreUIUtility getCurrentVisibleController];
|
||||||
UIViewController *viewController = nil;
|
|
||||||
while (baseViewController.presentedViewController && !baseViewController.presentedViewController.isBeingDismissed) {
|
|
||||||
viewController = baseViewController.presentedViewController;
|
|
||||||
baseViewController = viewController;
|
|
||||||
}
|
|
||||||
// if it is not presented viewcontroller, existing BAU logic will be working
|
|
||||||
if (!viewController) {
|
|
||||||
viewController = [MVMCoreUIUtility getViewControllerTraversingManagers:self.navigationController.topViewController];
|
|
||||||
}
|
|
||||||
return viewController;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (UIViewController *)getCurrentDetailViewController {
|
- (UIViewController *)getCurrentDetailViewController {
|
||||||
|
|||||||
@ -13,6 +13,8 @@ open class ContainerModel: ContainerModelProtocol, Codable {
|
|||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
public var id: String = UUID().uuidString
|
||||||
|
|
||||||
public var horizontalAlignment: UIStackView.Alignment?
|
public var horizontalAlignment: UIStackView.Alignment?
|
||||||
public var useHorizontalMargins: Bool?
|
public var useHorizontalMargins: Bool?
|
||||||
public var leftPadding: CGFloat?
|
public var leftPadding: CGFloat?
|
||||||
@ -30,6 +32,7 @@ open class ContainerModel: ContainerModelProtocol, Codable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case id
|
||||||
case horizontalAlignment
|
case horizontalAlignment
|
||||||
case useHorizontalMargins
|
case useHorizontalMargins
|
||||||
case leftPadding
|
case leftPadding
|
||||||
@ -74,6 +77,9 @@ open class ContainerModel: ContainerModelProtocol, Codable {
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
|
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
|
|
||||||
if let verticalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .verticalAlignment) {
|
if let verticalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .verticalAlignment) {
|
||||||
verticalAlignment = ContainerHelper.getAlignment(for: verticalAlignmentString)
|
verticalAlignment = ContainerHelper.getAlignment(for: verticalAlignmentString)
|
||||||
}
|
}
|
||||||
@ -92,6 +98,7 @@ open class ContainerModel: ContainerModelProtocol, Codable {
|
|||||||
|
|
||||||
open func encode(to encoder: Encoder) throws {
|
open func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(id, forKey: .id)
|
||||||
try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: verticalAlignment), forKey: .verticalAlignment)
|
try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: verticalAlignment), forKey: .verticalAlignment)
|
||||||
try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: horizontalAlignment), forKey: .horizontalAlignment)
|
try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: horizontalAlignment), forKey: .horizontalAlignment)
|
||||||
try container.encodeIfPresent(useHorizontalMargins, forKey: .useHorizontalMargins)
|
try container.encodeIfPresent(useHorizontalMargins, forKey: .useHorizontalMargins)
|
||||||
|
|||||||
@ -205,7 +205,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func navigationController(_ navigationController: UINavigationController, interactionControllerForAnimationController animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
|
public func navigationController(_ navigationController: UINavigationController, interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
|
||||||
// Only percent interact if we've already loaded the view controller
|
// Only percent interact if we've already loaded the view controller
|
||||||
guard let customInteractor = customInteractor,
|
guard let customInteractor = customInteractor,
|
||||||
let index = index,
|
let index = index,
|
||||||
@ -229,7 +229,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol,
|
|||||||
hideNavigationBarLine(true)
|
hideNavigationBarLine(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func navigationController(_ navigationController: UINavigationController, willDisplay viewController: UIViewController) {
|
public func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
|
||||||
guard navigationController == subNavigationController else { return }
|
guard navigationController == subNavigationController else { return }
|
||||||
|
|
||||||
if let viewController = viewController as? UIViewController & MVMCoreViewManagerViewControllerProtocol & MVMCoreViewControllerProtocol {
|
if let viewController = viewController as? UIViewController & MVMCoreViewManagerViewControllerProtocol & MVMCoreViewControllerProtocol {
|
||||||
@ -247,7 +247,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol,
|
|||||||
commitTo(controller: viewController)
|
commitTo(controller: viewController)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func navigationController(_ navigationController: UINavigationController, displayedViewController viewController: UIViewController) {
|
public func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
|
||||||
guard navigationController == subNavigationController else { return }
|
guard navigationController == subNavigationController else { return }
|
||||||
// Need to track swipe action.
|
// Need to track swipe action.
|
||||||
if needToTrackTabSelect {
|
if needToTrackTabSelect {
|
||||||
@ -272,7 +272,9 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol,
|
|||||||
if let controller = viewControllers[indexPath.row] {
|
if let controller = viewControllers[indexPath.row] {
|
||||||
// Load controller from the cache
|
// Load controller from the cache
|
||||||
needToTrackTabSelect = true
|
needToTrackTabSelect = true
|
||||||
MVMCoreNavigationHandler.shared()?.replaceTopViewController(with: controller, navigationController: subNavigationController, animated: true, delegate: self, replaceInStack: false, completionHandler: nil)
|
Task(priority: .userInitiated) {
|
||||||
|
await NavigationHandler.shared().replace(viewController: controller, navigationController:subNavigationController, delegateObject:delegateObject(), tryToReplace: false, animated: true)
|
||||||
|
}
|
||||||
} else if let tabsModel = tabs.tabsModel,
|
} else if let tabsModel = tabs.tabsModel,
|
||||||
let action = tabsModel.tabs[indexPath.row].action {
|
let action = tabsModel.tabs[indexPath.row].action {
|
||||||
// Perform the tab action
|
// Perform the tab action
|
||||||
|
|||||||
@ -268,7 +268,7 @@ public class NotificationOperation: MVMCoreOperation {
|
|||||||
}
|
}
|
||||||
})!
|
})!
|
||||||
transitionOperation.completionBlock = completionBlock
|
transitionOperation.completionBlock = completionBlock
|
||||||
MVMCoreNavigationHandler.shared()?.addNavigationOperation(transitionOperation)
|
NavigationHandler.shared().navigationQueue.addOperation(transitionOperation)
|
||||||
return transitionOperation
|
return transitionOperation
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,6 +314,8 @@ open class NotificationHandler {
|
|||||||
|
|
||||||
private var transitionDelegate: NotificationTransitionDelegateProtocol
|
private var transitionDelegate: NotificationTransitionDelegateProtocol
|
||||||
|
|
||||||
|
private var cancellable: Cancellable?
|
||||||
|
|
||||||
// MARK: - Publishers
|
// MARK: - Publishers
|
||||||
|
|
||||||
/// Publishes when a notification will show.
|
/// Publishes when a notification will show.
|
||||||
@ -354,7 +356,27 @@ open class NotificationHandler {
|
|||||||
|
|
||||||
/// Registers to know when pages change.
|
/// Registers to know when pages change.
|
||||||
private func registerForPageChanges() {
|
private func registerForPageChanges() {
|
||||||
MVMCoreNavigationHandler.shared()?.addDelegate(self)
|
cancellable = NavigationHandler.shared().onNavigation
|
||||||
|
.filter({ $0.0 == .didNavigate })
|
||||||
|
.sink { [weak self] (event, operation) in
|
||||||
|
guard let self = self else { return }
|
||||||
|
Task {
|
||||||
|
// Update displayable for each top alert operation when page type changes, in top queue priority order.
|
||||||
|
guard self.queue.operations.count > 0,
|
||||||
|
let navigationController = await operation.navigationType.getNavigationController(),
|
||||||
|
await navigationController == MVMCoreUISplitViewController.main()?.navigationController,
|
||||||
|
let viewController = await navigationController.getViewController() else { return }
|
||||||
|
let pageType = (viewController as? MVMCoreViewControllerProtocol)?.pageType
|
||||||
|
self.queue.operations.compactMap {
|
||||||
|
$0 as? NotificationOperation
|
||||||
|
}.sorted {
|
||||||
|
$0.notificationModel.priority.rawValue > $1.notificationModel.priority.rawValue
|
||||||
|
}.forEach {
|
||||||
|
$0.updateDisplayable(by: pageType)
|
||||||
|
}
|
||||||
|
self.reevaluteQueue()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks for new top alert json
|
/// Checks for new top alert json
|
||||||
@ -534,26 +556,6 @@ open class NotificationHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension NotificationHandler: MVMCorePresentationDelegateProtocol {
|
|
||||||
// Update displayable for each top alert operation when page type changes, in top queue priority order.
|
|
||||||
public func navigationController(_ navigationController: UINavigationController, displayedViewController viewController: UIViewController) {
|
|
||||||
guard queue.operations.count > 0 else { return }
|
|
||||||
let viewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController)
|
|
||||||
guard viewController == MVMCoreUISplitViewController.main()?.getCurrentViewController() else { return }
|
|
||||||
let pageType = (viewController as? MVMCoreViewControllerProtocol)?.pageType
|
|
||||||
Task {
|
|
||||||
queue.operations.compactMap {
|
|
||||||
$0 as? NotificationOperation
|
|
||||||
}.sorted {
|
|
||||||
$0.notificationModel.priority.rawValue > $1.notificationModel.priority.rawValue
|
|
||||||
}.forEach {
|
|
||||||
$0.updateDisplayable(by: pageType)
|
|
||||||
}
|
|
||||||
reevaluteQueue()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension NotificationOperation {
|
extension NotificationOperation {
|
||||||
/// Updates the operation and notification with the new model.
|
/// Updates the operation and notification with the new model.
|
||||||
public func update(with model: NotificationModel, delegateObject: MVMCoreUIDelegateObject?) {
|
public func update(with model: NotificationModel, delegateObject: MVMCoreUIDelegateObject?) {
|
||||||
@ -562,7 +564,9 @@ extension NotificationOperation {
|
|||||||
guard isExecuting,
|
guard isExecuting,
|
||||||
!isCancelled else { return }
|
!isCancelled else { return }
|
||||||
self.log(message: "Operation Updated")
|
self.log(message: "Operation Updated")
|
||||||
updateStopTimer()
|
displayableQueue.async(flags: .barrier) { [self] in
|
||||||
|
updateStopTimer()
|
||||||
|
}
|
||||||
Task {
|
Task {
|
||||||
await transitionDelegate.update(with: notificationModel, delegateObject: delegateObject)
|
await transitionDelegate.update(with: notificationModel, delegateObject: delegateObject)
|
||||||
NotificationHandler.shared()?.onNotificationUpdated.send((notification, notificationModel))
|
NotificationHandler.shared()?.onNotificationUpdated.send((notification, notificationModel))
|
||||||
|
|||||||
@ -9,19 +9,22 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
import MVMCore
|
import MVMCore
|
||||||
|
|
||||||
@objcMembers open class CoreUIObject: MVMCoreObject {
|
@objcMembers
|
||||||
|
public class CoreUIObject: NSObject {
|
||||||
|
private static var singleton = CoreUIObject()
|
||||||
|
public static func sharedInstance() -> CoreUIObject? { singleton }
|
||||||
|
private override init() {}
|
||||||
|
|
||||||
public var alertHandler: AlertHandler?
|
public var alertHandler: AlertHandler?
|
||||||
public var topNotificationHandler: NotificationHandler?
|
public var topNotificationHandler: NotificationHandler?
|
||||||
|
|
||||||
open override func defaultInitialSetup() {
|
public func defaultInitialSetup() {
|
||||||
|
MVMCoreObject.sharedInstance()?.defaultInitialSetup()
|
||||||
CoreUIModelMapping.registerObjects()
|
CoreUIModelMapping.registerObjects()
|
||||||
loadHandler = MVMCoreLoadHandler()
|
MVMCoreObject.sharedInstance()?.session = MVMCoreUISession()
|
||||||
cache = MVMCoreCache()
|
MVMCoreObject.sharedInstance()?.actionHandler = MVMCoreUIActionHandler()
|
||||||
session = MVMCoreUISession()
|
MVMCoreObject.sharedInstance()?.viewControllerMapping = MVMCoreUIViewControllerMappingObject()
|
||||||
sessionHandler = MVMCoreSessionTimeHandler()
|
MVMCoreObject.sharedInstance()?.loggingDelegate = MVMCoreUILoggingHandler()
|
||||||
actionHandler = MVMCoreUIActionHandler()
|
|
||||||
viewControllerMapping = MVMCoreUIViewControllerMappingObject()
|
|
||||||
loggingDelegate = MVMCoreUILoggingHandler()
|
|
||||||
alertHandler = AlertHandler()
|
alertHandler = AlertHandler()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,6 +57,8 @@ import SafariServices
|
|||||||
@MainActor
|
@MainActor
|
||||||
open func openURL(inSafariWebView url: URL) {
|
open func openURL(inSafariWebView url: URL) {
|
||||||
let safariViewController = SFSafariViewController(url: url)
|
let safariViewController = SFSafariViewController(url: url)
|
||||||
MVMCoreNavigationHandler.shared()?.present(safariViewController, animated: true)
|
Task(priority: .high) {
|
||||||
|
await NavigationHandler.shared().present(viewController: safariViewController)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,8 @@
|
|||||||
#import "MVMCoreUISession.h"
|
#import "MVMCoreUISession.h"
|
||||||
#import "MFLoadingViewController.h"
|
#import "MFLoadingViewController.h"
|
||||||
#import "NSLayoutConstraint+MFConvenience.h"
|
#import "NSLayoutConstraint+MFConvenience.h"
|
||||||
@import MVMCore.MVMCoreObject;
|
@import MVMCore.MVMCoreLoadingOverlayDelegateProtocol;
|
||||||
|
@import MVMCore.Swift;
|
||||||
|
|
||||||
@interface MVMCoreUISession () <MVMCoreLoadingOverlayDelegateProtocol>
|
@interface MVMCoreUISession () <MVMCoreLoadingOverlayDelegateProtocol>
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
import MVMCore
|
||||||
|
|
||||||
public extension MVMCoreUIUtility {
|
public extension MVMCoreUIUtility {
|
||||||
|
|
||||||
@ -66,3 +66,25 @@ public extension MVMCoreUIUtility {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc
|
||||||
|
public extension MVMCoreUIUtility {
|
||||||
|
@objc @MainActor
|
||||||
|
static func getVisibleViewController() -> UIViewController? {
|
||||||
|
var viewController = NavigationHandler.shared().getViewControllerToPresentOn()
|
||||||
|
while let presentedController = viewController?.presentedViewController,
|
||||||
|
!presentedController.isBeingDismissed {
|
||||||
|
viewController = presentedController
|
||||||
|
}
|
||||||
|
if let navigationController = viewController as? UINavigationController {
|
||||||
|
viewController = navigationController.topViewController
|
||||||
|
}
|
||||||
|
if let viewController = viewController {
|
||||||
|
return getViewControllerTraversingManagers(viewController)
|
||||||
|
} else if let viewController = MVMCoreUISession.sharedGlobal()?.navigationController?.topViewController {
|
||||||
|
return getViewControllerTraversingManagers(viewController)
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -11,7 +11,6 @@
|
|||||||
#import "MVMCoreUISession.h"
|
#import "MVMCoreUISession.h"
|
||||||
#import "MVMCoreUISplitViewController.h"
|
#import "MVMCoreUISplitViewController.h"
|
||||||
#import <MVMCoreUI/MVMCoreUI-Swift.h>
|
#import <MVMCoreUI/MVMCoreUI-Swift.h>
|
||||||
@import MVMCore.MVMCoreNavigationHandler;
|
|
||||||
@import MVMCore.MVMCoreGetterUtility;
|
@import MVMCore.MVMCoreGetterUtility;
|
||||||
|
|
||||||
@implementation MVMCoreUIUtility
|
@implementation MVMCoreUIUtility
|
||||||
@ -52,19 +51,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
+ (UIViewController *)getCurrentVisibleController {
|
+ (UIViewController *)getCurrentVisibleController {
|
||||||
UIViewController *baseViewController = [MVMCoreNavigationHandler sharedNavigationHandler].viewControllerToPresentOn ?: [MVMCoreGetterUtility getKeyWindow].rootViewController;
|
__block UIViewController *viewController = nil;
|
||||||
UIViewController *viewController = nil;
|
[MVMCoreDispatchUtility performSyncBlockOnMainThread:^{
|
||||||
while (baseViewController.presentedViewController && !baseViewController.presentedViewController.isBeingDismissed) {
|
viewController = [self getVisibleViewController];
|
||||||
viewController = baseViewController.presentedViewController;
|
}];
|
||||||
baseViewController = viewController;
|
|
||||||
}
|
|
||||||
if ([viewController isKindOfClass:[UINavigationController class]]) {
|
|
||||||
viewController = ((UINavigationController *)viewController).topViewController;
|
|
||||||
}
|
|
||||||
// if it is not presented viewcontroller, existing BAU logic will be working
|
|
||||||
if (!viewController) {
|
|
||||||
viewController = [self getViewControllerTraversingManagers:[MVMCoreUISession sharedGlobal].navigationController.topViewController];
|
|
||||||
}
|
|
||||||
return viewController;
|
return viewController;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user