Merge pull request #2116 from AlphaWallet/#2113

Make Add/Hide Tokens easier to tap #2113
pull/2114/head
Hwee-Boon Yar 4 years ago committed by GitHub
commit 449dd54ac4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      AlphaWallet/Tokens/ViewControllers/TokensViewController.swift
  2. 11
      AlphaWallet/Tokens/Views/AddHideTokensView.swift
  3. 4
      AlphaWallet/Tokens/Views/TokensViewControllerTableViewSectionHeader.swift

@ -352,7 +352,7 @@ extension TokensViewController: UITableViewDelegate {
case .addHideToken:
let header: ShowAddHideTokensView = tableView.dequeueReusableHeaderFooterView()
header.delegate = self
header.configure(viewModel: .init())
header.configure()
return header
case .tokens:

@ -71,9 +71,14 @@ class ShowAddHideTokensView: UITableViewHeaderFooterView {
badgeIndicatorView.centerYAnchor.constraint(equalTo: addTokenButton.topAnchor),
badgeLabel.anchorsConstraint(to: badgeIndicatorView)
])
//NOTE: We add tap gesture to prevent broke layout for 'badgeIndicatorView', because it snapped to buttons top, and we can't set buttons height is equal to superview height.
let tap = UITapGestureRecognizer(target: self, action: #selector(viewTapped))
contentView.isUserInteractionEnabled = true
contentView.addGestureRecognizer(tap)
}
func configure(viewModel: ShowAddHideTokensViewModel) {
func configure(viewModel: ShowAddHideTokensViewModel = .init()) {
backgroundColor = R.color.alabaster()
addTokenButton.setImage(viewModel.addHideTokensIcon, for: .normal)
addTokenButton.setTitle(viewModel.addHideTokensTitle, for: .normal)
@ -90,6 +95,10 @@ class ShowAddHideTokensView: UITableViewHeaderFooterView {
badgeIndicatorView.layer.cornerRadius = value / 2.0
}
@objc private func viewTapped(_ sender: UITapGestureRecognizer) {
delegate?.view(self, didSelectAddHideTokensButton: addTokenButton)
}
@objc private func addHideTokensSelected(_ sender: UIButton) {
delegate?.view(self, didSelectAddHideTokensButton: sender)
}

@ -17,7 +17,7 @@ extension TokensViewController {
filterView.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(filterView)
NSLayoutConstraint.activate([
filterView.anchorsConstraint(to: contentView, edgeInsets: .init(top: 0, left: 0, bottom: 0, right: 0)),
filterView.anchorsConstraint(to: contentView),
])
}
}
@ -29,7 +29,7 @@ extension TokensViewController {
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
return nil
}
}
}

Loading…
Cancel
Save