blockchainethereumblockchain-walleterc20erc721walletxdaidappdecentralizederc1155erc875iosswifttokens
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.7 KiB
68 lines
1.7 KiB
7 years ago
|
//
|
||
6 years ago
|
// RedeemTokensViewModel.swift
|
||
7 years ago
|
// Alpha-Wallet
|
||
|
//
|
||
|
// Created by Oguzhan Gungor on 3/4/18.
|
||
|
// Copyright © 2018 Alpha-Wallet. All rights reserved.
|
||
|
//
|
||
|
|
||
|
import Foundation
|
||
|
import UIKit
|
||
|
|
||
6 years ago
|
struct RedeemTokensViewModel {
|
||
7 years ago
|
|
||
|
var token: TokenObject
|
||
6 years ago
|
var TokenHolders: [TokenHolder]
|
||
7 years ago
|
|
||
|
init(token: TokenObject) {
|
||
|
self.token = token
|
||
6 years ago
|
self.TokenHolders = TokenAdaptor(token: token).getTokenHolders()
|
||
7 years ago
|
}
|
||
|
|
||
6 years ago
|
func item(for indexPath: IndexPath) -> TokenHolder {
|
||
6 years ago
|
return TokenHolders[indexPath.row]
|
||
7 years ago
|
}
|
||
|
|
||
|
func numberOfItems(for section: Int) -> Int {
|
||
6 years ago
|
return TokenHolders.count
|
||
7 years ago
|
}
|
||
|
|
||
|
func height(for section: Int) -> CGFloat {
|
||
|
return 90
|
||
|
}
|
||
|
|
||
|
var title: String {
|
||
6 years ago
|
return R.string.localizable.aWalletTokenTokenRedeemSelectTokensTitle ()
|
||
7 years ago
|
}
|
||
|
|
||
7 years ago
|
var buttonTitleColor: UIColor {
|
||
|
return Colors.appWhite
|
||
|
}
|
||
|
|
||
|
var buttonBackgroundColor: UIColor {
|
||
|
return Colors.appHighlightGreen
|
||
7 years ago
|
}
|
||
|
|
||
7 years ago
|
var buttonFont: UIFont {
|
||
|
return Fonts.regular(size: 20)!
|
||
|
}
|
||
7 years ago
|
|
||
7 years ago
|
func toggleSelection(for indexPath: IndexPath) -> [IndexPath] {
|
||
6 years ago
|
let TokenHolder = item(for: indexPath)
|
||
7 years ago
|
var changed = [indexPath]
|
||
6 years ago
|
if TokenHolder.areDetailsVisible {
|
||
|
TokenHolder.areDetailsVisible = false
|
||
|
TokenHolder.isSelected = false
|
||
7 years ago
|
} else {
|
||
6 years ago
|
for (i, each) in TokenHolders.enumerated() where each.areDetailsVisible {
|
||
7 years ago
|
each.areDetailsVisible = false
|
||
|
each.isSelected = false
|
||
|
changed.append(.init(row: i, section: indexPath.section))
|
||
7 years ago
|
}
|
||
6 years ago
|
TokenHolder.areDetailsVisible = true
|
||
|
TokenHolder.isSelected = true
|
||
7 years ago
|
}
|
||
|
return changed
|
||
|
}
|
||
7 years ago
|
}
|