diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift index 2eefd716..191ee0f1 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift @@ -262,17 +262,12 @@ open class BarsIndicatorView: CarouselIndicator { refreshAccessibilityLabels() } - let expression = { [self] in - barReferences[previousIndex].backgroundColor = isEnabled ? indicatorColor : disabledIndicatorColor - barReferences[previousIndex].constraint?.constant = IndicatorBar.unselectedHeight - barReferences[previousIndex].layer.cornerRadius = IndicatorBar.unselectedCornerRadius - barReferences[newIndex].backgroundColor = isEnabled ? currentIndicatorColor : disabledIndicatorColor - barReferences[newIndex].constraint?.constant = IndicatorBar.selectedHeight - barReferences[newIndex].layer.cornerRadius = IndicatorBar.selectedCornerRadius - layoutIfNeeded() - } - - // Perform the animation. - isAnimated ? UIView.animate(withDuration: 0.25) { expression() } : expression() + barReferences[previousIndex].backgroundColor = isEnabled ? indicatorColor : disabledIndicatorColor + barReferences[previousIndex].constraint?.constant = IndicatorBar.unselectedHeight + barReferences[previousIndex].layer.cornerRadius = IndicatorBar.unselectedCornerRadius + barReferences[newIndex].backgroundColor = isEnabled ? currentIndicatorColor : disabledIndicatorColor + barReferences[newIndex].constraint?.constant = IndicatorBar.selectedHeight + barReferences[newIndex].layer.cornerRadius = IndicatorBar.selectedCornerRadius + layoutIfNeeded() } } diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index 18aa904e..197c4f9f 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -23,10 +23,21 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc open var title: String? open var hidden: Bool? - open var line: LineModel? open var hidesSystemBackButton: Bool? open var style: NavigationItemStyle? + open var _line: LineModel? + open var line: LineModel? { + get { + let line = _line ?? LineModel(type: .secondary) + line.inverted = style == .dark + return line + } + set { + _line = newValue + } + } + open var _backgroundColor: Color? open var backgroundColor: Color? { get { @@ -100,7 +111,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc hidden = try typeContainer.decodeIfPresent(Bool.self, forKey: .hidden) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) _tintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .tintColor) - line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) + _line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) hidesSystemBackButton = try typeContainer.decodeIfPresent(Bool.self, forKey: .hidesSystemBackButton) alwaysShowBackButton = try typeContainer.decodeIfPresent(Bool.self, forKey: .alwaysShowBackButton) backButton = try typeContainer.decodeModelIfPresent(codingKey: .backButton) @@ -119,7 +130,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc try container.encodeIfPresent(hidden, forKey: .hidden) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(_tintColor, forKey: .tintColor) - try container.encodeIfPresent(line, forKey: .line) + try container.encodeIfPresent(_line, forKey: .line) try container.encodeIfPresent(hidesSystemBackButton, forKey: .hidesSystemBackButton) try container.encodeIfPresent(alwaysShowBackButton, forKey: .alwaysShowBackButton) try container.encodeModelIfPresent(backButton, forKey: .backButton) diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeView.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeView.swift index 414d3dfa..13cdc73d 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeView.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeView.swift @@ -46,7 +46,7 @@ import VDS self.accessibilityIdentifier = accessibilityIdentifier } - if var closeButton = viewModel.closeButton { + if let closeButton = viewModel.closeButton { onCloseClick = { [weak self] _ in guard let self else { return } if closeButton.action.actionType == ActionNoopModel.identifier { diff --git a/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift b/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift index 7035ab75..4e1c9ba4 100644 --- a/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/StackPageTemplateModel.swift @@ -20,8 +20,10 @@ } public override func replaceChildMolecule(with molecule: MoleculeModelProtocol) throws -> MoleculeModelProtocol? { + if let replacedMolecule = try super.replaceChildMolecule(with: molecule) { + return replacedMolecule + } var replacedMolecule: MoleculeModelProtocol? - return try super.replaceChildMolecule(with: molecule) if try replaceChildMolecule(at: &navigationBar, with: molecule, replaced: &replacedMolecule) || replaceChildMolecule(at: &moleculeStack, with: molecule, replaced: &replacedMolecule) { return replacedMolecule diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index d2638243..dc2ed356 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -264,7 +264,7 @@ import MVMCore self.pageModel = newPageModel // Run through the differences between separate page model trees. - var pageUpdatedModels = [MoleculeModelProtocol]() + //var pageUpdatedModels = [MoleculeModelProtocol]() if let originalModel, // We had a prior. let newPageModel = newPageModel as? TemplateModelProtocol, originalModel.id != newPageModel.id { @@ -279,17 +279,13 @@ import MVMCore // Notify the manager of new data. // Warning: Some flows cause table reloads. Until the UI update is decoupled, should be after the updateUI. manager?.newDataReceived?(in: self) - - // Dispatch to decouple execution. First massage data through template classes, then render. - Task { @MainActor in - - if allUpdatedMolecules.isEmpty || isFirstRender { - debugLog("Performing full page render...") - updateUI() - } else { - debugLog("Performing partial render of \(allUpdatedMolecules) molecules...") - updateUI(for: allUpdatedMolecules) - } + + if allUpdatedMolecules.isEmpty || isFirstRender { + debugLog("Performing full page render...") + updateUI() + } else { + debugLog("Performing partial render of \(allUpdatedMolecules) molecules...") + updateUI(for: allUpdatedMolecules) } } @@ -319,7 +315,7 @@ import MVMCore if let updatedMolecules = behavior.onPageNew(rootMolecules: newTemplateModel.rootMolecules, delegateObjectIVar, changes: &changes) { updatedMolecules.forEach { molecule in // Replace again in case there is a template level child. - if let replaced = try? newTemplateModel.replaceChildMolecule(with: molecule) { + if let _ = try? newTemplateModel.replaceChildMolecule(with: molecule) { // Only recognize the molecules that actually changed. if changes.count > 0 { debugLog("\(behavior) updated \(changes) in template model.")