From 8f2a4b2469ba592d61af6f845502c04d1b816891 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Thu, 22 Jul 2021 11:42:04 -0400 Subject: [PATCH 1/3] Revert "Merge branch 'bugfix/carousel_issues' into 'develop'" This reverts merge request !734 --- .../CarouselIndicator/BarsIndicatorView.swift | 1 - .../CarouselIndicator/CarouselIndicator.swift | 6 ------ .../Atomic/Organisms/Carousel/Carousel.swift | 15 +-------------- .../Atomic/Organisms/Carousel/CarouselModel.swift | 4 ++-- 4 files changed, 3 insertions(+), 23 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift index 8a1f960b..975c7ebb 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift @@ -234,7 +234,6 @@ open class BarsIndicatorView: CarouselIndicator { super.reset() barReferences.forEach { $0.removeFromSuperview() } barReferences = [] - currentIndex = 0 } public override func updateUI(previousIndex: Int, newIndex: Int, totalCount: Int, isAnimated: Bool) { diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift index 5b04d065..6a82ef80 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift @@ -248,10 +248,4 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol { bottomConstraint?.constant = constant topConstraint?.constant = constant } - - open override func reset() { - super.reset() - currentIndex = 0 - previousIndex = 0 - } } diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index 24ae0c06..67e024ca 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -41,7 +41,7 @@ open class Carousel: View { open var numberOfPages = 0 /// The models for the molecules. - public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol & CollectionItemModelProtocol]? + public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol]? /// The horizontal alignment of the cell in the collection view. Only noticeable if the itemWidthPercent is less than 100%. public var itemAlignment = UICollectionView.ScrollPosition.left @@ -177,7 +177,6 @@ open class Carousel: View { if let selectedIndex = carouselModel.selectedIndex { let adjustedIndex = loop ? selectedIndex + 2 : selectedIndex collectionView.selectItem(at: IndexPath(row: adjustedIndex, section: 0), animated: false, scrollPosition: []) - goTo(adjustedIndex, animated: false) } } @@ -208,13 +207,6 @@ open class Carousel: View { pageIndex = 0 } - open override func reset() { - super.reset() - currentIndex = 0 - pageIndex = 0 - pagingView?.reset() - } - var pagingMoleculeName: String? /// Sets up the paging molecule @@ -224,7 +216,6 @@ open class Carousel: View { molecule.moleculeName == pagingMoleculeName { pagingView?.set(with: molecule, delegateObject, nil) pagingView?.numberOfPages = numberOfPages - pagingView?.currentIndex = currentIndex return } @@ -432,10 +423,6 @@ extension Carousel: UICollectionViewDelegate { adjustedIndex = adjustedIndex + numberOfPages } model.selectedIndex = adjustedIndex - currentIndex = adjustedIndex - pageIndex = currentIndex - pagingView?.currentIndex = adjustedIndex - updateModelIndex() } if let cell = collectionView.cellForItem(at: indexPath) as? CollectionTemplateItemProtocol { cell.didSelectCell(at: indexPath, delegateObject: delegateObject, additionalData: nil) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift index df258324..8721db72 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift @@ -20,7 +20,7 @@ import UIKit } public var backgroundColor: Color? - public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol & CollectionItemModelProtocol] + public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol] public var index: Int = 0 public var spacing: CGFloat? public var border: Bool? @@ -41,7 +41,7 @@ import UIKit public var selectable = false public var selectedIndex: Int? - public init(molecules: [MoleculeModelProtocol & CarouselItemModelProtocol & CollectionItemModelProtocol]) { + public init(molecules: [MoleculeModelProtocol & CarouselItemModelProtocol]) { self.molecules = molecules } From 69499bf0495b57eaa3e9787abf6bd0ac49ef99b5 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 22 Jul 2021 15:10:11 -0400 Subject: [PATCH 2/3] threading fix --- .../SplitViewController/MVMCoreUISplitViewController.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 20f0d227..d8639b56 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -1053,7 +1053,11 @@ CGFloat const PanelAnimationDuration = 0.2; } + (CGFloat)getApplicationViewWidth { - return CGRectGetWidth([self getBounds:[MVMCoreUISession sharedGlobal].splitViewController.view.superview]); + __block CGFloat width; + [MVMCoreDispatchUtility performSyncBlockOnMainThread:^{ + width = CGRectGetWidth([self getBounds:[MVMCoreUISession sharedGlobal].splitViewController.view.superview]); + }]; + return width; } + (CGFloat)getApplicationViewMaxSize { From 8562806880341e941ae24c5c754ca650d9d23453 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 22 Jul 2021 21:24:19 -0400 Subject: [PATCH 3/3] error checks --- .../Dropdown Fields/BaseDropdownEntryField.swift | 14 +++++++++----- .../Containers/Views/EntryFieldContainer.swift | 4 +++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift index 5a7f1702..d9b42a41 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift @@ -88,14 +88,18 @@ import UIKit } @objc public override func dismissFieldInput(_ sender: Any?) { - performDropdownAction() + if !textField.isFirstResponder { + performDropdownAction() + } super.dismissFieldInput(sender) } func performDropdownAction() { - if let baseDropdownEntryFieldModel = baseDropdownEntryFieldModel, let actionModel = baseDropdownEntryFieldModel.action { - let additionalDataWithSource = additionalData.dictionaryAdding(key: KeySourceModel, value: baseDropdownEntryFieldModel) - MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionModel, additionalData: additionalDataWithSource, delegateObject: delegateObject) - } + guard let baseDropdownEntryFieldModel = baseDropdownEntryFieldModel, + let actionModel = baseDropdownEntryFieldModel.action + else { return } + + let additionalDataWithSource = additionalData.dictionaryAdding(key: KeySourceModel, value: baseDropdownEntryFieldModel) + MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionModel, additionalData: additionalDataWithSource, delegateObject: delegateObject) } } diff --git a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift index 9ccd1d25..50236e45 100644 --- a/MVMCoreUI/Containers/Views/EntryFieldContainer.swift +++ b/MVMCoreUI/Containers/Views/EntryFieldContainer.swift @@ -270,7 +270,9 @@ import UIKit bottomBar?.frame = CGRect(x: 0, y: bounds.height - size, width: bounds.width, height: size) if updateMoleculeLayout || heightChanged { - delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) + DispatchQueue.main.async { [self] in + delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) + } } setNeedsDisplay()