-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable managing coins for Watch wallets
- Loading branch information
Showing
7 changed files
with
53 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 40 additions & 23 deletions
63
UnstoppableWallet/UnstoppableWallet/Modules/Wallet/Views/WalletHeaderView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,70 @@ | ||
import UIKit | ||
import ThemeKit | ||
import SnapKit | ||
import ComponentKit | ||
import HUD | ||
import SnapKit | ||
import ThemeKit | ||
import UIKit | ||
|
||
class WalletHeaderView: UITableViewHeaderFooterView { | ||
static var height: CGFloat = TextDropDownAndSettingsView.height | ||
static var height: CGFloat = .heightSingleLineCell | ||
|
||
private let sortByButton = SecondaryButton() | ||
|
||
private let sortAddCoinView = TextDropDownAndSettingsView() | ||
private let stackView = UIStackView() | ||
private let settingsButton = SecondaryCircleButton() | ||
private let watchAccountImage = ImageComponent(size: .iconSize24) | ||
|
||
var onTapSortBy: (() -> ())? | ||
var onTapAddCoin: (() -> ())? | ||
var onTapSortBy: (() -> Void)? | ||
var onTapSettings: (() -> Void)? | ||
|
||
override init(reuseIdentifier: String?) { | ||
super.init(reuseIdentifier: reuseIdentifier) | ||
|
||
backgroundView = UIView() | ||
backgroundView?.backgroundColor = .themeNavigationBarBackground | ||
|
||
contentView.addSubview(sortAddCoinView) | ||
sortAddCoinView.snp.makeConstraints { maker in | ||
maker.leading.top.trailing.equalToSuperview() | ||
maker.height.equalTo(TextDropDownAndSettingsView.height) | ||
addSubview(sortByButton) | ||
sortByButton.snp.makeConstraints { maker in | ||
maker.leading.centerY.equalToSuperview() | ||
} | ||
|
||
sortAddCoinView.onTapDropDown = { [weak self] in self?.onTapSortBy?() } | ||
sortAddCoinView.onTapSettings = { [weak self] in self?.onTapAddCoin?() } | ||
sortByButton.set(style: .transparent, image: UIImage(named: "arrow_small_down_20")) | ||
sortByButton.addTarget(self, action: #selector(onTapSortByButton), for: .touchUpInside) | ||
|
||
contentView.addSubview(watchAccountImage) | ||
watchAccountImage.snp.makeConstraints { maker in | ||
addSubview(stackView) | ||
stackView.snp.makeConstraints { maker in | ||
maker.trailing.equalToSuperview().inset(CGFloat.margin16) | ||
maker.centerY.equalTo(sortAddCoinView) | ||
maker.centerY.equalToSuperview() | ||
} | ||
|
||
stackView.axis = .horizontal | ||
stackView.spacing = .margin16 | ||
|
||
stackView.addArrangedSubview(watchAccountImage) | ||
watchAccountImage.imageView.image = UIImage(named: "binocule_24")?.withTintColor(.themeGray) | ||
|
||
stackView.addArrangedSubview(settingsButton) | ||
settingsButton.set(image: UIImage(named: "manage_2_20")) | ||
settingsButton.addTarget(self, action: #selector(onTapSettingsButton), for: .touchUpInside) | ||
} | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
@available(*, unavailable) | ||
required init?(coder _: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
func bind(sortBy: String?) { | ||
sortAddCoinView.set(dropdownTitle: sortBy) | ||
@objc private func onTapSortByButton() { | ||
onTapSortBy?() | ||
} | ||
|
||
func bind(controlViewItem: WalletViewModel.ControlViewItem) { | ||
sortAddCoinView.set(settingsHidden: !controlViewItem.coinManagerVisible) | ||
watchAccountImage.isHidden = !controlViewItem.watchVisible | ||
@objc private func onTapSettingsButton() { | ||
onTapSettings?() | ||
} | ||
|
||
func set(sortByTitle: String?) { | ||
sortByButton.setTitle(sortByTitle, for: .normal) | ||
} | ||
|
||
func set(controlViewItem: WalletViewModel.ControlViewItem) { | ||
watchAccountImage.isHidden = !controlViewItem.watchVisible | ||
settingsButton.isHidden = !controlViewItem.coinManagerVisible | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters