Refactor UI so UIStackView is created with a function that has reasonable defaults

pull/238/head
Hwee-Boon Yar 7 years ago
parent 874628285e
commit 5b084050ff
  1. 6
      Trust.xcodeproj/project.pbxproj
  2. 6
      Trust/AlphaWalletHelp/Views/ContactUsBannerView.swift
  3. 11
      Trust/Browser/Views/BrowserNavigationBar.swift
  4. 25
      Trust/Export/ViewControllers/BackUpViewController.swift
  5. 30
      Trust/Extensions/UIStackView+Array.swift
  6. 50
      Trust/Market/ViewControllers/ImportTicketViewController.swift
  7. 7
      Trust/Market/ViewControllers/StatusViewController.swift
  8. 14
      Trust/Redeem/ViewControllers/RedeemTicketsQuantitySelectionViewController.swift
  9. 6
      Trust/Redeem/ViewControllers/RedeemTicketsViewController.swift
  10. 12
      Trust/Redeem/ViewControllers/TicketRedemptionViewController.swift
  11. 66
      Trust/Redeem/Views/TicketRowView.swift
  12. 5
      Trust/Redeem/Views/TicketsViewControllerTitleHeader.swift
  13. 39
      Trust/Sell/ViewControllers/EnterSellTicketsPriceQuantityViewController.swift
  14. 7
      Trust/Sell/ViewControllers/GenerateSellMagicLinkViewController.swift
  15. 6
      Trust/Sell/ViewControllers/SellTicketsViewController.swift
  16. 46
      Trust/Sell/ViewControllers/SetSellTicketsExpiryDateViewController.swift
  17. 8
      Trust/Sell/Views/AmountTextField.swift
  18. 18
      Trust/Sell/Views/DateEntryField.swift
  19. 18
      Trust/Sell/Views/TimeEntryField.swift
  20. 7
      Trust/Settings/ViewControllers/WellDoneViewController.swift
  21. 6
      Trust/Tokens/ViewControllers/TicketsViewController.swift
  22. 7
      Trust/Tokens/ViewControllers/TokensViewController.swift
  23. 40
      Trust/Tokens/Views/EthTokenViewCell.swift
  24. 8
      Trust/Tokens/Views/ImportWalletHelpBubbleView.swift
  25. 14
      Trust/Tokens/Views/TicketTokenViewCell.swift
  26. 14
      Trust/Tokens/Views/TicketsViewControllerHeader.swift
  27. 14
      Trust/Tokens/Views/TokenViewCell.swift
  28. 5
      Trust/Tokens/Views/TokensFooterView.swift
  29. 5
      Trust/Tokens/Views/TokensHeaderView.swift
  30. 5
      Trust/Tokens/Views/WalletFilterView.swift
  31. 4
      Trust/Transactions/ViewControllers/TransactionViewController.swift
  32. 16
      Trust/Transactions/Views/TransactionViewCell.swift
  33. 7
      Trust/Transactions/Views/TransactionsEmptyView.swift
  34. 6
      Trust/Transactions/Views/TransactionsFooterView.swift
  35. 14
      Trust/Transfer/ViewControllers/ChooseTicketTransferModeViewController.swift
  36. 9
      Trust/Transfer/ViewControllers/GenerateTransferMagicLinkViewController.swift
  37. 50
      Trust/Transfer/ViewControllers/SendViewController.swift
  38. 46
      Trust/Transfer/ViewControllers/SetTransferTicketsExpiryDateViewController.swift
  39. 15
      Trust/Transfer/ViewControllers/TransferTicketsQuantitySelectionViewController.swift
  40. 22
      Trust/Transfer/ViewControllers/TransferTicketsViaWalletAddressViewController.swift
  41. 6
      Trust/Transfer/ViewControllers/TransferTicketsViewController.swift
  42. 39
      Trust/Transfer/Views/SendHeaderView.swift
  43. 6
      Trust/UI/BalanceTitleView.swift
  44. 7
      Trust/UI/EmptyView.swift
  45. 7
      Trust/UI/ErrorView.swift
  46. 8
      Trust/UI/Form/FieldAppereance.swift
  47. 7
      Trust/UI/Form/TransactionAppearance.swift
  48. 7
      Trust/UI/LoadingView.swift
  49. 7
      Trust/Wallet/ViewControllers/PassphraseViewController.swift
  50. 7
      Trust/Welcome/Views/OnboardingPage.swift

