Skip to content

Commit

Permalink
Merge branch 'feature/pre_beta' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmcl committed May 10, 2024
2 parents f3d61e6 + 2c2a321 commit 85e573f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class CollectiblesCollectionsViewController: UIViewController, UICollectionViewD
case .success:
//self?.hideLoadingView(completion: nil)
if self?.refreshingFromParent == true || self?.viewModel.needsLayoutChange == true {
if self?.viewModel.isSearching == false {
self?.clearSearchTextField()
}

self?.collectionView.collectionViewLayout = self?.viewModel.layout() ?? UICollectionViewFlowLayout()
self?.collectionView.contentOffset = CGPoint(x: 0, y: 0)
self?.refreshingFromParent = false
Expand Down Expand Up @@ -219,14 +223,7 @@ extension CollectiblesCollectionsViewController: ValidatorTextFieldDelegate {

private func hideSearchingUI() {
self.viewModel.isSearching = false

let searchCell = collectionView.cellForItem(at: IndexPath(row: 0, section: 0)) as? CollectiblesSearchCell
searchCell?.searchBar.text = ""
searchCell?.cancelButton.isHidden = true

UIView.animate(withDuration: 0.3) {
searchCell?.contentView.layoutIfNeeded()
}
self.clearSearchTextField()

viewModel.endSearching(forColelctionView: self.collectionView, completion: {})

Expand All @@ -245,4 +242,14 @@ extension CollectiblesCollectionsViewController: ValidatorTextFieldDelegate {
}
*/
}

private func clearSearchTextField() {
let searchCell = collectionView.cellForItem(at: IndexPath(row: 0, section: 0)) as? CollectiblesSearchCell
searchCell?.searchBar.text = ""
searchCell?.cancelButton.isHidden = true

UIView.animate(withDuration: 0.3) {
searchCell?.contentView.layoutIfNeeded()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class CollectiblesCollectionsViewModel: ViewModel, UICollectionViewDiffableDataS
.sink { [weak self] address in
if DependencyManager.shared.selectedWalletAddress == address {
self?.forceRefresh = true
self?.isSearching = false
self?.needsLayoutChange = true

if self?.isVisible == true {
self?.refresh(animate: true)
}
Expand Down

0 comments on commit 85e573f

Please sign in to comment.