|
|
@ -92,30 +92,41 @@ final class NewDMVC: BaseVC, UIPageViewControllerDataSource, UIPageViewControlle
|
|
|
|
navigationItem.leftBarButtonItem = closeButton
|
|
|
|
navigationItem.leftBarButtonItem = closeButton
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Set up tab bar
|
|
|
|
// Page VC
|
|
|
|
|
|
|
|
let hasCameraAccess = (AVCaptureDevice.authorizationStatus(for: .video) == .authorized)
|
|
|
|
|
|
|
|
pages = [ enterPublicKeyVC, (hasCameraAccess ? scanQRCodeWrapperVC : scanQRCodePlaceholderVC) ]
|
|
|
|
|
|
|
|
pageVC.dataSource = self
|
|
|
|
|
|
|
|
pageVC.delegate = self
|
|
|
|
|
|
|
|
pageVC.setViewControllers([ enterPublicKeyVC ], direction: .forward, animated: false, completion: nil)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Tab bar
|
|
|
|
view.addSubview(tabBar)
|
|
|
|
view.addSubview(tabBar)
|
|
|
|
tabBar.pin(.top, to: .top, of: view)
|
|
|
|
tabBar.pin(.top, to: .top, of: view)
|
|
|
|
tabBar.pin(.leading, to: .leading, of: view)
|
|
|
|
tabBar.pin(.leading, to: .leading, of: view)
|
|
|
|
tabBar.pin(.trailing, to: .trailing, of: view)
|
|
|
|
tabBar.pin(.trailing, to: .trailing, of: view)
|
|
|
|
|
|
|
|
|
|
|
|
// Set up page VC
|
|
|
|
// Page VC constraints
|
|
|
|
let containerView: UIView = UIView()
|
|
|
|
let pageVCView = pageVC.view!
|
|
|
|
view.addSubview(containerView)
|
|
|
|
view.addSubview(pageVCView)
|
|
|
|
containerView.pin(.top, to: .bottom, of: tabBar)
|
|
|
|
pageVCView.pin(.leading, to: .leading, of: view)
|
|
|
|
containerView.pin(.leading, to: .leading, of: view)
|
|
|
|
pageVCView.pin(.top, to: .bottom, of: tabBar)
|
|
|
|
containerView.pin(.trailing, to: .trailing, of: view)
|
|
|
|
pageVCView.pin(.trailing, to: .trailing, of: view)
|
|
|
|
containerView.pin(.bottom, to: .bottom, of: view)
|
|
|
|
pageVCView.pin(.bottom, to: .bottom, of: view)
|
|
|
|
|
|
|
|
|
|
|
|
let hasCameraAccess = (AVCaptureDevice.authorizationStatus(for: .video) == .authorized)
|
|
|
|
let navBarHeight: CGFloat = (navigationController?.navigationBar.frame.size.height ?? 0)
|
|
|
|
pages = [ enterPublicKeyVC, (hasCameraAccess ? scanQRCodeWrapperVC : scanQRCodePlaceholderVC) ]
|
|
|
|
let statusBarHeight: CGFloat = UIApplication.shared.statusBarFrame.size.height
|
|
|
|
pageVC.dataSource = self
|
|
|
|
let height: CGFloat = ((navigationController?.view.bounds.height ?? 0) - navBarHeight - TabBar.snHeight - statusBarHeight)
|
|
|
|
pageVC.delegate = self
|
|
|
|
let size: CGSize = CGSize(width: UIScreen.main.bounds.width, height: height)
|
|
|
|
pageVC.setViewControllers([ enterPublicKeyVC ], direction: .forward, animated: false, completion: nil)
|
|
|
|
enterPublicKeyVC.constrainSize(to: size)
|
|
|
|
addChild(pageVC)
|
|
|
|
scanQRCodePlaceholderVC.constrainSize(to: size)
|
|
|
|
containerView.addSubview(pageVC.view)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pageVC.view.pin(to: containerView)
|
|
|
|
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
|
|
|
pageVC.didMove(toParent: self)
|
|
|
|
super.viewWillTransition(to: size, with: coordinator)
|
|
|
|
|
|
|
|
let height: CGFloat = (size.height - TabBar.snHeight)
|
|
|
|
|
|
|
|
let size: CGSize = CGSize(width: size.width, height: height)
|
|
|
|
|
|
|
|
enterPublicKeyVC.constrainSize(to: size)
|
|
|
|
|
|
|
|
scanQRCodePlaceholderVC.constrainSize(to: size)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: - General
|
|
|
|
// MARK: - General
|
|
|
@ -351,11 +362,6 @@ private final class EnterPublicKeyVC: UIViewController {
|
|
|
|
result.spacing = UIDevice.current.isIPad ? Values.iPadButtonSpacing : Values.mediumSpacing
|
|
|
|
result.spacing = UIDevice.current.isIPad ? Values.iPadButtonSpacing : Values.mediumSpacing
|
|
|
|
result.distribution = .fillEqually
|
|
|
|
result.distribution = .fillEqually
|
|
|
|
|
|
|
|
|
|
|
|
if (UIDevice.current.isIPad) {
|
|
|
|
|
|
|
|
result.layoutMargins = UIEdgeInsets(top: 0, left: Values.iPadButtonContainerMargin, bottom: 0, right: Values.iPadButtonContainerMargin)
|
|
|
|
|
|
|
|
result.isLayoutMarginsRelativeArrangement = true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
@ -396,6 +402,9 @@ private final class EnterPublicKeyVC: UIViewController {
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var viewWidth: NSLayoutConstraint?
|
|
|
|
|
|
|
|
private var viewHeight: NSLayoutConstraint?
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: - Lifecycle
|
|
|
|
// MARK: - Lifecycle
|
|
|
|
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
override func viewDidLoad() {
|
|
|
@ -429,10 +438,8 @@ private final class EnterPublicKeyVC: UIViewController {
|
|
|
|
mainStackView.isLayoutMarginsRelativeArrangement = true
|
|
|
|
mainStackView.isLayoutMarginsRelativeArrangement = true
|
|
|
|
view.addSubview(mainStackView)
|
|
|
|
view.addSubview(mainStackView)
|
|
|
|
|
|
|
|
|
|
|
|
mainStackView.pin(.top, to: .top, of: view)
|
|
|
|
mainStackView.pin([ UIView.HorizontalEdge.leading, UIView.HorizontalEdge.trailing, UIView.VerticalEdge.top ], to: view)
|
|
|
|
mainStackView.pin(.leading, to: .leading, of: view)
|
|
|
|
bottomConstraint = mainStackView.pin(.bottom, to: .bottom, of: view, withInset: bottomMargin)
|
|
|
|
mainStackView.pin(.trailing, to: .trailing, of: view)
|
|
|
|
|
|
|
|
bottomConstraint = mainStackView.pin(.bottom, to: .bottom, of: view, withInset: -bottomMargin)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Dismiss keyboard on tap
|
|
|
|
// Dismiss keyboard on tap
|
|
|
|
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
|
|
|
|
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
|
|
|
@ -450,6 +457,27 @@ private final class EnterPublicKeyVC: UIViewController {
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: - General
|
|
|
|
// MARK: - General
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func constrainSize(to size: CGSize) {
|
|
|
|
|
|
|
|
if viewWidth == nil {
|
|
|
|
|
|
|
|
viewWidth = view.set(.width, to: size.width)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
viewWidth?.constant = size.width
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if viewHeight == nil {
|
|
|
|
|
|
|
|
viewHeight = view.set(.height, to: size.height)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
viewHeight?.constant = size.height
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (UIDevice.current.isIPad) {
|
|
|
|
|
|
|
|
let iPadButtonContainerMargin: CGFloat = (size.width - Values.iPadButtonSpacing) / 2 - Values.iPadButtonWidth - Values.largeSpacing
|
|
|
|
|
|
|
|
buttonContainer.layoutMargins = UIEdgeInsets(top: 0, left: iPadButtonContainerMargin, bottom: 0, right: iPadButtonContainerMargin)
|
|
|
|
|
|
|
|
buttonContainer.isLayoutMarginsRelativeArrangement = true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func setSessionId(to sessionId: String) {
|
|
|
|
func setSessionId(to sessionId: String) {
|
|
|
|
publicKeyTextView.insertText(sessionId)
|
|
|
|
publicKeyTextView.insertText(sessionId)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -609,6 +637,9 @@ private final class EnterPublicKeyVC: UIViewController {
|
|
|
|
private final class ScanQRCodePlaceholderVC: UIViewController {
|
|
|
|
private final class ScanQRCodePlaceholderVC: UIViewController {
|
|
|
|
weak var newDMVC: NewDMVC!
|
|
|
|
weak var newDMVC: NewDMVC!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var viewWidth: NSLayoutConstraint?
|
|
|
|
|
|
|
|
private var viewHeight: NSLayoutConstraint?
|
|
|
|
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
override func viewDidLoad() {
|
|
|
|
// Remove background color
|
|
|
|
// Remove background color
|
|
|
|
view.themeBackgroundColor = .clear
|
|
|
|
view.themeBackgroundColor = .clear
|
|
|
@ -638,10 +669,27 @@ private final class ScanQRCodePlaceholderVC: UIViewController {
|
|
|
|
// Set up constraints
|
|
|
|
// Set up constraints
|
|
|
|
view.addSubview(stackView)
|
|
|
|
view.addSubview(stackView)
|
|
|
|
stackView.pin(.leading, to: .leading, of: view, withInset: Values.massiveSpacing)
|
|
|
|
stackView.pin(.leading, to: .leading, of: view, withInset: Values.massiveSpacing)
|
|
|
|
stackView.pin(.trailing, to: .trailing, of: view, withInset: -Values.massiveSpacing)
|
|
|
|
view.pin(.trailing, to: .trailing, of: stackView, withInset: Values.massiveSpacing)
|
|
|
|
stackView.center(.vertical, in: view, withInset: -16) // Makes things appear centered visually
|
|
|
|
|
|
|
|
|
|
|
|
let verticalCenteringConstraint = stackView.center(.vertical, in: view)
|
|
|
|
|
|
|
|
verticalCenteringConstraint.constant = -16 // Makes things appear centered visually
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func constrainSize(to size: CGSize) {
|
|
|
|
|
|
|
|
if viewWidth == nil {
|
|
|
|
|
|
|
|
viewWidth = view.set(.width, to: size.width)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
viewWidth?.constant = size.width
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if viewHeight == nil {
|
|
|
|
|
|
|
|
viewHeight = view.set(.height, to: size.height)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
viewHeight?.constant = size.height
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@objc private func requestCameraAccess() {
|
|
|
|
@objc private func requestCameraAccess() {
|
|
|
|
Permissions.requestCameraPermissionIfNeeded { [weak self] in
|
|
|
|
Permissions.requestCameraPermissionIfNeeded { [weak self] in
|
|
|
|
self?.newDMVC.handleCameraAccessGranted()
|
|
|
|
self?.newDMVC.handleCameraAccessGranted()
|
|
|
|