@ -299,6 +299,7 @@
5E7C72B0A10A92E591696E48 /* ContactUsBannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7AE6FAE0DF969B4F52E9 /* ContactUsBannerView.swift */; };
5E7C72C8A15397C5A40BFE76 /* WhatIsEthereumInfoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C774BCA281E4B077DBBFA /* WhatIsEthereumInfoViewController.swift */; };
5E7C72E1D4B4B4C8443F3DA1 /* SendHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7828BD821B6F04B71C00 /* SendHeaderView.swift */; };
5E7C7317533D24B6A292F88D /* UIStackView+Array.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C73ED9226646D562B5A3C /* UIStackView+Array.swift */; };
5E7C731B88842C036A74A039 /* AlphaWalletSettingsButtonRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C71EBD4C95AD4E11F3352 /* AlphaWalletSettingsButtonRow.swift */; };
5E7C733638D7596F93DEE2A9 /* OnboardingCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C75CE3F1D6B7993E7A840 /* OnboardingCollectionViewController.swift */; };
5E7C7376B566E5A59CC8F463 /* ImportTicketViewControllerViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C72D0E7CA03ADE5CFAE7A /* ImportTicketViewControllerViewModel.swift */; };
@ -351,6 +352,7 @@
5E7C7C658D619C70F1E3DE59 /* AdvancedSettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C719B717E002583B1E2E9 /* AdvancedSettingsViewModel.swift */; };
5E7C7C98EAF40E8110241DBD /* TicketTokenViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C783E3ADA4CF9554A0E7D /* TicketTokenViewCell.swift */; };
5E7C7C9E89056069C8FEFA76 /* AlphaWalletSettingsSwitchRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7534FB6BF4D199643246 /* AlphaWalletSettingsSwitchRow.swift */; };
5E7C7CCA357CB7BF12E1F2B4 /* UIStackView+Array.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C73ED9226646D562B5A3C /* UIStackView+Array.swift */; };
5E7C7CCC8D376C6E5C245715 /* EthCurrencyHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C73DF5FBFE756097D32B1 /* EthCurrencyHelper.swift */; };
5E7C7CDB837DCD57E0594CBA /* TicketsViewControllerTitleHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7821694C489D5114DB18 /* TicketsViewControllerTitleHeader.swift */; };
5E7C7CE5CA19183FCED8C907 /* TokensViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7EE467A7F5F2E5B1F660 /* TokensViewModel.swift */; };
@ -814,6 +816,7 @@
5E7C73495E0C0A207152EC25 /* LockEnterPasscodeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LockEnterPasscodeViewController.swift; path = Trust/AlphaWalletLock/ViewControllers/LockEnterPasscodeViewController.swift; sourceTree = SOURCE_ROOT; };
5E7C73617E3A4C0B9A90A5F8 /* AmountTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmountTextField.swift; sourceTree = "<group>"; };
5E7C73DF5FBFE756097D32B1 /* EthCurrencyHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EthCurrencyHelper.swift; sourceTree = "<group>"; };
5E7C73ED9226646D562B5A3C /* UIStackView+Array.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIStackView+Array.swift"; sourceTree = "<group>"; };
5E7C741196D9D9C9C3EE5E30 /* LockCreatePasscodeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LockCreatePasscodeViewController.swift; sourceTree = "<group>"; };
5E7C7419F47CC8B2996AA8F9 /* TransferTicketsQuantitySelectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransferTicketsQuantitySelectionViewController.swift; sourceTree = "<group>"; };
5E7C74A2C738BF2412D412A7 /* TicketSellInfoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TicketSellInfoViewController.swift; sourceTree = "<group>"; };
@ -1787,6 +1790,7 @@
AA26C62220412A4100318B9B /* Double.swift */,
AA26C62120412A4100318B9B /* UIViewInspectableEnhancements.swift */,
AA4E531720425A9500143A09 /* Date.swift */,
5E7C73ED9226646D562B5A3C /* UIStackView+Array.swift */,
);
path = Extensions;
sourceTree = "<group>";
@ -3615,6 +3619,7 @@
5E7C7EAEBB435F3909DA36FB /* TransferTicketsViaWalletAddressViewControllerViewModel.swift in Sources */,
5E7C7CCC8D376C6E5C245715 /* EthCurrencyHelper.swift in Sources */,
5E7C77A8425E0AFAB11F1FCD /* PromptBackupCoordinator.swift in Sources */,
5E7C7317533D24B6A292F88D /* UIStackView+Array.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -3690,6 +3695,7 @@
76F1DC92CDEB695115DBC47C /* UniversalLinkHandlerTests.swift in Sources */,
76F1D850F4F2E968CF8D9C86 /* MonkeyTest.swift in Sources */,
5E7C786AD8E4877C36D3B14A /* TicketAdaptorTest.swift in Sources */,
5E7C7CCA357CB7BF12E1F2B4 /* UIStackView+Array.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

@ -17,12 +17,8 @@ class ContactUsBannerView: UIView {
override init(frame: CGRect) {
super.init(frame: CGRect())
let stackView = UIStackView(arrangedSubviews: [imageView, label])
let stackView = [imageView, label].asStackView(spacing: 14, contentHuggingPriority: .required)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .horizontal
stackView.spacing = 14
stackView.distribution = .fill
stackView.setContentHuggingPriority(UILayoutPriority.required, for: .horizontal)
addSubview(stackView)
button.translatesAutoresizingMaskIntoConstraints = false

@ -51,17 +51,8 @@ class BrowserNavigationBar: UINavigationBar {
moreButton.setImage(R.image.toolbarMenu(), for: .normal)
moreButton.addTarget(self, action: #selector(moreAction(_:)), for: .touchUpInside)
let stackView = UIStackView(arrangedSubviews: [
goBack,
goForward,
textField,
moreButton,
])
let stackView = [goBack, goForward, textField, moreButton].asStackView(spacing: 4)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .horizontal
stackView.distribution = .fill
stackView.spacing = 4
addSubview(stackView)
NSLayoutConstraint.activate([

@ -49,21 +49,16 @@ class BackupViewController: UIViewController {
backupButton.setTitle(NSLocalizedString("export.backup.button.title", value: "Backup Wallet", comment: ""), for: .normal)
backupButton.addTarget(self, action: #selector(backup), for: .touchUpInside)
let stackView = UIStackView(
arrangedSubviews: [
warningImageView,
.spacer(),
noBackupLabel,
.spacer(height: 15),
controlMoneyLabel,
neverStoredLabel,
.spacer(height: 15),
backupButton,
]
)
stackView.axis = .vertical
stackView.spacing = 20
stackView.alignment = .center
let stackView = [
warningImageView,
.spacer(),
noBackupLabel,
.spacer(height: 15),
controlMoneyLabel,
neverStoredLabel,
.spacer(height: 15),
backupButton,
].asStackView(axis: .vertical, spacing: 20, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor = .white

@ -0,0 +1,30 @@
// Copyright © 2018 Stormbird PTE. LTD.
import UIKit
extension Array where Iterator.Element == UIView {
public func asStackView(axis: UILayoutConstraintAxis = .horizontal, distribution: UIStackViewDistribution = .fill, spacing: CGFloat = 0, contentHuggingPriority: UILayoutPriority? = nil, perpendicularContentHuggingPriority: UILayoutPriority? = nil, alignment: UIStackViewAlignment = .fill) -> UIStackView {
let stackView = UIStackView(arrangedSubviews: self)
stackView.axis = axis
stackView.distribution = distribution
stackView.alignment = alignment
stackView.spacing = spacing
if let contentHuggingPriority = contentHuggingPriority {
switch axis {
case .horizontal:
stackView.setContentHuggingPriority(contentHuggingPriority, for: .horizontal)
case .vertical:
stackView.setContentHuggingPriority(contentHuggingPriority, for: .vertical)
}
}
if let perpendicularContentHuggingPriority = perpendicularContentHuggingPriority {
switch axis {
case .horizontal:
stackView.setContentHuggingPriority(perpendicularContentHuggingPriority, for: .vertical)
case .vertical:
stackView.setContentHuggingPriority(perpendicularContentHuggingPriority, for: .horizontal)
}
}
return stackView
}
}

@ -16,7 +16,7 @@ class ImportTicketViewController: UIViewController {
let ticketView = TicketRowView()
let statusLabel = UILabel()
let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge)
let costStackView = UIStackView()
var costStackView: UIStackView?
let ethCostLabelLabel = UILabel()
let ethCostLabel = UILabel()
let dollarCostLabelLabel = UILabel()
@ -56,35 +56,29 @@ class ImportTicketViewController: UIViewController {
let separator2 = UIView()
separator2.backgroundColor = UIColor(red: 230, green: 230, blue: 230)
costStackView.addArrangedSubview(ethCostLabelLabel)
costStackView.addArrangedSubview(.spacer(height: 7))
costStackView.addArrangedSubview(separator1)
costStackView.addArrangedSubview(.spacer(height: 7))
costStackView.addArrangedSubview(ethCostLabel)
costStackView.addArrangedSubview(.spacer(height: 7))
costStackView.addArrangedSubview(separator2)
costStackView.addArrangedSubview(.spacer(height: 7))
costStackView.addArrangedSubview(dollarCostLabelLabel)
costStackView.addArrangedSubview(.spacer(height: 3))
costStackView.addArrangedSubview(dollarCostLabel)
costStackView.translatesAutoresizingMaskIntoConstraints = false
costStackView.axis = .vertical
costStackView.spacing = 0
costStackView.distribution = .fill
costStackView.alignment = .center
costStackView = [
ethCostLabelLabel,
.spacer(height: 7),
separator1,
.spacer(height: 7),
ethCostLabel,
.spacer(height: 7),
separator2,
.spacer(height: 7),
dollarCostLabelLabel,
.spacer(height: 3),
dollarCostLabel,
].asStackView(axis: .vertical, alignment: .center)
costStackView?.translatesAutoresizingMaskIntoConstraints = false
actionButton.addTarget(self, action: #selector(actionTapped), for: .touchUpInside)
cancelButton.addTarget(self, action: #selector(cancel), for: .touchUpInside)
let buttonsStackView = UIStackView(arrangedSubviews: [actionButton, cancelButton])
let buttonsStackView = [actionButton, cancelButton].asStackView(distribution: .fillEqually, contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
buttonsStackView.axis = .horizontal
buttonsStackView.spacing = 0
buttonsStackView.distribution = .fillEqually
buttonsStackView.setContentHuggingPriority(UILayoutPriority.required, for: .horizontal)
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
header,
.spacer(height: 1),
ticketView,
@ -93,13 +87,9 @@ class ImportTicketViewController: UIViewController {
.spacer(height: 14),
statusLabel,
.spacer(height: 20),
costStackView,
])
costStackView!,
].asStackView(axis: .vertical, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 0
stackView.distribution = .fill
stackView.alignment = .center
roundedBackground.addSubview(stackView)
let marginToHideBottomRoundedCorners = CGFloat(30)
@ -196,7 +186,7 @@ class ImportTicketViewController: UIViewController {
statusLabel.text = viewModel.statusText
statusLabel.numberOfLines = 0
costStackView.isHidden = !viewModel.showCost
costStackView?.isHidden = !viewModel.showCost
ethCostLabelLabel.textColor = viewModel.ethCostLabelLabelColor
ethCostLabelLabel.font = viewModel.ethCostLabelLabelFont

@ -38,7 +38,7 @@ class StatusViewController: UIViewController {
actionButton.addTarget(self, action: #selector(done), for: .touchUpInside)
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
.spacer(height: 20),
imageHolder,
.spacer(height: 20),
@ -46,11 +46,8 @@ class StatusViewController: UIViewController {
.spacer(height: 20),
actionButton,
.spacer(height: 18)
])
].asStackView(axis: .vertical)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 0
stackView.distribution = .fill
background.addSubview(stackView)
NSLayoutConstraint.activate([

@ -48,27 +48,19 @@ class RedeemTicketsQuantitySelectionViewController: UIViewController {
quantityStepper.value = 1
view.addSubview(quantityStepper)
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
header,
subtitleLabel,
.spacer(height: 4),
quantityStepper,
.spacer(height: 50),
ticketView,
])
].asStackView(axis: .vertical, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 0
stackView.distribution = .fill
stackView.alignment = .center
roundedBackground.addSubview(stackView)
let buttonsStackView = UIStackView(arrangedSubviews: [nextButton])
let buttonsStackView = [nextButton].asStackView(distribution: .fillEqually, contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
buttonsStackView.axis = .horizontal
buttonsStackView.spacing = 0
buttonsStackView.distribution = .fillEqually
buttonsStackView.setContentHuggingPriority(.required, for: .horizontal)
let marginToHideBottomRoundedCorners = CGFloat(30)
let footerBar = UIView()

@ -46,12 +46,8 @@ class RedeemTicketsViewController: UIViewController {
nextButton.setTitle(R.string.localizable.aWalletNextButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
let buttonsStackView = UIStackView(arrangedSubviews: [nextButton])
let buttonsStackView = [nextButton].asStackView(distribution: .fillEqually, contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
buttonsStackView.axis = .horizontal
buttonsStackView.spacing = 0
buttonsStackView.distribution = .fillEqually
buttonsStackView.setContentHuggingPriority(UILayoutPriority.required, for: .horizontal)
let marginToHideBottomRoundedCorners = CGFloat(30)
let footerBar = UIView()

@ -37,18 +37,14 @@ class TicketRedemptionViewController: UIViewController {
ticketView.translatesAutoresizingMaskIntoConstraints = false
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
titleLabel,
.spacer(height: 10),
imageHolder,
.spacer(height: 4),
ticketView,
])
.spacer(height: 4),
ticketView,
].asStackView(axis: .vertical, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 0
stackView.distribution = .fill
stackView.alignment = .center
view.addSubview(stackView)
let xMargin = CGFloat(16)

@ -18,11 +18,11 @@ class TicketRowView: UIView {
let cityLabel = UILabel()
let timeLabel = UILabel()
let teamsLabel = UILabel()
let detailsRowStack = UIStackView()
var detailsRowStack: UIStackView? = nil
let showCheckbox: Bool
var areDetailsVisible = false {
didSet {
detailsRowStack.isHidden = !areDetailsVisible
detailsRowStack?.isHidden = !areDetailsVisible
}
}
@ -39,64 +39,28 @@ class TicketRowView: UIView {
background.translatesAutoresizingMaskIntoConstraints = false
addSubview(background)
let topRowStack = UIStackView(arrangedSubviews: [
ticketCountLabel,
titleLabel,
])
topRowStack.axis = .horizontal
topRowStack.spacing = 15
topRowStack.distribution = .fill
topRowStack.setContentHuggingPriority(UILayoutPriority.required, for: .horizontal)
let bottomRowStack = UIStackView(arrangedSubviews: [
dateImageView,
dateLabel,
.spacerWidth(7),
seatRangeImageView,
seatRangeLabel,
.spacerWidth(7),
categoryImageView,
categoryLabel,
])
bottomRowStack.axis = .horizontal
bottomRowStack.spacing = 7
bottomRowStack.distribution = .fill
bottomRowStack.setContentHuggingPriority(UILayoutPriority.required, for: .horizontal)
let detailsRow0 = UIStackView(arrangedSubviews: [
timeLabel,
.spacerWidth(10),
cityLabel,
])
detailsRow0.axis = .horizontal
detailsRow0.spacing = 0
detailsRow0.distribution = .fill
detailsRow0.setContentHuggingPriority(UILayoutPriority.required, for: .horizontal)
detailsRowStack.addArrangedSubview(.spacer(height: 10))
detailsRowStack.addArrangedSubview(detailsRow0)
detailsRowStack.addArrangedSubview(teamsLabel)
detailsRowStack.axis = .vertical
detailsRowStack.spacing = 0
detailsRowStack.distribution = .fill
detailsRowStack.setContentHuggingPriority(UILayoutPriority.required, for: .vertical)
detailsRowStack.isHidden = true
let topRowStack = [ticketCountLabel, titleLabel].asStackView(spacing: 15, contentHuggingPriority: .required)
let bottomRowStack = [dateImageView, dateLabel, .spacerWidth(7), seatRangeImageView, seatRangeLabel, .spacerWidth(7), categoryImageView, categoryLabel].asStackView(spacing: 7, contentHuggingPriority: .required)
let detailsRow0 = [timeLabel, .spacerWidth(10), cityLabel].asStackView(contentHuggingPriority: .required)
detailsRowStack = [
.spacer(height: 10),
detailsRow0,
teamsLabel,
].asStackView(axis: .vertical, contentHuggingPriority: .required)
detailsRowStack?.isHidden = true
//TODO variable names are unwieldy after several rounds of changes, fix them
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
stateLabel,
topRowStack,
venueLabel,
.spacer(height: 10),
bottomRowStack,
detailsRowStack,
])
detailsRowStack!,
].asStackView(axis: .vertical, contentHuggingPriority: .required)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.alignment = .leading
stackView.spacing = 0
stackView.distribution = .fill
stackView.setContentHuggingPriority(UILayoutPriority.required, for: .vertical)
background.addSubview(stackView)
// TODO extract constant. Maybe StyleLayout.sideMargin

@ -15,11 +15,8 @@ class TicketsViewControllerTitleHeader: UIView {
titleLabel.textAlignment = .center
titleLabel.translatesAutoresizingMaskIntoConstraints = false
let stackView = UIStackView(arrangedSubviews: [titleLabel])
let stackView = [titleLabel].asStackView(axis: .vertical)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 0
stackView.distribution = .fill
background.addSubview(stackView)
let backgroundWidthConstraint = background.widthAnchor.constraint(equalTo: widthAnchor)

@ -86,40 +86,27 @@ class EnterSellTicketsPriceQuantityViewController: UIViewController {
quantityStepper.value = 1
quantityStepper.addTarget(self, action: #selector(quantityChanged), for: .valueChanged)
let col0 = UIStackView(arrangedSubviews: [
let col0 = [
pricePerTicketLabel,
.spacer(height: 4),
pricePerTicketField,
pricePerTicketField.alternativeAmountLabel,
])
].asStackView(axis: .vertical)
col0.translatesAutoresizingMaskIntoConstraints = false
col0.axis = .vertical
col0.spacing = 0
col0.distribution = .fill
let sameHeightAsPricePerTicketAlternativeAmountLabelPlaceholder = UIView()
sameHeightAsPricePerTicketAlternativeAmountLabelPlaceholder.translatesAutoresizingMaskIntoConstraints = false
let col1 = UIStackView(arrangedSubviews: [
let col1 = [
quantityLabel,
.spacer(height: 4),
quantityStepper,
sameHeightAsPricePerTicketAlternativeAmountLabelPlaceholder,
])
].asStackView(axis: .vertical)
col1.translatesAutoresizingMaskIntoConstraints = false
col1.axis = .vertical
col1.spacing = 0
col1.distribution = .fill
let choicesStackView = UIStackView(arrangedSubviews: [
col0,
.spacerWidth(10),
col1,
])
let choicesStackView = [col0, .spacerWidth(10), col1].asStackView()
choicesStackView.translatesAutoresizingMaskIntoConstraints = false
choicesStackView.axis = .horizontal
choicesStackView.spacing = 0
choicesStackView.distribution = .fill
let separator1 = UIView()
separator1.backgroundColor = UIColor(red: 230, green: 230, blue: 230)
@ -127,7 +114,7 @@ class EnterSellTicketsPriceQuantityViewController: UIViewController {
let separator2 = UIView()
separator2.backgroundColor = UIColor(red: 230, green: 230, blue: 230)
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
header,
ticketView,
.spacer(height: 20),
@ -144,20 +131,12 @@ class EnterSellTicketsPriceQuantityViewController: UIViewController {
dollarCostLabelLabel,
.spacer(height: 10),
dollarCostLabel,
])
].asStackView(axis: .vertical, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 0
stackView.distribution = .fill
stackView.alignment = .center
scrollView.addSubview(stackView)
let buttonsStackView = UIStackView(arrangedSubviews: [nextButton])
let buttonsStackView = [nextButton].asStackView(distribution: .fillEqually, contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
buttonsStackView.axis = .horizontal
buttonsStackView.spacing = 0
buttonsStackView.distribution = .fillEqually
buttonsStackView.setContentHuggingPriority(.required, for: .horizontal)
let marginToHideBottomRoundedCorners = CGFloat(30)
let footerBar = UIView()

@ -54,7 +54,7 @@ class GenerateSellMagicLinkViewController: UIViewController {
actionButton.addTarget(self, action: #selector(share), for: .touchUpInside)
cancelButton.addTarget(self, action: #selector(cancel), for: .touchUpInside)
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
header,
.spacer(height: 20),
subtitleLabel,
@ -68,11 +68,8 @@ class GenerateSellMagicLinkViewController: UIViewController {
.spacer(height: 10),
cancelButton,
.spacer(height: 1)
])
].asStackView(axis: .vertical)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 0
stackView.distribution = .fill
background.addSubview(stackView)
NSLayoutConstraint.activate([

@ -42,12 +42,8 @@ class SellTicketsViewController: UIViewController {
nextButton.setTitle(R.string.localizable.aWalletNextButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
let buttonsStackView = UIStackView(arrangedSubviews: [nextButton])
let buttonsStackView = [nextButton].asStackView(distribution: .fillEqually, contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
buttonsStackView.axis = .horizontal
buttonsStackView.spacing = 0
buttonsStackView.distribution = .fillEqually
buttonsStackView.setContentHuggingPriority(UILayoutPriority.required, for: .horizontal)
let marginToHideBottomRoundedCorners = CGFloat(30)
let footerBar = UIView()

@ -79,45 +79,29 @@ class SetSellTicketsExpiryDateViewController: UIViewController {
linkExpiryTimeField.translatesAutoresizingMaskIntoConstraints = false
linkExpiryTimeField.delegate = self
let col0 = UIStackView(arrangedSubviews: [
let col0 = [
linkExpiryDateLabel,
.spacer(height: 4),
linkExpiryDateField,
])
].asStackView(axis: .vertical)
col0.translatesAutoresizingMaskIntoConstraints = false
col0.axis = .vertical
col0.spacing = 0
col0.distribution = .fill
let col1 = UIStackView(arrangedSubviews: [
let col1 = [
linkExpiryTimeLabel,
.spacer(height: 4),
linkExpiryTimeField,
])
].asStackView(axis: .vertical)
col1.translatesAutoresizingMaskIntoConstraints = false
col1.axis = .vertical
col1.spacing = 0
col1.distribution = .fill
let choicesStackView = UIStackView(arrangedSubviews: [
col0,
.spacerWidth(10),
col1,
])
let choicesStackView = [col0, .spacerWidth(10), col1].asStackView()
choicesStackView.translatesAutoresizingMaskIntoConstraints = false
choicesStackView.axis = .horizontal
choicesStackView.spacing = 0
choicesStackView.distribution = .fill
let noteStackView = UIStackView(arrangedSubviews: [
let noteStackView = [
noteTitleLabel,
.spacer(height: 4),
noteLabel,
])
].asStackView(axis: .vertical)
noteStackView.translatesAutoresizingMaskIntoConstraints = false
noteStackView.axis = .vertical
noteStackView.spacing = 0
noteStackView.distribution = .fill
noteBorderView.addSubview(noteStackView)
datePicker.datePickerMode = .date
@ -130,7 +114,7 @@ class SetSellTicketsExpiryDateViewController: UIViewController {
timePicker.addTarget(self, action: #selector(timePickerValueChanged), for: .valueChanged)
timePicker.isHidden = true
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
header,
ticketView,
.spacer(height: 18),
@ -145,20 +129,12 @@ class SetSellTicketsExpiryDateViewController: UIViewController {
timePicker,
.spacer(height: 10),
noteBorderView,
])
].asStackView(axis: .vertical, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 0
stackView.distribution = .fill
stackView.alignment = .center
scrollView.addSubview(stackView)
let buttonsStackView = UIStackView(arrangedSubviews: [nextButton])
let buttonsStackView = [nextButton].asStackView(distribution: .fillEqually, contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
buttonsStackView.axis = .horizontal
buttonsStackView.spacing = 0
buttonsStackView.distribution = .fillEqually
buttonsStackView.setContentHuggingPriority(.required, for: .horizontal)
let marginToHideBottomRoundedCorners = CGFloat(30)
let footerBar = UIView()

@ -88,14 +88,8 @@ class AmountTextField: UIControl {
fiatButton.setTitleColor(Colors.appGrayLabelColor, for: .normal)
fiatButton.addTarget(self, action: #selector(fiatAction), for: .touchUpInside)
let amountRightView = UIStackView(arrangedSubviews: [
fiatButton,
])
let amountRightView = [fiatButton].asStackView(distribution: .equalSpacing)
amountRightView.translatesAutoresizingMaskIntoConstraints = false
amountRightView.distribution = .equalSpacing
amountRightView.spacing = 1
amountRightView.axis = .horizontal
return amountRightView
}

@ -24,16 +24,8 @@ class DateEntryField: UIControl {
displayDateString()
let rightView = makeRightView()
let stackView = UIStackView(arrangedSubviews: [
.spacerWidth(22),
leftButton,
rightView,
])
let stackView = [.spacerWidth(22), leftButton, rightView].asStackView(alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .horizontal
stackView.spacing = 0
stackView.distribution = .fill
stackView.alignment = .center
addSubview(stackView)
NSLayoutConstraint.activate([
@ -62,14 +54,8 @@ class DateEntryField: UIControl {
rightButton.setImage(R.image.calendar(), for: .normal)
rightButton.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
let rightView = UIStackView(arrangedSubviews: [
rightButton,
])
let rightView = [rightButton].asStackView(distribution: .equalSpacing, spacing: 1)
rightView.translatesAutoresizingMaskIntoConstraints = false
rightView.distribution = .equalSpacing
rightView.spacing = 1
rightView.axis = .horizontal
return rightView
}

@ -24,16 +24,8 @@ class TimeEntryField: UIControl {
displayTimeString()
let rightView = makeRightView()
let stackView = UIStackView(arrangedSubviews: [
.spacerWidth(22),
leftButton,
rightView,
])
let stackView = [.spacerWidth(22), leftButton, rightView].asStackView(alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .horizontal
stackView.spacing = 0
stackView.distribution = .fill
stackView.alignment = .center
addSubview(stackView)
NSLayoutConstraint.activate([
@ -62,14 +54,8 @@ class TimeEntryField: UIControl {
rightButton.setImage(R.image.time(), for: .normal)
rightButton.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
let rightView = UIStackView(arrangedSubviews: [
rightButton,
])
let rightView = [rightButton].asStackView(distribution: .equalSpacing, spacing: 1)
rightView.translatesAutoresizingMaskIntoConstraints = false
rightView.distribution = .equalSpacing
rightView.spacing = 1
rightView.axis = .horizontal
return rightView
}

@ -32,18 +32,15 @@ class WellDoneViewController: UIViewController {
otherButton.setTitle(NSLocalizedString("welldone.share.label.text", value: "Share", comment: ""), for: .normal)
otherButton.addTarget(self, action: #selector(other(_:)), for: .touchUpInside)
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
imageView,
//titleLabel,
descriptionLabel,
.spacer(height: 10),
.spacer(),
otherButton,
])
].asStackView(axis: .vertical, spacing: 10, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.alignment = .center
stackView.axis = .vertical
stackView.spacing = 10
view.backgroundColor = .white
view.addSubview(stackView)

@ -66,12 +66,8 @@ class TicketsViewController: UIViewController {
transferButton.setTitle(R.string.localizable.aWalletTicketTokenTransferButtonTitle(), for: .normal)
transferButton.addTarget(self, action: #selector(transfer), for: .touchUpInside)
let buttonsStackView = UIStackView(arrangedSubviews: [redeemButton, sellButton, transferButton])
let buttonsStackView = [redeemButton, sellButton, transferButton].asStackView(distribution: .fillEqually, contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
buttonsStackView.axis = .horizontal
buttonsStackView.spacing = 0
buttonsStackView.distribution = .fillEqually
buttonsStackView.setContentHuggingPriority(UILayoutPriority.required, for: .horizontal)
let marginToHideBottomRoundedCorners = CGFloat(30)
let footerBar = UIView()

@ -141,14 +141,11 @@ class TokensViewController: UIViewController {
label.textColor = .white
label.text = R.string.localizable.aWalletImportWalletTitle()
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
imageView,
label,
])
].asStackView(axis: .vertical, spacing: 10, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.alignment = .center
stackView.spacing = 10
importWalletView.addSubview(stackView)
let sideMargin = CGFloat(7)

@ -34,33 +34,21 @@ class EthTokenViewCell: UITableViewCell {
valueLabel.textAlignment = .center
valueNameLabel.textAlignment = .center
let bottomRowStack = UIStackView(arrangedSubviews: [blockchainLabel, separator, issuerLabel])
bottomRowStack.axis = .horizontal
bottomRowStack.spacing = 15
bottomRowStack.distribution = .fill
let footerValuesStack = UIStackView(arrangedSubviews: [valuePercentageChangeValueLabel, valueChangeLabel, valueLabel])
footerValuesStack.axis = .horizontal
footerValuesStack.spacing = 15
footerValuesStack.distribution = .fillEqually
let footerNamesStack = UIStackView(arrangedSubviews: [valuePercentageChangePeriodLabel, valueChangeNameLabel, valueNameLabel])
footerNamesStack.axis = .horizontal
footerNamesStack.spacing = 15
footerNamesStack.distribution = .fillEqually
let footerStackView = UIStackView(arrangedSubviews: [middleBorder, .spacer(height: 14), footerValuesStack, footerNamesStack])
footerStackView.translatesAutoresizingMaskIntoConstraints = false
footerStackView.axis = .vertical
footerStackView.spacing = 0
footerStackView.distribution = .fill
footerValuesStack.setContentHuggingPriority(.defaultLow, for: .horizontal)
let stackView = UIStackView(arrangedSubviews: [titleLabel, bottomRowStack, footerStackView])
let bottomRowStack = [blockchainLabel, separator, issuerLabel].asStackView(spacing: 15)
let footerValuesStack = [valuePercentageChangeValueLabel, valueChangeLabel, valueLabel].asStackView(distribution: .fillEqually, spacing: 15)
let footerNamesStack = [valuePercentageChangePeriodLabel, valueChangeNameLabel, valueNameLabel].asStackView(distribution: .fillEqually, spacing: 15)
let footerStackView = [
middleBorder,
.spacer(height: 14),
footerValuesStack,
footerNamesStack,
].asStackView(axis: .vertical, perpendicularContentHuggingPriority: .defaultLow)
let stackView = [
titleLabel,
bottomRowStack,
footerStackView
].asStackView(axis: .vertical, spacing: 15)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 15
stackView.distribution = .fill
background.addSubview(stackView)
// TODO extract constant. Maybe StyleLayout.sideMargin

@ -19,15 +19,11 @@ class ImportWalletHelpBubbleView: UIView {
descriptionLabel.translatesAutoresizingMaskIntoConstraints = false
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
titleLabel,
descriptionLabel,
])
].asStackView(axis: .vertical, spacing: 7, contentHuggingPriority: .required)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 7
stackView.distribution = .fill
stackView.setContentHuggingPriority(UILayoutPriority.required, for: .vertical)
addSubview(stackView)
configure(viewModel: ImportWalletHelpBubbleViewViewModel())

@ -19,17 +19,13 @@ class TicketTokenViewCell: UITableViewCell {
contentView.addSubview(background)
background.translatesAutoresizingMaskIntoConstraints = false
let bottomRowStack = UIStackView(arrangedSubviews: [blockchainLabel, separator, issuerLabel])
bottomRowStack.axis = .horizontal
bottomRowStack.spacing = 15
bottomRowStack.distribution = .fill
let bottomRowStack = [blockchainLabel, separator, issuerLabel].asStackView(spacing: 15)
let stackView = UIStackView(arrangedSubviews: [titleLabel, bottomRowStack])
let stackView = [
titleLabel,
bottomRowStack,
].asStackView(axis: .vertical, spacing: 15, alignment: .leading)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 15
stackView.distribution = .fill
stackView.alignment = .leading
background.addSubview(stackView)
// TODO extract constant. Maybe StyleLayout.sideMargin

@ -17,16 +17,12 @@ class TicketsViewControllerHeader: UIView {
titleLabel.translatesAutoresizingMaskIntoConstraints = false
let bottomRowStack = UIStackView(arrangedSubviews: [blockchainLabel, separator, issuerLabel])
bottomRowStack.axis = .horizontal
bottomRowStack.spacing = 15
bottomRowStack.distribution = .fill
let stackView = UIStackView(arrangedSubviews: [titleLabel, bottomRowStack])
let bottomRowStack = [blockchainLabel, separator, issuerLabel].asStackView(spacing: 15)
let stackView = [
titleLabel,
bottomRowStack
].asStackView(axis: .vertical, spacing: 15)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 15
stackView.distribution = .fill
background.addSubview(stackView)
let backgroundWidthConstraint = background.widthAnchor.constraint(equalTo: widthAnchor)

@ -19,17 +19,13 @@ class TokenViewCell: UITableViewCell {
contentView.addSubview(background)
background.translatesAutoresizingMaskIntoConstraints = false
let bottomRowStack = UIStackView(arrangedSubviews: [blockchainLabel, separator, issuerLabel])
bottomRowStack.axis = .horizontal
bottomRowStack.spacing = 15
bottomRowStack.distribution = .fill
let bottomRowStack = [blockchainLabel, separator, issuerLabel].asStackView(spacing: 15)
let stackView = UIStackView(arrangedSubviews: [titleLabel, bottomRowStack])
let stackView = [
titleLabel,
bottomRowStack
].asStackView(axis: .vertical, spacing: 15, alignment: .leading)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 15
stackView.distribution = .fill
stackView.alignment = .leading
background.addSubview(stackView)
// TODO extract constant. Maybe StyleLayout.sideMargin

@ -16,11 +16,8 @@ class TokensFooterView: UIView {
textLabel.translatesAutoresizingMaskIntoConstraints = false
let stackView = UIStackView(arrangedSubviews: [
textLabel,
])
let stackView = [textLabel].asStackView(axis: .vertical)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
addSubview(stackView)
NSLayoutConstraint.activate([

@ -17,11 +17,8 @@ class TokensHeaderView: UIView {
amountLabel.translatesAutoresizingMaskIntoConstraints = false
let stackView = UIStackView(arrangedSubviews: [
amountLabel,
])
let stackView = [amountLabel].asStackView(axis: .vertical)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
addSubview(stackView)
NSLayoutConstraint.activate([

@ -40,11 +40,8 @@ class WalletFilterView: UIView {
assetsButton.titleLabel?.font = viewModel.font
assetsButton.addTarget(self, action: #selector(showAssetsOnly), for: .touchUpInside)
let buttonsStackView = UIStackView(arrangedSubviews: [allButton, currencyButton, assetsButton])
let buttonsStackView = [allButton, currencyButton, assetsButton].asStackView(spacing: 20)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
buttonsStackView.axis = .horizontal
buttonsStackView.spacing = 20
buttonsStackView.distribution = .fill
addSubview(buttonsStackView)
let fullWidthBar = UIView()

@ -85,10 +85,8 @@ class TransactionViewController: UIViewController {
button.translatesAutoresizingMaskIntoConstraints = false
button.addTarget(self, action: #selector(more), for: .touchUpInside)
let stackView = UIStackView(arrangedSubviews: [button])
let stackView = [button].asStackView(spacing: 10)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 10
stackView.layoutMargins = UIEdgeInsets(top: 15, left: 15, bottom: 15, right: 15)
stackView.isLayoutMarginsRelativeArrangement = true

@ -29,21 +29,17 @@ class TransactionViewCell: UITableViewCell {
amountLabel.textAlignment = .right
amountLabel.translatesAutoresizingMaskIntoConstraints = false
let leftStackView = UIStackView(arrangedSubviews: [titleLabel, subTitleLabel])
let leftStackView = [
titleLabel,
subTitleLabel,
].asStackView(axis: .vertical, distribution: .fillProportionally, spacing: 6)
leftStackView.translatesAutoresizingMaskIntoConstraints = false
leftStackView.axis = .vertical
leftStackView.distribution = .fillProportionally
leftStackView.spacing = 6
let rightStackView = UIStackView(arrangedSubviews: [amountLabel])
let rightStackView = [amountLabel].asStackView(axis: .vertical)
rightStackView.translatesAutoresizingMaskIntoConstraints = false
rightStackView.axis = .vertical
let stackView = UIStackView(arrangedSubviews: [statusImageView, leftStackView, rightStackView])
let stackView = [statusImageView, leftStackView, rightStackView].asStackView(spacing: 15)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .horizontal
stackView.spacing = 15
stackView.distribution = .fill
statusImageView.setContentHuggingPriority(UILayoutPriority.defaultLow, for: .horizontal)
subTitleLabel.setContentHuggingPriority(UILayoutPriority.defaultLow, for: .horizontal)

@ -51,15 +51,12 @@ class TransactionsEmptyView: UIView {
depositButton.setTitle(NSLocalizedString("transactions.deposit.button.title", value: "Buy", comment: ""), for: .normal)
depositButton.addTarget(self, action: #selector(deposit(_:)), for: .touchUpInside)
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
imageView,
titleLabel,
//depositButton,
])
].asStackView(axis: .vertical, spacing: 30, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.alignment = .center
stackView.axis = .vertical
stackView.spacing = 30
if let _ = onRetry {
stackView.addArrangedSubview(button)

@ -16,12 +16,8 @@ class TransactionsFooterView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
let stackView = UIStackView(arrangedSubviews: [
sendButton,
])
let stackView = [sendButton].asStackView(distribution: .fillEqually)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.distribution = .fillEqually
stackView.spacing = 0
addSubview(stackView)
backgroundColor = Colors.appHighlightGreen

@ -43,23 +43,15 @@ class ChooseTicketTransferModeViewController: UIViewController {
ticketView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(ticketView)
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
header,
ticketView,
])
].asStackView(axis: .vertical, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 0
stackView.distribution = .fill
stackView.alignment = .center
roundedBackground.addSubview(stackView)
let buttonsStackView = UIStackView(arrangedSubviews: [generateMagicLinkButton, transferNowButton])
let buttonsStackView = [generateMagicLinkButton, transferNowButton].asStackView(distribution: .fillEqually, contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
buttonsStackView.axis = .horizontal
buttonsStackView.spacing = 0
buttonsStackView.distribution = .fillEqually
buttonsStackView.setContentHuggingPriority(.required, for: .horizontal)
let marginToHideBottomRoundedCorners = CGFloat(30)
let footerBar = UIView()

@ -46,8 +46,8 @@ class GenerateTransferMagicLinkViewController: UIViewController {
actionButton.addTarget(self, action: #selector(share), for: .touchUpInside)
cancelButton.addTarget(self, action: #selector(cancel), for: .touchUpInside)
let stackView = UIStackView(arrangedSubviews: [
header,
let stackView = [
header,
.spacer(height: 20),
subtitleLabel,
ticketCountLabel,
@ -58,11 +58,8 @@ class GenerateTransferMagicLinkViewController: UIViewController {
.spacer(height: 10),
cancelButton,
.spacer(height: 1)
])
].asStackView(axis: .vertical)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 0
stackView.distribution = .fill
background.addSubview(stackView)
NSLayoutConstraint.activate([

@ -120,42 +120,26 @@ class SendViewController: UIViewController {
myAddressContainer.translatesAutoresizingMaskIntoConstraints = false
let myAddressContainerCol0 = UIStackView(arrangedSubviews: [
let myAddressContainerCol0 = [
myAddressLabelLabel,
.spacer(height: 10),
myAddressLabel,
.spacer(height: 10),
copyButton,
])
].asStackView(axis: .vertical, alignment: .center)
myAddressContainerCol0.translatesAutoresizingMaskIntoConstraints = false
myAddressContainerCol0.axis = .vertical
myAddressContainerCol0.spacing = 0
myAddressContainerCol0.distribution = .fill
myAddressContainerCol0.alignment = .center
let myAddressContainerStackView = UIStackView(arrangedSubviews: [
myAddressContainerCol0,
.spacerWidth(20),
imageView,
])
let myAddressContainerStackView = [myAddressContainerCol0, .spacerWidth(20), imageView].asStackView(alignment: .center)
myAddressContainerStackView.translatesAutoresizingMaskIntoConstraints = false
myAddressContainerStackView.axis = .horizontal
myAddressContainerStackView.spacing = 0
myAddressContainerStackView.distribution = .fill
myAddressContainerStackView.alignment = .center
myAddressContainer.addSubview(myAddressContainerStackView)
nextButton.setTitle(R.string.localizable.aWalletTicketTokenTransferButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(send), for: .touchUpInside)
let buttonsStackView = UIStackView(arrangedSubviews: [nextButton])
let buttonsStackView = [nextButton].asStackView(distribution: .fillEqually, contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
buttonsStackView.axis = .horizontal
buttonsStackView.spacing = 0
buttonsStackView.distribution = .fillEqually
buttonsStackView.setContentHuggingPriority(.required, for: .horizontal)
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
header,
.spacer(height: ScreenChecker().isNarrowScreen() ? 7: 20),
targetAddressLabel,
@ -168,12 +152,8 @@ class SendViewController: UIViewController {
alternativeAmountLabel,
.spacer(height: ScreenChecker().isNarrowScreen() ? 10: 20),
myAddressContainer,
])
].asStackView(axis: .vertical, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 0
stackView.distribution = .fill
stackView.alignment = .center
roundedBackground.addSubview(stackView)
@ -554,14 +534,8 @@ class SendViewController: UIViewController {
scanQRCodeButton.setTitleColor(Colors.appGrayLabelColor, for: .normal)
scanQRCodeButton.addTarget(self, action: #selector(openReader), for: .touchUpInside)
let targetAddressRightView = UIStackView(arrangedSubviews: [
pasteButton,
scanQRCodeButton,
])
let targetAddressRightView = [pasteButton, scanQRCodeButton].asStackView(distribution: .equalSpacing)
targetAddressRightView.translatesAutoresizingMaskIntoConstraints = false
targetAddressRightView.distribution = .equalSpacing
targetAddressRightView.spacing = 0
targetAddressRightView.axis = .horizontal
return targetAddressRightView
}
@ -574,14 +548,8 @@ class SendViewController: UIViewController {
fiatButton.addTarget(self, action: #selector(fiatAction), for: .touchUpInside)
fiatButton.isHidden = !viewModel.showAlternativeAmount
let amountRightView = UIStackView(arrangedSubviews: [
fiatButton,
])
let amountRightView = [fiatButton].asStackView(distribution: .equalSpacing, spacing: 1)
amountRightView.translatesAutoresizingMaskIntoConstraints = false
amountRightView.distribution = .equalSpacing
amountRightView.spacing = 1
amountRightView.axis = .horizontal
return amountRightView
}

@ -61,45 +61,29 @@ class SetTransferTicketsExpiryDateViewController: UIViewController {
noteBorderView.translatesAutoresizingMaskIntoConstraints = false
scrollView.addSubview(noteBorderView)
let col0 = UIStackView(arrangedSubviews: [
let col0 = [
linkExpiryDateLabel,
.spacer(height: 4),
linkExpiryDateField,
])
].asStackView(axis: .vertical)
col0.translatesAutoresizingMaskIntoConstraints = false
col0.axis = .vertical
col0.spacing = 0
col0.distribution = .fill
let col1 = UIStackView(arrangedSubviews: [
let col1 = [
linkExpiryTimeLabel,
.spacer(height: 4),
linkExpiryTimeField,
])
].asStackView(axis: .vertical)
col1.translatesAutoresizingMaskIntoConstraints = false
col1.axis = .vertical
col1.spacing = 0
col1.distribution = .fill
let choicesStackView = UIStackView(arrangedSubviews: [
col0,
.spacerWidth(10),
col1,
])
let choicesStackView = [col0, .spacerWidth(10), col1].asStackView()
choicesStackView.translatesAutoresizingMaskIntoConstraints = false
choicesStackView.axis = .horizontal
choicesStackView.spacing = 0
choicesStackView.distribution = .fill
let noteStackView = UIStackView(arrangedSubviews: [
let noteStackView = [
noteTitleLabel,
.spacer(height: 4),
noteLabel,
])
].asStackView(axis: .vertical)
noteStackView.translatesAutoresizingMaskIntoConstraints = false
noteStackView.axis = .vertical
noteStackView.spacing = 0
noteStackView.distribution = .fill
noteBorderView.addSubview(noteStackView)
datePicker.datePickerMode = .date
@ -112,7 +96,7 @@ class SetTransferTicketsExpiryDateViewController: UIViewController {
timePicker.addTarget(self, action: #selector(timePickerValueChanged), for: .valueChanged)
timePicker.isHidden = true
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
header,
ticketView,
.spacer(height: 18),
@ -123,12 +107,8 @@ class SetTransferTicketsExpiryDateViewController: UIViewController {
timePicker,
.spacer(height: 10),
noteBorderView,
])
].asStackView(axis: .vertical, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 0
stackView.distribution = .fill
stackView.alignment = .center
scrollView.addSubview(stackView)
linkExpiryDateField.translatesAutoresizingMaskIntoConstraints = false
@ -138,12 +118,8 @@ class SetTransferTicketsExpiryDateViewController: UIViewController {
linkExpiryTimeField.translatesAutoresizingMaskIntoConstraints = false
linkExpiryTimeField.delegate = self
let buttonsStackView = UIStackView(arrangedSubviews: [nextButton])
let buttonsStackView = [nextButton].asStackView(distribution: .fillEqually, contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
buttonsStackView.axis = .horizontal
buttonsStackView.spacing = 0
buttonsStackView.distribution = .fillEqually
buttonsStackView.setContentHuggingPriority(.required, for: .horizontal)
let marginToHideBottomRoundedCorners = CGFloat(30)
let footerBar = UIView()

@ -44,27 +44,18 @@ class TransferTicketsQuantitySelectionViewController: UIViewController {
quantityStepper.value = 1
view.addSubview(quantityStepper)
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
header,
ticketView,
.spacer(height: 20),
subtitleLabel,
.spacer(height: 4),
quantityStepper,
])
].asStackView(axis: .vertical, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 0
stackView.distribution = .fill
stackView.alignment = .center
roundedBackground.addSubview(stackView)
let buttonsStackView = UIStackView(arrangedSubviews: [nextButton])
let buttonsStackView = [nextButton].asStackView(distribution: .fillEqually, contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
buttonsStackView.axis = .horizontal
buttonsStackView.spacing = 0
buttonsStackView.distribution = .fillEqually
buttonsStackView.setContentHuggingPriority(.required, for: .horizontal)
let marginToHideBottomRoundedCorners = CGFloat(30)
let footerBar = UIView()

@ -46,27 +46,19 @@ class TransferTicketsViaWalletAddressViewController: UIViewController {
ticketView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(ticketView)
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
header,
ticketView,
.spacer(height: 10),
targetAddressLabel,
.spacer(height: ScreenChecker().isNarrowScreen() ? 2 : 4),
targetAddressTextField,
])
].asStackView(axis: .vertical, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 0
stackView.distribution = .fill
stackView.alignment = .center
roundedBackground.addSubview(stackView)
let buttonsStackView = UIStackView(arrangedSubviews: [nextButton])
let buttonsStackView = [nextButton].asStackView(distribution: .fillEqually, contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
buttonsStackView.axis = .horizontal
buttonsStackView.spacing = 0
buttonsStackView.distribution = .fillEqually
buttonsStackView.setContentHuggingPriority(.required, for: .horizontal)
let marginToHideBottomRoundedCorners = CGFloat(30)
let footerBar = UIView()
@ -206,14 +198,8 @@ class TransferTicketsViaWalletAddressViewController: UIViewController {
scanQRCodeButton.setTitleColor(Colors.appGrayLabelColor, for: .normal)
scanQRCodeButton.addTarget(self, action: #selector(openReader), for: .touchUpInside)
let targetAddressRightView = UIStackView(arrangedSubviews: [
pasteButton,
scanQRCodeButton,
])
let targetAddressRightView = [pasteButton, scanQRCodeButton].asStackView(distribution: .equalSpacing)
targetAddressRightView.translatesAutoresizingMaskIntoConstraints = false
targetAddressRightView.distribution = .equalSpacing
targetAddressRightView.spacing = 0
targetAddressRightView.axis = .horizontal
return targetAddressRightView
}

@ -42,12 +42,8 @@ class TransferTicketsViewController: UIViewController {
nextButton.setTitle(R.string.localizable.aWalletNextButtonTitle(), for: .normal)
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
let buttonsStackView = UIStackView(arrangedSubviews: [nextButton])
let buttonsStackView = [nextButton].asStackView(distribution: .fillEqually, contentHuggingPriority: .required)
buttonsStackView.translatesAutoresizingMaskIntoConstraints = false
buttonsStackView.axis = .horizontal
buttonsStackView.spacing = 0
buttonsStackView.distribution = .fillEqually
buttonsStackView.setContentHuggingPriority(UILayoutPriority.required, for: .horizontal)
let marginToHideBottomRoundedCorners = CGFloat(30)
let footerBar = UIView()

@ -30,38 +30,27 @@ class SendHeaderView: UIView {
valueLabel.textAlignment = .center
valueNameLabel.textAlignment = .center
let bottomRowStack = UIStackView(arrangedSubviews: [blockchainLabel, issuerLabel])
bottomRowStack.axis = .horizontal
bottomRowStack.spacing = 15
bottomRowStack.distribution = .fill
let footerValuesStack = UIStackView(arrangedSubviews: [valuePercentageChangeValueLabel, valueChangeLabel, valueLabel])
footerValuesStack.axis = .horizontal
footerValuesStack.spacing = 15
footerValuesStack.distribution = .fillEqually
let footerNamesStack = UIStackView(arrangedSubviews: [valuePercentageChangePeriodLabel, valueChangeNameLabel, valueNameLabel])
footerNamesStack.axis = .horizontal
footerNamesStack.spacing = 15
footerNamesStack.distribution = .fillEqually
let footerStackView = UIStackView(arrangedSubviews: [middleBorder, .spacer(height: 14), footerValuesStack, footerNamesStack])
let bottomRowStack = [blockchainLabel, issuerLabel].asStackView(spacing: 15)
let footerValuesStack = [valuePercentageChangeValueLabel, valueChangeLabel, valueLabel].asStackView(distribution: .fillEqually, spacing: 15)
let footerNamesStack = [valuePercentageChangePeriodLabel, valueChangeNameLabel, valueNameLabel].asStackView(distribution: .fillEqually, spacing: 15)
let footerStackView = [
middleBorder,
.spacer(height: 14),
footerValuesStack,
footerNamesStack,
].asStackView(axis: .vertical, perpendicularContentHuggingPriority: .defaultLow)
footerStackView.translatesAutoresizingMaskIntoConstraints = false
footerStackView.axis = .vertical
footerStackView.spacing = 0
footerStackView.distribution = .fill
footerValuesStack.setContentHuggingPriority(.defaultLow, for: .horizontal)
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
titleLabel,
bottomRowStack,
.spacer(height: 7),
footerStackView,
])
].asStackView(axis: .vertical)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 0
stackView.distribution = .fill
background.addSubview(stackView)
let backgroundWidthConstraint = background.widthAnchor.constraint(equalTo: widthAnchor)

@ -40,13 +40,11 @@ class BalanceTitleView: UIView {
subTitleLabel.textAlignment = .center
subTitleLabel.adjustsFontSizeToFitWidth = true
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
titleLabel,
subTitleLabel,
])
].asStackView(axis: .vertical, spacing: 2)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 2
addSubview(stackView)
NSLayoutConstraint.activate([

@ -38,14 +38,11 @@ class EmptyView: UIView {
button.setTitle(NSLocalizedString("Refresh", value: "Refresh", comment: ""), for: .normal)
button.addTarget(self, action: #selector(retry), for: .touchUpInside)
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
imageView,
titleLabel,
])
].asStackView(axis: .vertical, spacing: 30, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.alignment = .center
stackView.axis = .vertical
stackView.spacing = 30
if let _ = onRetry {
stackView.addArrangedSubview(button)

@ -38,15 +38,12 @@ class ErrorView: UIView {
button.setTitle(NSLocalizedString("Retry", value: "Retry", comment: ""), for: .normal)
button.addTarget(self, action: #selector(retry), for: .touchUpInside)
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
imageView,
descriptionLabel,
button,
])
].asStackView(axis: .vertical, spacing: viewModel.stackSpacing, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.alignment = .center
stackView.axis = .vertical
stackView.spacing = viewModel.stackSpacing
addSubview(stackView)

@ -24,14 +24,8 @@ class FieldAppereance {
UITapGestureRecognizer(addToView: qrButton) {
qrAction()
}
let recipientRightView = UIStackView(arrangedSubviews: [
pasteButton,
qrButton,
])
let recipientRightView = [pasteButton, qrButton].asStackView(distribution: .equalSpacing, spacing: 2)
recipientRightView.translatesAutoresizingMaskIntoConstraints = false
recipientRightView.distribution = .equalSpacing
recipientRightView.spacing = 2
recipientRightView.axis = .horizontal
return recipientRightView
}
}

@ -28,10 +28,11 @@ struct TransactionAppearance {
subTitleLabel.font = Fonts.light(size: 15)
subTitleLabel.numberOfLines = 0
let stackView = UIStackView(arrangedSubviews: [titleLabel, subTitleLabel])
let stackView = [
titleLabel,
subTitleLabel,
].asStackView(axis: .vertical, spacing: 10)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 10
stackView.layoutMargins = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20)
stackView.isLayoutMarginsRelativeArrangement = true

@ -34,15 +34,12 @@ class LoadingView: UIView {
loadingIndicator.translatesAutoresizingMaskIntoConstraints = false
loadingIndicator.startAnimating()
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
loadingIndicator,
label,
imageView,
])
].asStackView(axis: .vertical, spacing: viewModel.stackSpacing, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.alignment = .center
stackView.axis = .vertical
stackView.spacing = viewModel.stackSpacing
addSubview(stackView)

@ -28,16 +28,13 @@ class PassphraseViewController: UIViewController {
copyButton.translatesAutoresizingMaskIntoConstraints = false
copyButton.addTarget(self, action: #selector(copyAction), for: .touchUpInside)
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
.spacer(height: 10),
passphraseView,
copyButton,
label,
])
].asStackView(axis: .vertical, spacing: 10)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 10
view.addSubview(stackView)
NSLayoutConstraint.activate([

@ -43,14 +43,11 @@ final class OnboardingPage: UICollectionViewCell {
titleLabel.font = style.titleFont
titleLabel.numberOfLines = 0
let stackView = UIStackView(arrangedSubviews: [
let stackView = [
titleLabel,
imageView,
])
].asStackView(axis: .vertical, spacing: 80, alignment: .center)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.alignment = .center
stackView.spacing = 80
addSubview(stackView)
NSLayoutConstraint.activate([

Loading…
Cancel
Save