Skip to content

Commit

Permalink
handling empty wordsList (while loading)
Browse files Browse the repository at this point in the history
  • Loading branch information
yassram committed May 15, 2019
1 parent 6902f6a commit bbe2f28
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion WordSearch/Controllers/GameVC+CollectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import UIKit
extension GameVC: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection _: Int) -> Int {
if collectionView == boardCollectionView {
return collumnNumber * lineNumber
return wordsList.count > 0 ? collumnNumber * lineNumber : 0
} else if collectionView == wordsCollectionView {
return wordsList.count
}
Expand All @@ -29,12 +29,14 @@ extension GameVC: UICollectionViewDelegate, UICollectionViewDataSource, UICollec
if logicPositioning.isInRange(index: indexPath.item, start: startSelected, end: endSelected) {
cell.backgroundColor = .orange
}

for word in logicPositioning.wordsFound {
if logicPositioning.isInRange(index: indexPath.item, start: word.value.0, end: word.value.1) {
cell.backgroundColor = wordColor[word.key]
}
}
cell.letterLabel.text = logicPositioning.wordsGrid[indexPath.item]

return cell
}

Expand Down

0 comments on commit bbe2f28

Please sign in to comment.