Skip to content

Commit

Permalink
use different placeholder for asset operation search for assets list …
Browse files Browse the repository at this point in the history
…style
  • Loading branch information
svojsu committed Nov 8, 2024
1 parent 7741c0c commit 9af2c58
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,20 @@ class AssetOperationViewController: AssetsSearchViewController {
selectedLocale: selectedLocale
)
}

override func setupLocalization() {
super.setupLocalization()

let languages = selectedLocale.rLanguages

rootView.searchBar.textField.placeholder = if assetGroupsLayoutStyle == .networks {
R.string.localizable.assetsSearchPlaceholder(
preferredLanguages: languages
)
} else {
R.string.localizable.assetsSearchTokenHint(
preferredLanguages: languages
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ protocol AssetsSearchCollectionManagerProtocol {
func updateSelectedLocale(with locale: Locale)

func updateTokensGroupLayout()
func changeCollectionViewLayout(to style: AssetListGroupsStyle)
}

protocol AssetsSearchCollectionManagerDelegate: AnyObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,7 @@ class AssetsSearchViewController: UIViewController, ViewHolder {
)
}

private func setupCollectionView() {
setupCollectionManager()

collectionViewManager?.setupCollectionView()
}

private func setupLocalization() {
func setupLocalization() {
let languages = selectedLocale.rLanguages
rootView.searchBar.textField.placeholder = R.string.localizable.assetsSearchPlaceholder(
preferredLanguages: languages
Expand All @@ -108,6 +102,12 @@ class AssetsSearchViewController: UIViewController, ViewHolder {
}
}

private func setupCollectionView() {
setupCollectionManager()

collectionViewManager?.setupCollectionView()
}

private func setupSearchBar() {
rootView.searchBar.textField.addTarget(
self,
Expand Down Expand Up @@ -158,12 +158,15 @@ extension AssetsSearchViewController: AssetsSearchViewProtocol {
rootView.collectionView.reloadData()

collectionViewManager?.updateTokensGroupLayout()
setupLocalization()
}

func didReceiveAssetGroupsStyle(_ style: AssetListGroupsStyle) {
guard rootView.assetGroupsLayoutStyle != style else { return }
guard assetGroupsLayoutStyle != style else { return }

assetGroupsLayoutStyle = style

rootView.assetGroupsLayoutStyle = style
setupLocalization()

rootView.collectionViewLayout.changeGroupLayoutStyle(to: style)
rootView.collectionView.reloadData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,6 @@ extension AssetsSearchCollectionManager: AssetsSearchCollectionManagerProtocol {
)
}

func changeCollectionViewLayout(to style: AssetListGroupsStyle) {
guard let view else { return }

view.assetGroupsLayoutStyle = style

let layout: UICollectionViewLayout = view.collectionViewLayout

view.collectionView.setCollectionViewLayout(
layout,
animated: false
)

layout.invalidateLayout()
}

func updateGroupsViewModel(with model: AssetListViewModel) {
groupsViewModel = model

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ class BaseAssetsSearchViewLayout: UIView {

var cancelButton: RoundedButton? { searchView.optionalCancelButton }

var assetGroupsLayoutStyle: AssetListGroupsStyle?

let collectionViewLayout: AssetsSearchFlowLayout = {
let layout = AssetsSearchFlowLayout()
layout.scrollDirection = .vertical
Expand Down
1 change: 1 addition & 0 deletions novawallet/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1768,3 +1768,4 @@
"wallet.receive.details.format" = "Send only %@ token and tokens in %@ network to this address, or you might lose your funds";
"common.address.coppied" = "Address copied";
"common.networks" = "Networks";
"assets.search.token.hint" = "Search by token";

0 comments on commit 9af2c58

Please sign in to comment.