From 7536774c0fd0cd27aacefea8c88b01113b17cf9f Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 21 Aug 2024 15:32:20 -0500 Subject: [PATCH 1/7] fixed bug in checkbox getting crushed. Signed-off-by: Matt Bruce --- VDS/BaseClasses/Selector/SelectorBase.swift | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/VDS/BaseClasses/Selector/SelectorBase.swift b/VDS/BaseClasses/Selector/SelectorBase.swift index 6af003fd..fe5cb8fc 100644 --- a/VDS/BaseClasses/Selector/SelectorBase.swift +++ b/VDS/BaseClasses/Selector/SelectorBase.swift @@ -84,9 +84,6 @@ open class SelectorBase: Control, SelectorControlable { open var selectorColorConfiguration = ControlColorConfiguration() { didSet { setNeedsUpdate() } } - /// The natural size for the receiving view, considering only properties of the view itself. - open override var intrinsicContentSize: CGSize { size } - //-------------------------------------------------- // MARK: - Private Properties //-------------------------------------------------- @@ -106,6 +103,16 @@ open class SelectorBase: Control, SelectorControlable { super.setup() isAccessibilityElement = true accessibilityTraits = .button + + let layoutGuide = UILayoutGuide() + addLayoutGuide(layoutGuide) + layoutGuide + .pinTop(0) + .pinLeading(0) + .pinTrailing(0, .defaultHigh) + .pinBottom(0, .defaultHigh) + .width(size.width) + .height(size.height) } open override func setDefaults() { From 31f01773c4395e7e67b86f00977e90fa78a27ae8 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 27 Aug 2024 11:44:10 -0500 Subject: [PATCH 2/7] added borders to the cells for carousel Signed-off-by: Matt Bruce --- VDS/Components/Carousel/Carousel.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/VDS/Components/Carousel/Carousel.swift b/VDS/Components/Carousel/Carousel.swift index debe9042..a2dd4d7d 100644 --- a/VDS/Components/Carousel/Carousel.swift +++ b/VDS/Components/Carousel/Carousel.swift @@ -520,6 +520,11 @@ extension Carousel: UICollectionViewDelegate, UICollectionViewDataSource, UIColl let component = views[indexPath.row] cell.update(with: component, slotAlignment: slotAlignment, surface: surface) cell.layoutIfNeeded() + if hasDebugBorder { + cell.addDebugBorder() + } else { + cell.removeDebugBorder() + } return cell } From ad6291af30122316d42cc54f0d06d3cf45316fda Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 27 Aug 2024 11:56:19 -0500 Subject: [PATCH 3/7] force component to redraw Signed-off-by: Matt Bruce --- VDS/Components/Carousel/Carousel.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/VDS/Components/Carousel/Carousel.swift b/VDS/Components/Carousel/Carousel.swift index a2dd4d7d..b344ad9a 100644 --- a/VDS/Components/Carousel/Carousel.swift +++ b/VDS/Components/Carousel/Carousel.swift @@ -520,6 +520,7 @@ extension Carousel: UICollectionViewDelegate, UICollectionViewDataSource, UIColl let component = views[indexPath.row] cell.update(with: component, slotAlignment: slotAlignment, surface: surface) cell.layoutIfNeeded() + component.setNeedsLayout() if hasDebugBorder { cell.addDebugBorder() } else { From 35036ca8044d68886e477aff5e571245de16f125 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 27 Aug 2024 13:31:48 -0500 Subject: [PATCH 4/7] more updates on carousel Signed-off-by: Matt Bruce --- VDS/Components/Carousel/Carousel.swift | 4 ++-- VDS/Components/Carousel/CarouselSlotCell.swift | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/VDS/Components/Carousel/Carousel.swift b/VDS/Components/Carousel/Carousel.swift index b344ad9a..dc1ef104 100644 --- a/VDS/Components/Carousel/Carousel.swift +++ b/VDS/Components/Carousel/Carousel.swift @@ -272,6 +272,7 @@ open class Carousel: View { super.updateView() updateScrollbar() updateCarousel() + collectionView.collectionViewLayout.invalidateLayout() collectionView.reloadData() } @@ -516,11 +517,10 @@ extension Carousel: UICollectionViewDelegate, UICollectionViewDataSource, UIColl public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CarouselSlotCell.identifier, for: indexPath) as? CarouselSlotCell else { return UICollectionViewCell() } - cell.contentView.subviews.forEach { $0.removeFromSuperview() } let component = views[indexPath.row] cell.update(with: component, slotAlignment: slotAlignment, surface: surface) cell.layoutIfNeeded() - component.setNeedsLayout() + //component.setNeedsLayout() if hasDebugBorder { cell.addDebugBorder() } else { diff --git a/VDS/Components/Carousel/CarouselSlotCell.swift b/VDS/Components/Carousel/CarouselSlotCell.swift index 11807747..d47a2595 100644 --- a/VDS/Components/Carousel/CarouselSlotCell.swift +++ b/VDS/Components/Carousel/CarouselSlotCell.swift @@ -25,11 +25,6 @@ final class CarouselSlotCell: UICollectionViewCell { super.init(coder: coder) setUp() } - - //-------------------------------------------------- - // MARK: - Private Properties - //-------------------------------------------------- - private var surface: Surface = .light //-------------------------------------------------- // MARK: - Private Methods @@ -42,7 +37,7 @@ final class CarouselSlotCell: UICollectionViewCell { /// Updating UI based on data along with surface. func update(with component: UIView, slotAlignment: Carousel.CarouselSlotAlignmentModel?, surface: Surface) { - self.surface = surface + contentView.subviews.forEach { $0.removeFromSuperview() } contentView.addSubview(component) if var surfacedView = component as? Surfaceable { surfacedView.surface = surface From c76d3e7b760390470a107027fd55f2ffa407e696 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 27 Aug 2024 14:04:41 -0500 Subject: [PATCH 5/7] updated Pagination to a Control Signed-off-by: Matt Bruce --- VDS/Components/Pagination/Pagination.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/VDS/Components/Pagination/Pagination.swift b/VDS/Components/Pagination/Pagination.swift index cf4f9183..50684e7e 100644 --- a/VDS/Components/Pagination/Pagination.swift +++ b/VDS/Components/Pagination/Pagination.swift @@ -13,7 +13,7 @@ import Combine ///Pagination is a control that enables customers to navigate multiple pages of content by selecting either a specific page or the next or previous set of four pages. @objcMembers @objc(VDSPagination) -open class Pagination: View { +open class Pagination: Control, Changeable { //-------------------------------------------------- // MARK: - Private Properties @@ -52,6 +52,8 @@ open class Pagination: View { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- + public var onChangeSubscriber: AnyCancellable? + ///Previous button to select previous page public let previousButton: PaginationButton = .init(type: .previous) ///Next button to select next page @@ -195,6 +197,8 @@ open class Pagination: View { let isNextAction = sender == nextButton _selectedPageIndex = if isNextAction { _selectedPageIndex + 1 } else { _selectedPageIndex - 1 } updateSelection() + onPageDidSelect?(selectedPage) + sendActions(for: .valueChanged) DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in guard let self else { return } UIAccessibility.post(notification: .announcement, argument: paginationDescription) @@ -250,6 +254,7 @@ extension Pagination: UICollectionViewDelegate, UICollectionViewDataSource, UICo _selectedPageIndex = indexPath.row updateSelection() onPageDidSelect?(selectedPage) + sendActions(for: .valueChanged) } } From 296703076e8a22ebb85d05886ffe7a3432e0ddaf Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 27 Aug 2024 14:28:51 -0500 Subject: [PATCH 6/7] updated from Control to View and add publisher Signed-off-by: Matt Bruce --- VDS/Components/Pagination/Pagination.swift | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/VDS/Components/Pagination/Pagination.swift b/VDS/Components/Pagination/Pagination.swift index 50684e7e..00892fe3 100644 --- a/VDS/Components/Pagination/Pagination.swift +++ b/VDS/Components/Pagination/Pagination.swift @@ -13,11 +13,13 @@ import Combine ///Pagination is a control that enables customers to navigate multiple pages of content by selecting either a specific page or the next or previous set of four pages. @objcMembers @objc(VDSPagination) -open class Pagination: Control, Changeable { +open class Pagination: View { //-------------------------------------------------- // MARK: - Private Properties //-------------------------------------------------- + private let pageChangedSubject = PassthroughSubject() + ///Maximum component width private let maxWidth: CGFloat = 288.0 ///Collectionview width anchor @@ -52,8 +54,8 @@ open class Pagination: Control, Changeable { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - public var onChangeSubscriber: AnyCancellable? - + public var pageChangedPublisher: AnyPublisher { pageChangedSubject.eraseToAnyPublisher() } + ///Previous button to select previous page public let previousButton: PaginationButton = .init(type: .previous) ///Next button to select next page @@ -147,6 +149,11 @@ open class Pagination: Control, Changeable { .sink { [weak self] value in self?.collectionViewWidthAnchor?.constant = value //As cell width is dynamic i.e cell may contain 2 or 3 or 4 charcters. Make sure that all the visible cells are displayed. }.store(in: &subscribers) + + pageChangedPublisher.sink { [weak self] control in + guard let self else { return } + onPageDidSelect?(control.selectedPage) + }.store(in: &subscribers) } open override func setDefaults() { @@ -197,8 +204,7 @@ open class Pagination: Control, Changeable { let isNextAction = sender == nextButton _selectedPageIndex = if isNextAction { _selectedPageIndex + 1 } else { _selectedPageIndex - 1 } updateSelection() - onPageDidSelect?(selectedPage) - sendActions(for: .valueChanged) + pageChangedSubject.send(self) DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in guard let self else { return } UIAccessibility.post(notification: .announcement, argument: paginationDescription) @@ -253,8 +259,7 @@ extension Pagination: UICollectionViewDelegate, UICollectionViewDataSource, UICo guard _selectedPageIndex != indexPath.row else { return } _selectedPageIndex = indexPath.row updateSelection() - onPageDidSelect?(selectedPage) - sendActions(for: .valueChanged) + pageChangedSubject.send(self) } } From 2365f8dbf40162c638aca5de5071ab73c3a7a7f8 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 27 Aug 2024 14:57:20 -0500 Subject: [PATCH 7/7] updated version Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index ee29c530..3da4fb0d 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -1593,7 +1593,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 72; + CURRENT_PROJECT_VERSION = 73; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1631,7 +1631,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 72; + CURRENT_PROJECT_VERSION = 73; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1;