Remove unused inherited code

pull/632/head
Hwee-Boon Yar 6 years ago
parent 979f8cb026
commit 499cb39fdf
  1. 20
      AlphaWallet.xcodeproj/project.pbxproj
  2. 107
      AlphaWallet/Tokens/ViewControllers/EditTokensViewController.swift
  3. 67
      AlphaWallet/Tokens/ViewModels/EditTokenTableCellViewModel.swift
  4. 11
      AlphaWallet/Tokens/ViewModels/EditTokenViewModel.swift
  5. 38
      AlphaWallet/Tokens/Views/EditTokenTableViewCell.swift
  6. 84
      AlphaWallet/Tokens/Views/EditTokenTableViewCell.xib
  7. 4
      AlphaWalletTests/Settings/ConfigTests.swift

@ -205,11 +205,6 @@
29F114F61FA8147300114A29 /* RequestCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F114F51FA8147300114A29 /* RequestCoordinator.swift */; };
29F114F81FA8165200114A29 /* SendCoordinatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F114F71FA8165200114A29 /* SendCoordinatorTests.swift */; };
29F114FA1FA817A800114A29 /* RequestCoordinatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F114F91FA817A800114A29 /* RequestCoordinatorTests.swift */; };
29F1C83E1FEB5C91003780D8 /* EditTokensViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F1C83D1FEB5C91003780D8 /* EditTokensViewController.swift */; };
29F1C8421FEB62ED003780D8 /* EditTokenTableCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F1C8411FEB62ED003780D8 /* EditTokenTableCellViewModel.swift */; };
29F1C8471FEB6664003780D8 /* EditTokenTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F1C8451FEB6664003780D8 /* EditTokenTableViewCell.swift */; };
29F1C8481FEB6664003780D8 /* EditTokenTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 29F1C8461FEB6664003780D8 /* EditTokenTableViewCell.xib */; };
29F1C84A1FEB6D6B003780D8 /* EditTokenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F1C8491FEB6D6B003780D8 /* EditTokenViewModel.swift */; };
29F1C84C1FEC4F6F003780D8 /* TokensFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F1C84B1FEC4F6F003780D8 /* TokensFooterView.swift */; };
29F1C85120032688003780D8 /* Address.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F1C85020032688003780D8 /* Address.swift */; };
29F1C853200363B2003780D8 /* PassphraseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F1C852200363B2003780D8 /* PassphraseViewController.swift */; };
@ -783,11 +778,6 @@
29F114F51FA8147300114A29 /* RequestCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestCoordinator.swift; sourceTree = "<group>"; };
29F114F71FA8165200114A29 /* SendCoordinatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendCoordinatorTests.swift; sourceTree = "<group>"; };
29F114F91FA817A800114A29 /* RequestCoordinatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestCoordinatorTests.swift; sourceTree = "<group>"; };
29F1C83D1FEB5C91003780D8 /* EditTokensViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditTokensViewController.swift; sourceTree = "<group>"; };
29F1C8411FEB62ED003780D8 /* EditTokenTableCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditTokenTableCellViewModel.swift; sourceTree = "<group>"; };
29F1C8451FEB6664003780D8 /* EditTokenTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditTokenTableViewCell.swift; sourceTree = "<group>"; };
29F1C8461FEB6664003780D8 /* EditTokenTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = EditTokenTableViewCell.xib; sourceTree = "<group>"; };
29F1C8491FEB6D6B003780D8 /* EditTokenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditTokenViewModel.swift; sourceTree = "<group>"; };
29F1C84B1FEC4F6F003780D8 /* TokensFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokensFooterView.swift; sourceTree = "<group>"; };
29F1C85020032688003780D8 /* Address.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Address.swift; sourceTree = "<group>"; };
29F1C852200363B2003780D8 /* PassphraseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PassphraseViewController.swift; sourceTree = "<group>"; };
@ -1773,8 +1763,6 @@
children = (
AA26C627204134C500318B9B /* TokenCardTableViewCellWithoutCheckbox.swift */,
295B61D01FE7B20400642E60 /* TokensHeaderView.swift */,
29F1C8451FEB6664003780D8 /* EditTokenTableViewCell.swift */,
29F1C8461FEB6664003780D8 /* EditTokenTableViewCell.xib */,
29F1C84B1FEC4F6F003780D8 /* TokensFooterView.swift */,
5E7C796039C0F47CDCA236C0 /* TokenCardsViewControllerHeader.swift */,
5E7C7C077372C3F2A4349FA1 /* TokenViewCell.swift */,
@ -1795,7 +1783,6 @@
children = (
AA26C61D20412A1D00318B9B /* TokensCardViewController.swift */,
294DFBA81FE6EBFB004CEB56 /* NewTokenViewController.swift */,
29F1C83D1FEB5C91003780D8 /* EditTokensViewController.swift */,
5E7C778F20D32B70D7FF2135 /* TokenCardRedemptionInfoViewController.swift */,
5E7C764B98F526271E4C2A6A /* StaticHTMLViewController.swift */,
5E7C74A2C738BF2412D412A7 /* TokenCardSellInfoViewController.swift */,
@ -1809,8 +1796,6 @@
isa = PBXGroup;
children = (
29E9CFCC1FE7343C00017744 /* NewTokenViewModel.swift */,
29F1C8411FEB62ED003780D8 /* EditTokenTableCellViewModel.swift */,
29F1C8491FEB6D6B003780D8 /* EditTokenViewModel.swift */,
442FCB182F854B307761CD82 /* TokensCardViewModel.swift */,
5E7C77316522DF2B256F1F92 /* TokensCardViewControllerHeaderViewModel.swift */,
5E7C79ED9F842D3FC102AC54 /* TokenViewCellViewModel.swift */,
@ -3241,7 +3226,6 @@
290B2B541F8F50030053C83E /* Localizable.strings in Resources */,
2912CD021F6A830700C6CBE3 /* Assets.xcassets in Resources */,
C880332220551DF800D73D6F /* whatIsEthereumInfo.html in Resources */,
29F1C8481FEB6664003780D8 /* EditTokenTableViewCell.xib in Resources */,
5E7C71D40F530871D95170C6 /* BookmarkViewCell.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -3521,7 +3505,6 @@
29FA00D4201EC662002F7DC5 /* NSObject.swift in Sources */,
299B5E341FCBC5180051361C /* ConfirmPaymentViewModel.swift in Sources */,
771AA94E1FF971CD00D25403 /* DappAction.swift in Sources */,
29F1C8471FEB6664003780D8 /* EditTokenTableViewCell.swift in Sources */,
29FF6D6B2011D2AF00A3011C /* InCoordinatorError.swift in Sources */,
77B3BF352017D0D000EEC15A /* MarketplaceViewModel.swift in Sources */,
29F114F01FA6D53700114A29 /* ImportSelectionType.swift in Sources */,
@ -3552,7 +3535,6 @@
73C41C71201B46AD00243C6C /* LockEnterPasscodeViewModel.swift in Sources */,
2959960C1FAB03EC00DB66A8 /* CoinbaseBuyWidget.swift in Sources */,
291A1B671F98092F00ADEC80 /* ConfirmPaymentViewController.swift in Sources */,
29F1C8421FEB62ED003780D8 /* EditTokenTableCellViewModel.swift in Sources */,
2931122E1FC94E4200966EEA /* SettingsError.swift in Sources */,
29FA00D0201CA66A002F7DC5 /* DAppError.swift in Sources */,
291EC9DF1F7053C50004EDD0 /* NavigationController.swift in Sources */,
@ -3651,7 +3633,6 @@
73ED85A72034BFEF00593BF3 /* UITextFieldAdditions.swift in Sources */,
2923D9B51FDA4E07000CF3F8 /* PasswordGenerator.swift in Sources */,
298542F51FBD8E6A00CB5081 /* ConfigExplorer.swift in Sources */,
29F1C84A1FEB6D6B003780D8 /* EditTokenViewModel.swift in Sources */,
29DF400A1FD3E80A000077CA /* TabBarController.swift in Sources */,
29C80D4F1FB520AF0037B1E0 /* BalanceTokenViewModel.swift in Sources */,
7721A6CE202EFC21004DB16C /* AddCustomNetworkViewModel.swift in Sources */,
@ -3698,7 +3679,6 @@
2963B6AF1F9823E6003063C1 /* UnconfirmedTransaction.swift in Sources */,
2996F1431F6C96FF005C33AE /* ImportWalletViewModel.swift in Sources */,
291ED08D1F6F5F0A00E7E93A /* KeyStoreError.swift in Sources */,
29F1C83E1FEB5C91003780D8 /* EditTokensViewController.swift in Sources */,
296AF9A31F733AB30058AF78 /* WalletCoordinator.swift in Sources */,
442FCBBFCC5926B4D416E6D3 /* GetNameCoordinator.swift in Sources */,
442FC5F70AF003F331F7C841 /* GetSymbolCoordinator.swift in Sources */,

@ -1,107 +0,0 @@
// Copyright SIX DAY LLC. All rights reserved.
import Foundation
import UIKit
class EditTokensViewController: UITableViewController {
let session: WalletSession
let storage: TokensDataStore
let viewModel = EditTokenViewModel()
let searchController = UISearchController(searchResultsController: nil)
var filteredTokens = [TokenObject]()
var isFiltering: Bool {
return searchController.isActive && !searchBarIsEmpty
}
var searchBarIsEmpty: Bool {
return searchController.searchBar.text?.isEmpty ?? true
}
init(
session: WalletSession,
storage: TokensDataStore
) {
self.session = session
self.storage = storage
super.init(nibName: nil, bundle: nil)
navigationItem.title = viewModel.title
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.placeholder = R.string.localizable.editTokensSearchBarPlaceholderTitle()
definesPresentationContext = true
searchController.searchBar.delegate = self
tableView.register(R.nib.editTokenTableViewCell(), forCellReuseIdentifier: R.nib.editTokenTableViewCell.name)
tableView.tableHeaderView = searchController.searchBar
tableView.separatorStyle = .none
tableView.separatorInset = .zero
tableView.rowHeight = UITableViewAutomaticDimension
}
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if isFiltering {
return filteredTokens.count
}
return storage.objects.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: R.nib.editTokenTableViewCell.name, for: indexPath) as! EditTokenTableViewCell
cell.delegate = self
let token = self.token(for: indexPath)
cell.viewModel = EditTokenTableCellViewModel(
token: token,
coinTicker: storage.coinTicker(for: token),
config: session.config
)
return cell
}
func token(for indexPath: IndexPath) -> TokenObject {
if isFiltering {
return filteredTokens[indexPath.row]
}
return storage.objects[indexPath.row]
}
func filter(for searchText: String?) {
let text = searchText?.lowercased() ?? ""
filteredTokens = storage.objects.filter { $0.name.lowercased().contains(text) || $0.symbol.lowercased().contains(text) }
tableView.reloadData()
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 80
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension EditTokensViewController: EditTokenTableViewCellDelegate {
func didChangeState(state: Bool, in cell: EditTokenTableViewCell) {
guard let indexPath = tableView.indexPath(for: cell) else { return }
storage.update(token: token(for: indexPath), action: .isDisabled(!state))
}
}
extension EditTokensViewController: UISearchBarDelegate {
func searchBar(_ searchBar: UISearchBar, selectedScopeButtonIndexDidChange selectedScope: Int) {
filter(for: searchBar.text)
}
}
extension EditTokensViewController: UISearchResultsUpdating {
func updateSearchResults(for searchController: UISearchController) {
filter(for: searchController.searchBar.text)
}
}

@ -1,67 +0,0 @@
// Copyright SIX DAY LLC. All rights reserved.
import Foundation
import UIKit
struct EditTokenTableCellViewModel {
let token: TokenObject
let coinTicker: CoinTicker?
let config: Config
init(
token: TokenObject,
coinTicker: CoinTicker?,
config: Config
) {
self.token = token
self.coinTicker = coinTicker
self.config = config
}
var title: String {
return token.title
}
var titleFont: UIFont {
return Fonts.semibold(size: 18)!
}
var titleTextColor: UIColor {
return Colors.black
}
var placeholderImage: UIImage? {
return R.image.ethereumToken()
}
var imageUrl: URL? {
return coinTicker?.imageURL
}
var isEnabled: Bool {
return !token.isDisabled
}
private var isAvailableForChange: Bool {
return token.contract == TokensDataStore.etherToken(for: config).contract ? true : false
}
var contractText: String? {
if !isAvailableForChange {
return token.contract
}
return .none
}
var isTokenContractLabelHidden: Bool {
if contractText == nil {
return true
}
return false
}
var isSwitchHidden: Bool {
return isAvailableForChange
}
}

@ -1,11 +0,0 @@
// Copyright SIX DAY LLC. All rights reserved.
import Foundation
import UIKit
struct EditTokenViewModel {
var title: String {
return R.string.localizable.tokenTitlecase()
}
}

@ -1,38 +0,0 @@
// Copyright SIX DAY LLC. All rights reserved.
import UIKit
import Kingfisher
protocol EditTokenTableViewCellDelegate: class {
func didChangeState(state: Bool, in cell: EditTokenTableViewCell)
}
class EditTokenTableViewCell: UITableViewCell {
@IBOutlet weak var tokenImageView: UIImageView!
@IBOutlet weak var tokenLabel: UILabel!
@IBOutlet weak var tokenEnableSwitch: UISwitch!
@IBOutlet weak var tokenContractLabel: UILabel!
weak var delegate: EditTokenTableViewCellDelegate?
var viewModel: EditTokenTableCellViewModel? {
didSet {
guard let viewModel = viewModel else { return }
tokenLabel.text = viewModel.title
tokenLabel.font = viewModel.titleFont
tokenLabel.textColor = viewModel.titleTextColor
tokenEnableSwitch.isOn = viewModel.isEnabled
tokenContractLabel.text = viewModel.contractText
tokenContractLabel.isHidden = viewModel.isTokenContractLabelHidden
tokenEnableSwitch.isHidden = viewModel.isSwitchHidden
tokenImageView.kf.setImage(
with: viewModel.imageUrl,
placeholder: viewModel.placeholderImage
)
}
}
@IBAction func didChangeSwitch(_ sender: UISwitch) {
delegate?.didChangeState(state: sender.isOn, in: self)
}
}

@ -1,84 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="0.0" id="KGk-i7-Jjw" customClass="EditTokenTableViewCell" customModule="Trust" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="319" height="80"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="319" height="79.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" alignment="top" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="d5W-Lo-p3o">
<rect key="frame" x="10" y="10" width="299" height="60"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Tfc-cq-2hm">
<rect key="frame" x="0.0" y="0.0" width="72" height="50"/>
<constraints>
<constraint firstAttribute="width" constant="72" id="uhQ-eN-kxx"/>
</constraints>
</imageView>
<stackView opaque="NO" contentMode="scaleAspectFit" semanticContentAttribute="spatial" axis="vertical" distribution="equalCentering" alignment="top" spacing="-2" translatesAutoresizingMaskIntoConstraints="NO" id="fRy-j2-9ES" userLabel="Label Stack View">
<rect key="frame" x="77" y="0.0" width="168" height="55"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="751" text="Test lable" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.69999999999999996" translatesAutoresizingMaskIntoConstraints="NO" id="gzC-hL-qRv">
<rect key="frame" x="0.0" y="0.0" width="73" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Su7-1W-bDk">
<rect key="frame" x="0.0" y="20" width="33" height="35"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="Su7-1W-bDk" firstAttribute="centerY" secondItem="fRy-j2-9ES" secondAttribute="centerY" constant="10" id="VAL-9W-wbh"/>
</constraints>
</stackView>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Uf5-TC-p3g">
<rect key="frame" x="250" y="0.0" width="51" height="31"/>
<connections>
<action selector="didChangeSwitch:" destination="KGk-i7-Jjw" eventType="valueChanged" id="RNY-kW-3Zh"/>
</connections>
</switch>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="Tfc-cq-2hm" secondAttribute="bottom" constant="10" id="85M-T3-zGn"/>
<constraint firstAttribute="trailing" secondItem="Uf5-TC-p3g" secondAttribute="trailing" id="pKu-nx-1qR"/>
<constraint firstAttribute="bottom" secondItem="fRy-j2-9ES" secondAttribute="bottom" constant="5" id="sQQ-18-ZYL"/>
</constraints>
</stackView>
</subviews>
<constraints>
<constraint firstItem="d5W-Lo-p3o" firstAttribute="centerX" secondItem="H2p-sc-9uM" secondAttribute="centerX" id="8PS-GA-H74"/>
<constraint firstItem="d5W-Lo-p3o" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" constant="-1" id="YfI-ez-BFb"/>
<constraint firstItem="d5W-Lo-p3o" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="cS9-mR-210"/>
<constraint firstItem="d5W-Lo-p3o" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leadingMargin" constant="-6" id="vlf-YR-icm"/>
</constraints>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
<inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
<connections>
<outlet property="tokenContractLabel" destination="Su7-1W-bDk" id="gpT-3O-qkl"/>
<outlet property="tokenEnableSwitch" destination="Uf5-TC-p3g" id="Lcf-e0-JTA"/>
<outlet property="tokenImageView" destination="Tfc-cq-2hm" id="QtY-sC-dhw"/>
<outlet property="tokenLabel" destination="gzC-hL-qRv" id="cHh-cJ-bga"/>
</connections>
<point key="canvasLocation" x="33.5" y="72"/>
</tableViewCell>
</objects>
</document>

@ -59,8 +59,8 @@ class ConfigTests: XCTestCase {
config.locale = AppLocale.simplifiedChinese.id
let tableView = UITableView()
tableView.register(R.nib.editTokenTableViewCell(), forCellReuseIdentifier: R.nib.editTokenTableViewCell.name)
XCTAssertNoThrow(tableView.dequeueReusableCell(withIdentifier: R.nib.editTokenTableViewCell.name))
tableView.register(R.nib.bookmarkViewCell(), forCellReuseIdentifier: R.nib.bookmarkViewCell.name)
XCTAssertNoThrow(tableView.dequeueReusableCell(withIdentifier: R.nib.bookmarkViewCell.name))
//Must change this back to system, otherwise other tests will break either immediately or the next run
config.locale = AppLocale.system.id

Loading…
Cancel
Save