Explorar el Código

add email to contact cell, layouting of contact cell

Alla Reinsch hace 7 años
padre
commit
5862ffc414
Se han modificado 2 ficheros con 35 adiciones y 12 borrados
  1. 34 9
      deltachat-ios/ContactCell.swift
  2. 1 3
      deltachat-ios/NewChatViewController.swift

+ 34 - 9
deltachat-ios/ContactCell.swift

@@ -12,21 +12,22 @@ class ContactCell: UITableViewCell {
     //Klasse initialisieren nachschauen
     let initialsLabel:UILabel = UILabel()
     let nameLabel = UILabel()
+    let emailLabel = UILabel()
     
     override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
         //Init von der Superklasse aufrufen nachschauen
         super.init(style: style, reuseIdentifier: reuseIdentifier)
         //configure and layout initialsLabel
-        let labelSize:CGFloat = 60
-        let cornerRadius = labelSize/2
+        let initialsLabelSize:CGFloat = 60
+        let initialsLabelCornerRadius = initialsLabelSize/2
         let margin:CGFloat = 15
         initialsLabel.textAlignment = NSTextAlignment.center
         initialsLabel.translatesAutoresizingMaskIntoConstraints = false
-        initialsLabel.widthAnchor.constraint(equalToConstant: labelSize).isActive = true
-        initialsLabel.heightAnchor.constraint(equalToConstant: labelSize).isActive = true
+        initialsLabel.widthAnchor.constraint(equalToConstant: initialsLabelSize).isActive = true
+        initialsLabel.heightAnchor.constraint(equalToConstant: initialsLabelSize).isActive = true
         initialsLabel.backgroundColor = UIColor.green
         
-        initialsLabel.layer.cornerRadius = cornerRadius
+        initialsLabel.layer.cornerRadius = initialsLabelCornerRadius
         initialsLabel.clipsToBounds = true
         
         self.contentView.addSubview(initialsLabel)
@@ -34,13 +35,37 @@ class ContactCell: UITableViewCell {
         initialsLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: margin).isActive = true
         initialsLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -margin).isActive = true
         
+        let myStackView = UIStackView()
+        myStackView.translatesAutoresizingMaskIntoConstraints = false
+        self.contentView.addSubview(myStackView)
+        myStackView.leadingAnchor.constraint(equalTo: initialsLabel.trailingAnchor, constant: margin).isActive = true
+        myStackView.centerYAnchor.constraint(equalTo: initialsLabel.centerYAnchor).isActive = true
+        myStackView.axis = .vertical
+        myStackView.addArrangedSubview(nameLabel)
+        myStackView.addArrangedSubview(emailLabel)
+        
+        emailLabel.font = UIFont.systemFont(ofSize: 14)
+        emailLabel.textColor = UIColor.gray
+        
+        
+        
+
         //configure and layout nameLabel
-        nameLabel.translatesAutoresizingMaskIntoConstraints = false
-        self.contentView.addSubview(nameLabel)
-        nameLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -margin).isActive = true
-        nameLabel.centerYAnchor.constraint(equalTo: initialsLabel.centerYAnchor).isActive = true
+        //nameLabel.translatesAutoresizingMaskIntoConstraints = false
+        //self.contentView.addSubview(nameLabel)
+        //nameLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -margin).isActive = true
+        //nameLabel.centerYAnchor.constraint(equalTo: initialsLabel.centerYAnchor).isActive = true
+    
+        //emailLabel.translatesAutoresizingMaskIntoConstraints = false
+        //self.contentView.addSubview(emailLabel)
+        //emailLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -margin).isActive = true
+        //emailLabel.centerYAnchor.constraint(equalTo: initialsLabel.centerYAnchor).isActive = true
+        
+        
+    
     }
     
+    
     func setColor(_ color: UIColor) {
         self.initialsLabel.backgroundColor = color
     }

+ 1 - 3
deltachat-ios/NewChatViewController.swift

@@ -90,13 +90,11 @@ class NewChatViewController: UITableViewController {
             cell = ContactCell(style: .default, reuseIdentifier: "contactCell")
         }
         
-        cell.accessoryType = .detailDisclosureButton
-        
         let contactRow = row - 2
 
         let contact = MRContact(id: contactIds[contactRow])
         cell.nameLabel.text = contact.name
-        // cell.detailTextLabel?.text = contact.email
+        cell.emailLabel.text = contact.email
         cell.initialsLabel.text = Utils.getInitials(inputName: contact.name)
         let contactColor = Utils.color(row: contactRow, colors: Constants.chatColors)
         cell.setColor(contactColor)