Merge branch 'ipad-support-1' into voice-calls-2

pull/605/head
Ryan Zhao 2 years ago
commit 2bfbf25c75

@ -332,13 +332,8 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
messageRequestAcceptButton.pin(.bottom, to: .bottom, of: messageRequestView)
messageRequestAcceptButton.set(.height, to: ConversationVC.messageRequestButtonHeight)
messageRequestAcceptButton.pin(.top, to: .bottom, of: messageRequestDescriptionLabel, withInset: 20)
messageRequestAcceptButton.pin(.left, to: .left, of: messageRequestView, withInset: 20)
messageRequestAcceptButton.pin(.bottom, to: .bottom, of: messageRequestView)
messageRequestAcceptButton.set(.height, to: ConversationVC.messageRequestButtonHeight)
messageRequestDeleteButton.pin(.top, to: .bottom, of: messageRequestDescriptionLabel, withInset: 20)
messageRequestDeleteButton.pin(.left, to: .right, of: messageRequestAcceptButton, withInset: 20)
messageRequestDeleteButton.pin(.left, to: .right, of: messageRequestAcceptButton, withInset: UIDevice.current.isIPad ? Values.iPadButtonSpacing : 20)
messageRequestDeleteButton.pin(.right, to: .right, of: messageRequestView, withInset: -20)
messageRequestDeleteButton.pin(.bottom, to: .bottom, of: messageRequestView)
messageRequestDeleteButton.set(.width, to: .width, of: messageRequestAcceptButton)

