Merge pull request #3797 from oa-s/#3795

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
pull/3804/head
Hwee-Boon Yar 3 years ago committed by GitHub
commit d1f9e564be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 49
      AlphaWallet/Tokens/ViewControllers/TokensViewController.swift
  2. 20
      AlphaWallet/Tokens/Views/OpenSea/OpenSeaNonFungibleTokenViewCell.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<UISearchBar>.self)
tableView.registerHeaderFooterView(GeneralTableViewSectionHeader<ScrollableSegmentedControl>.self)
tableView.registerHeaderFooterView(GeneralTableViewSectionHeader<AddHideTokensView>.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<WalletSession>,
account: Wallet,
@ -570,16 +535,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

@ -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?

Loading…
Cancel
Save