Skip to content

Commit

Permalink
trustwallet#113: Move backup to wallets section (trustwallet#118)
Browse files Browse the repository at this point in the history
* trustwallet#113: Move backup to wallets section

* trustwallet#113: Update travis version of xcode
  • Loading branch information
kerrmarin authored and Michael Scoff committed Dec 10, 2017
1 parent 4b66fd9 commit 562c12f
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 156 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: swift
osx_image: xcode9.1
osx_image: xcode9.2

branches:
only:
Expand Down
18 changes: 1 addition & 17 deletions Trust.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@
2996F1431F6C96FF005C33AE /* ImportWalletViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2996F1421F6C96FF005C33AE /* ImportWalletViewModel.swift */; };
2996F1461F6C98B3005C33AE /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2996F1451F6C98B3005C33AE /* SettingsViewController.swift */; };
2996F1481F6C9AE5005C33AE /* SettingsCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2996F1471F6C9AE5005C33AE /* SettingsCoordinator.swift */; };
2996F14A1F6C9D10005C33AE /* ExportCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2996F1491F6C9D10005C33AE /* ExportCoordinator.swift */; };
2996F14D1F6CA743005C33AE /* UIViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2996F14C1F6CA742005C33AE /* UIViewController.swift */; };
2996F1501F6CA80C005C33AE /* ExportError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2996F14F1F6CA80C005C33AE /* ExportError.swift */; };
299B5E271FC9C5E40051361C /* ExchangeTokenError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 299B5E261FC9C5E40051361C /* ExchangeTokenError.swift */; };
299B5E291FCA8F040051361C /* GetERC20Balance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 299B5E281FCA8F040051361C /* GetERC20Balance.swift */; };
299B5E2B1FCA9A640051361C /* ApproveERC20.swift in Sources */ = {isa = PBXBuildFile; fileRef = 299B5E2A1FCA9A640051361C /* ApproveERC20.swift */; };
Expand Down Expand Up @@ -464,9 +462,7 @@
2996F1421F6C96FF005C33AE /* ImportWalletViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImportWalletViewModel.swift; sourceTree = "<group>"; };
2996F1451F6C98B3005C33AE /* SettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = "<group>"; };
2996F1471F6C9AE5005C33AE /* SettingsCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsCoordinator.swift; sourceTree = "<group>"; };
2996F1491F6C9D10005C33AE /* ExportCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExportCoordinator.swift; sourceTree = "<group>"; };
2996F14C1F6CA742005C33AE /* UIViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewController.swift; sourceTree = "<group>"; };
2996F14F1F6CA80C005C33AE /* ExportError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExportError.swift; sourceTree = "<group>"; };
299B5E261FC9C5E40051361C /* ExchangeTokenError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExchangeTokenError.swift; sourceTree = "<group>"; };
299B5E281FCA8F040051361C /* GetERC20Balance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetERC20Balance.swift; sourceTree = "<group>"; };
299B5E2A1FCA9A640051361C /* ApproveERC20.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApproveERC20.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1043,20 +1039,11 @@
2977CAE11F7E0B17009682A0 /* Coordinators */ = {
isa = PBXGroup;
children = (
2996F1491F6C9D10005C33AE /* ExportCoordinator.swift */,
29DBF2A21F9DBFF400327C60 /* BackupCoordinator.swift */,
);
path = Coordinators;
sourceTree = "<group>";
};
2977CAE21F7E0B2D009682A0 /* Types */ = {
isa = PBXGroup;
children = (
2996F14F1F6CA80C005C33AE /* ExportError.swift */,
);
path = Types;
sourceTree = "<group>";
};
2977CAE31F7E0B3F009682A0 /* Coordinators */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1089,7 +1076,6 @@
2977CAE61F7E0B7C009682A0 /* ViewControllers */ = {
isa = PBXGroup;
children = (
291F52BE1F6C874E00B369AB /* AccountsViewController.swift */,
);
path = ViewControllers;
sourceTree = "<group>";
Expand All @@ -1099,6 +1085,7 @@
children = (
291F52C01F6C8A1F00B369AB /* AccountsViewModel.swift */,
290B2B601F9179880053C83E /* AccountViewModel.swift */,
291F52BE1F6C874E00B369AB /* AccountsViewController.swift */,
);
path = ViewModels;
sourceTree = "<group>";
Expand Down Expand Up @@ -1349,7 +1336,6 @@
children = (
299B5E391FD141A40051361C /* ViewModels */,
29DBF29F1F9DA6E200327C60 /* ViewControllers */,
2977CAE21F7E0B2D009682A0 /* Types */,
2977CAE11F7E0B17009682A0 /* Coordinators */,
);
path = Export;
Expand Down Expand Up @@ -2151,7 +2137,6 @@
615F10591FCBEF7C008A45AF /* OnboardingPage.swift in Sources */,
2963B6B91F9A7EEA003063C1 /* CoinTicker.swift in Sources */,
29F114EC1FA448F400114A29 /* TokensCoordinator.swift in Sources */,
2996F14A1F6C9D10005C33AE /* ExportCoordinator.swift in Sources */,
2932488E1F88E69F008A9818 /* OnePasswordError.swift in Sources */,
293E62711FA2F63500CB0A66 /* InitialWalletCreationCoordinator.swift in Sources */,
291D73C61F7F500D00A8AB56 /* TransactionItemState.swift in Sources */,
Expand Down Expand Up @@ -2262,7 +2247,6 @@
296AF9A91F737F6F0058AF78 /* SendRawTransactionRequest.swift in Sources */,
293112121FC4F48400966EEA /* ServiceProvider.swift in Sources */,
2912CD2F1F6A83A100C6CBE3 /* ImportWalletViewController.swift in Sources */,
2996F1501F6CA80C005C33AE /* ExportError.swift in Sources */,
298543041FC15F6D00CB5081 /* ExchangeCoordinator.swift in Sources */,
2996F1461F6C98B3005C33AE /* SettingsViewController.swift in Sources */,
2963B6AD1F981A96003063C1 /* TransactionAppearance.swift in Sources */,
Expand Down
31 changes: 31 additions & 0 deletions Trust/Accounts/Coordinators/AccountsCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@ class AccountsCoordinator: Coordinator {
coordinator.start(.welcome)
navigationController.present(coordinator.navigationController, animated: true, completion: nil)
}

func showInfoSheet(for account: Account) {
let controller = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
let actionTitle = NSLocalizedString("wallets.backup.backup-action.title", comment: "The title of the backup button in the wallet's action sheet")
let action = UIAlertAction(title: actionTitle, style: .default) { _ in
let coordinator = BackupCoordinator(
navigationController: self.navigationController,
keystore: self.keystore,
account: account
)
coordinator.delegate = self
coordinator.start()
self.addCoordinator(coordinator)
}
controller.addAction(action)
navigationController.present(controller, animated: true, completion: nil)
}
}