@ -126,7 +126,13 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewDelegate {
static let largeCornerRadius: CGFloat = 18
static let contactThreadHSpacing = Values.mediumSpacing
static var gutterSize: CGFloat { groupThreadHSpacing + profilePictureSize + groupThreadHSpacing }
static var gutterSize: CGFloat = {
var result = groupThreadHSpacing + profilePictureSize + groupThreadHSpacing
if UIDevice.current.isIPad {
result += CGFloat(UIScreen.main.bounds.width / 2 - 88)
}
return result
}()
private var bodyLabelTextColor: UIColor {
switch (direction, AppModeManager.shared.currentAppMode) {

@ -212,7 +212,7 @@ private final class EnterPublicKeyVC : UIViewController {
private lazy var buttonContainer: UIStackView = {
let result = UIStackView()
result.axis = .horizontal
result.spacing = Values.mediumSpacing
result.spacing = UIDevice.current.isIPad ? Values.iPadButtonSpacing : Values.mediumSpacing
result.distribution = .fillEqually
return result
}()
@ -240,12 +240,7 @@ 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()
nextButtonContainer.addSubview(nextButton)
nextButton.pin(.leading, to: .leading, of: nextButtonContainer, withInset: 80)
nextButton.pin(.top, to: .top, of: nextButtonContainer)
nextButtonContainer.pin(.trailing, to: .trailing, of: nextButton, withInset: 80)
nextButtonContainer.pin(.bottom, to: .bottom, of: nextButton)
let nextButtonContainer = UIView(wrapping: nextButton, withInsets: UIEdgeInsets(top: 0, leading: 80, bottom: 0, trailing: 80), shouldAdaptForIPad: true)
// Main stack view
let mainStackView = UIStackView(arrangedSubviews: [ publicKeyTextView, UIView.spacer(withHeight: Values.smallSpacing), explanationLabel, spacer1, separator, spacer2, userPublicKeyLabel, spacer3, buttonContainer, UIView.vStretchingSpacer(), nextButtonContainer ])
mainStackView.axis = .vertical

@ -50,9 +50,14 @@ final class DisplayNameVC : BaseVC {
// Set up register button container
let registerButtonContainer = UIView()
registerButtonContainer.addSubview(registerButton)
registerButton.pin(.leading, to: .leading, of: registerButtonContainer, withInset: Values.massiveSpacing)
if UIDevice.current.isIPad {
registerButton.set(.width, to: Values.iPadButtonWidth)
registerButton.center(in: registerButtonContainer)
} else {
registerButton.pin(.leading, to: .leading, of: registerButtonContainer, withInset: Values.massiveSpacing)
registerButtonContainer.pin(.trailing, to: .trailing, of: registerButton, withInset: Values.massiveSpacing)
}
registerButton.pin(.top, to: .top, of: registerButtonContainer)
registerButtonContainer.pin(.trailing, to: .trailing, of: registerButton, withInset: Values.massiveSpacing)
registerButtonContainer.pin(.bottom, to: .bottom, of: registerButton)
// Set up top stack view
let topStackView = UIStackView(arrangedSubviews: [ titleLabel, spacer1, explanationLabel, spacer2, displayNameTextField ])

@ -68,6 +68,11 @@ final class LandingVC : BaseVC {
buttonStackView.axis = .vertical
buttonStackView.spacing = isIPhone5OrSmaller ? Values.smallSpacing : Values.mediumSpacing
buttonStackView.alignment = .fill
if UIDevice.current.isIPad {
registerButton.set(.width, to: Values.iPadButtonWidth)
restoreButton.set(.width, to: Values.iPadButtonWidth)
buttonStackView.alignment = .center
}
// Button stack view container
let buttonStackViewContainer = UIView()
buttonStackViewContainer.addSubview(buttonStackView)

@ -196,12 +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()
continueButtonContainer.addSubview(continueButton)
continueButton.pin(.leading, to: .leading, of: continueButtonContainer, withInset: Values.massiveSpacing)
continueButton.pin(.top, to: .top, of: continueButtonContainer)
continueButtonContainer.pin(.trailing, to: .trailing, of: continueButton, withInset: Values.massiveSpacing)
continueButtonContainer.pin(.bottom, to: .bottom, of: continueButton)
let continueButtonContainer = UIView(wrapping: continueButton, withInsets: UIEdgeInsets(top: 0, leading: Values.massiveSpacing, bottom: 0, trailing: Values.massiveSpacing), shouldAdaptForIPad: true)
// Top stack view
let topStackView = UIStackView(arrangedSubviews: [ titleLabel, spacer1, explanationLabel, spacer2, mnemonicTextView ])
topStackView.axis = .vertical

@ -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))
let registerButtonContainer = UIView(wrapping: registerButton, withInsets: UIEdgeInsets(top: 0, leading: Values.massiveSpacing, bottom: 0, trailing: Values.massiveSpacing), shouldAdaptForIPad: true)
// Set up options stack view
let optionsStackView = UIStackView(arrangedSubviews: optionViews)
optionsStackView.axis = .vertical

@ -80,6 +80,11 @@ final class RegisterVC : BaseVC {
buttonStackView.axis = .vertical
buttonStackView.spacing = isIPhone5OrSmaller ? Values.smallSpacing : Values.mediumSpacing
buttonStackView.alignment = .fill
if UIDevice.current.isIPad {
registerButton.set(.width, to: Values.iPadButtonWidth)
copyPublicKeyButton.set(.width, to: Values.iPadButtonWidth)
buttonStackView.alignment = .center
}
// Set up button stack view container
let buttonStackViewContainer = UIView()
buttonStackViewContainer.addSubview(buttonStackView)

@ -71,12 +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()
restoreButtonContainer.addSubview(restoreButton)
restoreButton.pin(.leading, to: .leading, of: restoreButtonContainer, withInset: Values.massiveSpacing)
restoreButton.pin(.top, to: .top, of: restoreButtonContainer)
restoreButtonContainer.pin(.trailing, to: .trailing, of: restoreButton, withInset: Values.massiveSpacing)
restoreButtonContainer.pin(.bottom, to: .bottom, of: restoreButton)
let restoreButtonContainer = UIView(wrapping: restoreButton, withInsets: UIEdgeInsets(top: 0, leading: Values.massiveSpacing, bottom: 0, trailing: Values.massiveSpacing), shouldAdaptForIPad: true)
// Set up top stack view
let topStackView = UIStackView(arrangedSubviews: [ titleLabel, spacer1, explanationLabel, spacer2, mnemonicTextView, spacer3, legalLabel ])
topStackView.axis = .vertical

@ -200,12 +200,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()
nextButtonContainer.addSubview(nextButton)
nextButton.pin(.leading, to: .leading, of: nextButtonContainer, withInset: 80)
nextButton.pin(.top, to: .top, of: nextButtonContainer)
nextButtonContainer.pin(.trailing, to: .trailing, of: nextButton, withInset: 80)
nextButtonContainer.pin(.bottom, to: .bottom, of: nextButton)
let nextButtonContainer = UIView(wrapping: nextButton, withInsets: UIEdgeInsets(top: 0, leading: 80, bottom: 0, trailing: 80), shouldAdaptForIPad: true)
// Stack view
let stackView = UIStackView(arrangedSubviews: [ urlTextView, UIView.spacer(withHeight: Values.mediumSpacing), suggestionGridTitleLabel,
UIView.spacer(withHeight: Values.mediumSpacing), suggestionGrid, UIView.vStretchingSpacer(), nextButtonContainer ])

@ -79,7 +79,8 @@ final class OpenGroupSuggestionGrid : UIView, UICollectionViewDataSource, UIColl
// MARK: Layout
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: maxWidth / 2, height: OpenGroupSuggestionGrid.cellHeight)
let cellWidth = UIDevice.current.isIPad ? maxWidth / 4 : maxWidth / 2
return CGSize(width: cellWidth, height: OpenGroupSuggestionGrid.cellHeight)
}
// MARK: Data Source

@ -1,4 +1,5 @@
import NVActivityIndicatorView
import UIKit
final class PathVC : BaseVC {
@ -65,12 +66,8 @@ final class PathVC : BaseVC {
pathStackViewContainer.bottomAnchor.constraint(greaterThanOrEqualTo: spinner.bottomAnchor).isActive = true
spinner.center(in: pathStackViewContainer)
// Set up rebuild path button
let learnMoreButtonContainer = UIView()
learnMoreButtonContainer.addSubview(learnMoreButton)
learnMoreButton.pin(.leading, to: .leading, of: learnMoreButtonContainer, withInset: isIPhone5OrSmaller ? 64 : 80)
learnMoreButton.pin(.top, to: .top, of: learnMoreButtonContainer)
learnMoreButtonContainer.pin(.trailing, to: .trailing, of: learnMoreButton, withInset: isIPhone5OrSmaller ? 64 : 80)
learnMoreButtonContainer.pin(.bottom, to: .bottom, of: learnMoreButton)
let inset: CGFloat = isIPhone5OrSmaller ? 64 : 80
let learnMoreButtonContainer = UIView(wrapping: learnMoreButton, withInsets: UIEdgeInsets(top: 0, leading: inset, bottom: 0, trailing: inset), shouldAdaptForIPad: true)
// Set up spacers
let topSpacer = UIView.vStretchingSpacer()
let bottomSpacer = UIView.vStretchingSpacer()

@ -173,7 +173,7 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate {
// Button container
let buttonContainer = UIStackView(arrangedSubviews: [ copyButton, shareButton ])
buttonContainer.axis = .horizontal
buttonContainer.spacing = Values.mediumSpacing
buttonContainer.spacing = UIDevice.current.isIPad ? Values.iPadButtonSpacing : Values.mediumSpacing
buttonContainer.distribution = .fillEqually
// Top stack view
let topStackView = UIStackView(arrangedSubviews: [ headerStackView, separator, publicKeyLabel, buttonContainer ])

@ -2,7 +2,6 @@ import UIKit
@objc(LKModal)
class Modal: BaseVC, UIGestureRecognizerDelegate {
private(set) var verticalCenteringConstraint: NSLayoutConstraint!
// MARK: Components
lazy var contentView: UIView = {
@ -53,9 +52,14 @@ class Modal: BaseVC, UIGestureRecognizerDelegate {
private func setUpViewHierarchy() {
view.addSubview(contentView)
contentView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: Values.veryLargeSpacing).isActive = true
view.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: Values.veryLargeSpacing).isActive = true
verticalCenteringConstraint = contentView.center(.vertical, in: view)
if UIDevice.current.isIPad {
contentView.set(.width, to: Values.iPadButtonWidth)
contentView.center(in: view)
} else {
contentView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: Values.veryLargeSpacing).isActive = true
view.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: Values.veryLargeSpacing).isActive = true
contentView.center(.vertical, in: view)
}
populateContentView()
}

@ -1,12 +1,17 @@
extension UIView {
convenience init(wrapping view: UIView, withInsets insets: UIEdgeInsets) {
convenience init(wrapping view: UIView, withInsets insets: UIEdgeInsets, shouldAdaptForIPad: Bool = false) {
self.init()
addSubview(view)
view.pin(.leading, to: .leading, of: self, withInset: insets.left)
if UIDevice.current.isIPad && shouldAdaptForIPad {
view.set(.width, to: Values.iPadButtonWidth)
view.center(in: self)
} else {
view.pin(.leading, to: .leading, of: self, withInset: insets.left)
self.pin(.trailing, to: .trailing, of: view, withInset: insets.right)
}
view.pin(.top, to: .top, of: self, withInset: insets.top)
self.pin(.trailing, to: .trailing, of: view, withInset: insets.right)
self.pin(.bottom, to: .bottom, of: view, withInset: insets.bottom)
}
}

@ -42,4 +42,8 @@ public final class Values : NSObject {
@objc public static let massiveSpacing = CGFloat(64)
@objc public static let newConversationButtonBottomOffset = CGFloat(52)
@objc public static let onboardingButtonBottomOffset = isIPhone5OrSmaller ? CGFloat(52) : CGFloat(72)
// MARK: - iPad Sizes
@objc public static let iPadButtonWidth = UIScreen.main.bounds.width / 2
@objc public static let iPadButtonSpacing = CGFloat(32)
}

Loading…
Cancel
Save