diff --git a/Session/DMs/NewDMVC.swift b/Session/DMs/NewDMVC.swift index 9c4c9d5a6..05ff3f049 100644 --- a/Session/DMs/NewDMVC.swift +++ b/Session/DMs/NewDMVC.swift @@ -216,8 +216,7 @@ private final class EnterPublicKeyVC : UIViewController { result.spacing = UIDevice.current.isIPad ? Values.iPadButtonSpacing : Values.mediumSpacing result.distribution = .fillEqually if (UIDevice.current.isIPad) { - let margin = (UIScreen.main.bounds.width - result.spacing - Values.iPadButtonWidth * 2) / 2 - result.layoutMargins = UIEdgeInsets(top: 0, left: margin, bottom: 0, right: margin) + result.layoutMargins = UIEdgeInsets(top: 0, left: Values.iPadButtonContainerMargin, bottom: 0, right: Values.iPadButtonContainerMargin) result.isLayoutMarginsRelativeArrangement = true } return result @@ -227,6 +226,8 @@ private final class EnterPublicKeyVC : UIViewController { override func viewDidLoad() { // Remove background color view.backgroundColor = .clear + // User session id container + let userPublicKeyContainer = UIView(wrapping: userPublicKeyLabel, withInsets: .zero, shouldAdaptForIPadWithWidth: Values.iPadUserSessionIdContainerWidth) // Explanation label let explanationLabel = UILabel() explanationLabel.textColor = Colors.text.withAlphaComponent(Values.mediumOpacity) @@ -246,9 +247,9 @@ private final class EnterPublicKeyVC : UIViewController { let nextButton = Button(style: .prominentOutline, size: .large) nextButton.setTitle(NSLocalizedString("next", comment: ""), for: UIControl.State.normal) nextButton.addTarget(self, action: #selector(startNewDMIfPossible), for: UIControl.Event.touchUpInside) - let nextButtonContainer = UIView(wrapping: nextButton, withInsets: UIEdgeInsets(top: 0, leading: 80, bottom: 0, trailing: 80), shouldAdaptForIPad: true) + let nextButtonContainer = UIView(wrapping: nextButton, withInsets: UIEdgeInsets(top: 0, leading: 80, bottom: 0, trailing: 80), shouldAdaptForIPadWithWidth: Values.iPadButtonWidth) // Main stack view - let mainStackView = UIStackView(arrangedSubviews: [ publicKeyTextView, UIView.spacer(withHeight: Values.smallSpacing), explanationLabel, spacer1, separator, spacer2, userPublicKeyLabel, spacer3, buttonContainer, UIView.vStretchingSpacer(), nextButtonContainer ]) + let mainStackView = UIStackView(arrangedSubviews: [ publicKeyTextView, UIView.spacer(withHeight: Values.smallSpacing), explanationLabel, spacer1, separator, spacer2, userPublicKeyContainer, spacer3, buttonContainer, UIView.vStretchingSpacer(), nextButtonContainer ]) mainStackView.axis = .vertical mainStackView.alignment = .fill mainStackView.layoutMargins = UIEdgeInsets(top: Values.largeSpacing, left: Values.largeSpacing, bottom: Values.largeSpacing, right: Values.largeSpacing) diff --git a/Session/Onboarding/LinkDeviceVC.swift b/Session/Onboarding/LinkDeviceVC.swift index 621f5cf53..f8d1fb514 100644 --- a/Session/Onboarding/LinkDeviceVC.swift +++ b/Session/Onboarding/LinkDeviceVC.swift @@ -196,7 +196,7 @@ private final class RecoveryPhraseVC : UIViewController { continueButton.titleLabel!.font = .boldSystemFont(ofSize: Values.mediumFontSize) continueButton.addTarget(self, action: #selector(handleContinueButtonTapped), for: UIControl.Event.touchUpInside) // Continue button container - let continueButtonContainer = UIView(wrapping: continueButton, withInsets: UIEdgeInsets(top: 0, leading: Values.massiveSpacing, bottom: 0, trailing: Values.massiveSpacing), shouldAdaptForIPad: true) + let continueButtonContainer = UIView(wrapping: continueButton, withInsets: UIEdgeInsets(top: 0, leading: Values.massiveSpacing, bottom: 0, trailing: Values.massiveSpacing), shouldAdaptForIPadWithWidth: Values.iPadButtonWidth) // Top stack view let topStackView = UIStackView(arrangedSubviews: [ titleLabel, spacer1, explanationLabel, spacer2, mnemonicTextView ]) topStackView.axis = .vertical diff --git a/Session/Onboarding/PNModeVC.swift b/Session/Onboarding/PNModeVC.swift index 393041fc2..d8684976d 100644 --- a/Session/Onboarding/PNModeVC.swift +++ b/Session/Onboarding/PNModeVC.swift @@ -52,7 +52,7 @@ final class PNModeVC : BaseVC, OptionViewDelegate { registerButton.titleLabel!.font = .boldSystemFont(ofSize: Values.mediumFontSize) registerButton.addTarget(self, action: #selector(register), for: UIControl.Event.touchUpInside) // Set up register button container - let registerButtonContainer = UIView(wrapping: registerButton, withInsets: UIEdgeInsets(top: 0, leading: Values.massiveSpacing, bottom: 0, trailing: Values.massiveSpacing), shouldAdaptForIPad: true) + let registerButtonContainer = UIView(wrapping: registerButton, withInsets: UIEdgeInsets(top: 0, leading: Values.massiveSpacing, bottom: 0, trailing: Values.massiveSpacing), shouldAdaptForIPadWithWidth: Values.iPadButtonWidth) // Set up options stack view let optionsStackView = UIStackView(arrangedSubviews: optionViews) optionsStackView.axis = .vertical diff --git a/Session/Onboarding/RestoreVC.swift b/Session/Onboarding/RestoreVC.swift index e1dc36d36..35ed24610 100644 --- a/Session/Onboarding/RestoreVC.swift +++ b/Session/Onboarding/RestoreVC.swift @@ -71,7 +71,7 @@ final class RestoreVC : BaseVC { restoreButton.titleLabel!.font = .boldSystemFont(ofSize: Values.mediumFontSize) restoreButton.addTarget(self, action: #selector(restore), for: UIControl.Event.touchUpInside) // Set up restore button container - let restoreButtonContainer = UIView(wrapping: restoreButton, withInsets: UIEdgeInsets(top: 0, leading: Values.massiveSpacing, bottom: 0, trailing: Values.massiveSpacing), shouldAdaptForIPad: true) + let restoreButtonContainer = UIView(wrapping: restoreButton, withInsets: UIEdgeInsets(top: 0, leading: Values.massiveSpacing, bottom: 0, trailing: Values.massiveSpacing), shouldAdaptForIPadWithWidth: Values.iPadButtonWidth) // Set up top stack view let topStackView = UIStackView(arrangedSubviews: [ titleLabel, spacer1, explanationLabel, spacer2, mnemonicTextView, spacer3, legalLabel ]) topStackView.axis = .vertical diff --git a/Session/Open Groups/JoinOpenGroupVC.swift b/Session/Open Groups/JoinOpenGroupVC.swift index ff5be20df..86cbdbf24 100644 --- a/Session/Open Groups/JoinOpenGroupVC.swift +++ b/Session/Open Groups/JoinOpenGroupVC.swift @@ -203,7 +203,7 @@ private final class EnterURLVC : UIViewController, UIGestureRecognizerDelegate, let nextButton = Button(style: .prominentOutline, size: .large) nextButton.setTitle(NSLocalizedString("next", comment: ""), for: UIControl.State.normal) nextButton.addTarget(self, action: #selector(joinOpenGroup), for: UIControl.Event.touchUpInside) - let nextButtonContainer = UIView(wrapping: nextButton, withInsets: UIEdgeInsets(top: 0, leading: 80, bottom: 0, trailing: 80), shouldAdaptForIPad: true) + let nextButtonContainer = UIView(wrapping: nextButton, withInsets: UIEdgeInsets(top: 0, leading: 80, bottom: 0, trailing: 80), shouldAdaptForIPadWithWidth: Values.iPadButtonWidth) // Stack view let stackView = UIStackView(arrangedSubviews: [ urlTextView, UIView.spacer(withHeight: Values.mediumSpacing), suggestionGridTitleLabel, UIView.spacer(withHeight: Values.mediumSpacing), suggestionGrid, UIView.vStretchingSpacer(), nextButtonContainer ]) diff --git a/Session/Path/PathVC.swift b/Session/Path/PathVC.swift index 7e08f6dd9..26e7f9392 100644 --- a/Session/Path/PathVC.swift +++ b/Session/Path/PathVC.swift @@ -67,7 +67,7 @@ final class PathVC : BaseVC { spinner.center(in: pathStackViewContainer) // Set up rebuild path button let inset: CGFloat = isIPhone5OrSmaller ? 64 : 80 - let learnMoreButtonContainer = UIView(wrapping: learnMoreButton, withInsets: UIEdgeInsets(top: 0, leading: inset, bottom: 0, trailing: inset), shouldAdaptForIPad: true) + let learnMoreButtonContainer = UIView(wrapping: learnMoreButton, withInsets: UIEdgeInsets(top: 0, leading: inset, bottom: 0, trailing: inset), shouldAdaptForIPadWithWidth: Values.iPadButtonWidth) // Set up spacers let topSpacer = UIView.vStretchingSpacer() let bottomSpacer = UIView.vStretchingSpacer() diff --git a/Session/Settings/SettingsVC.swift b/Session/Settings/SettingsVC.swift index 99f85113c..a4febb1f0 100644 --- a/Session/Settings/SettingsVC.swift +++ b/Session/Settings/SettingsVC.swift @@ -176,12 +176,13 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate { buttonContainer.spacing = UIDevice.current.isIPad ? Values.iPadButtonSpacing : Values.mediumSpacing buttonContainer.distribution = .fillEqually if (UIDevice.current.isIPad) { - let margin = (UIScreen.main.bounds.width - buttonContainer.spacing - Values.iPadButtonWidth * 2) / 2 - buttonContainer.layoutMargins = UIEdgeInsets(top: 0, left: margin, bottom: 0, right: margin) + buttonContainer.layoutMargins = UIEdgeInsets(top: 0, left: Values.iPadButtonContainerMargin, bottom: 0, right: Values.iPadButtonContainerMargin) buttonContainer.isLayoutMarginsRelativeArrangement = true } + // User session id container + let userPublicKeyContainer = UIView(wrapping: publicKeyLabel, withInsets: .zero, shouldAdaptForIPadWithWidth: Values.iPadUserSessionIdContainerWidth) // Top stack view - let topStackView = UIStackView(arrangedSubviews: [ headerStackView, separator, publicKeyLabel, buttonContainer ]) + let topStackView = UIStackView(arrangedSubviews: [ headerStackView, separator, userPublicKeyContainer, buttonContainer ]) topStackView.axis = .vertical topStackView.spacing = Values.largeSpacing topStackView.alignment = .fill diff --git a/Session/Utilities/UIView+Wrapping.swift b/Session/Utilities/UIView+Wrapping.swift index d7804d0a2..5bfc0553f 100644 --- a/Session/Utilities/UIView+Wrapping.swift +++ b/Session/Utilities/UIView+Wrapping.swift @@ -1,11 +1,11 @@ extension UIView { - convenience init(wrapping view: UIView, withInsets insets: UIEdgeInsets, shouldAdaptForIPad: Bool = false) { + convenience init(wrapping view: UIView, withInsets insets: UIEdgeInsets, shouldAdaptForIPadWithWidth width: CGFloat? = nil) { self.init() addSubview(view) - if UIDevice.current.isIPad && shouldAdaptForIPad { - view.set(.width, to: Values.iPadButtonWidth) + if UIDevice.current.isIPad, let width = width { + view.set(.width, to: width) view.center(in: self) } else { view.pin(.leading, to: .leading, of: self, withInset: insets.left) diff --git a/SessionUIKit/Style Guide/Values.swift b/SessionUIKit/Style Guide/Values.swift index 0b18e2ce8..7c4b67adc 100644 --- a/SessionUIKit/Style Guide/Values.swift +++ b/SessionUIKit/Style Guide/Values.swift @@ -47,4 +47,6 @@ public final class Values : NSObject { @objc public static let iPadModalWidth = UIScreen.main.bounds.width / 2 @objc public static let iPadButtonWidth = CGFloat(196) @objc public static let iPadButtonSpacing = CGFloat(32) + @objc public static let iPadUserSessionIdContainerWidth = CGFloat(424) // iPadButtonWidth * 2 + iPadButtonSpacing + @objc public static let iPadButtonContainerMargin = UIScreen.main.bounds.width / 2 - 236 // ScreenWidth / 2 - iPadButtonSpacing / 2 - iPadButtonWidth - largeSpacing }