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; diff --git a/VDS/BaseClasses/Selector/SelectorBase.swift b/VDS/BaseClasses/Selector/SelectorBase.swift index 97e72afd..9a3ee2ec 100644 --- a/VDS/BaseClasses/Selector/SelectorBase.swift +++ b/VDS/BaseClasses/Selector/SelectorBase.swift @@ -87,9 +87,6 @@ open class SelectorBase: Control, SelectorControlable, ParentViewProtocol { 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 //-------------------------------------------------- @@ -109,6 +106,16 @@ open class SelectorBase: Control, SelectorControlable, ParentViewProtocol { 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() { diff --git a/VDS/Components/Carousel/Carousel.swift b/VDS/Components/Carousel/Carousel.swift index debe9042..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,10 +517,15 @@ 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() + if hasDebugBorder { + cell.addDebugBorder() + } else { + cell.removeDebugBorder() + } return cell } 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 diff --git a/VDS/Components/Pagination/Pagination.swift b/VDS/Components/Pagination/Pagination.swift index cf4f9183..00892fe3 100644 --- a/VDS/Components/Pagination/Pagination.swift +++ b/VDS/Components/Pagination/Pagination.swift @@ -18,6 +18,8 @@ open class Pagination: View { //-------------------------------------------------- // MARK: - Private Properties //-------------------------------------------------- + private let pageChangedSubject = PassthroughSubject() + ///Maximum component width private let maxWidth: CGFloat = 288.0 ///Collectionview width anchor @@ -52,6 +54,8 @@ open class Pagination: View { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- + 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 @@ -145,6 +149,11 @@ open class Pagination: View { .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() { @@ -195,6 +204,7 @@ open class Pagination: View { let isNextAction = sender == nextButton _selectedPageIndex = if isNextAction { _selectedPageIndex + 1 } else { _selectedPageIndex - 1 } updateSelection() + pageChangedSubject.send(self) DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in guard let self else { return } UIAccessibility.post(notification: .announcement, argument: paginationDescription) @@ -249,7 +259,7 @@ extension Pagination: UICollectionViewDelegate, UICollectionViewDataSource, UICo guard _selectedPageIndex != indexPath.row else { return } _selectedPageIndex = indexPath.row updateSelection() - onPageDidSelect?(selectedPage) + pageChangedSubject.send(self) } }