Skip to content

Instantly share code, notes, and snippets.

@aheze
Last active July 26, 2020 20:16
Show Gist options
  • Save aheze/a4aba07c49eb048ef99d95dc6b2ce8cd to your computer and use it in GitHub Desktop.
Save aheze/a4aba07c49eb048ef99d95dc6b2ce8cd to your computer and use it in GitHub Desktop.
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if collectionView == baseCollectionView {
let alphabetLetter = newBaseCollectionViewArray[indexPath.item]
secondCollectionViewArray.append(alphabetLetter)
let newIndexPath = IndexPath(item: secondCollectionViewArray.count - 1, section: 0)
secondCollectionView.insertItems(at: [newIndexPath])
newBaseCollectionViewArray.remove(at: indexPath.item)
baseCollectionView.deleteItems(at: [indexPath])
} else {
let alphabetLetter = secondCollectionViewArray[indexPath.item]
calculateWhereToPlaceComponent(component: alphabetLetter, placeInSecondCollectionView: indexPath)
// newBaseCollectionViewArray.insert(alphabetLetter, at: 0)
// let newIndexPath = IndexPath(item: 0, section: 0)
// ///I guess we'll put it at the front for now?
// baseCollectionView.insertItems(at: [newIndexPath])
//
// secondCollectionViewArray.remove(at: indexPath.item)
// secondCollectionView.deleteItems(at: [indexPath])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment