From 2c22c16da1e0b25489a2964e7932d2595df612dc Mon Sep 17 00:00:00 2001 From: Krypto Pank Date: Mon, 24 Jan 2022 11:37:17 +0200 Subject: [PATCH] Right after importing a wallet and going to the Collectibles tab and waiting for a short while, the app shows this (a vertical gap) #3795 --- .../TokensViewController.swift | 49 ++----------------- .../OpenSeaNonFungibleTokenViewCell.swift | 20 +++----- 2 files changed, 9 insertions(+), 60 deletions(-) diff --git a/AlphaWallet/Tokens/ViewControllers/TokensViewController.swift b/AlphaWallet/Tokens/ViewControllers/TokensViewController.swift index 10d64c78c..e0f8a859b 100644 --- a/AlphaWallet/Tokens/ViewControllers/TokensViewController.swift +++ b/AlphaWallet/Tokens/ViewControllers/TokensViewController.swift @@ -13,32 +13,7 @@ protocol TokensViewControllerDelegate: AnyObject { func walletConnectSelected(in viewController: UIViewController) func whereAreMyTokensSelected(in viewController: UIViewController) } - -extension UISearchBar: ReusableTableHeaderViewType {} -extension UICollectionViewFlowLayout { - static var heightForLabel: CGFloat { - return CGFloat(25) * 2 + (8 + 8) - } - - static var itemsInOneLine: CGFloat { - return 2 - } - - static var itemSpacing: CGFloat { - return 0 - } - - static var collectiblesItemSize: CGSize = { - let width = UIScreen.main.bounds.size.width - itemSpacing * CGFloat(itemsInOneLine - 1) - let dimension = width / itemsInOneLine - return CGSize(width: floor(dimension), height: dimension + heightForLabel) - }() - - static var collectiblesItemImageSize: CGSize { - return CGSize(width: collectiblesItemSize.width, height: collectiblesItemSize.height - heightForLabel) - } -} - + class TokensViewController: UIViewController { private static let filterViewHeight = DataEntry.Metric.Tokens.Filter.height static let addHideTokensViewHeight = DataEntry.Metric.AddHideToken.Header.height @@ -115,7 +90,6 @@ class TokensViewController: UIViewController { tableView.register(ServerTableViewCell.self) tableView.register(OpenSeaNonFungibleTokenPairTableCell.self) - tableView.registerHeaderFooterView(GeneralTableViewSectionHeader.self) tableView.registerHeaderFooterView(GeneralTableViewSectionHeader.self) tableView.registerHeaderFooterView(GeneralTableViewSectionHeader.self) tableView.registerHeaderFooterView(ActiveWalletSessionView.self) @@ -203,14 +177,6 @@ class TokensViewController: UIViewController { } } - private func resetTableHeaderViewWithSubview() { - if !isConsoleButtonHidden || !isPromptBackupWalletViewHolderHidden { - adjustTableViewHeaderHeightToFitContents() - } else { - //tableView.tableHeaderView = nil - } - } - weak var delegate: TokensViewControllerDelegate? //TODO The name "bad" isn't correct. Because it includes "conflicts" too var listOfBadTokenScriptFiles: [TokenScriptFileIndices.FileName] = .init() { @@ -251,7 +217,6 @@ class TokensViewController: UIViewController { return header }() - private var cachedCollectiblePairCells: [CollectiblePairs: OpenSeaNonFungibleTokenPairTableCell] = [:] init(sessions: ServerDictionary, account: Wallet, @@ -557,16 +522,8 @@ extension TokensViewController: UITableViewDataSource { case .collectiblePairs: let pair = viewModel.collectiblePairs[indexPath.row] - let cell: OpenSeaNonFungibleTokenPairTableCell - //NOTE: lets keep for now approach with caching cells for pairs, to - if let value = cachedCollectiblePairCells[pair] { - cell = value - } else { - cell = tableView.dequeueReusableCell(for: indexPath) - cell.delegate = self - - cachedCollectiblePairCells[pair] = cell - } + let cell: OpenSeaNonFungibleTokenPairTableCell = tableView.dequeueReusableCell(for: indexPath) + cell.delegate = self let left: OpenSeaNonFungibleTokenViewCellViewModel = .init(token: pair.left) let right: OpenSeaNonFungibleTokenViewCellViewModel? = pair.right.flatMap { token in diff --git a/AlphaWallet/Tokens/Views/OpenSea/OpenSeaNonFungibleTokenViewCell.swift b/AlphaWallet/Tokens/Views/OpenSea/OpenSeaNonFungibleTokenViewCell.swift index 3120d5ed1..a076ac307 100644 --- a/AlphaWallet/Tokens/Views/OpenSea/OpenSeaNonFungibleTokenViewCell.swift +++ b/AlphaWallet/Tokens/Views/OpenSea/OpenSeaNonFungibleTokenViewCell.swift @@ -40,8 +40,7 @@ class OpenSeaNonFungibleTokenView: UIView { background.anchorsConstraint(to: self, edgeInsets: .zero), stackView.anchorsConstraint(to: background), - imageView.anchorsConstraint(to: imageHolder), - textsStackView.heightAnchor.constraint(equalToConstant: 40) + imageView.anchorsConstraint(to: imageHolder) ]) translatesAutoresizingMaskIntoConstraints = false } @@ -79,8 +78,6 @@ class OpenSeaNonFungibleTokenView: UIView { imageView.subscribable = viewModel.tokenIcon } - imageView.subscribable = viewModel.tokenIcon - label.textAlignment = .center label.attributedText = viewModel.tickersTitleAttributedString @@ -102,11 +99,11 @@ protocol OpenSeaNonFungibleTokenPairTableCellDelegate: class { class OpenSeaNonFungibleTokenPairTableCell: UITableViewCell { private lazy var left: OpenSeaNonFungibleTokenView = { - return OpenSeaNonFungibleTokenView.init(frame: .zero) + return OpenSeaNonFungibleTokenView(frame: .zero) }() private lazy var right: OpenSeaNonFungibleTokenView = { - return OpenSeaNonFungibleTokenView.init(frame: .zero) + return OpenSeaNonFungibleTokenView(frame: .zero) }() private let background = UIView() @@ -114,18 +111,13 @@ class OpenSeaNonFungibleTokenPairTableCell: UITableViewCell { return 16 } - var edgeInsets: UIEdgeInsets { + private var edgeInsets: UIEdgeInsets { return .init(top: 16, left: 16, bottom: 0, right: 16) } - private var cellWidth: CGFloat { - let width = UIScreen.main.bounds.size.width - edgeInsets.left - edgeInsets.right - spacing - return width / 2 - } - - var cellSize: CGSize { + private var cellSize: CGSize { let width = UIScreen.main.bounds.size.width - edgeInsets.left - edgeInsets.right - spacing - return .init(width: width / 2, height: UICollectionViewFlowLayout.collectiblesItemSize.height - edgeInsets.bottom - edgeInsets.top) + return .init(width: width / 2, height: 0) } weak var delegate: OpenSeaNonFungibleTokenPairTableCellDelegate?