Parcourir la source

allow editing broadcast names

B. Petersen il y a 3 ans
Parent
commit
9f82916a2f
1 fichiers modifiés avec 12 ajouts et 4 suppressions
  1. 12 4
      deltachat-ios/Controller/EditGroupViewController.swift

+ 12 - 4
deltachat-ios/Controller/EditGroupViewController.swift

@@ -9,8 +9,11 @@ class EditGroupViewController: UITableViewController, MediaPickerDelegate {
     private var deleteGroupImage: Bool = false
     private var useGroupWording: Bool
 
-    private let rowGroupName = 0
-    private let rowAvatar = 1
+    enum EditRows {
+         case name
+         case avatar
+    }
+    private let editRows: [EditRows]
 
     var avatarSelectionCell: AvatarSelectionCell
 
@@ -43,6 +46,11 @@ class EditGroupViewController: UITableViewController, MediaPickerDelegate {
         self.chat = chat
         self.avatarSelectionCell = AvatarSelectionCell(image: chat.profileImage)
         self.useGroupWording = !chat.isBroadcast && !chat.isMailinglist
+        if chat.isBroadcast {
+            self.editRows = [.name]
+        } else {
+            self.editRows = [.name, .avatar]
+        }
         super.init(style: .grouped)
         self.avatarSelectionCell.hintLabel.text = String.localized(useGroupWording ? "group_avatar" : "image")
         self.avatarSelectionCell.onAvatarTapped = onAvatarTapped
@@ -61,7 +69,7 @@ class EditGroupViewController: UITableViewController, MediaPickerDelegate {
     }
 
     override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-        if indexPath.row == rowAvatar {
+        if editRows[indexPath.row] == .avatar {
             return avatarSelectionCell
         } else {
             return groupNameCell
@@ -73,7 +81,7 @@ class EditGroupViewController: UITableViewController, MediaPickerDelegate {
     }
 
     override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-        return 2
+        return editRows.count
     }
     
     @objc func saveContactButtonPressed() {