     
     func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
         
+        if( currentSkinName == nil) {
+            currentSkinName = viewModel[indexPath.row].name
+        } else {
+            nextSkinName = viewModel[indexPath.row].name
+        }
     }
     
     func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
         
+        if (viewModel[indexPath.row].name == currentSkinName) {
+            currentSkinName = nextSkinName
+        }
     }
 }

        
        navigationController?.hidesBarsOnTap = true
        navigationController?.navigationBar.backItem?.title = " "
    }
    
    override func viewDidAppear(_ animated: Bool) {

    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        
        nextSkinName = nil
    }
    
    override func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) {
        
        vertSizeClass = newCollection.verticalSizeClass
        
        coordinator.animate(alongsideTransition: { [weak self] context in
            self?.collectionView.performBatchUpdates(nil, completion: nil)
            }, completion: { [weak self] context in
                self?.collectionView.reloadData()
        })
        
        //        coordinator.animate(alongsideTransition: nil) { [weak self] _ in
        //            self?.collectionView.collectionViewLayout.invalidateLayout()
        //            self?.collectionView.reloadData()
        //        }
    }
}