extension AccountsCoordinator: AccountsViewControllerDelegate {
Expand All @@ -65,6 +82,10 @@ extension AccountsCoordinator: AccountsViewControllerDelegate {
func didDeleteAccount(account: Account, in viewController: AccountsViewController) {
delegate?.didDeleteAccount(account: account, in: self)
}

func didSelectInfoForAccount(account: Account, in viewController: AccountsViewController) {
showInfoSheet(for: account)
}
}

extension AccountsCoordinator: WalletCoordinatorDelegate {
Expand All @@ -85,3 +106,13 @@ extension AccountsCoordinator: WalletCoordinatorDelegate {
removeCoordinator(coordinator)
}
}

extension AccountsCoordinator: BackupCoordinatorDelegate {
func didCancel(coordinator: BackupCoordinator) {
removeCoordinator(coordinator)
}

func didFinish(account: Account, in coordinator: BackupCoordinator) {
removeCoordinator(coordinator)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import UIKit
protocol AccountsViewControllerDelegate: class {
func didSelectAccount(account: Account, in viewController: AccountsViewController)
func didDeleteAccount(account: Account, in viewController: AccountsViewController)
func didSelectInfoForAccount(account: Account, in viewController: AccountsViewController)
}

class AccountsViewController: UITableViewController {
Expand Down Expand Up @@ -72,7 +73,8 @@ class AccountsViewController: UITableViewController {
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let account = self.account(for: indexPath)
let cell = AccountViewCell(style: .default, reuseIdentifier: AccountViewCell.identifier)
cell.configure(viewModel: AccountViewModel(account: account, current: EtherKeystore.current))
cell.viewModel = AccountViewModel(account: account, current: EtherKeystore.current)
cell.delegate = self
return cell
}

Expand Down Expand Up @@ -124,3 +126,9 @@ class AccountsViewController: UITableViewController {
fatalError("init(coder:) has not been implemented")
}
}

extension AccountsViewController: AccountViewCellDelegate {
func accountViewCell(_ cell: AccountViewCell, didTapInfoViewForAccount account: Account) {
self.delegate?.didSelectInfoForAccount(account: account, in: self)
}
}
39 changes: 35 additions & 4 deletions Trust/Accounts/Views/AccountViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,30 @@

import UIKit

protocol AccountViewCellDelegate: class {
func accountViewCell(_ cell: AccountViewCell, didTapInfoViewForAccount _: Account)
}

class AccountViewCell: UITableViewCell {

static let identifier = "AccountViewCell"

weak var delegate: AccountViewCellDelegate?

let walletImageView = UIImageView()
let walletLabel = UILabel()
let infoButton = UIButton(type: .infoLight)

var viewModel: AccountViewModel? {
didSet {
walletImageView.image = viewModel?.image
walletLabel.text = viewModel?.title
}
}

private struct Layout {
static let activeSize: CGFloat = 8
static let infoButtonWidth: CGFloat = 22
}

override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
Expand All @@ -23,25 +38,41 @@ class AccountViewCell: UITableViewCell {
walletLabel.translatesAutoresizingMaskIntoConstraints = false
walletLabel.lineBreakMode = .byTruncatingMiddle

infoButton.translatesAutoresizingMaskIntoConstraints = false
infoButton.tintColor = Colors.blue
infoButton.addTarget(self, action: #selector(AccountViewCell.didTapInfoButton(sender:)), for: .touchUpInside)

contentView.addSubview(walletImageView)
contentView.addSubview(walletLabel)
contentView.addSubview(infoButton)

NSLayoutConstraint.activate([
walletImageView.widthAnchor.constraint(equalToConstant: Layout.activeSize),
walletImageView.heightAnchor.constraint(equalToConstant: Layout.activeSize),
walletImageView.centerYAnchor.constraint(equalTo: centerYAnchor),
walletImageView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: StyleLayout.sideMargin),

walletLabel.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -StyleLayout.sideMargin),
walletLabel.trailingAnchor.constraint(equalTo: infoButton.leadingAnchor, constant: -StyleLayout.sideMargin),
walletLabel.leadingAnchor.constraint(equalTo: walletImageView.trailingAnchor, constant: StyleLayout.sideMargin),
walletLabel.topAnchor.constraint(equalTo: topAnchor),
walletLabel.bottomAnchor.constraint(equalTo: bottomAnchor),

infoButton.centerYAnchor.constraint(equalTo: centerYAnchor),
infoButton.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -StyleLayout.sideMargin),
infoButton.widthAnchor.constraint(equalToConstant: Layout.infoButtonWidth),
])
}

func configure(viewModel: AccountViewModel) {
walletImageView.image = viewModel.image
walletLabel.text = viewModel.title
override func prepareForReuse() {
super.prepareForReuse()
self.viewModel = nil
}

@objc private func didTapInfoButton(sender: UIButton) {
guard let account = viewModel?.account else {
return
}
delegate?.accountViewCell(self, didTapInfoViewForAccount: account)
}

required init?(coder aDecoder: NSCoder) {
Expand Down
79 changes: 0 additions & 79 deletions Trust/Export/Coordinators/ExportCoordinator.swift

This file was deleted.

14 changes: 0 additions & 14 deletions Trust/Export/Types/ExportError.swift

This file was deleted.

22 changes: 0 additions & 22 deletions Trust/Settings/Coordinators/SettingsCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,11 @@ class SettingsCoordinator: Coordinator {
@objc func dismiss() {
delegate?.didCancel(in: self)
}

@objc func export(in viewController: UIViewController) {
let coordinator = ExportCoordinator(keystore: keystore)
coordinator.delegate = self
coordinator.start()
addCoordinator(coordinator)
viewController.present(coordinator.navigationController, animated: true, completion: nil)
}
}

extension SettingsCoordinator: SettingsViewControllerDelegate {
func didAction(action: SettingsAction, in viewController: SettingsViewController) {
switch action {
case .exportPrivateKey:
export(in: viewController)
case .RPCServer: break
case .donate: break
case .pushNotifications(let enabled):
Expand All @@ -69,15 +59,3 @@ extension SettingsCoordinator: SettingsViewControllerDelegate {
delegate?.didUpdate(action: action, in: self)
}
}

extension SettingsCoordinator: ExportCoordinatorDelegate {
func didFinish(in coordinator: ExportCoordinator) {
coordinator.navigationController.dismiss(animated: true, completion: nil)
removeCoordinator(coordinator)
}

func didCancel(in coordinator: ExportCoordinator) {
coordinator.navigationController.dismiss(animated: true, completion: nil)
removeCoordinator(coordinator)
}
}
4 changes: 2 additions & 2 deletions Trust/Settings/Types/BiometryAuthenticationType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ extension BiometryAuthenticationType {
static var current: BiometryAuthenticationType {
if #available(iOS 11.0, *) {
switch LAContext().biometryType {
case .typeTouchID: return .touchID
case .typeFaceID: return .faceID
case .touchID: return .touchID
case .faceID: return .faceID
case .none: return .none
}
}
Expand Down
1 change: 0 additions & 1 deletion Trust/Settings/Types/SettingsAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import Foundation

enum SettingsAction {
case exportPrivateKey
case RPCServer
case donate(address: Address)
case pushNotifications(enabled: Bool)
Expand Down
Loading

0 comments on commit 562c12f

Please sign in to comment.