Browse Source

added responsive container to contentview

nayooti 5 years ago
parent
commit
ee98666224
1 changed files with 45 additions and 0 deletions
  1. 45 0
      deltachat-ios/Controller/QrViewController.swift

+ 45 - 0
deltachat-ios/Controller/QrViewController.swift

@@ -42,6 +42,17 @@ class QrViewController: UIViewController {
         setupSubviews()
         setupSubviews()
     }
     }
 
 
+    override func viewDidLayoutSubviews() {
+        super.viewDidLayoutSubviews()
+        qrContentView.minContainerHeight = view.frame.height
+    }
+
+    override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
+        super.viewWillTransition(to: size, with: coordinator)
+        qrContentView.minContainerHeight = size.height
+        scrollView.setContentOffset(CGPoint(x: 0, y: 0), animated: true)
+    }
+
     // MARK: - setup
     // MARK: - setup
     private func setupSubviews() {
     private func setupSubviews() {
         view.addSubview(scrollView)
         view.addSubview(scrollView)
@@ -78,6 +89,40 @@ class QrViewController: UIViewController {
 // MARK: - QrViewContentView
 // MARK: - QrViewContentView
 class QrViewContentView: UIView {
 class QrViewContentView: UIView {
 
 
+    private let container = UIView()
+
+    var minContainerHeight: CGFloat = 0 {
+        didSet {
+            containerMinHeightConstraint.constant = minContainerHeight
+        }
+    }
+
+    private lazy var containerMinHeightConstraint: NSLayoutConstraint = {
+        return container.heightAnchor.constraint(greaterThanOrEqualToConstant: 0)
+    }()
+
+    init() {
+        super.init(frame: .zero)
+        setupSubviews()
+    }
+    
+    required init?(coder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+    
+    private func setupSubviews() {
+        addSubview(container)
+        container.translatesAutoresizingMaskIntoConstraints = false
+
+        container.topAnchor.constraint(equalTo: topAnchor).isActive = true
+        container.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
+        container.widthAnchor.constraint(equalTo: widthAnchor, multiplier: 0.75).isActive = true
+        container.centerXAnchor.constraint(equalTo: centerXAnchor, constant: 0).isActive = true
+
+        containerMinHeightConstraint.isActive = true
+
+    }
+
 }
 }
 
 
 /*
 /*