Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.hideSkeleton() function does not work with UICollectionViewCompositionalLayout's Orthogonal Section Scrolling #546

Open
4 of 8 tasks
dbpradana opened this issue Aug 15, 2023 · 5 comments

Comments

@dbpradana
Copy link

dbpradana commented Aug 15, 2023

Description

The skeletonView won't hide when the .hideSkeleton() function runs for a UICollectionView that has orthogonal scrolling behavior set at the Compositional Layout.

Code snippets and some more explanation are provided at the Attachment section below.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

SkeletonView Environment:

SkeletonView version: 1.30.4
Xcode version: 14.3 (14E222b)
Swift version: Swift 5

Steps to reproduce:

  1. Setup UICollectionView with UICollectionViewCompositionalLayout and orthogonalScrollingBehavior.
  2. Set isSkeletonable for collection view and it's cells to true.
  3. Run collectionView.showAnimatedGradientSkeleton().
  4. Run collectionView.hideSkeleton(reloadDataAfter: true, transition: .crossDissolve(0.25)) when data load is finished.

Expected result:

Animated skeleton hides

Actual result:

Animated skeleton are still showing

Attachments:

Here's the code when i set the UICollectionView's Compositional Layout:
I've tried to comment out the section.orthogonalScrollingBehavior = .continuous part and the animated skeleton views are hides as expected when the .hideSkeleton() function runs.

// Set the UICollectionView
    private func setupCollectionView() {
        collectionView.delegate             = self
        collectionView.dataSource           = self
        collectionView.alwaysBounceVertical = false
        collectionView.collectionViewLayout = setCollectionCompositionalLayout()
        collectionView.register(SliderCell.self, forCellWithReuseIdentifier: "SliderCell")
        
        collectionView.showAnimatedGradientSkeleton()
    }
    
// Creates UICollectionView Compositional Layout
    private func setCollectionCompositionalLayout() -> UICollectionViewLayout {
        let item_size = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1))
        let item      = NSCollectionLayoutItem(layoutSize: item_size)
        
        let group_size = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1))
        let group      = NSCollectionLayoutGroup.horizontal(layoutSize: group_size, subitems: [item])
        
        let section = NSCollectionLayoutSection(group: group)
        section.orthogonalScrollingBehavior = .continuous
        return UICollectionViewCompositionalLayout(section: section)
    }

@noorbhatia
Copy link

@dbpradana I am facing the same issue, did you find any workaround?

@noorbhatia
Copy link

@Juanpe pls help

@WangGouHei
Copy link

same issue

@dbpradana
Copy link
Author

dbpradana commented Oct 23, 2023

@noorbhatia i don't really know if this workaround is affecting any performance or not, but right now the only way i could make it works is by modifying the function to set up the collectionView layout at my above code to setCollectionCompositionalLayout(shouldUseOrthogonalScroll: Bool).

Basically i need to first create a compositional layout without the orthogonal scrolling, do the data load, and after i run the .hideSkeleton() function, i run the setCollectionCompositionalLayout() function again but this time i set the shouldUseOrthogonalScroll to true, resetting the collectionView's layout and run collectionView.reloadData()

@dbpradana dbpradana reopened this Oct 23, 2023
@Mohamedgamal423
Copy link

just type cellname.hideSkeleton() in (cell for row at ) before configure cell with data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants