Quellcode durchsuchen

WIP - layouting welcome cell

nayooti vor 5 Jahren
Ursprung
Commit
e84189c626

+ 23 - 0
deltachat-ios/Assets.xcassets/ic_launcher.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "ic_launcher.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "ic_launcher-1.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "ic_launcher-2.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
deltachat-ios/Assets.xcassets/ic_launcher.imageset/ic_launcher-1.png


BIN
deltachat-ios/Assets.xcassets/ic_launcher.imageset/ic_launcher-2.png


BIN
deltachat-ios/Assets.xcassets/ic_launcher.imageset/ic_launcher.png


+ 67 - 4
deltachat-ios/Controller/WelcomeViewController.swift

@@ -1,18 +1,27 @@
 import UIKit
 
-class WelcomeViewController: UIViewController {
+class WelcomeViewController: UIViewController, UITableViewDataSource {
 
-    lazy var tableView: UITableView = {
+    private lazy var tableView: UITableView = {
         let tableView = UITableView()
-        tableView.separatorStyle = .none
+        tableView.dataSource = self
+        tableView.showsVerticalScrollIndicator = false
+        tableView.allowsSelection = false
         return tableView
     }()
 
+    private let welcomeCell = WelcomeCell()
+
     override func viewDidLoad() {
         super.viewDidLoad()
         setupSubviews()
     }
 
+    override func viewDidLayoutSubviews() {
+        super.viewDidLayoutSubviews()
+        tableView.rowHeight = view.frame.height
+    }
+
     private func setupSubviews() {
         view.addSubview(tableView)
         tableView.translatesAutoresizingMaskIntoConstraints = false
@@ -20,16 +29,48 @@ class WelcomeViewController: UIViewController {
         tableView.topAnchor.constraint(equalTo: view.topAnchor, constant: 0).isActive = true
         tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0).isActive = true
         tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0).isActive = true
+        tableView.rowHeight = view.frame.height
+    }
+
+    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        return 1
+    }
+
+    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+        return welcomeCell
     }
 }
 
+
 class WelcomeCell: UITableViewCell {
 
+    private let fontSize: CGFloat = 24 // probably better to make larger for ipad
+
     private var logoView: UIImageView = {
-        let view = UIImageView()
+        let image = #imageLiteral(resourceName: "ic_launcher").withRenderingMode(.alwaysOriginal)
+        let view = UIImageView(image: image)
         return view
     }()
 
+    private lazy var titleLabel: UILabel = {
+        let label = UILabel()
+        label.text = "Welcome to Delta Chat"
+        label.textColor = DcColors.grayTextColor
+        label.textAlignment = .center
+        label.font = UIFont.systemFont(ofSize: fontSize, weight: .bold)
+        return label
+    }()
+
+    private lazy var subtitleLabel: UILabel = {
+        let label = UILabel()
+        label.text = "The messenger with the broadest audience in the world. Free and independent."
+        label.font = UIFont.systemFont(ofSize: 22, weight: .regular)
+        label.textColor = DcColors.grayTextColor
+        label.numberOfLines = 0
+        label.textAlignment = .center
+        return label
+    }()
+
     init() {
         super.init(style: .default, reuseIdentifier: nil)
         setupSubviews()
@@ -40,6 +81,28 @@ class WelcomeCell: UITableViewCell {
     }
 
     private func setupSubviews() {
+        _ = [subtitleLabel, titleLabel, logoView].map {
+            contentView.addSubview($0)
+            $0.translatesAutoresizingMaskIntoConstraints = false
+            $0.centerXAnchor.constraint(equalTo: contentView.centerXAnchor).isActive = true
+        }
+
+        // subtitleLabel.centerYAnchor.constraint(equalTo: contentView.centerYAnchor).isActive = true
+        subtitleLabel.centerYAnchor.constraint(equalTo: contentView.centerYAnchor).isActive = true
+        subtitleLabel.widthAnchor.constraint(lessThanOrEqualTo: contentView.widthAnchor, multiplier: 0.8).isActive = true
+
+        titleLabel.bottomAnchor.constraint(equalTo: subtitleLabel.topAnchor, constant: -20).isActive = true
+
+        let layoutGuide = UILayoutGuide()
+        contentView.addLayoutGuide(layoutGuide)
+
+        layoutGuide.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 0).isActive = true
+        layoutGuide.bottomAnchor.constraint(equalTo: titleLabel.topAnchor).isActive = true
+
+        logoView.heightAnchor.constraint(equalTo: layoutGuide.heightAnchor, multiplier: 0.3).isActive = true
+        logoView.widthAnchor.constraint(equalTo: logoView.heightAnchor).isActive = true
+        logoView.bottomAnchor.constraint(equalTo: layoutGuide.bottomAnchor, constant: -20).isActive = true
+
 
     }
 }