Extract green footer buttons as a footer class

pull/1047/head
Hwee-Boon Yar 6 years ago
parent 37bcbc0618
commit c1a4e38282
  1. 4
      AlphaWallet.xcodeproj/project.pbxproj
  2. 27
      AlphaWallet/Browser/ViewControllers/EditMyDappViewController.swift
  3. 16
      AlphaWallet/Browser/ViewModel/EditMyDappViewControllerViewModel.swift
  4. 43
      AlphaWallet/Market/ViewControllers/ImportMagicTokenViewController.swift
  5. 32
      AlphaWallet/Market/ViewModels/ImportMagicTokenViewControllerViewModel.swift
  6. 31
      AlphaWallet/Redeem/ViewControllers/RedeemTokenCardQuantitySelectionViewController.swift
  7. 31
      AlphaWallet/Redeem/ViewControllers/RedeemTokenViewController.swift
  8. 32
      AlphaWallet/Redeem/ViewModels/RedeemTokenCardQuantitySelectionViewModel.swift
  9. 32
      AlphaWallet/Redeem/ViewModels/RedeemTokenCardViewModel.swift
  10. 32
      AlphaWallet/Sell/ViewControllers/EnterSellTokensCardPriceQuantityViewController.swift
  11. 31
      AlphaWallet/Sell/ViewControllers/SellTokensCardViewController.swift
  12. 32
      AlphaWallet/Sell/ViewControllers/SetSellTokensCardExpiryDateViewController.swift
  13. 32
      AlphaWallet/Sell/ViewModels/EnterSellTokensCardPriceQuantityViewControllerViewModel.swift
  14. 31
      AlphaWallet/Sell/ViewModels/SellTokensCardViewModel.swift
  15. 32
      AlphaWallet/Sell/ViewModels/SetSellTokensCardExpiryDateViewControllerViewModel.swift
  16. 2
      AlphaWallet/Style/AppStyle.swift
  17. 35
      AlphaWallet/Tokens/ViewControllers/NewTokenViewController.swift
  18. 31
      AlphaWallet/Tokens/ViewControllers/TokenViewController.swift
  19. 76
      AlphaWallet/Tokens/ViewControllers/TokensCardViewController.swift
  20. 32
      AlphaWallet/Tokens/ViewModels/NewTokenViewModel.swift
  21. 28
      AlphaWallet/Tokens/ViewModels/TokenViewControllerViewModel.swift
  22. 36
      AlphaWallet/Tokens/ViewModels/TokensCardViewModel.swift
  23. 49
      AlphaWallet/Transfer/ViewControllers/ChooseTokenCardTransferModeViewController.swift
  24. 31
      AlphaWallet/Transfer/ViewControllers/SendViewController.swift
  25. 31
      AlphaWallet/Transfer/ViewControllers/SetTransferTokensCardExpiryDateViewController.swift
  26. 31
      AlphaWallet/Transfer/ViewControllers/TransferTokensCardQuantitySelectionViewController.swift
  27. 31
      AlphaWallet/Transfer/ViewControllers/TransferTokensCardViaWalletAddressViewController.swift
  28. 31
      AlphaWallet/Transfer/ViewControllers/TransferTokensCardViewController.swift
  29. 28
      AlphaWallet/Transfer/ViewModels/ChooseTokenCardTransferModeViewControllerViewModel.swift
  30. 30
      AlphaWallet/Transfer/ViewModels/SendViewModel.swift
  31. 32
      AlphaWallet/Transfer/ViewModels/SetTransferTokensCardExpiryDateViewControllerViewModel.swift
  32. 32
      AlphaWallet/Transfer/ViewModels/TransferTokensCardQuantitySelectionViewModel.swift
  33. 32
      AlphaWallet/Transfer/ViewModels/TransferTokensCardViaWalletAddressViewControllerViewModel.swift
  34. 32
      AlphaWallet/Transfer/ViewModels/TransferTokensCardViewModel.swift
  35. 97
      AlphaWallet/UI/ButtonsBar.swift
  36. 31
      AlphaWallet/Wallet/ViewControllers/ImportWalletViewController.swift
  37. 32
      AlphaWallet/Wallet/ViewModels/ImportWalletViewModel.swift

