diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/NftAsset/NftAssetButtonCell.swift b/UnstoppableWallet/UnstoppableWallet/Modules/NftAsset/NftAssetButtonCell.swift index e82d980b9a..816dfef702 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/NftAsset/NftAssetButtonCell.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/NftAsset/NftAssetButtonCell.swift @@ -1,16 +1,14 @@ -import UIKit import ComponentKit +import UIKit class NftAssetButtonCell: UITableViewCell { - private let providerButton = PrimaryButton() - private let sendButton = PrimaryButton() - private let moreButton = PrimaryCircleButton() + private let saveButton = PrimaryButton() + private let shareButton = PrimaryButton() private let stackView = UIStackView() - private var onTapSend: (() -> ())? - private var onTapProvider: (() -> ())? - private var onTapMore: (() -> ())? + private var onTapShare: (() -> Void)? + private var onTapSave: (() -> Void)? override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) @@ -25,51 +23,37 @@ class NftAssetButtonCell: UITableViewCell { maker.height.equalTo(CGFloat.heightButton) } - stackView.addArrangedSubview(sendButton) - stackView.addArrangedSubview(providerButton) - stackView.addArrangedSubview(moreButton) + stackView.addArrangedSubview(shareButton) + stackView.addArrangedSubview(saveButton) stackView.spacing = .margin8 stackView.alignment = .fill - stackView.distribution = .fill + stackView.distribution = .fillEqually - sendButton.set(style: .yellow) - sendButton.addTarget(self, action: #selector(onTapSendButton), for: .touchUpInside) - sendButton.setTitle("button.send".localized, for: .normal) + shareButton.set(style: .yellow) + shareButton.addTarget(self, action: #selector(onTapShareButton), for: .touchUpInside) + shareButton.setTitle("button.share".localized, for: .normal) - providerButton.set(style: .gray) - providerButton.addTarget(self, action: #selector(onTapProviderButton), for: .touchUpInside) - - moreButton.set(style: .gray) - moreButton.set(image: UIImage(named: "more_24")) - moreButton.addTarget(self, action: #selector(onTapMoreButton), for: .touchUpInside) + saveButton.set(style: .gray) + saveButton.addTarget(self, action: #selector(onTapSaveButton), for: .touchUpInside) + saveButton.setTitle("button.save".localized, for: .normal) } - required init?(coder aDecoder: NSCoder) { + @available(*, unavailable) + required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } - @objc private func onTapSendButton() { - onTapSend?() - } - - @objc private func onTapProviderButton() { - onTapProvider?() + @objc private func onTapSaveButton() { + onTapSave?() } - @objc private func onTapMoreButton() { - onTapMore?() + @objc private func onTapShareButton() { + onTapShare?() } - func bind(providerTitle: String?, onTapSend: (() -> ())?, onTapProvider: @escaping () -> (), onTapMore: @escaping () -> ()) { - providerButton.setTitle(providerTitle, for: .normal) - - sendButton.isHidden = onTapSend == nil - providerButton.isHidden = onTapSend != nil - - self.onTapSend = onTapSend - self.onTapProvider = onTapProvider - self.onTapMore = onTapMore + func bind(onTapShare: @escaping () -> Void, onTapSave: @escaping () -> Void) { + self.onTapShare = onTapShare + self.onTapSave = onTapSave } - } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/NftAsset/Overview/NftAssetOverviewViewController.swift b/UnstoppableWallet/UnstoppableWallet/Modules/NftAsset/Overview/NftAssetOverviewViewController.swift index 723790ddf6..c3cfe9853b 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/NftAsset/Overview/NftAssetOverviewViewController.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/NftAsset/Overview/NftAssetOverviewViewController.swift @@ -180,35 +180,6 @@ class NftAssetOverviewViewController: ThemeViewController { urlManager.open(url: url, from: parentNavigationController ?? self) } - private func openSend() { - guard let viewController = SendNftModule.viewController(nftUid: viewModel.nftUid) else { - return - } - - parentNavigationController?.present(viewController, animated: true) - } - - private func openOptionsMenu() { - let controller = AlertViewControllerNew.instance( - viewItems: [ - .init(text: "button.share".localized), - .init(text: "nft_asset.options.save_to_photos".localized), -// .init(text: "nft_asset.options.set_as_watch_face".localized) - ], - reportAfterDismiss: true, - onSelect: { [weak self] index in - switch index { - case 0: self?.handleShare() - case 1: self?.handleSaveToPhotos() -// case 2: self?.handleSetWatchFace() - default: () - } - } - ) - - (parentNavigationController ?? self).present(controller, animated: true) - } - private func handleShare() { if let providerUrl = providerUrl { openShare(text: providerUrl) @@ -319,17 +290,11 @@ extension NftAssetOverviewViewController: SectionsDataSource { height: .heightButton, bind: { [weak self] cell, _ in cell.bind( - providerTitle: self?.viewModel.providerTitle, - onTapSend: sendVisible ? { [weak self] in - self?.openSend() - } : nil, - onTapProvider: { - if let url = self?.providerUrl { - self?.openLink(url: url) - } + onTapShare: { [weak self] in + self?.handleShare() }, - onTapMore: { - self?.openOptionsMenu() + onTapSave: { [weak self] in + self?.handleSaveToPhotos() } ) }