IOS-1145 Show unflag on SwipeCellAction.
authorborja <borja@helm.cat>
Tue, 24 Jul 2018 16:11:57 +0200
changeset 5624dd87f56bdfd4
parent 5623 485aee5e32e9
child 5625 22eabe64ee3c
IOS-1145 Show unflag on SwipeCellAction.
pEpForiOS/UI/EmailDisplayList/EmailListViewController.swift
     1.1 --- a/pEpForiOS/UI/EmailDisplayList/EmailListViewController.swift	Tue Jul 24 10:58:34 2018 +0200
     1.2 +++ b/pEpForiOS/UI/EmailDisplayList/EmailListViewController.swift	Tue Jul 24 16:11:57 2018 +0200
     1.3 @@ -503,11 +503,17 @@
     1.4          // Flag
     1.5          if folderIsDraft(parentFolder) {
     1.6              // Do not add "Flag" action to drafted mails.
     1.7 +
     1.8              let flagAction = SwipeAction(style: .default, title: "Flag") { action, indexPath in
     1.9                  self.flagAction(forCellAt: indexPath)
    1.10              }
    1.11 +
    1.12              flagAction.hidesWhenSelected = true
    1.13 -            configure(action: flagAction, with: .flag)
    1.14 +            
    1.15 +            let flagged = model?.message(representedByRowAt: indexPath)?.imapFlags?.flagged ?? false
    1.16 +            let actionDescriptor: SwipeActionDescriptor = flagged == true ? .unflag : .flag
    1.17 +
    1.18 +            configure(action: flagAction, with: actionDescriptor)
    1.19              swipeActions.append(flagAction)
    1.20          }
    1.21  
    1.22 @@ -1112,7 +1118,7 @@
    1.23          case .reply: name = "reply"
    1.24          case .more: name = "more"
    1.25          case .flag: name = "flag"
    1.26 -        case .unflag: name = "unflag"
    1.27 +        case .unflag: name = "flag"
    1.28          case .trash: name = "trash"
    1.29          case .archive: name = "archive"
    1.30          }