Minor refactoring

This commit is contained in:
nielsandriesse 2020-06-18 14:41:02 +10:00
parent 2d3df5a261
commit 15eee23ad8
15 changed files with 107 additions and 80 deletions

View File

@ -8,8 +8,8 @@ final class TextField : UITextField {
init(placeholder: String, usesDefaultHeight: Bool = true, customHeight: CGFloat? = nil, customHorizontalInset: CGFloat? = nil, customVerticalInset: CGFloat? = nil) {
self.usesDefaultHeight = usesDefaultHeight
self.height = customHeight ?? Values.textFieldHeight
self.horizontalInset = customHorizontalInset ?? (isSmallScreen ? Values.mediumSpacing : Values.largeSpacing)
self.verticalInset = customVerticalInset ?? (isSmallScreen ? Values.smallSpacing : Values.largeSpacing)
self.horizontalInset = customHorizontalInset ?? (isIPhone5OrSmaller ? Values.mediumSpacing : Values.largeSpacing)
self.verticalInset = customVerticalInset ?? (isIPhone5OrSmaller ? Values.smallSpacing : Values.largeSpacing)
super.init(frame: CGRect.zero)
self.placeholder = placeholder
setUpStyle()

View File

@ -21,7 +21,7 @@ final class DisplayNameVC : BaseVC {
// Set up title label
let titleLabel = UILabel()
titleLabel.textColor = Colors.text
titleLabel.font = .boldSystemFont(ofSize: isSmallScreen ? Values.largeFontSize : Values.veryLargeFontSize)
titleLabel.font = .boldSystemFont(ofSize: isIPhone5OrSmaller ? Values.largeFontSize : Values.veryLargeFontSize)
titleLabel.text = NSLocalizedString("Pick your display name", comment: "")
titleLabel.numberOfLines = 0
titleLabel.lineBreakMode = .byWordWrapping
@ -35,9 +35,9 @@ final class DisplayNameVC : BaseVC {
// Set up spacers
let topSpacer = UIView.vStretchingSpacer()
let spacer1 = UIView()
spacer1HeightConstraint = spacer1.set(.height, to: isSmallScreen ? Values.smallSpacing : Values.veryLargeSpacing)
spacer1HeightConstraint = spacer1.set(.height, to: isIPhone5OrSmaller ? Values.smallSpacing : Values.veryLargeSpacing)
let spacer2 = UIView()
spacer2HeightConstraint = spacer2.set(.height, to: isSmallScreen ? Values.smallSpacing : Values.veryLargeSpacing)
spacer2HeightConstraint = spacer2.set(.height, to: isIPhone5OrSmaller ? Values.smallSpacing : Values.veryLargeSpacing)
let bottomSpacer = UIView.vStretchingSpacer()
let registerButtonBottomOffsetSpacer = UIView()
registerButtonBottomOffsetConstraint = registerButtonBottomOffsetSpacer.set(.height, to: Values.onboardingButtonBottomOffset)
@ -101,9 +101,9 @@ final class DisplayNameVC : BaseVC {
@objc private func handleKeyboardWillChangeFrameNotification(_ notification: Notification) {
guard let newHeight = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue.size.height else { return }
bottomConstraint.constant = -newHeight // Negative due to how the constraint is set up
registerButtonBottomOffsetConstraint.constant = isSmallScreen ? Values.smallSpacing : Values.largeSpacing
spacer1HeightConstraint.constant = isSmallScreen ? Values.smallSpacing : Values.mediumSpacing
spacer2HeightConstraint.constant = isSmallScreen ? Values.smallSpacing : Values.mediumSpacing
registerButtonBottomOffsetConstraint.constant = isIPhone5OrSmaller ? Values.smallSpacing : Values.largeSpacing
spacer1HeightConstraint.constant = isIPhone5OrSmaller ? Values.smallSpacing : Values.mediumSpacing
spacer2HeightConstraint.constant = isIPhone5OrSmaller ? Values.smallSpacing : Values.mediumSpacing
UIView.animate(withDuration: 0.25) {
self.view.layoutIfNeeded()
}
@ -112,8 +112,8 @@ final class DisplayNameVC : BaseVC {
@objc private func handleKeyboardWillHideNotification(_ notification: Notification) {
bottomConstraint.constant = 0
registerButtonBottomOffsetConstraint.constant = Values.onboardingButtonBottomOffset
spacer1HeightConstraint.constant = isSmallScreen ? Values.smallSpacing : Values.veryLargeSpacing
spacer2HeightConstraint.constant = isSmallScreen ? Values.smallSpacing : Values.veryLargeSpacing
spacer1HeightConstraint.constant = isIPhone5OrSmaller ? Values.smallSpacing : Values.veryLargeSpacing
spacer2HeightConstraint.constant = isIPhone5OrSmaller ? Values.smallSpacing : Values.veryLargeSpacing
UIView.animate(withDuration: 0.25) {
self.view.layoutIfNeeded()
}

View File

@ -210,7 +210,7 @@ private final class EnterChatURLVC : UIViewController {
let stackView = UIStackView(arrangedSubviews: [ chatURLTextField, UIView.vStretchingSpacer(), nextButtonContainer, UIView.spacer(withHeight: Values.smallSpacing), explanationLabel ])
stackView.axis = .vertical
stackView.alignment = .fill
let bottomSpacing = isSmallScreen ? Values.smallSpacing : Values.largeSpacing
let bottomSpacing = isIPhone5OrSmaller ? Values.smallSpacing : Values.largeSpacing
stackView.layoutMargins = UIEdgeInsets(top: Values.largeSpacing, left: Values.largeSpacing, bottom: bottomSpacing, right: Values.largeSpacing)
stackView.isLayoutMarginsRelativeArrangement = true
view.addSubview(stackView)

View File

@ -42,7 +42,7 @@ final class LandingVC : BaseVC, LinkDeviceVCDelegate, DeviceLinkingModalDelegate
// Set up title label
let titleLabel = UILabel()
titleLabel.textColor = Colors.text
titleLabel.font = .boldSystemFont(ofSize: isSmallScreen ? Values.largeFontSize : Values.veryLargeFontSize)
titleLabel.font = .boldSystemFont(ofSize: isIPhone5OrSmaller ? Values.largeFontSize : Values.veryLargeFontSize)
titleLabel.text = NSLocalizedString("Your Session begins here...", comment: "")
titleLabel.numberOfLines = 0
titleLabel.lineBreakMode = .byWordWrapping
@ -63,11 +63,11 @@ final class LandingVC : BaseVC, LinkDeviceVCDelegate, DeviceLinkingModalDelegate
linkButton.pin(.leading, to: .leading, of: linkButtonContainer, withInset: Values.massiveSpacing)
linkButton.pin(.top, to: .top, of: linkButtonContainer)
linkButtonContainer.pin(.trailing, to: .trailing, of: linkButton, withInset: Values.massiveSpacing)
linkButtonContainer.pin(.bottom, to: .bottom, of: linkButton, withInset: isSmallScreen ? 6 : 10)
linkButtonContainer.pin(.bottom, to: .bottom, of: linkButton, withInset: isIPhone5OrSmaller ? 6 : 10)
// Set up button stack view
let buttonStackView = UIStackView(arrangedSubviews: [ registerButton, restoreButton ])
buttonStackView.axis = .vertical
buttonStackView.spacing = isSmallScreen ? Values.smallSpacing : Values.mediumSpacing
buttonStackView.spacing = isIPhone5OrSmaller ? Values.smallSpacing : Values.mediumSpacing
buttonStackView.alignment = .fill
// Set up button stack view container
let buttonStackViewContainer = UIView()
@ -77,7 +77,7 @@ final class LandingVC : BaseVC, LinkDeviceVCDelegate, DeviceLinkingModalDelegate
buttonStackViewContainer.pin(.trailing, to: .trailing, of: buttonStackView, withInset: Values.massiveSpacing)
buttonStackViewContainer.pin(.bottom, to: .bottom, of: buttonStackView)
// Set up main stack view
let mainStackView = UIStackView(arrangedSubviews: [ topSpacer, titleLabelContainer, UIView.spacer(withHeight: isSmallScreen ? Values.smallSpacing : Values.mediumSpacing), fakeChatView, bottomSpacer, buttonStackViewContainer, linkButtonContainer ])
let mainStackView = UIStackView(arrangedSubviews: [ topSpacer, titleLabelContainer, UIView.spacer(withHeight: isIPhone5OrSmaller ? Values.smallSpacing : Values.mediumSpacing), fakeChatView, bottomSpacer, buttonStackViewContainer, linkButtonContainer ])
mainStackView.axis = .vertical
mainStackView.alignment = .fill
view.addSubview(mainStackView)

View File

@ -134,11 +134,20 @@ final class LinkDeviceVC : BaseVC, UIPageViewControllerDataSource, UIPageViewCon
private final class EnterPublicKeyVC : UIViewController {
weak var linkDeviceVC: LinkDeviceVC!
private var spacer1HeightConstraint: NSLayoutConstraint!
private var spacer2HeightConstraint: NSLayoutConstraint!
private var spacer3HeightConstraint: NSLayoutConstraint!
private var bottomConstraint: NSLayoutConstraint!
private var linkButtonBottomConstraint: NSLayoutConstraint!
private var linkButtonBottomOffsetConstraint: NSLayoutConstraint!
// MARK: Components
private lazy var publicKeyTextField = TextField(placeholder: NSLocalizedString("Enter your Session ID", comment: ""), customHeight: 56, customVerticalInset: 12)
private lazy var publicKeyTextField: TextField = {
if isIPhone6OrSmaller {
return TextField(placeholder: NSLocalizedString("Enter your Session ID", comment: ""), customHeight: 56, customVerticalInset: 12)
} else {
return TextField(placeholder: NSLocalizedString("Enter your Session ID", comment: ""))
}
}()
// MARK: Lifecycle
override func viewDidLoad() {
@ -147,7 +156,7 @@ private final class EnterPublicKeyVC : UIViewController {
// Set up title label
let titleLabel = UILabel()
titleLabel.textColor = Colors.text
titleLabel.font = .boldSystemFont(ofSize: isSmallScreen ? Values.largeFontSize : Values.veryLargeFontSize)
titleLabel.font = .boldSystemFont(ofSize: isIPhone6OrSmaller ? Values.largeFontSize : Values.veryLargeFontSize)
titleLabel.text = NSLocalizedString("Link your device", comment: "")
titleLabel.numberOfLines = 0
titleLabel.lineBreakMode = .byWordWrapping
@ -165,23 +174,33 @@ private final class EnterPublicKeyVC : UIViewController {
linkButton.addTarget(self, action: #selector(requestDeviceLink), for: UIControl.Event.touchUpInside)
let linkButtonContainer = UIView()
linkButtonContainer.addSubview(linkButton)
linkButton.pin(.leading, to: .leading, of: linkButtonContainer, withInset: isSmallScreen ? 48 : 80)
linkButton.pin(.leading, to: .leading, of: linkButtonContainer, withInset: Values.massiveSpacing)
linkButton.pin(.top, to: .top, of: linkButtonContainer)
linkButtonContainer.pin(.trailing, to: .trailing, of: linkButton, withInset: isSmallScreen ? 48 : 80)
linkButtonBottomConstraint = linkButtonContainer.pin(.bottom, to: .bottom, of: linkButton, withInset: Values.largeSpacing)
// Set up top stack view
let topStackView = UIStackView(arrangedSubviews: [ titleLabel, explanationLabel, publicKeyTextField ])
topStackView.axis = .vertical
topStackView.spacing = Values.smallSpacing
linkButtonContainer.pin(.trailing, to: .trailing, of: linkButton, withInset: Values.massiveSpacing)
linkButtonContainer.pin(.bottom, to: .bottom, of: linkButton)
// Set up spacers
let topSpacer = UIView.vStretchingSpacer()
let spacer1 = UIView()
spacer1HeightConstraint = spacer1.set(.height, to: isIPhone6OrSmaller ? Values.smallSpacing : Values.veryLargeSpacing)
let spacer2 = UIView()
spacer2HeightConstraint = spacer2.set(.height, to: isIPhone6OrSmaller ? Values.smallSpacing : Values.veryLargeSpacing)
let bottomSpacer = UIView.vStretchingSpacer()
let linkButtonBottomOffsetSpacer = UIView()
linkButtonBottomOffsetConstraint = linkButtonBottomOffsetSpacer.set(.height, to: Values.onboardingButtonBottomOffset)
// Set up top stack view
let topStackView = UIStackView(arrangedSubviews: [ titleLabel, spacer1, explanationLabel, spacer2, publicKeyTextField ])
topStackView.axis = .vertical
// Set up top stack view container
let topStackViewContainer = UIView()
topStackViewContainer.addSubview(topStackView)
topStackView.pin(.leading, to: .leading, of: topStackViewContainer, withInset: Values.veryLargeSpacing)
topStackView.pin(.top, to: .top, of: topStackViewContainer)
topStackViewContainer.pin(.trailing, to: .trailing, of: topStackView, withInset: Values.veryLargeSpacing)
topStackViewContainer.pin(.bottom, to: .bottom, of: topStackView)
// Set up stack view
let stackView = UIStackView(arrangedSubviews: [ topSpacer, topStackView, bottomSpacer, linkButtonContainer ])
let stackView = UIStackView(arrangedSubviews: [ topSpacer, topStackViewContainer, bottomSpacer, linkButtonContainer, linkButtonBottomOffsetSpacer ])
stackView.axis = .vertical
stackView.alignment = .fill
stackView.layoutMargins = UIEdgeInsets(top: 0, left: Values.veryLargeSpacing, bottom: 0, right: Values.veryLargeSpacing)
stackView.isLayoutMarginsRelativeArrangement = true
view.addSubview(stackView)
stackView.pin(.leading, to: .leading, of: view)
stackView.pin(.top, to: .top, of: view)
@ -216,7 +235,9 @@ private final class EnterPublicKeyVC : UIViewController {
@objc private func handleKeyboardWillChangeFrameNotification(_ notification: Notification) {
guard let newHeight = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue.size.height else { return }
bottomConstraint.constant = -newHeight
linkButtonBottomConstraint.constant = isSmallScreen ? Values.smallSpacing : Values.mediumSpacing
linkButtonBottomOffsetConstraint.constant = isIPhone6OrSmaller ? Values.smallSpacing : Values.largeSpacing
spacer1HeightConstraint.constant = isIPhone6OrSmaller ? Values.smallSpacing : Values.mediumSpacing
spacer2HeightConstraint.constant = isIPhone6OrSmaller ? Values.smallSpacing : Values.mediumSpacing
UIView.animate(withDuration: 0.25) {
self.view.layoutIfNeeded()
}
@ -224,7 +245,9 @@ private final class EnterPublicKeyVC : UIViewController {
@objc private func handleKeyboardWillHideNotification(_ notification: Notification) {
bottomConstraint.constant = 0
linkButtonBottomConstraint.constant = Values.largeSpacing
linkButtonBottomOffsetConstraint.constant = Values.onboardingButtonBottomOffset
spacer1HeightConstraint.constant = isIPhone6OrSmaller ? Values.smallSpacing : Values.veryLargeSpacing
spacer2HeightConstraint.constant = isIPhone6OrSmaller ? Values.smallSpacing : Values.veryLargeSpacing
UIView.animate(withDuration: 0.25) {
self.view.layoutIfNeeded()
}

View File

@ -47,7 +47,7 @@ final class NewClosedGroupVC : BaseVC, UITableViewDataSource, UITableViewDelegat
super.viewDidLoad()
setUpGradientBackground()
setUpNavBarStyle()
let customTitleFontSize = isSmallScreen ? Values.largeFontSize : Values.veryLargeFontSize
let customTitleFontSize = isIPhone5OrSmaller ? Values.largeFontSize : Values.veryLargeFontSize
setNavBarTitle(NSLocalizedString("New Closed Group", comment: ""), customFontSize: customTitleFontSize)
// Set up navigation bar buttons
let closeButton = UIBarButtonItem(image: #imageLiteral(resourceName: "X"), style: .plain, target: self, action: #selector(close))

View File

@ -19,7 +19,7 @@ final class PNModeSheet : Sheet, OptionViewDelegate {
// Set up title label
let titleLabel = UILabel()
titleLabel.textColor = Colors.text
titleLabel.font = .boldSystemFont(ofSize: isSmallScreen ? Values.largeFontSize : Values.veryLargeFontSize)
titleLabel.font = .boldSystemFont(ofSize: isIPhone5OrSmaller ? Values.largeFontSize : Values.veryLargeFontSize)
titleLabel.text = NSLocalizedString("Push Notifications", comment: "")
titleLabel.numberOfLines = 0
titleLabel.lineBreakMode = .byWordWrapping
@ -48,19 +48,19 @@ final class PNModeSheet : Sheet, OptionViewDelegate {
// Set up button stack view
let bottomStackView = UIStackView(arrangedSubviews: [ confirmButton, skipButton ])
bottomStackView.axis = .vertical
bottomStackView.spacing = isSmallScreen ? Values.smallSpacing : Values.mediumSpacing
bottomStackView.spacing = isIPhone5OrSmaller ? Values.smallSpacing : Values.mediumSpacing
bottomStackView.alignment = .fill
// Set up main stack view
let stackView = UIStackView(arrangedSubviews: [ titleLabel, explanationLabel, optionsStackView, bottomStackView ])
stackView.axis = .vertical
stackView.spacing = isSmallScreen ? 12 : Values.largeSpacing
stackView.spacing = isIPhone5OrSmaller ? 12 : Values.largeSpacing
stackView.alignment = .center
// Set up constraints
contentView.addSubview(stackView)
stackView.pin(.leading, to: .leading, of: contentView, withInset: isSmallScreen ? Values.mediumSpacing : Values.largeSpacing)
stackView.pin(.top, to: .top, of: contentView, withInset: isSmallScreen ? Values.mediumSpacing : Values.largeSpacing)
contentView.pin(.trailing, to: .trailing, of: stackView, withInset: isSmallScreen ? Values.mediumSpacing : Values.largeSpacing)
contentView.pin(.bottom, to: .bottom, of: stackView, withInset: (isSmallScreen ? Values.mediumSpacing : Values.veryLargeSpacing) + overshoot)
stackView.pin(.leading, to: .leading, of: contentView, withInset: isIPhone5OrSmaller ? Values.mediumSpacing : Values.largeSpacing)
stackView.pin(.top, to: .top, of: contentView, withInset: isIPhone5OrSmaller ? Values.mediumSpacing : Values.largeSpacing)
contentView.pin(.trailing, to: .trailing, of: stackView, withInset: isIPhone5OrSmaller ? Values.mediumSpacing : Values.largeSpacing)
contentView.pin(.bottom, to: .bottom, of: stackView, withInset: (isIPhone5OrSmaller ? Values.mediumSpacing : Values.veryLargeSpacing) + overshoot)
}
// MARK: Interaction

View File

@ -23,7 +23,7 @@ final class PNModeVC : BaseVC, OptionViewDelegate {
// Set up title label
let titleLabel = UILabel()
titleLabel.textColor = Colors.text
titleLabel.font = .boldSystemFont(ofSize: isSmallScreen ? Values.largeFontSize : Values.veryLargeFontSize)
titleLabel.font = .boldSystemFont(ofSize: isIPhone5OrSmaller ? Values.largeFontSize : Values.veryLargeFontSize)
titleLabel.text = NSLocalizedString("Push Notifications", comment: "")
titleLabel.numberOfLines = 0
titleLabel.lineBreakMode = .byWordWrapping
@ -55,7 +55,7 @@ final class PNModeVC : BaseVC, OptionViewDelegate {
let topStackView = UIStackView(arrangedSubviews: [ titleLabel, explanationLabel, optionsStackView ])
topStackView.axis = .vertical
let isMediumScreen = (UIScreen.main.bounds.height - 667) < 1
topStackView.spacing = isSmallScreen ? Values.smallSpacing : (isMediumScreen ? Values.mediumSpacing : Values.veryLargeSpacing)
topStackView.spacing = isIPhone5OrSmaller ? Values.smallSpacing : (isMediumScreen ? Values.mediumSpacing : Values.veryLargeSpacing)
topStackView.alignment = .fill
// Set up top stack view container
let topStackViewContainer = UIView(wrapping: topStackView, withInsets: UIEdgeInsets(top: 0, leading: Values.veryLargeSpacing, bottom: 0, trailing: Values.veryLargeSpacing))

View File

@ -152,7 +152,7 @@ private final class ViewMyQRCodeVC : UIViewController {
// Set up title label
let titleLabel = UILabel()
titleLabel.textColor = Colors.text
titleLabel.font = .boldSystemFont(ofSize: isSmallScreen ? CGFloat(40) : Values.massiveFontSize)
titleLabel.font = .boldSystemFont(ofSize: isIPhone5OrSmaller ? CGFloat(40) : Values.massiveFontSize)
titleLabel.text = NSLocalizedString("Scan Me", comment: "")
titleLabel.numberOfLines = 0
titleLabel.textAlignment = .center
@ -162,8 +162,8 @@ private final class ViewMyQRCodeVC : UIViewController {
let qrCode = QRCode.generate(for: userHexEncodedPublicKey, hasBackground: true)
qrCodeImageView.image = qrCode
qrCodeImageView.contentMode = .scaleAspectFit
qrCodeImageView.set(.height, to: isSmallScreen ? 180 : 240)
qrCodeImageView.set(.width, to: isSmallScreen ? 180 : 240)
qrCodeImageView.set(.height, to: isIPhone5OrSmaller ? 180 : 240)
qrCodeImageView.set(.width, to: isIPhone5OrSmaller ? 180 : 240)
// Set up QR code image view container
let qrCodeImageViewContainer = UIView()
qrCodeImageViewContainer.addSubview(qrCodeImageView)
@ -196,7 +196,7 @@ private final class ViewMyQRCodeVC : UIViewController {
// Set up stack view
let stackView = UIStackView(arrangedSubviews: [ titleLabel, qrCodeImageViewContainer, explanationLabel, shareButtonContainer, UIView.vStretchingSpacer() ])
stackView.axis = .vertical
stackView.spacing = isSmallScreen ? Values.mediumSpacing : Values.largeSpacing
stackView.spacing = isIPhone5OrSmaller ? Values.mediumSpacing : Values.largeSpacing
stackView.alignment = .fill
stackView.layoutMargins = UIEdgeInsets(top: Values.largeSpacing, left: Values.largeSpacing, bottom: Values.largeSpacing, right: Values.largeSpacing)
stackView.isLayoutMarginsRelativeArrangement = true

View File

@ -7,7 +7,7 @@ final class RegisterVC : BaseVC {
private lazy var publicKeyLabel: UILabel = {
let result = UILabel()
result.textColor = Colors.text
result.font = Fonts.spaceMono(ofSize: isSmallScreen ? Values.mediumFontSize : 20)
result.font = Fonts.spaceMono(ofSize: isIPhone5OrSmaller ? Values.mediumFontSize : 20)
result.numberOfLines = 0
result.lineBreakMode = .byCharWrapping
return result
@ -46,7 +46,7 @@ final class RegisterVC : BaseVC {
// Set up title label
let titleLabel = UILabel()
titleLabel.textColor = Colors.text
titleLabel.font = .boldSystemFont(ofSize: isSmallScreen ? Values.largeFontSize : Values.veryLargeFontSize)
titleLabel.font = .boldSystemFont(ofSize: isIPhone5OrSmaller ? Values.largeFontSize : Values.veryLargeFontSize)
titleLabel.text = NSLocalizedString("Say hello to your Session ID", comment: "")
titleLabel.numberOfLines = 0
titleLabel.lineBreakMode = .byWordWrapping
@ -75,7 +75,7 @@ final class RegisterVC : BaseVC {
// Set up button stack view
let buttonStackView = UIStackView(arrangedSubviews: [ registerButton, copyPublicKeyButton ])
buttonStackView.axis = .vertical
buttonStackView.spacing = isSmallScreen ? Values.smallSpacing : Values.mediumSpacing
buttonStackView.spacing = isIPhone5OrSmaller ? Values.smallSpacing : Values.mediumSpacing
buttonStackView.alignment = .fill
// Set up button stack view container
let buttonStackViewContainer = UIView()
@ -95,11 +95,11 @@ final class RegisterVC : BaseVC {
legalLabel.pin(.leading, to: .leading, of: legalLabelContainer, withInset: Values.massiveSpacing)
legalLabel.pin(.top, to: .top, of: legalLabelContainer)
legalLabelContainer.pin(.trailing, to: .trailing, of: legalLabel, withInset: Values.massiveSpacing)
legalLabelContainer.pin(.bottom, to: .bottom, of: legalLabel, withInset: isSmallScreen ? 6 : 10)
legalLabelContainer.pin(.bottom, to: .bottom, of: legalLabel, withInset: isIPhone5OrSmaller ? 6 : 10)
// Set up top stack view
let topStackView = UIStackView(arrangedSubviews: [ titleLabel, explanationLabel, publicKeyLabelContainer ])
topStackView.axis = .vertical
topStackView.spacing = isSmallScreen ? Values.smallSpacing : Values.veryLargeSpacing
topStackView.spacing = isIPhone5OrSmaller ? Values.smallSpacing : Values.veryLargeSpacing
topStackView.alignment = .fill
// Set up top stack view container
let topStackViewContainer = UIView()

View File

@ -38,7 +38,7 @@ final class RestoreVC : BaseVC {
// Set up title label
let titleLabel = UILabel()
titleLabel.textColor = Colors.text
titleLabel.font = .boldSystemFont(ofSize: isSmallScreen ? Values.largeFontSize : Values.veryLargeFontSize)
titleLabel.font = .boldSystemFont(ofSize: isIPhone5OrSmaller ? Values.largeFontSize : Values.veryLargeFontSize)
titleLabel.text = NSLocalizedString("Restore your account", comment: "")
titleLabel.numberOfLines = 0
titleLabel.lineBreakMode = .byWordWrapping
@ -56,11 +56,11 @@ final class RestoreVC : BaseVC {
// Set up spacers
let topSpacer = UIView.vStretchingSpacer()
let spacer1 = UIView()
spacer1HeightConstraint = spacer1.set(.height, to: isSmallScreen ? Values.smallSpacing : Values.veryLargeSpacing)
spacer1HeightConstraint = spacer1.set(.height, to: isIPhone5OrSmaller ? Values.smallSpacing : Values.veryLargeSpacing)
let spacer2 = UIView()
spacer2HeightConstraint = spacer2.set(.height, to: isSmallScreen ? Values.smallSpacing : Values.veryLargeSpacing)
spacer2HeightConstraint = spacer2.set(.height, to: isIPhone5OrSmaller ? Values.smallSpacing : Values.veryLargeSpacing)
let spacer3 = UIView()
spacer3HeightConstraint = spacer3.set(.height, to: isSmallScreen ? Values.smallSpacing : Values.veryLargeSpacing)
spacer3HeightConstraint = spacer3.set(.height, to: isIPhone5OrSmaller ? Values.smallSpacing : Values.veryLargeSpacing)
let bottomSpacer = UIView.vStretchingSpacer()
let restoreButtonBottomOffsetSpacer = UIView()
restoreButtonBottomOffsetConstraint = restoreButtonBottomOffsetSpacer.set(.height, to: Values.onboardingButtonBottomOffset)
@ -124,10 +124,10 @@ final class RestoreVC : BaseVC {
@objc private func handleKeyboardWillChangeFrameNotification(_ notification: Notification) {
guard let newHeight = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue.size.height else { return }
bottomConstraint.constant = -newHeight // Negative due to how the constraint is set up
restoreButtonBottomOffsetConstraint.constant = isSmallScreen ? Values.smallSpacing : Values.largeSpacing
spacer1HeightConstraint.constant = isSmallScreen ? Values.smallSpacing : Values.mediumSpacing
spacer2HeightConstraint.constant = isSmallScreen ? Values.smallSpacing : Values.mediumSpacing
spacer3HeightConstraint.constant = isSmallScreen ? Values.smallSpacing : Values.mediumSpacing
restoreButtonBottomOffsetConstraint.constant = isIPhone5OrSmaller ? Values.smallSpacing : Values.largeSpacing
spacer1HeightConstraint.constant = isIPhone5OrSmaller ? Values.smallSpacing : Values.mediumSpacing
spacer2HeightConstraint.constant = isIPhone5OrSmaller ? Values.smallSpacing : Values.mediumSpacing
spacer3HeightConstraint.constant = isIPhone5OrSmaller ? Values.smallSpacing : Values.mediumSpacing
UIView.animate(withDuration: 0.25) {
self.view.layoutIfNeeded()
}
@ -136,9 +136,9 @@ final class RestoreVC : BaseVC {
@objc private func handleKeyboardWillHideNotification(_ notification: Notification) {
bottomConstraint.constant = 0
restoreButtonBottomOffsetConstraint.constant = Values.onboardingButtonBottomOffset
spacer1HeightConstraint.constant = isSmallScreen ? Values.smallSpacing : Values.veryLargeSpacing
spacer2HeightConstraint.constant = isSmallScreen ? Values.smallSpacing : Values.veryLargeSpacing
spacer3HeightConstraint.constant = isSmallScreen ? Values.smallSpacing : Values.veryLargeSpacing
spacer1HeightConstraint.constant = isIPhone5OrSmaller ? Values.smallSpacing : Values.veryLargeSpacing
spacer2HeightConstraint.constant = isIPhone5OrSmaller ? Values.smallSpacing : Values.veryLargeSpacing
spacer3HeightConstraint.constant = isIPhone5OrSmaller ? Values.smallSpacing : Values.veryLargeSpacing
UIView.animate(withDuration: 0.25) {
self.view.layoutIfNeeded()
}

View File

@ -65,7 +65,7 @@ final class SeedVC : BaseVC {
// Set up title label
let titleLabel = UILabel()
titleLabel.textColor = Colors.text
titleLabel.font = .boldSystemFont(ofSize: isSmallScreen ? Values.largeFontSize : Values.veryLargeFontSize)
titleLabel.font = .boldSystemFont(ofSize: isIPhone5OrSmaller ? Values.largeFontSize : Values.veryLargeFontSize)
titleLabel.text = NSLocalizedString("Meet your recovery phrase", comment: "")
titleLabel.numberOfLines = 0
titleLabel.lineBreakMode = .byWordWrapping
@ -85,14 +85,14 @@ final class SeedVC : BaseVC {
// Set up mnemonic label container
let mnemonicLabelContainer = UIView()
mnemonicLabelContainer.addSubview(mnemonicLabel)
mnemonicLabel.pin(to: mnemonicLabelContainer, withInset: isSmallScreen ? Values.smallSpacing : Values.mediumSpacing)
mnemonicLabel.pin(to: mnemonicLabelContainer, withInset: isIPhone5OrSmaller ? Values.smallSpacing : Values.mediumSpacing)
mnemonicLabelContainer.layer.cornerRadius = Values.textFieldCornerRadius
mnemonicLabelContainer.layer.borderWidth = Values.borderThickness
mnemonicLabelContainer.layer.borderColor = Colors.text.cgColor
// Set up call to action label
let callToActionLabel = UILabel()
callToActionLabel.textColor = Colors.text.withAlphaComponent(Values.unimportantElementOpacity)
callToActionLabel.font = .systemFont(ofSize: isSmallScreen ? Values.smallFontSize : Values.mediumFontSize)
callToActionLabel.font = .systemFont(ofSize: isIPhone5OrSmaller ? Values.smallFontSize : Values.mediumFontSize)
callToActionLabel.text = NSLocalizedString("Hold to reveal", comment: "")
callToActionLabel.textAlignment = .center
let callToActionLabelGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(revealMnemonic))
@ -112,7 +112,7 @@ final class SeedVC : BaseVC {
// Set up top stack view
let topStackView = UIStackView(arrangedSubviews: [ titleLabel, explanationLabel, mnemonicLabelContainer, callToActionLabel ])
topStackView.axis = .vertical
topStackView.spacing = isSmallScreen ? Values.smallSpacing : Values.largeSpacing
topStackView.spacing = isIPhone5OrSmaller ? Values.smallSpacing : Values.largeSpacing
topStackView.alignment = .fill
// Set up top stack view container
let topStackViewContainer = UIView()

View File

@ -88,7 +88,7 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate {
// Set up public key label
let publicKeyLabel = UILabel()
publicKeyLabel.textColor = Colors.text
publicKeyLabel.font = Fonts.spaceMono(ofSize: isSmallScreen ? Values.mediumFontSize : Values.largeFontSize)
publicKeyLabel.font = Fonts.spaceMono(ofSize: isIPhone5OrSmaller ? Values.mediumFontSize : Values.largeFontSize)
publicKeyLabel.numberOfLines = 0
publicKeyLabel.textAlignment = .center
publicKeyLabel.lineBreakMode = .byCharWrapping

View File

@ -11,17 +11,17 @@ public final class Values : NSObject {
@objc public static let composeViewTextFieldPlaceholderOpacity = CGFloat(0.4)
// MARK: - Font Sizes
@objc public static let verySmallFontSize = isSmallScreen ? CGFloat(10) : CGFloat(12)
@objc public static let smallFontSize = isSmallScreen ? CGFloat(13) : CGFloat(15)
@objc public static let mediumFontSize = isSmallScreen ? CGFloat(15) : CGFloat(17)
@objc public static let largeFontSize = isSmallScreen ? CGFloat(20) : CGFloat(22)
@objc public static let veryLargeFontSize = isSmallScreen ? CGFloat(25) : CGFloat(27)
@objc public static let verySmallFontSize = isIPhone5OrSmaller ? CGFloat(10) : CGFloat(12)
@objc public static let smallFontSize = isIPhone5OrSmaller ? CGFloat(13) : CGFloat(15)
@objc public static let mediumFontSize = isIPhone5OrSmaller ? CGFloat(15) : CGFloat(17)
@objc public static let largeFontSize = isIPhone5OrSmaller ? CGFloat(20) : CGFloat(22)
@objc public static let veryLargeFontSize = isIPhone5OrSmaller ? CGFloat(25) : CGFloat(27)
@objc public static let massiveFontSize = CGFloat(50)
// MARK: - Element Sizes
@objc public static let smallButtonHeight = isSmallScreen ? CGFloat(24) : CGFloat(27)
@objc public static let mediumButtonHeight = isSmallScreen ? CGFloat(30) : CGFloat(34)
@objc public static let largeButtonHeight = isSmallScreen ? CGFloat(40) : CGFloat(45)
@objc public static let smallButtonHeight = isIPhone5OrSmaller ? CGFloat(24) : CGFloat(27)
@objc public static let mediumButtonHeight = isIPhone5OrSmaller ? CGFloat(30) : CGFloat(34)
@objc public static let largeButtonHeight = isIPhone5OrSmaller ? CGFloat(40) : CGFloat(45)
@objc public static let accentLineThickness = CGFloat(4)
@objc public static let verySmallProfilePictureSize = CGFloat(26)
@objc public static let smallProfilePictureSize = CGFloat(35)
@ -32,17 +32,17 @@ public final class Values : NSObject {
@objc public static let searchBarHeight = CGFloat(36)
@objc public static let newConversationButtonCollapsedSize = CGFloat(60)
@objc public static let newConversationButtonExpandedSize = CGFloat(72)
@objc public static let textFieldHeight = isSmallScreen ? CGFloat(48) : CGFloat(80)
@objc public static let textFieldHeight = isIPhone5OrSmaller ? CGFloat(48) : CGFloat(80)
@objc public static let textFieldCornerRadius = CGFloat(8)
@objc public static let separatorLabelHeight = CGFloat(24)
@objc public static var separatorThickness: CGFloat { return 1 / UIScreen.main.scale }
@objc public static let tabBarHeight = isSmallScreen ? CGFloat(32) : CGFloat(48)
@objc public static let settingButtonHeight = isSmallScreen ? CGFloat(52) : CGFloat(75)
@objc public static let tabBarHeight = isIPhone5OrSmaller ? CGFloat(32) : CGFloat(48)
@objc public static let settingButtonHeight = isIPhone5OrSmaller ? CGFloat(52) : CGFloat(75)
@objc public static let modalCornerRadius = CGFloat(10)
@objc public static let modalButtonCornerRadius = CGFloat(5)
@objc public static let fakeChatBubbleWidth = CGFloat(224)
@objc public static let fakeChatBubbleCornerRadius = CGFloat(10)
@objc public static let fakeChatViewHeight = isSmallScreen ? CGFloat(234) : CGFloat(260)
@objc public static let fakeChatViewHeight = isIPhone5OrSmaller ? CGFloat(234) : CGFloat(260)
@objc public static let composeViewTextFieldBorderThickness = 1 / UIScreen.main.scale
@objc public static let messageBubbleCornerRadius: CGFloat = 10
@objc public static let progressBarThickness: CGFloat = 2
@ -51,7 +51,7 @@ public final class Values : NSObject {
@objc public static var pathRowLineThickness: CGFloat { return 1 / UIScreen.main.scale }
@objc public static let pathRowDotSize = CGFloat(8)
@objc public static let pathRowExpandedDotSize = CGFloat(16)
@objc public static let pathRowHeight = isSmallScreen ? CGFloat(52) : CGFloat(75)
@objc public static let pathRowHeight = isIPhone5OrSmaller ? CGFloat(52) : CGFloat(75)
// MARK: - Distances
@objc public static let verySmallSpacing = CGFloat(4)
@ -61,7 +61,7 @@ public final class Values : NSObject {
@objc public static let veryLargeSpacing = CGFloat(35)
@objc public static let massiveSpacing = CGFloat(64)
@objc public static let newConversationButtonBottomOffset = CGFloat(52)
@objc public static let onboardingButtonBottomOffset = isSmallScreen ? CGFloat(52) : CGFloat(72)
@objc public static let onboardingButtonBottomOffset = isIPhone5OrSmaller ? CGFloat(52) : CGFloat(72)
// MARK: - Animation Values
@objc public static let fakeChatStartDelay: TimeInterval = 1.5

View File

@ -1,4 +1,8 @@
public var isSmallScreen: Bool {
public var isIPhone5OrSmaller: Bool {
return (UIScreen.main.bounds.height - 568) < 1
}
public var isIPhone6OrSmaller: Bool {
return (UIScreen.main.bounds.height - 667) < 1
}