@ -417,6 +417,7 @@
5E7C7BFE9C8CAA3E204B1FAA /* TokenRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7F89E3480D3680750EA9 /* TokenRowView.swift */; };
5E7C7C0D3181CD31A581AEBE /* EditMyDappViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7F55495A6095B3E86248 /* EditMyDappViewController.swift */; };
5E7C7C0FAC500A6651E663FD /* TransferTokensCardQuantitySelectionViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C703BA1D0E9ACB7399155 /* TransferTokensCardQuantitySelectionViewModel.swift */; };
5E7C7C0FBEF6206024FB355E /* ButtonsBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C774238AE6861A7935EEE /* ButtonsBar.swift */; };
5E7C7C21E5CAF122AA4F6617 /* HowDoIGetMyMoneyInfoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C78B001F9F95F404D5FEF /* HowDoIGetMyMoneyInfoViewController.swift */; };
5E7C7C7142C4519873B2BB4E /* ImportWalletTabBarViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7C2872E213BBB05D55BA /* ImportWalletTabBarViewModel.swift */; };
5E7C7C8BC4763CFDD3EE119D /* AssetAttributeFunctionCall.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C75C1D4D61A74BACAFF69 /* AssetAttributeFunctionCall.swift */; };
@ -962,6 +963,7 @@
5E7C7721E0E4D4EFDD35E196 /* ScanQRCodeCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScanQRCodeCoordinator.swift; sourceTree = "<group>"; };
5E7C772DC28C5110021894E3 /* ImageCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageCache.swift; sourceTree = "<group>"; };
5E7C77316522DF2B256F1F92 /* TokensCardViewControllerHeaderViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TokensCardViewControllerHeaderViewModel.swift; sourceTree = "<group>"; };
5E7C774238AE6861A7935EEE /* ButtonsBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ButtonsBar.swift; path = AlphaWallet/UI/ButtonsBar.swift; sourceTree = SOURCE_ROOT; };
5E7C774BCA281E4B077DBBFA /* WhatIsEthereumInfoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WhatIsEthereumInfoViewController.swift; sourceTree = "<group>"; };
5E7C775FD95FE80B0F1CEA33 /* TokenAdaptorTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TokenAdaptorTest.swift; sourceTree = "<group>"; };
5E7C776B129861728FFB8CC8 /* EditMyDappViewControllerViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditMyDappViewControllerViewModel.swift; sourceTree = "<group>"; };
@ -1789,6 +1791,7 @@
5E7C7CC48CA7A1EA7D539C87 /* VerifiableStatusViewController.swift */,
5E7C77B790551456E111ED4F /* PeekOpenSeaNonFungibleTokenViewController.swift */,
5E7C7EC53B2B5DFAAC7965EC /* TokenViewController.swift */,
5E7C774238AE6861A7935EEE /* ButtonsBar.swift */,
);
path = ViewControllers;
sourceTree = "<group>";
@ -4079,6 +4082,7 @@
5E7C7A6E4C1AEFED0B0630A6 /* TokenViewControllerTransactionCellViewModel.swift in Sources */,
5E7C749615D227B91E40B274 /* TokenViewControllerHeaderView.swift in Sources */,
5E7C72EECA8154CEB7D9F46C /* ContainerViewWithShadow.swift in Sources */,
5E7C7C0FBEF6206024FB355E /* ButtonsBar.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

@ -17,7 +17,7 @@ class EditMyDappViewController: UIViewController {
private let urlLabel = UILabel()
private let urlTextField = UITextField()
private let cancelButton = UIButton(type: .system)
private let saveButton = UIButton(type: .system)
private let buttonsBar = ButtonsBar(numberOfButtons: 1)
private var viewModel: EditMyDappViewControllerViewModel?
weak var delegate: EditMyDappViewControllerDelegate?
@ -53,12 +53,7 @@ class EditMyDappViewController: UIViewController {
footerBar.translatesAutoresizingMaskIntoConstraints = false
roundedBackground.addSubview(footerBar)
let buttonsHeight = Metrics.greenButtonHeight
saveButton.translatesAutoresizingMaskIntoConstraints = false
saveButton.setContentCompressionResistancePriority(.required, for: .horizontal)
saveButton.setContentHuggingPriority(.defaultLow, for: .horizontal)
saveButton.addTarget(self, action: #selector(save), for: .touchUpInside)
footerBar.addSubview(saveButton)
footerBar.addSubview(buttonsBar)
cancelButton.addTarget(self, action: #selector(cancel), for: .touchUpInside)
cancelButton.translatesAutoresizingMaskIntoConstraints = false
@ -79,14 +74,13 @@ class EditMyDappViewController: UIViewController {
footerBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
footerBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
//Additional allowance so there's a margin below the buttons for non-iPhone X devices
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -buttonsHeight - 3),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -ButtonsBar.buttonsHeight - ButtonsBar.marginAtBottomScreen),
footerBar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
saveButton.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor, constant: 15),
saveButton.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor, constant: -15),
saveButton.topAnchor.constraint(equalTo: footerBar.topAnchor),
saveButton.heightAnchor.constraint(equalToConstant: buttonsHeight),
buttonsBar.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsBar.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsBar.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsBar.heightAnchor.constraint(equalToConstant: ButtonsBar.buttonsHeight),
stackView.leadingAnchor.constraint(equalTo: roundedBackground.leadingAnchor, constant: 37),
stackView.trailingAnchor.constraint(equalTo: roundedBackground.trailingAnchor, constant: -37),
@ -148,11 +142,10 @@ class EditMyDappViewController: UIViewController {
urlTextField.returnKeyType = .done
urlTextField.text = viewModel.urlTextFieldText
saveButton.setTitleColor(viewModel.saveButtonTitleColor, for: .normal)
saveButton.backgroundColor = viewModel.saveButtonBackgroundColor
saveButton.titleLabel?.font = viewModel.saveButtonFont
buttonsBar.configure()
let saveButton = buttonsBar.buttons[0]
saveButton.addTarget(self, action: #selector(save), for: .touchUpInside)
saveButton.setTitle(viewModel.saveButtonTitle, for: .normal)
saveButton.cornerRadius = viewModel.saveButtonCornerRadius
cancelButton.setTitleColor(viewModel.cancelButtonTitleColor, for: .normal)
cancelButton.titleLabel?.font = viewModel.cancelButtonFont

@ -118,26 +118,10 @@ struct EditMyDappViewControllerViewModel {
return dapp.url
}
var saveButtonTitleColor: UIColor {
return Colors.appWhite
}
var saveButtonBackgroundColor: UIColor {
return Colors.appHighlightGreen
}
var saveButtonFont: UIFont {
return Fonts.regular(size: 20)!
}
var saveButtonTitle: String {
return R.string.localizable.save()
}
var saveButtonCornerRadius: CGFloat {
return 16
}
var cancelButtonTitleColor: UIColor {
return Colors.appWhite
}

@ -24,8 +24,7 @@ class ImportMagicTokenViewController: UIViewController, OptionalTokenVerifiableS
private let ethCostLabel = UILabel()
private let dollarCostLabelLabel = UILabel()
private let dollarCostLabel = PaddedLabel()
private var actionButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private var cancelButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private let buttonsBar = ButtonsBar(numberOfButtons: 2)
private var viewModel: ImportMagicTokenViewControllerViewModel?
let config: Config
@ -90,15 +89,6 @@ class ImportMagicTokenViewController: UIViewController, OptionalTokenVerifiableS
].asStackView(axis: .vertical, alignment: .center)
costStackView?.translatesAutoresizingMaskIntoConstraints = false
let actionButton = actionButtonContainer.childView
actionButton.addTarget(self, action: #selector(actionTapped), for: .touchUpInside)
let cancelButton = cancelButtonContainer.childView
cancelButton.addTarget(self, action: #selector(cancel), for: .touchUpInside)
let buttonsStackView = [.spacerWidth(20), actionButtonContainer, .spacerWidth(7), cancelButtonContainer, .spacerWidth(20)].asStackView(contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
let stackView = [
header,
.spacer(height: 1),
@ -118,8 +108,7 @@ class ImportMagicTokenViewController: UIViewController, OptionalTokenVerifiableS
footerBar.backgroundColor = .clear
roundedBackground.addSubview(footerBar)
let buttonsHeight = Metrics.greenButtonHeight
footerBar.addSubview(buttonsStackView)
footerBar.addSubview(buttonsBar)
let separatorThickness = CGFloat(1)
@ -137,16 +126,14 @@ class ImportMagicTokenViewController: UIViewController, OptionalTokenVerifiableS
separator2.leadingAnchor.constraint(equalTo: tokenCardRowView.background.leadingAnchor),
separator2.trailingAnchor.constraint(equalTo: tokenCardRowView.background.trailingAnchor),
buttonsStackView.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsStackView.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsStackView.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsStackView.heightAnchor.constraint(equalToConstant: buttonsHeight),
actionButtonContainer.widthAnchor.constraint(equalTo: cancelButtonContainer.widthAnchor),
buttonsBar.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsBar.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsBar.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsBar.heightAnchor.constraint(equalToConstant: ButtonsBar.buttonsHeight),
footerBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
footerBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -buttonsHeight - 3),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -ButtonsBar.buttonsHeight - ButtonsBar.marginAtBottomScreen),
footerBar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
statusLabel.widthAnchor.constraint(equalTo: tokenCardRowView.widthAnchor, constant: -20),
@ -213,19 +200,15 @@ class ImportMagicTokenViewController: UIViewController, OptionalTokenVerifiableS
activityIndicator.stopAnimating()
}
actionButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.actionButtonCornerRadius)
let actionButton = actionButtonContainer.childView
actionButton.setTitleColor(viewModel.buttonTitleColor, for: .normal)
actionButton.backgroundColor = viewModel.buttonBackgroundColor
actionButton.titleLabel?.font = viewModel.buttonFont
buttonsBar.configure()
let actionButton = buttonsBar.buttons[0]
actionButton.setTitle(viewModel.actionButtonTitle, for: .normal)
actionButton.addTarget(self, action: #selector(actionTapped), for: .touchUpInside)
cancelButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.actionButtonCornerRadius)
let cancelButton = cancelButtonContainer.childView
cancelButton.setTitleColor(viewModel.buttonTitleColor, for: .normal)
cancelButton.backgroundColor = viewModel.buttonBackgroundColor
cancelButton.titleLabel?.font = viewModel.buttonFont
let cancelButton = buttonsBar.buttons[1]
cancelButton.setTitle(viewModel.cancelButtonTitle, for: .normal)
cancelButton.addTarget(self, action: #selector(cancel), for: .touchUpInside)
actionButton.isHidden = !viewModel.showActionButton

@ -244,18 +244,6 @@ struct ImportMagicTokenViewControllerViewModel {
return Fonts.light(size: 21)!
}
var buttonTitleColor: UIColor {
return Colors.appWhite
}
var buttonBackgroundColor: UIColor {
return Colors.appActionButtonGreen
}
var buttonFont: UIFont {
return Fonts.regular(size: 20)!
}
var showActionButton: Bool {
switch state {
case .promptImport:
@ -326,24 +314,4 @@ struct ImportMagicTokenViewControllerViewModel {
self.state = state
self.server = server
}
var actionButtonCornerRadius: CGFloat {
return 16
}
var actionButtonShadowColor: UIColor {
return Colors.appActionButtonShadow
}
var actionButtonShadowOffset: CGSize {
return .init(width: 1, height: 2)
}
var actionButtonShadowOpacity: Float {
return 0.3
}
var actionButtonShadowRadius: CGFloat {
return 5
}
}

@ -20,7 +20,7 @@ class RedeemTokenCardQuantitySelectionViewController: UIViewController, TokenVer
private let subtitleLabel = UILabel()
private let quantityStepper = NumberStepper()
private let tokenRowView: TokenRowView & UIView
private var nextButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private let buttonsBar = ButtonsBar(numberOfButtons: 1)
private var viewModel: RedeemTokenCardQuantitySelectionViewModel
let config: Config
@ -51,10 +51,6 @@ class RedeemTokenCardQuantitySelectionViewController: UIViewController, TokenVer
subtitleLabel.translatesAutoresizingMaskIntoConstraints = false
let nextButton = nextButtonContainer.childView
nextButton.setTitle(R.string.localizable.aWalletTokenRedeemButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
tokenRowView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(tokenRowView)
@ -74,16 +70,12 @@ class RedeemTokenCardQuantitySelectionViewController: UIViewController, TokenVer
stackView.translatesAutoresizingMaskIntoConstraints = false
roundedBackground.addSubview(stackView)
let buttonsStackView = [.spacerWidth(20), nextButtonContainer, .spacerWidth(20)].asStackView(contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
let footerBar = UIView()
footerBar.translatesAutoresizingMaskIntoConstraints = false
footerBar.backgroundColor = .clear
roundedBackground.addSubview(footerBar)
let buttonsHeight = Metrics.greenButtonHeight
footerBar.addSubview(buttonsStackView)
footerBar.addSubview(buttonsBar)
NSLayoutConstraint.activate([
header.heightAnchor.constraint(equalToConstant: 90),
@ -97,14 +89,14 @@ class RedeemTokenCardQuantitySelectionViewController: UIViewController, TokenVer
stackView.trailingAnchor.constraint(equalTo: roundedBackground.trailingAnchor),
stackView.topAnchor.constraint(equalTo: roundedBackground.topAnchor),
buttonsStackView.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsStackView.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsStackView.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsStackView.heightAnchor.constraint(equalToConstant: buttonsHeight),
buttonsBar.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsBar.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsBar.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsBar.heightAnchor.constraint(equalToConstant: ButtonsBar.buttonsHeight),
footerBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
footerBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -buttonsHeight - 3),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -ButtonsBar.buttonsHeight - ButtonsBar.marginAtBottomScreen),
footerBar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
] + roundedBackground.createConstraintsWithContainer(view: view))
}
@ -161,11 +153,10 @@ class RedeemTokenCardQuantitySelectionViewController: UIViewController, TokenVer
tokenRowView.stateLabel.isHidden = true
nextButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.actionButtonCornerRadius)
let nextButton = nextButtonContainer.childView
nextButton.setTitleColor(viewModel.buttonTitleColor, for: .normal)
nextButton.backgroundColor = viewModel.buttonBackgroundColor
nextButton.titleLabel?.font = viewModel.buttonFont
buttonsBar.configure()
let nextButton = buttonsBar.buttons[0]
nextButton.setTitle(R.string.localizable.aWalletTokenRedeemButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
}
private func getTokenHolderFromQuantity() -> TokenHolder {

@ -19,7 +19,7 @@ class RedeemTokenViewController: UIViewController, TokenVerifiableStatusViewCont
private let roundedBackground = RoundedBackground()
private let header = TokensCardViewControllerTitleHeader()
private let tableView = UITableView(frame: .zero, style: .plain)
private var nextButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private let buttonsBar = ButtonsBar(numberOfButtons: 1)
private var viewModel: RedeemTokenCardViewModel
let config: Config
@ -51,20 +51,12 @@ class RedeemTokenViewController: UIViewController, TokenVerifiableStatusViewCont
tableView.estimatedRowHeight = TokensCardViewController.anArbitaryRowHeightSoAutoSizingCellsWorkIniOS10
roundedBackground.addSubview(tableView)
let nextButton = nextButtonContainer.childView
nextButton.setTitle(R.string.localizable.aWalletNextButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
let buttonsStackView = [.spacerWidth(20), nextButtonContainer, .spacerWidth(20)].asStackView(contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
let footerBar = UIView()
footerBar.translatesAutoresizingMaskIntoConstraints = false
footerBar.backgroundColor = .clear
roundedBackground.addSubview(footerBar)
let buttonsHeight = Metrics.greenButtonHeight
footerBar.addSubview(buttonsStackView)
footerBar.addSubview(buttonsBar)
NSLayoutConstraint.activate([
tableView.leadingAnchor.constraint(equalTo: roundedBackground.leadingAnchor),
@ -72,14 +64,14 @@ class RedeemTokenViewController: UIViewController, TokenVerifiableStatusViewCont
tableView.topAnchor.constraint(equalTo: roundedBackground.topAnchor),
tableView.bottomAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsStackView.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsStackView.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsStackView.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsStackView.heightAnchor.constraint(equalToConstant: buttonsHeight),
buttonsBar.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsBar.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsBar.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsBar.heightAnchor.constraint(equalToConstant: ButtonsBar.buttonsHeight),
footerBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
footerBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -buttonsHeight - 3),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -ButtonsBar.buttonsHeight - ButtonsBar.marginAtBottomScreen),
footerBar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
] + roundedBackground.createConstraintsWithContainer(view: view))
}
@ -98,11 +90,10 @@ class RedeemTokenViewController: UIViewController, TokenVerifiableStatusViewCont
header.configure(title: viewModel.title)
tableView.tableHeaderView = header
nextButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.actionButtonCornerRadius)
let nextButton = nextButtonContainer.childView
nextButton.setTitleColor(viewModel.buttonTitleColor, for: .normal)
nextButton.backgroundColor = viewModel.buttonBackgroundColor
nextButton.titleLabel?.font = viewModel.buttonFont
buttonsBar.configure()
let nextButton = buttonsBar.buttons[0]
nextButton.setTitle(R.string.localizable.aWalletNextButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
}
@objc

@ -26,18 +26,6 @@ struct RedeemTokenCardQuantitySelectionViewModel {
return Colors.appBackground
}
var buttonTitleColor: UIColor {
return Colors.appWhite
}
var buttonBackgroundColor: UIColor {
return Colors.appActionButtonGreen
}
var buttonFont: UIFont {
return Fonts.regular(size: 20)!
}
var subtitleColor: UIColor {
return Colors.appGrayLabelColor
}
@ -54,24 +42,4 @@ struct RedeemTokenCardQuantitySelectionViewModel {
let tokenTypeName = XMLHandler(contract: token.address.eip55String).getTokenTypeName()
return R.string.localizable.aWalletTokenRedeemQuantityTitle(tokenTypeName.localizedUppercase)
}
var actionButtonCornerRadius: CGFloat {
return 16
}
var actionButtonShadowColor: UIColor {
return Colors.appActionButtonShadow
}
var actionButtonShadowOffset: CGSize {
return .init(width: 1, height: 2)
}
var actionButtonShadowOpacity: Float {
return 0.3
}
var actionButtonShadowRadius: CGFloat {
return 5
}
}

@ -31,18 +31,6 @@ struct RedeemTokenCardViewModel {
return R.string.localizable.aWalletTokenRedeemSelectTokensTitle(tokenTypeName)
}
var buttonTitleColor: UIColor {
return Colors.appWhite
}
var buttonBackgroundColor: UIColor {
return Colors.appActionButtonGreen
}
var buttonFont: UIFont {
return Fonts.regular(size: 20)!
}
func toggleSelection(for indexPath: IndexPath) -> [IndexPath] {
let tokenHolder = item(for: indexPath)
var changed = [indexPath]
@ -60,24 +48,4 @@ struct RedeemTokenCardViewModel {
}
return changed
}
var actionButtonCornerRadius: CGFloat {
return 16
}
var actionButtonShadowColor: UIColor {
return Colors.appActionButtonShadow
}
var actionButtonShadowOffset: CGSize {
return .init(width: 1, height: 2)
}
var actionButtonShadowOpacity: Float {
return 0.3
}
var actionButtonShadowRadius: CGFloat {
return 5
}
}

@ -21,7 +21,7 @@ class EnterSellTokensCardPriceQuantityViewController: UIViewController, TokenVer
private let dollarCostLabelLabel = UILabel()
private let dollarCostLabel = PaddedLabel()
private let tokenRowView: TokenRowView & UIView
private var nextButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private let buttonsBar = ButtonsBar(numberOfButtons: 1)
private var viewModel: EnterSellTokensCardPriceQuantityViewControllerViewModel
private let ethPrice: Subscribable<Double>
private var totalEthCost: Ether {
@ -81,10 +81,6 @@ class EnterSellTokensCardPriceQuantityViewController: UIViewController, TokenVer
scrollView.translatesAutoresizingMaskIntoConstraints = false
roundedBackground.addSubview(scrollView)
let nextButton = nextButtonContainer.childView
nextButton.setTitle(R.string.localizable.aWalletNextButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
tokenRowView.translatesAutoresizingMaskIntoConstraints = false
scrollView.addSubview(tokenRowView)
@ -155,16 +151,12 @@ class EnterSellTokensCardPriceQuantityViewController: UIViewController, TokenVer
stackView.translatesAutoresizingMaskIntoConstraints = false
scrollView.addSubview(stackView)
let buttonsStackView = [.spacerWidth(20), nextButtonContainer, .spacerWidth(20)].asStackView(contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
let footerBar = UIView()
footerBar.translatesAutoresizingMaskIntoConstraints = false
footerBar.backgroundColor = .clear
roundedBackground.addSubview(footerBar)
let buttonsHeight = Metrics.greenButtonHeight
footerBar.addSubview(buttonsStackView)
footerBar.addSubview(buttonsBar)
NSLayoutConstraint.activate([
header.heightAnchor.constraint(equalToConstant: 90),
@ -192,14 +184,14 @@ class EnterSellTokensCardPriceQuantityViewController: UIViewController, TokenVer
stackView.topAnchor.constraint(equalTo: scrollView.topAnchor),
stackView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor),
buttonsStackView.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsStackView.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsStackView.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsStackView.heightAnchor.constraint(equalToConstant: buttonsHeight),
buttonsBar.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsBar.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsBar.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsBar.heightAnchor.constraint(equalToConstant: ButtonsBar.buttonsHeight),
footerBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
footerBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -buttonsHeight - 3),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -ButtonsBar.buttonsHeight - ButtonsBar.marginAtBottomScreen),
footerBar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
@ -321,11 +313,11 @@ class EnterSellTokensCardPriceQuantityViewController: UIViewController, TokenVer
tokenRowView.stateLabel.isHidden = true
nextButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.actionButtonCornerRadius)
let nextButton = nextButtonContainer.childView
nextButton.setTitleColor(viewModel.buttonTitleColor, for: .normal)
nextButton.backgroundColor = viewModel.buttonBackgroundColor
nextButton.titleLabel?.font = viewModel.buttonFont
buttonsBar.configure()
let nextButton = buttonsBar.buttons[0]
nextButton.setTitle(R.string.localizable.aWalletNextButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
}
private func getTokenHolderFromQuantity() -> TokenHolder {

@ -12,7 +12,7 @@ class SellTokensCardViewController: UIViewController, TokenVerifiableStatusViewC
private let roundedBackground = RoundedBackground()
private let header = TokensCardViewControllerTitleHeader()
private let tableView = UITableView(frame: .zero, style: .plain)
private var nextButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private let buttonsBar = ButtonsBar(numberOfButtons: 1)
private var viewModel: SellTokensCardViewModel
let config: Config
@ -45,20 +45,12 @@ class SellTokensCardViewController: UIViewController, TokenVerifiableStatusViewC
tableView.estimatedRowHeight = TokensCardViewController.anArbitaryRowHeightSoAutoSizingCellsWorkIniOS10
roundedBackground.addSubview(tableView)
let nextButton = nextButtonContainer.childView
nextButton.setTitle(R.string.localizable.aWalletNextButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
let buttonsStackView = [.spacerWidth(20), nextButtonContainer, .spacerWidth(20)].asStackView(contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
let footerBar = UIView()
footerBar.translatesAutoresizingMaskIntoConstraints = false
footerBar.backgroundColor = .clear
roundedBackground.addSubview(footerBar)
let buttonsHeight = Metrics.greenButtonHeight
footerBar.addSubview(buttonsStackView)
footerBar.addSubview(buttonsBar)
NSLayoutConstraint.activate([
tableView.leadingAnchor.constraint(equalTo: roundedBackground.leadingAnchor),
@ -66,14 +58,14 @@ class SellTokensCardViewController: UIViewController, TokenVerifiableStatusViewC
tableView.topAnchor.constraint(equalTo: roundedBackground.topAnchor),
tableView.bottomAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsStackView.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsStackView.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsStackView.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsStackView.heightAnchor.constraint(equalToConstant: buttonsHeight),
buttonsBar.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsBar.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsBar.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsBar.heightAnchor.constraint(equalToConstant: ButtonsBar.buttonsHeight),
footerBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
footerBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -buttonsHeight - 3),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -ButtonsBar.buttonsHeight - ButtonsBar.marginAtBottomScreen),
footerBar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
] + roundedBackground.createConstraintsWithContainer(view: view))
}
@ -92,11 +84,10 @@ class SellTokensCardViewController: UIViewController, TokenVerifiableStatusViewC
header.configure(title: viewModel.title)
tableView.tableHeaderView = header
nextButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.actionButtonCornerRadius)
let nextButton = nextButtonContainer.childView
nextButton.setTitleColor(viewModel.buttonTitleColor, for: .normal)
nextButton.backgroundColor = viewModel.buttonBackgroundColor
nextButton.titleLabel?.font = viewModel.buttonFont
buttonsBar.configure()
let nextButton = buttonsBar.buttons[0]
nextButton.setTitle(R.string.localizable.aWalletNextButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
}
@objc

@ -24,7 +24,7 @@ class SetSellTokensCardExpiryDateViewController: UIViewController, TokenVerifiab
private let noteLabel = UILabel()
private let noteBorderView = UIView()
private let tokenRowView: TokenRowView & UIView
private var nextButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private let buttonsBar = ButtonsBar(numberOfButtons: 1)
private let datePicker = UIDatePicker()
private let timePicker = UIDatePicker()
private var viewModel: SetSellTokensCardExpiryDateViewControllerViewModel
@ -71,10 +71,6 @@ class SetSellTokensCardExpiryDateViewController: UIViewController, TokenVerifiab
scrollView.translatesAutoresizingMaskIntoConstraints = false
roundedBackground.addSubview(scrollView)
let nextButton = nextButtonContainer.childView
nextButton.setTitle(R.string.localizable.aWalletNextButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
tokenRowView.translatesAutoresizingMaskIntoConstraints = false
scrollView.addSubview(tokenRowView)
@ -157,16 +153,12 @@ class SetSellTokensCardExpiryDateViewController: UIViewController, TokenVerifiab
stackView.translatesAutoresizingMaskIntoConstraints = false
scrollView.addSubview(stackView)
let buttonsStackView = [.spacerWidth(20), nextButtonContainer, .spacerWidth(20)].asStackView(contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
let footerBar = UIView()
footerBar.translatesAutoresizingMaskIntoConstraints = false
footerBar.backgroundColor = .clear
roundedBackground.addSubview(footerBar)
let buttonsHeight = Metrics.greenButtonHeight
footerBar.addSubview(buttonsStackView)
footerBar.addSubview(buttonsBar)
NSLayoutConstraint.activate([
header.heightAnchor.constraint(equalToConstant: 90),
@ -202,14 +194,14 @@ class SetSellTokensCardExpiryDateViewController: UIViewController, TokenVerifiab
stackView.topAnchor.constraint(equalTo: scrollView.topAnchor),
stackView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor),
buttonsStackView.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsStackView.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsStackView.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsStackView.heightAnchor.constraint(equalToConstant: buttonsHeight),
buttonsBar.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsBar.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsBar.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsBar.heightAnchor.constraint(equalToConstant: ButtonsBar.buttonsHeight),
footerBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
footerBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -buttonsHeight - 3),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -ButtonsBar.buttonsHeight - ButtonsBar.marginAtBottomScreen),
footerBar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
@ -318,11 +310,11 @@ class SetSellTokensCardExpiryDateViewController: UIViewController, TokenVerifiab
tokenRowView.stateLabel.isHidden = true
nextButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.actionButtonCornerRadius)
let nextButton = nextButtonContainer.childView
nextButton.setTitleColor(viewModel.buttonTitleColor, for: .normal)
nextButton.backgroundColor = viewModel.buttonBackgroundColor
nextButton.titleLabel?.font = viewModel.buttonFont
buttonsBar.configure()
let nextButton = buttonsBar.buttons[0]
nextButton.setTitle(R.string.localizable.aWalletNextButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
}
override func viewDidLayoutSubviews() {

@ -23,18 +23,6 @@ struct EnterSellTokensCardPriceQuantityViewControllerViewModel {
return Colors.appBackground
}
var buttonTitleColor: UIColor {
return Colors.appWhite
}
var buttonBackgroundColor: UIColor {
return Colors.appActionButtonGreen
}
var buttonFont: UIFont {
return Fonts.regular(size: 20)!
}
var choiceLabelColor: UIColor {
return Colors.appGrayLabelColor
}
@ -122,24 +110,4 @@ struct EnterSellTokensCardPriceQuantityViewControllerViewModel {
self.tokenHolder = tokenHolder
self.server = server
}
var actionButtonCornerRadius: CGFloat {
return 16
}
var actionButtonShadowColor: UIColor {
return Colors.appActionButtonShadow
}
var actionButtonShadowOffset: CGSize {
return .init(width: 1, height: 2)
}
var actionButtonShadowOpacity: Float {
return 0.3
}
var actionButtonShadowRadius: CGFloat {
return 5
}
}

@ -25,18 +25,6 @@ struct SellTokensCardViewModel {
return R.string.localizable.aWalletTokenSellSelectTokensTitle(tokenTypeName)
}
var buttonTitleColor: UIColor {
return Colors.appWhite
}
var buttonBackgroundColor: UIColor {
return Colors.appActionButtonGreen
}
var buttonFont: UIFont {
return Fonts.regular(size: 20)!
}
func toggleSelection(for indexPath: IndexPath) -> [IndexPath] {
let tokenHolder = item(for: indexPath)
var changed = [indexPath]
@ -55,23 +43,4 @@ struct SellTokensCardViewModel {
return changed
}
var actionButtonCornerRadius: CGFloat {
return 16
}
var actionButtonShadowColor: UIColor {
return Colors.appActionButtonShadow
}
var actionButtonShadowOffset: CGSize {
return .init(width: 1, height: 2)
}
var actionButtonShadowOpacity: Float {
return 0.3
}
var actionButtonShadowRadius: CGFloat {
return 5
}
}

@ -18,18 +18,6 @@ struct SetSellTokensCardExpiryDateViewControllerViewModel {
return Colors.appBackground
}
var buttonTitleColor: UIColor {
return Colors.appWhite
}
var buttonBackgroundColor: UIColor {
return Colors.appActionButtonGreen
}
var buttonFont: UIFont {
return Fonts.regular(size: 20)!
}
var choiceLabelColor: UIColor {
return Colors.appGrayLabelColor
}
@ -126,24 +114,4 @@ struct SetSellTokensCardExpiryDateViewControllerViewModel {
self.ethCost = ethCost
self.server = server
}
var actionButtonCornerRadius: CGFloat {
return 16
}
var actionButtonShadowColor: UIColor {
return Colors.appActionButtonShadow
}
var actionButtonShadowOffset: CGSize {
return .init(width: 1, height: 2)
}
var actionButtonShadowOpacity: Float {
return 0.3
}
var actionButtonShadowRadius: CGFloat {
return 5
}
}

@ -100,8 +100,6 @@ extension UISegmentedControl {
}
enum Metrics {
static let greenButtonHeight = CGFloat(48)
enum DappsHome {
enum Icon {
static let shadowOffset = CGSize(width: 0, height: 0)

@ -26,7 +26,7 @@ class NewTokenViewController: UIViewController, CanScanQRCode {
private let decimalsTextField = TextField()
private let balanceTextField = TextField()
private let nameTextField = TextField()
private var saveButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private let buttonsBar = ButtonsBar(numberOfButtons: 1)
private var scrollViewBottomAnchorConstraint: NSLayoutConstraint!
@ -96,20 +96,13 @@ class NewTokenViewController: UIViewController, CanScanQRCode {
stackView.translatesAutoresizingMaskIntoConstraints = false
scrollView.addSubview(stackView)
let saveButton = saveButtonContainer.childView
saveButton.addTarget(self, action: #selector(addToken), for: .touchUpInside)
saveButton.isEnabled = true
saveButton.setTitle(R.string.localizable.done(), for: .normal)
let buttonsStackView = [.spacerWidth(20), saveButtonContainer, .spacerWidth(20)].asStackView(contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
buttonsBar.buttons[0].isEnabled = true
footerBar.translatesAutoresizingMaskIntoConstraints = false
footerBar.backgroundColor = .clear
roundedBackground.addSubview(footerBar)
let buttonsHeight = Metrics.greenButtonHeight
footerBar.addSubview(buttonsStackView)
footerBar.addSubview(buttonsBar)
let xMargin = CGFloat(7)
scrollViewBottomAnchorConstraint = scrollView.bottomAnchor.constraint(equalTo: footerBar.topAnchor, constant: 0)
@ -124,14 +117,14 @@ class NewTokenViewController: UIViewController, CanScanQRCode {
stackView.topAnchor.constraint(equalTo: scrollView.topAnchor),
stackView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor),
buttonsStackView.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsStackView.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsStackView.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsStackView.heightAnchor.constraint(equalToConstant: buttonsHeight),
buttonsBar.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsBar.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsBar.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsBar.heightAnchor.constraint(equalToConstant: ButtonsBar.buttonsHeight),
footerBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
footerBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -buttonsHeight - 3),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -ButtonsBar.buttonsHeight - ButtonsBar.marginAtBottomScreen),
footerBar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
@ -170,16 +163,14 @@ class NewTokenViewController: UIViewController, CanScanQRCode {
nameTextField.label.textAlignment = .center
nameTextField.label.text = viewModel.nameLabel
saveButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.actionButtonCornerRadius)
let saveButton = saveButtonContainer.childView
saveButton.setTitleColor(viewModel.buttonTitleColor, for: .normal)
saveButton.setTitleColor(Colors.veryLightGray, for: .disabled)
saveButton.backgroundColor = viewModel.buttonBackgroundColor
saveButton.titleLabel?.font = viewModel.buttonFont
buttonsBar.configure()
let saveButton = buttonsBar.buttons[0]
saveButton.addTarget(self, action: #selector(addToken), for: .touchUpInside)
saveButton.setTitle(R.string.localizable.done(), for: .normal)
}
private func updateSaveButtonBasedOnTokenTypeDetected() {
let saveButton = saveButtonContainer.childView
let saveButton = buttonsBar.buttons[0]
if tokenType == nil {
saveButton.isEnabled = false
saveButton.setTitle(R.string.localizable.detectingTokenTypeTitle(), for: .normal)

@ -18,8 +18,7 @@ class TokenViewController: UIViewController {
private let tokensDataStore: TokensDataStore
private let transferType: TransferType
private let tableView = UITableView(frame: .zero, style: .plain)
private var sendButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private var receiveButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private let buttonsBar = ButtonsBar(numberOfButtons: 2)
weak var delegate: TokenViewControllerDelegate?
@ -42,13 +41,10 @@ class TokenViewController: UIViewController {
tableView.translatesAutoresizingMaskIntoConstraints = false
roundedBackground.addSubview(tableView)
let buttonsStackView = [.spacerWidth(20), sendButtonContainer, .spacerWidth(7), receiveButtonContainer, .spacerWidth(20)].asStackView(axis: .horizontal)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
roundedBackground.addSubview(buttonsStackView)
roundedBackground.addSubview(buttonsBar)
configureBalanceViewModel()
let buttonsHeight = Metrics.greenButtonHeight
NSLayoutConstraint.activate([
header.leadingAnchor.constraint(equalTo: roundedBackground.leadingAnchor),
header.trailingAnchor.constraint(equalTo: roundedBackground.trailingAnchor),
@ -58,13 +54,10 @@ class TokenViewController: UIViewController {
tableView.topAnchor.constraint(equalTo: roundedBackground.topAnchor),
tableView.bottomAnchor.constraint(equalTo: roundedBackground.bottomAnchor),
sendButtonContainer.widthAnchor.constraint(equalTo: receiveButtonContainer.widthAnchor),
buttonsStackView.leadingAnchor.constraint(equalTo: roundedBackground.leadingAnchor),
buttonsStackView.trailingAnchor.constraint(equalTo: roundedBackground.trailingAnchor),
buttonsStackView.heightAnchor.constraint(equalToConstant: buttonsHeight),
//Some gap so it doesn't stick to the bottom of devices without a bottom safe area
buttonsStackView.bottomAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -7),
buttonsBar.leadingAnchor.constraint(equalTo: roundedBackground.leadingAnchor),
buttonsBar.trailingAnchor.constraint(equalTo: roundedBackground.trailingAnchor),
buttonsBar.heightAnchor.constraint(equalToConstant: ButtonsBar.buttonsHeight),
buttonsBar.bottomAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -ButtonsBar.marginAtBottomScreen),
] + roundedBackground.createConstraintsWithContainer(view: view))
}
@ -88,21 +81,15 @@ class TokenViewController: UIViewController {
header.frame.size.height = 220
tableView.tableHeaderView = header
sendButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.sendReceiveButtonCornerRadius)
receiveButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.sendReceiveButtonCornerRadius)
buttonsBar.configure()
let sendButton = sendButtonContainer.childView
let sendButton = buttonsBar.buttons[0]
sendButton.setTitle(viewModel.sendButtonTitle, for: .normal)
sendButton.addTarget(self, action: #selector(send), for: .touchUpInside)
sendButton.setBackgroundColor(viewModel.sendReceiveButtonBackgroundColor, forState: .normal)
sendButton.setTitleColor(viewModel.sendReceiveButtonTitleColor, for: .normal)
let receiveButton = receiveButtonContainer.childView
let receiveButton = buttonsBar.buttons[1]
receiveButton.setTitle(viewModel.receiveButtonTitle, for: .normal)
receiveButton.addTarget(self, action: #selector(receive), for: .touchUpInside)
receiveButton.setBackgroundColor(viewModel.sendReceiveButtonBackgroundColor, forState: .normal)
receiveButton.setTitleColor(viewModel.sendReceiveButtonTitleColor, for: .normal)
tableView.reloadData()
}

@ -30,9 +30,7 @@ class TokensCardViewController: UIViewController, TokenVerifiableStatusViewContr
private let header = TokenCardsViewControllerHeader()
private let roundedBackground = RoundedBackground()
private let tableView = UITableView(frame: .zero, style: .plain)
private var redeemButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private var transferButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private var sellButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private let buttonsBar = ButtonsBar(numberOfButtons: 3)
let config: Config
var contract: String {
@ -81,28 +79,12 @@ class TokensCardViewController: UIViewController, TokenVerifiableStatusViewContr
tableView.estimatedRowHeight = TokensCardViewController.anArbitaryRowHeightSoAutoSizingCellsWorkIniOS10
roundedBackground.addSubview(tableView)
let redeemButton = redeemButtonContainer.childView
redeemButton.setTitle(R.string.localizable.aWalletTokenRedeemButtonTitle(), for: .normal)
redeemButton.addTarget(self, action: #selector(redeem), for: .touchUpInside)
let sellButton = sellButtonContainer.childView
sellButton.setTitle(R.string.localizable.aWalletTokenSellButtonTitle(), for: .normal)
sellButton.addTarget(self, action: #selector(sell), for: .touchUpInside)
let transferButton = transferButtonContainer.childView
transferButton.setTitle(R.string.localizable.aWalletTokenTransferButtonTitle(), for: .normal)
transferButton.addTarget(self, action: #selector(transfer), for: .touchUpInside)
let buttonsStackView = [.spacerWidth(20), redeemButtonContainer, .spacerWidth(7), sellButtonContainer, .spacerWidth(7), transferButtonContainer, .spacerWidth(20)].asStackView()
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
let footerBar = UIView()
footerBar.translatesAutoresizingMaskIntoConstraints = false
footerBar.backgroundColor = .clear
roundedBackground.addSubview(footerBar)
let buttonsHeight = Metrics.greenButtonHeight
footerBar.addSubview(buttonsStackView)
footerBar.addSubview(buttonsBar)
NSLayoutConstraint.activate([
tableView.leadingAnchor.constraint(equalTo: roundedBackground.leadingAnchor),
@ -110,17 +92,14 @@ class TokensCardViewController: UIViewController, TokenVerifiableStatusViewContr
tableView.topAnchor.constraint(equalTo: roundedBackground.topAnchor),
tableView.bottomAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsStackView.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsStackView.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsStackView.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsStackView.heightAnchor.constraint(equalToConstant: buttonsHeight),
redeemButtonContainer.widthAnchor.constraint(equalTo: sellButtonContainer.widthAnchor),
redeemButtonContainer.widthAnchor.constraint(equalTo: transferButtonContainer.widthAnchor),
buttonsBar.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsBar.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsBar.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsBar.heightAnchor.constraint(equalToConstant: ButtonsBar.buttonsHeight),
footerBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
footerBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -buttonsHeight - 3),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -ButtonsBar.buttonsHeight - ButtonsBar.marginAtBottomScreen),
footerBar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
] + roundedBackground.createConstraintsWithContainer(view: view))
@ -142,36 +121,29 @@ class TokensCardViewController: UIViewController, TokenVerifiableStatusViewContr
header.configure(viewModel: .init(tokenObject: tokenObject, server: config.server))
tableView.tableHeaderView = header
redeemButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.actionButtonCornerRadius)
let redeemButton = redeemButtonContainer.childView
redeemButton.setTitleColor(viewModel.buttonTitleColor, for: .normal)
redeemButton.setTitleColor(viewModel.disabledButtonTitleColor, for: .disabled)
redeemButton.backgroundColor = viewModel.buttonBackgroundColor
redeemButton.titleLabel?.font = viewModel.buttonFont
sellButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.actionButtonCornerRadius)
let sellButton = sellButtonContainer.childView
sellButton.setTitleColor(viewModel.buttonTitleColor, for: .normal)
sellButton.setTitleColor(viewModel.disabledButtonTitleColor, for: .disabled)
sellButton.backgroundColor = viewModel.buttonBackgroundColor
sellButton.titleLabel?.font = viewModel.buttonFont
transferButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.actionButtonCornerRadius)
let transferButton = transferButtonContainer.childView
transferButton.setTitleColor(viewModel.buttonTitleColor, for: .normal)
transferButton.setTitleColor(viewModel.disabledButtonTitleColor, for: .disabled)
transferButton.backgroundColor = viewModel.buttonBackgroundColor
transferButton.titleLabel?.font = viewModel.buttonFont
buttonsBar.configure()
let redeemButton = buttonsBar.buttons[0]
redeemButton.setTitle(R.string.localizable.aWalletTokenRedeemButtonTitle(), for: .normal)
redeemButton.addTarget(self, action: #selector(redeem), for: .touchUpInside)
let sellButton = buttonsBar.buttons[1]
sellButton.setTitle(R.string.localizable.aWalletTokenSellButtonTitle(), for: .normal)
sellButton.addTarget(self, action: #selector(sell), for: .touchUpInside)
let transferButton = buttonsBar.buttons[2]
transferButton.setTitle(R.string.localizable.aWalletTokenTransferButtonTitle(), for: .normal)
transferButton.addTarget(self, action: #selector(transfer), for: .touchUpInside)
switch tokenObject.type {
case .nativeCryptocurrency, .erc20, .xDai:
break
case .erc875:
redeemButtonContainer.isHidden = false
sellButtonContainer.isHidden = false
buttonsBar.buttons[0].isHidden = false
buttonsBar.buttons[1].isHidden = false
case .erc721:
redeemButtonContainer.isHidden = true
sellButtonContainer.isHidden = true
buttonsBar.buttons[0].isHidden = true
buttonsBar.buttons[1].isHidden = true
}
[redeemButton, sellButton, transferButton].forEach { $0.isEnabled = !isReadOnly }

@ -50,36 +50,4 @@ struct NewTokenViewModel {
var nameLabel: String {
return R.string.localizable.name().uppercased()
}
var buttonTitleColor: UIColor {
return Colors.appWhite
}
var buttonBackgroundColor: UIColor {
return Colors.appActionButtonGreen
}
var buttonFont: UIFont {
return Fonts.regular(size: 20)!
}
var actionButtonCornerRadius: CGFloat {
return 16
}
var actionButtonShadowColor: UIColor {
return Colors.appActionButtonShadow
}
var actionButtonShadowOffset: CGSize {
return .init(width: 1, height: 2)
}
var actionButtonShadowOpacity: Float {
return 0.3
}
var actionButtonShadowRadius: CGFloat {
return 5
}
}

@ -47,32 +47,4 @@ struct TokenViewControllerViewModel {
var receiveButtonTitle: String {
return R.string.localizable.receive()
}
var sendReceiveButtonBackgroundColor: UIColor {
return Colors.appActionButtonGreen
}
var sendReceiveButtonTitleColor: UIColor {
return Colors.appWhite
}
var sendReceiveButtonCornerRadius: CGFloat {
return 16
}
var actionButtonShadowColor: UIColor {
return Colors.appActionButtonShadow
}
var actionButtonShadowOffset: CGSize {
return .init(width: 1, height: 2)
}
var actionButtonShadowOpacity: Float {
return 0.3
}
var actionButtonShadowRadius: CGFloat {
return 5
}
}

@ -26,22 +26,6 @@ struct TokensCardViewModel {
return tokenHolders.count
}
var buttonTitleColor: UIColor {
return Colors.appWhite
}
var disabledButtonTitleColor: UIColor {
return Colors.darkGray
}
var buttonBackgroundColor: UIColor {
return Colors.appActionButtonGreen
}
var buttonFont: UIFont {
return Fonts.regular(size: 20)!
}
func toggleDetailsVisible(for indexPath: IndexPath) -> [IndexPath] {
let tokenHolder = item(for: indexPath)
var changed = [indexPath]
@ -56,24 +40,4 @@ struct TokensCardViewModel {
}
return changed
}
var actionButtonCornerRadius: CGFloat {
return 16
}
var actionButtonShadowColor: UIColor {
return Colors.appActionButtonShadow
}
var actionButtonShadowOffset: CGSize {
return .init(width: 1, height: 2)
}
var actionButtonShadowOpacity: Float {
return 0.3
}
var actionButtonShadowRadius: CGFloat {
return 5
}
}

@ -13,8 +13,7 @@ class ChooseTokenCardTransferModeViewController: UIViewController, TokenVerifiab
private let roundedBackground = RoundedBackground()
private let header = TokensCardViewControllerTitleHeader()
private let tokenRowView: TokenRowView & UIView
private var generateMagicLinkButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private var transferNowButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private let buttonsBar = ButtonsBar(numberOfButtons: 2)
private var viewModel: ChooseTokenCardTransferModeViewControllerViewModel
private let tokenHolder: TokenHolder
@ -51,14 +50,6 @@ class ChooseTokenCardTransferModeViewController: UIViewController, TokenVerifiab
roundedBackground.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(roundedBackground)
let generateMagicLinkButton = generateMagicLinkButtonContainer.childView
generateMagicLinkButton.setTitle(R.string.localizable.aWalletTokenTransferModeMagicLinkButtonTitle(), for: .normal)
generateMagicLinkButton.addTarget(self, action: #selector(generateMagicLinkTapped), for: .touchUpInside)
let transferNowButton = transferNowButtonContainer.childView
transferNowButton.setTitle(" \(R.string.localizable.aWalletTokenTransferModeNowButtonTitle()) ", for: .normal)
transferNowButton.addTarget(self, action: #selector(transferNowTapped), for: .touchUpInside)
tokenRowView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(tokenRowView)
@ -69,16 +60,12 @@ class ChooseTokenCardTransferModeViewController: UIViewController, TokenVerifiab
stackView.translatesAutoresizingMaskIntoConstraints = false
roundedBackground.addSubview(stackView)
let buttonsStackView = [.spacerWidth(18), generateMagicLinkButtonContainer, .spacerWidth(5), transferNowButtonContainer, .spacerWidth(18)].asStackView()
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
let footerBar = UIView()
footerBar.translatesAutoresizingMaskIntoConstraints = false
footerBar.backgroundColor = .clear
roundedBackground.addSubview(footerBar)
let buttonsHeight = Metrics.greenButtonHeight
footerBar.addSubview(buttonsStackView)
footerBar.addSubview(buttonsBar)
NSLayoutConstraint.activate([
header.heightAnchor.constraint(equalToConstant: 90),
@ -90,14 +77,14 @@ class ChooseTokenCardTransferModeViewController: UIViewController, TokenVerifiab
stackView.trailingAnchor.constraint(equalTo: roundedBackground.trailingAnchor),
stackView.topAnchor.constraint(equalTo: roundedBackground.topAnchor),
buttonsStackView.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsStackView.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsStackView.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsStackView.heightAnchor.constraint(equalToConstant: buttonsHeight),
buttonsBar.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsBar.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsBar.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsBar.heightAnchor.constraint(equalToConstant: ButtonsBar.buttonsHeight),
footerBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
footerBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -buttonsHeight - 3),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -ButtonsBar.buttonsHeight - ButtonsBar.marginAtBottomScreen),
footerBar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
] + roundedBackground.createConstraintsWithContainer(view: view))
}
@ -136,18 +123,18 @@ class ChooseTokenCardTransferModeViewController: UIViewController, TokenVerifiab
tokenRowView.stateLabel.isHidden = true
generateMagicLinkButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.actionButtonCornerRadius)
let generateMagicLinkButton = generateMagicLinkButtonContainer.childView
generateMagicLinkButton.setTitleColor(viewModel.buttonTitleColor, for: .normal)
generateMagicLinkButton.backgroundColor = viewModel.buttonBackgroundColor
generateMagicLinkButton.titleLabel?.font = viewModel.buttonFont
//Hardcode position because text is very long compared to the transferNowButton
generateMagicLinkButton.titleEdgeInsets = .init(top: 0, left: horizontalAdjustmentForLongMagicLinkButtonTitle, bottom: 0, right: 0)
buttonsBar.configure()
transferNowButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.actionButtonCornerRadius)
let transferNowButton = transferNowButtonContainer.childView
transferNowButton.setTitleColor(viewModel.buttonTitleColor, for: .normal)
transferNowButton.backgroundColor = viewModel.buttonBackgroundColor
let generateMagicLinkButton = buttonsBar.buttons[0]
generateMagicLinkButton.setTitle(R.string.localizable.aWalletTokenTransferModeMagicLinkButtonTitle(), for: .normal)
generateMagicLinkButton.addTarget(self, action: #selector(generateMagicLinkTapped), for: .touchUpInside)
let transferNowButton = buttonsBar.buttons[1]
transferNowButton.setTitle(" \(R.string.localizable.aWalletTokenTransferModeNowButtonTitle()) ", for: .normal)
transferNowButton.addTarget(self, action: #selector(transferNowTapped), for: .touchUpInside)
//Button fonts have to be smaller because the button title is too long
generateMagicLinkButton.titleLabel?.font = viewModel.buttonFont
transferNowButton.titleLabel?.font = viewModel.buttonFont
}
}

@ -24,7 +24,7 @@ class SendViewController: UIViewController, CanScanQRCode {
private let amountTextField = AmountTextField()
private let targetAddressLabel = UILabel()
private let amountLabel = UILabel()
private var nextButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private let buttonsBar = ButtonsBar(numberOfButtons: 1)
private var viewModel: SendViewModel!
private var headerViewModel = SendHeaderViewViewModel()
private var balanceViewModel: BalanceBaseViewModel?
@ -98,13 +98,6 @@ class SendViewController: UIViewController, CanScanQRCode {
amountTextField.isFiatButtonHidden = true
}
let nextButton = nextButtonContainer.childView
nextButton.setTitle(R.string.localizable.send(), for: .normal)
nextButton.addTarget(self, action: #selector(send), for: .touchUpInside)
let buttonsStackView = [.spacerWidth(20), nextButtonContainer, .spacerWidth(20)].asStackView(contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
let stackView = [
header,
.spacer(height: ScreenChecker().isNarrowScreen() ? 7: 20),
@ -126,8 +119,7 @@ class SendViewController: UIViewController, CanScanQRCode {
footerBar.backgroundColor = .clear
roundedBackground.addSubview(footerBar)
let buttonsHeight = Metrics.greenButtonHeight
footerBar.addSubview(buttonsStackView)
footerBar.addSubview(buttonsBar)
NSLayoutConstraint.activate([
header.leadingAnchor.constraint(equalTo: roundedBackground.leadingAnchor, constant: 30),
@ -144,14 +136,14 @@ class SendViewController: UIViewController, CanScanQRCode {
stackView.trailingAnchor.constraint(equalTo: roundedBackground.trailingAnchor),
stackView.topAnchor.constraint(equalTo: roundedBackground.topAnchor),
buttonsStackView.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsStackView.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsStackView.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsStackView.heightAnchor.constraint(equalToConstant: buttonsHeight),
buttonsBar.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsBar.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsBar.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsBar.heightAnchor.constraint(equalToConstant: ButtonsBar.buttonsHeight),
footerBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
footerBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -buttonsHeight - 3),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -ButtonsBar.buttonsHeight - ButtonsBar.marginAtBottomScreen),
footerBar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
] + roundedBackground.createConstraintsWithContainer(view: view))
@ -179,11 +171,10 @@ class SendViewController: UIViewController, CanScanQRCode {
amountLabel.font = viewModel.textFieldsLabelFont
amountLabel.textColor = viewModel.textFieldsLabelTextColor
nextButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.actionButtonCornerRadius)
let nextButton = nextButtonContainer.childView
nextButton.setTitleColor(viewModel.buttonTitleColor, for: .normal)
nextButton.backgroundColor = viewModel.buttonBackgroundColor
nextButton.titleLabel?.font = viewModel.buttonFont
buttonsBar.configure()
let nextButton = buttonsBar.buttons[0]
nextButton.setTitle(R.string.localizable.send(), for: .normal)
nextButton.addTarget(self, action: #selector(send), for: .touchUpInside)
}
override func viewDidLayoutSubviews() {

@ -22,7 +22,7 @@ class SetTransferTokensCardExpiryDateViewController: UIViewController, TokenVeri
private let noteTitleLabel = UILabel()
private let noteLabel = UILabel()
private let noteBorderView = UIView()
private var nextButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private let buttonsBar = ButtonsBar(numberOfButtons: 1)
private var viewModel: SetTransferTokensCardExpiryDateViewControllerViewModel
private let tokenHolder: TokenHolder
@ -65,10 +65,6 @@ class SetTransferTokensCardExpiryDateViewController: UIViewController, TokenVeri
linkExpiryDateLabel.translatesAutoresizingMaskIntoConstraints = false
linkExpiryTimeLabel.translatesAutoresizingMaskIntoConstraints = false
let nextButton = nextButtonContainer.childView
nextButton.setTitle(R.string.localizable.aWalletNextButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
tokenRowView.translatesAutoresizingMaskIntoConstraints = false
scrollView.addSubview(tokenRowView)
@ -142,16 +138,12 @@ class SetTransferTokensCardExpiryDateViewController: UIViewController, TokenVeri
linkExpiryTimeField.translatesAutoresizingMaskIntoConstraints = false
linkExpiryTimeField.delegate = self
let buttonsStackView = [.spacerWidth(20), nextButtonContainer, .spacerWidth(20)].asStackView(contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
let footerBar = UIView()
footerBar.translatesAutoresizingMaskIntoConstraints = false
footerBar.backgroundColor = .clear
roundedBackground.addSubview(footerBar)
let buttonsHeight = Metrics.greenButtonHeight
footerBar.addSubview(buttonsStackView)
footerBar.addSubview(buttonsBar)
NSLayoutConstraint.activate([
header.heightAnchor.constraint(equalToConstant: 90),
@ -184,14 +176,14 @@ class SetTransferTokensCardExpiryDateViewController: UIViewController, TokenVeri
stackView.topAnchor.constraint(equalTo: scrollView.topAnchor),
stackView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor),
buttonsStackView.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsStackView.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsStackView.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsStackView.heightAnchor.constraint(equalToConstant: buttonsHeight),
buttonsBar.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsBar.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsBar.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsBar.heightAnchor.constraint(equalToConstant: ButtonsBar.buttonsHeight),
footerBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
footerBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -buttonsHeight - 3),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -ButtonsBar.buttonsHeight - ButtonsBar.marginAtBottomScreen),
footerBar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
@ -298,11 +290,10 @@ class SetTransferTokensCardExpiryDateViewController: UIViewController, TokenVeri
noteBorderView.layer.borderColor = viewModel.noteBorderColor.cgColor
noteBorderView.layer.borderWidth = 1
nextButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.actionButtonCornerRadius)
let nextButton = nextButtonContainer.childView
nextButton.setTitleColor(viewModel.buttonTitleColor, for: .normal)
nextButton.backgroundColor = viewModel.buttonBackgroundColor
nextButton.titleLabel?.font = viewModel.buttonFont
buttonsBar.configure()
let nextButton = buttonsBar.buttons[0]
nextButton.setTitle(R.string.localizable.aWalletNextButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
}
}

@ -13,7 +13,7 @@ class TransferTokensCardQuantitySelectionViewController: UIViewController, Token
private let subtitleLabel = UILabel()
private let quantityStepper = NumberStepper()
private let tokenRowView: TokenRowView & UIView
private var nextButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private let buttonsBar = ButtonsBar(numberOfButtons: 1)
private var viewModel: TransferTokensCardQuantitySelectionViewModel
private let token: TokenObject
@ -52,10 +52,6 @@ class TransferTokensCardQuantitySelectionViewController: UIViewController, Token
subtitleLabel.translatesAutoresizingMaskIntoConstraints = false
let nextButton = nextButtonContainer.childView
nextButton.setTitle(R.string.localizable.aWalletNextButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
tokenRowView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(tokenRowView)
@ -75,16 +71,12 @@ class TransferTokensCardQuantitySelectionViewController: UIViewController, Token
stackView.translatesAutoresizingMaskIntoConstraints = false
roundedBackground.addSubview(stackView)
let buttonsStackView = [.spacerWidth(20), nextButtonContainer, .spacerWidth(20)].asStackView(contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
let footerBar = UIView()
footerBar.translatesAutoresizingMaskIntoConstraints = false
footerBar.backgroundColor = .clear
roundedBackground.addSubview(footerBar)
let buttonsHeight = Metrics.greenButtonHeight
footerBar.addSubview(buttonsStackView)
footerBar.addSubview(buttonsBar)
NSLayoutConstraint.activate([
header.heightAnchor.constraint(equalToConstant: 90),
@ -98,14 +90,14 @@ class TransferTokensCardQuantitySelectionViewController: UIViewController, Token
stackView.trailingAnchor.constraint(equalTo: roundedBackground.trailingAnchor),
stackView.topAnchor.constraint(equalTo: roundedBackground.topAnchor),
buttonsStackView.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsStackView.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsStackView.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsStackView.heightAnchor.constraint(equalToConstant: buttonsHeight),
buttonsBar.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsBar.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsBar.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsBar.heightAnchor.constraint(equalToConstant: ButtonsBar.buttonsHeight),
footerBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
footerBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -buttonsHeight - 3),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -ButtonsBar.buttonsHeight - ButtonsBar.marginAtBottomScreen),
footerBar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
] + roundedBackground.createConstraintsWithContainer(view: view))
}
@ -161,11 +153,10 @@ class TransferTokensCardQuantitySelectionViewController: UIViewController, Token
tokenRowView.stateLabel.isHidden = true
nextButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.actionButtonCornerRadius)
let nextButton = nextButtonContainer.childView
nextButton.setTitleColor(viewModel.buttonTitleColor, for: .normal)
nextButton.backgroundColor = viewModel.buttonBackgroundColor
nextButton.titleLabel?.font = viewModel.buttonFont
buttonsBar.configure()
let nextButton = buttonsBar.buttons[0]
nextButton.setTitle(R.string.localizable.aWalletNextButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
}
private func getTokenHolderFromQuantity() -> TokenHolder {

@ -14,7 +14,7 @@ class TransferTokensCardViaWalletAddressViewController: UIViewController, TokenV
private let header = TokensCardViewControllerTitleHeader()
private let tokenRowView: TokenRowView & UIView
private let targetAddressTextField = AddressTextField()
private var nextButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private let buttonsBar = ButtonsBar(numberOfButtons: 1)
private var viewModel: TransferTokensCardViaWalletAddressViewControllerViewModel
private var tokenHolder: TokenHolder
private var paymentFlow: PaymentFlow
@ -59,10 +59,6 @@ class TransferTokensCardViaWalletAddressViewController: UIViewController, TokenV
targetAddressTextField.delegate = self
targetAddressTextField.returnKeyType = .done
let nextButton = nextButtonContainer.childView
nextButton.setTitle(R.string.localizable.aWalletNextButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
tokenRowView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(tokenRowView)
@ -77,16 +73,12 @@ class TransferTokensCardViaWalletAddressViewController: UIViewController, TokenV
stackView.translatesAutoresizingMaskIntoConstraints = false
roundedBackground.addSubview(stackView)
let buttonsStackView = [.spacerWidth(20), nextButtonContainer, .spacerWidth(20)].asStackView(contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
let footerBar = UIView()
footerBar.translatesAutoresizingMaskIntoConstraints = false
footerBar.backgroundColor = .clear
roundedBackground.addSubview(footerBar)
let buttonsHeight = Metrics.greenButtonHeight
footerBar.addSubview(buttonsStackView)
footerBar.addSubview(buttonsBar)
NSLayoutConstraint.activate([
header.heightAnchor.constraint(equalToConstant: 90),
@ -101,14 +93,14 @@ class TransferTokensCardViaWalletAddressViewController: UIViewController, TokenV
stackView.trailingAnchor.constraint(equalTo: roundedBackground.trailingAnchor),
stackView.topAnchor.constraint(equalTo: roundedBackground.topAnchor),
buttonsStackView.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsStackView.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsStackView.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsStackView.heightAnchor.constraint(equalToConstant: buttonsHeight),
buttonsBar.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsBar.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsBar.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsBar.heightAnchor.constraint(equalToConstant: ButtonsBar.buttonsHeight),
footerBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
footerBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -buttonsHeight - 3),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -ButtonsBar.buttonsHeight - ButtonsBar.marginAtBottomScreen),
footerBar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
] + roundedBackground.createConstraintsWithContainer(view: view))
}
@ -148,11 +140,10 @@ class TransferTokensCardViaWalletAddressViewController: UIViewController, TokenV
targetAddressTextField.configureOnce()
nextButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.actionButtonCornerRadius)
let nextButton = nextButtonContainer.childView
nextButton.setTitleColor(viewModel.buttonTitleColor, for: .normal)
nextButton.backgroundColor = viewModel.buttonBackgroundColor
nextButton.titleLabel?.font = viewModel.buttonFont
buttonsBar.configure()
let nextButton = buttonsBar.buttons[0]
nextButton.setTitle(R.string.localizable.aWalletNextButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
}
}

@ -12,7 +12,7 @@ class TransferTokensCardViewController: UIViewController, TokenVerifiableStatusV
private let roundedBackground = RoundedBackground()
private let header = TokensCardViewControllerTitleHeader()
private let tableView = UITableView(frame: .zero, style: .plain)
private var nextButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private let buttonsBar = ButtonsBar(numberOfButtons: 1)
private var viewModel: TransferTokensCardViewModel
private let token: TokenObject
@ -47,20 +47,12 @@ class TransferTokensCardViewController: UIViewController, TokenVerifiableStatusV
tableView.estimatedRowHeight = TokensCardViewController.anArbitaryRowHeightSoAutoSizingCellsWorkIniOS10
roundedBackground.addSubview(tableView)
let nextButton = nextButtonContainer.childView
nextButton.setTitle(R.string.localizable.aWalletNextButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
let buttonsStackView = [.spacerWidth(20), nextButtonContainer, .spacerWidth(20)].asStackView(contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
let footerBar = UIView()
footerBar.translatesAutoresizingMaskIntoConstraints = false
footerBar.backgroundColor = .clear
roundedBackground.addSubview(footerBar)
let buttonsHeight = Metrics.greenButtonHeight
footerBar.addSubview(buttonsStackView)
footerBar.addSubview(buttonsBar)
NSLayoutConstraint.activate([
tableView.leadingAnchor.constraint(equalTo: roundedBackground.leadingAnchor),
@ -68,14 +60,14 @@ class TransferTokensCardViewController: UIViewController, TokenVerifiableStatusV
tableView.topAnchor.constraint(equalTo: roundedBackground.topAnchor),
tableView.bottomAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsStackView.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsStackView.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsStackView.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsStackView.heightAnchor.constraint(equalToConstant: buttonsHeight),
buttonsBar.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsBar.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsBar.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsBar.heightAnchor.constraint(equalToConstant: ButtonsBar.buttonsHeight),
footerBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
footerBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -buttonsHeight - 3),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -ButtonsBar.buttonsHeight - ButtonsBar.marginAtBottomScreen),
footerBar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
] + roundedBackground.createConstraintsWithContainer(view: view))
}
@ -94,11 +86,10 @@ class TransferTokensCardViewController: UIViewController, TokenVerifiableStatusV
header.configure(title: viewModel.title)
tableView.tableHeaderView = header
nextButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.actionButtonCornerRadius)
let nextButton = nextButtonContainer.childView
nextButton.setTitleColor(viewModel.buttonTitleColor, for: .normal)
nextButton.backgroundColor = viewModel.buttonBackgroundColor
nextButton.titleLabel?.font = viewModel.buttonFont
buttonsBar.configure()
let nextButton = buttonsBar.buttons[0]
nextButton.setTitle(R.string.localizable.aWalletNextButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
}
@objc

@ -16,14 +16,6 @@ struct ChooseTokenCardTransferModeViewControllerViewModel {
return Colors.appBackground
}
var buttonTitleColor: UIColor {
return Colors.appWhite
}
var buttonBackgroundColor: UIColor {
return Colors.appActionButtonGreen
}
var buttonFont: UIFont {
if ScreenChecker().isNarrowScreen() {
return Fonts.regular(size: 13)!
@ -31,24 +23,4 @@ struct ChooseTokenCardTransferModeViewControllerViewModel {
return Fonts.regular(size: 16)!
}
}
var actionButtonCornerRadius: CGFloat {
return 16
}
var actionButtonShadowColor: UIColor {
return Colors.appActionButtonShadow
}
var actionButtonShadowOffset: CGSize {
return .init(width: 1, height: 2)
}
var actionButtonShadowOpacity: Float {
return 0.3
}
var actionButtonShadowRadius: CGFloat {
return 5
}
}

@ -53,34 +53,4 @@ struct SendViewModel {
var textFieldsLabelFont: UIFont {
return Fonts.regular(size: 10)!
}
var buttonTitleColor: UIColor {
return Colors.appWhite
}
var buttonBackgroundColor: UIColor {
return Colors.appActionButtonGreen
}
var buttonFont: UIFont {
return Fonts.regular(size: 20)!
}
var actionButtonCornerRadius: CGFloat {
return 16
}
var actionButtonShadowColor: UIColor {
return Colors.appActionButtonShadow
}
var actionButtonShadowOffset: CGSize {
return .init(width: 1, height: 2)
}
var actionButtonShadowOpacity: Float {
return 0.3
}
var actionButtonShadowRadius: CGFloat {
return 5
}
}

@ -16,18 +16,6 @@ struct SetTransferTokensCardExpiryDateViewControllerViewModel {
return Colors.appBackground
}
var buttonTitleColor: UIColor {
return Colors.appWhite
}
var buttonBackgroundColor: UIColor {
return Colors.appActionButtonGreen
}
var buttonFont: UIFont {
return Fonts.regular(size: 20)!
}
var descriptionLabelText: String {
return R.string.localizable.aWalletTokenTransferMagicLinkDescriptionTitle()
}
@ -83,24 +71,4 @@ struct SetTransferTokensCardExpiryDateViewControllerViewModel {
var linkExpiryTimeLabelText: String {
return R.string.localizable.aWalletTokenSellLinkExpiryTimeTitle()
}
var actionButtonCornerRadius: CGFloat {
return 16
}
var actionButtonShadowColor: UIColor {
return Colors.appActionButtonShadow
}
var actionButtonShadowOffset: CGSize {
return .init(width: 1, height: 2)
}
var actionButtonShadowOpacity: Float {
return 0.3
}
var actionButtonShadowRadius: CGFloat {
return 5
}
}

@ -20,18 +20,6 @@ struct TransferTokensCardQuantitySelectionViewModel {
return Colors.appBackground
}
var buttonTitleColor: UIColor {
return Colors.appWhite
}
var buttonBackgroundColor: UIColor {
return Colors.appActionButtonGreen
}
var buttonFont: UIFont {
return Fonts.regular(size: 20)!
}
var subtitleColor: UIColor {
return Colors.appGrayLabelColor
}
@ -48,24 +36,4 @@ struct TransferTokensCardQuantitySelectionViewModel {
let tokenTypeName = XMLHandler(contract: token.address.eip55String).getTokenTypeName()
return R.string.localizable.aWalletTokenTransferQuantityTitle(tokenTypeName.localizedUppercase)
}
var actionButtonCornerRadius: CGFloat {
return 16
}
var actionButtonShadowColor: UIColor {
return Colors.appActionButtonShadow
}
var actionButtonShadowOffset: CGSize {
return .init(width: 1, height: 2)
}
var actionButtonShadowOpacity: Float {
return 0.3
}
var actionButtonShadowRadius: CGFloat {
return 5
}
}

@ -15,36 +15,4 @@ struct TransferTokensCardViaWalletAddressViewControllerViewModel {
var backgroundColor: UIColor {
return Colors.appBackground
}
var buttonTitleColor: UIColor {
return Colors.appWhite
}
var buttonBackgroundColor: UIColor {
return Colors.appActionButtonGreen
}
var buttonFont: UIFont {
return Fonts.regular(size: 20)!
}
var actionButtonCornerRadius: CGFloat {
return 16
}
var actionButtonShadowColor: UIColor {
return Colors.appActionButtonShadow
}
var actionButtonShadowOffset: CGSize {
return .init(width: 1, height: 2)
}
var actionButtonShadowOpacity: Float {
return 0.3
}
var actionButtonShadowRadius: CGFloat {
return 5
}
}

@ -25,18 +25,6 @@ struct TransferTokensCardViewModel {
return R.string.localizable.aWalletTokenTransferSelectTokensTitle(tokenTypeName)
}
var buttonTitleColor: UIColor {
return Colors.appWhite
}
var buttonBackgroundColor: UIColor {
return Colors.appActionButtonGreen
}
var buttonFont: UIFont {
return Fonts.regular(size: 20)!
}
func toggleSelection(for indexPath: IndexPath) -> [IndexPath] {
let tokenHolder = item(for: indexPath)
var changed = [indexPath]
@ -54,24 +42,4 @@ struct TransferTokensCardViewModel {
}
return changed
}
var actionButtonCornerRadius: CGFloat {
return 16
}
var actionButtonShadowColor: UIColor {
return Colors.appActionButtonShadow
}
var actionButtonShadowOffset: CGSize {
return .init(width: 1, height: 2)
}
var actionButtonShadowOpacity: Float {
return 0.3
}
var actionButtonShadowRadius: CGFloat {
return 5
}
}

@ -0,0 +1,97 @@
// Copyright © 2018 Stormbird PTE. LTD.
import Foundation
import UIKit
class ButtonsBar: UIView {
static let buttonsHeight = CGFloat(48)
//A gap so it doesn't stick to the bottom of devices without a bottom safe area
static let marginAtBottomScreen = CGFloat(3)
private let buttonContainerViews: [ContainerViewWithShadow<UIButton>]
var buttons: [UIButton] {
return buttonContainerViews.map { $0.childView }
}
init(numberOfButtons: Int, buttonsDistribution: UIStackView.Distribution = .fillEqually) {
buttonContainerViews = (0..<numberOfButtons).map { _ in ContainerViewWithShadow(aroundView: UIButton(type: .system)) }
super.init(frame: .zero)
translatesAutoresizingMaskIntoConstraints = false
let buttonsStackView = (buttons as [UIView]).asStackView(axis: .horizontal, distribution: buttonsDistribution, spacing: 7)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
addSubview(buttonsStackView)
let margin = CGFloat(20)
NSLayoutConstraint.activate([
buttonsStackView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: margin),
buttonsStackView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -margin),
buttonsStackView.topAnchor.constraint(equalTo: topAnchor),
buttonsStackView.bottomAnchor.constraint(equalTo: bottomAnchor),
])
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func configure() {
let viewModel = ButtonsBarViewModel()
for each in buttonContainerViews {
each.configureShadow(color: viewModel.buttonShadowColor, offset: viewModel.buttonShadowOffset, opacity: viewModel.buttonShadowOpacity, radius: viewModel.buttonShadowRadius, cornerRadius: viewModel.buttonCornerRadius)
let button = each.childView
button.setBackgroundColor(viewModel.buttonBackgroundColor, forState: .normal)
button.setBackgroundColor(viewModel.disabledButtonBackgroundColor, forState: .disabled)
button.setTitleColor(viewModel.buttonTitleColor, for: .normal)
button.setTitleColor(viewModel.disabledButtonTitleColor, for: .disabled)
button.titleLabel?.font = viewModel.buttonFont
}
}
}
fileprivate struct ButtonsBarViewModel {
var buttonBackgroundColor: UIColor {
return Colors.appActionButtonGreen
}
var disabledButtonBackgroundColor: UIColor {
return Colors.gray
}
var buttonTitleColor: UIColor {
return Colors.appWhite
}
var disabledButtonTitleColor: UIColor {
return Colors.darkGray
}
var buttonCornerRadius: CGFloat {
return 16
}
var buttonShadowColor: UIColor {
return Colors.appActionButtonShadow
}
var buttonShadowOffset: CGSize {
return .init(width: 1, height: 2)
}
var buttonShadowOpacity: Float {
return 0.3
}
var buttonShadowRadius: CGFloat {
return 5
}
var buttonFont: UIFont {
return Fonts.regular(size: 20)!
}
}

@ -28,7 +28,7 @@ class ImportWalletViewController: UIViewController, CanScanQRCode {
private var keystoreJSONControlsStackView: UIStackView!
private var privateKeyControlsStackView: UIStackView!
private var watchControlsStackView: UIStackView!
private var importButtonContainer = ContainerViewWithShadow(aroundView: UIButton(type: .system))
private let buttonsBar = ButtonsBar(numberOfButtons: 1)
weak var delegate: ImportWalletViewControllerDelegate?
@ -105,20 +105,12 @@ class ImportWalletViewController: UIViewController, CanScanQRCode {
stackView.translatesAutoresizingMaskIntoConstraints = false
scrollView.addSubview(stackView)
let importButton = importButtonContainer.childView
importButton.setTitle(R.string.localizable.importWalletImportButtonTitle(), for: .normal)
importButton.addTarget(self, action: #selector(importWallet), for: .touchUpInside)
let buttonsStackView = [.spacerWidth(20), importButtonContainer, .spacerWidth(20)].asStackView(contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
let footerBar = UIView()
footerBar.translatesAutoresizingMaskIntoConstraints = false
footerBar.backgroundColor = .clear
roundedBackground.addSubview(footerBar)
let buttonsHeight = Metrics.greenButtonHeight
footerBar.addSubview(buttonsStackView)
footerBar.addSubview(buttonsBar)
let xMargin = CGFloat(7)
let heightThatFitsPrivateKeyNicely = CGFloat(100)
@ -141,14 +133,14 @@ class ImportWalletViewController: UIViewController, CanScanQRCode {
stackView.topAnchor.constraint(equalTo: scrollView.topAnchor),
stackView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor),
buttonsStackView.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsStackView.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsStackView.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsStackView.heightAnchor.constraint(equalToConstant: buttonsHeight),
buttonsBar.leadingAnchor.constraint(equalTo: footerBar.leadingAnchor),
buttonsBar.trailingAnchor.constraint(equalTo: footerBar.trailingAnchor),
buttonsBar.topAnchor.constraint(equalTo: footerBar.topAnchor),
buttonsBar.heightAnchor.constraint(equalToConstant: ButtonsBar.buttonsHeight),
footerBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
footerBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -buttonsHeight - 3),
footerBar.topAnchor.constraint(equalTo: view.layoutGuide.bottomAnchor, constant: -ButtonsBar.buttonsHeight - ButtonsBar.marginAtBottomScreen),
footerBar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
@ -192,11 +184,10 @@ class ImportWalletViewController: UIViewController, CanScanQRCode {
watchAddressTextField.configureOnce()
importButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.actionButtonCornerRadius)
let importButton = importButtonContainer.childView
importButton.setTitleColor(viewModel.buttonTitleColor, for: .normal)
importButton.backgroundColor = viewModel.buttonBackgroundColor
importButton.titleLabel?.font = viewModel.buttonFont
buttonsBar.configure()
let importButton = buttonsBar.buttons[0]
importButton.setTitle(R.string.localizable.importWalletImportButtonTitle(), for: .normal)
importButton.addTarget(self, action: #selector(importWallet), for: .touchUpInside)
}
func didImport(account: Wallet) {

@ -11,18 +11,6 @@ struct ImportWalletViewModel {
return R.string.localizable.importNavigationTitle()
}
var buttonTitleColor: UIColor {
return Colors.appWhite
}
var buttonBackgroundColor: UIColor {
return Colors.appActionButtonGreen
}
var buttonFont: UIFont {
return Fonts.regular(size: 20)!
}
var keystoreJSONLabel: String {
return R.string.localizable.keystoreJSON().uppercased()
}
@ -38,24 +26,4 @@ struct ImportWalletViewModel {
var watchAddressLabel: String {
return R.string.localizable.ethereumAddress().uppercased()
}
var actionButtonCornerRadius: CGFloat {
return 16
}
var actionButtonShadowColor: UIColor {
return Colors.appActionButtonShadow
}
var actionButtonShadowOffset: CGSize {
return .init(width: 1, height: 2)
}
var actionButtonShadowOpacity: Float {
return 0.3
}
var actionButtonShadowRadius: CGFloat {
return 5
}
}

Loading…
Cancel
Save