1.1 --- a/pEpForiOS/UI/EmailDisplay/EmailListViewController.swift Mon Nov 07 17:33:38 2016 +0100
1.2 +++ b/pEpForiOS/UI/EmailDisplay/EmailListViewController.swift Thu Nov 10 14:16:21 2016 +0100
1.3 @@ -220,8 +220,9 @@
1.4 if let email = messageAt(indexPath: indexPath) {
1.5 let isFlagAction = createIsFlagAction(message: email, cell: cell)
1.6 let deleteAction = createDeleteAction(cell)
1.7 - let isReadAction = createIsReadAction(message: email, cell: cell)
1.8 - return [deleteAction,isFlagAction,isReadAction]
1.9 + //let isReadAction = createIsReadAction(message: email, cell: cell)
1.10 + let moreAction = createMoreAction(message: email, cell: cell)
1.11 + return [deleteAction,isFlagAction,moreAction]
1.12 }
1.13 return nil
1.14 }
1.15 @@ -317,16 +318,16 @@
1.16
1.17 func createIsFlagAction(message: Message, cell: EmailListViewCell) -> UITableViewRowAction {
1.18 // preparing the title action to show when user swipe
1.19 - var localizedIsFlagTitle = " "
1.20 - if (isImportant(message: message)) {
1.21 - localizedIsFlagTitle = NSLocalizedString(
1.22 - "Unflag",
1.23 - comment: "Unflag button title in swipe action on EmailListViewController")
1.24 - } else {
1.25 - localizedIsFlagTitle = NSLocalizedString(
1.26 - "Flag",
1.27 - comment: "Flag button title in swipe action on EmailListViewController")
1.28 - }
1.29 +// var localizedIsFlagTitle = " "
1.30 +// if (isImportant(message: message)) {
1.31 +// localizedIsFlagTitle = NSLocalizedString(
1.32 +// "Unflag",
1.33 +// comment: "Unflag button title in swipe action on EmailListViewController")
1.34 +// } else {
1.35 +// localizedIsFlagTitle = NSLocalizedString(
1.36 +// "Flag",
1.37 +// comment: "Flag button title in swipe action on EmailListViewController")
1.38 +// }
1.39
1.40 // preparing action to trigger when user swipe
1.41 let isFlagCompletionHandler: (UITableViewRowAction, IndexPath) -> Void =
1.42 @@ -341,10 +342,12 @@
1.43 self.tableView.reloadRows(at: [indexPath], with: .none)
1.44 }
1.45 // creating the action
1.46 - let isFlagAction = UITableViewRowAction(style: .default, title: localizedIsFlagTitle,
1.47 + let isFlagAction = UITableViewRowAction(style: .normal, title: " ",
1.48 handler: isFlagCompletionHandler)
1.49 // changing default action color
1.50 - isFlagAction.backgroundColor = UIColor.orange
1.51 + let swipeFlagImage = UIImage(named: "swipe-flag")
1.52 + let flagIconColor = UIColor(patternImage: swipeFlagImage!)
1.53 + isFlagAction.backgroundColor = flagIconColor
1.54
1.55 return isFlagAction
1.56 }
1.57 @@ -352,9 +355,6 @@
1.58 func createDeleteAction (_ cell: EmailListViewCell) -> UITableViewRowAction {
1.59
1.60 // preparing the title action to show when user swipe
1.61 - let localizedDeleteTitle = NSLocalizedString(
1.62 - "Erase",
1.63 - comment: "Erase button title in swipe action on EmailListViewController")
1.64
1.65 let deleteCompletionHandler: (UITableViewRowAction, IndexPath) -> Void =
1.66 { (action, indexPath) in
1.67 @@ -364,8 +364,11 @@
1.68 }
1.69
1.70 // creating the action
1.71 - let deleteAction = UITableViewRowAction(style: .default, title: localizedDeleteTitle,
1.72 + let deleteAction = UITableViewRowAction(style: .normal, title: " ",
1.73 handler: deleteCompletionHandler)
1.74 + let swipeTrashImage = UIImage(named: "swipe-trash")
1.75 + let trashIconColor = UIColor(patternImage: swipeTrashImage!)
1.76 + deleteAction.backgroundColor = trashIconColor
1.77 return deleteAction
1.78 }
1.79
1.80 @@ -399,4 +402,53 @@
1.81
1.82 return isReadAction
1.83 }
1.84 +
1.85 + func createMoreAction(message: Message, cell: EmailListViewCell) -> UITableViewRowAction {
1.86 + let moreCompletitionHandler :(UITableViewRowAction, IndexPath) -> Void = {(action, indexPath) in
1.87 + self.showMoreActionSheet(cell: cell)
1.88 + }
1.89 + let moreAction = UITableViewRowAction(style: .normal, title: " ", handler: moreCompletitionHandler)
1.90 + let swipeMoreImage = UIImage(named: "swipe-more")
1.91 + let moreIconColor = UIColor(patternImage: swipeMoreImage!)
1.92 + moreAction.backgroundColor = moreIconColor
1.93 + return moreAction
1.94 + }
1.95 +
1.96 + // MARK: - Action Sheet
1.97 +
1.98 + func showMoreActionSheet(cell: EmailListViewCell) {
1.99 + let alertControler = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
1.100 + let cancelAction = createCancelAction()
1.101 + let replyAction = createReplyAction(cell: cell)
1.102 + let forwardAction = createForwardAction(cell: cell)
1.103 + let markAction = createMarkAction()
1.104 + alertControler.addAction(cancelAction)
1.105 + alertControler.addAction(replyAction)
1.106 + alertControler.addAction(forwardAction)
1.107 + alertControler.addAction(markAction)
1.108 + present(alertControler, animated: true, completion: nil)
1.109 + }
1.110 +
1.111 + // MARK: - Action Sheet Actions
1.112 +
1.113 + func createCancelAction() -> UIAlertAction {
1.114 + return UIAlertAction(title: "Cancel", style: .cancel) { (action) in}
1.115 + }
1.116 +
1.117 + func createReplyAction(cell: EmailListViewCell) -> UIAlertAction {
1.118 + return UIAlertAction(title: "Reply", style: .default) { (action) in
1.119 + self.performSegue(withIdentifier: self.segueCompose, sender: cell)
1.120 + }
1.121 + }
1.122 +
1.123 + func createForwardAction(cell: EmailListViewCell) -> UIAlertAction {
1.124 + return UIAlertAction(title: "Forward", style: .default) { (action) in
1.125 + self.performSegue(withIdentifier: self.segueCompose, sender: cell)
1.126 + }
1.127 + }
1.128 +
1.129 + func createMarkAction() -> UIAlertAction {
1.130 + return UIAlertAction(title: "Mark", style: .default) { (action) in
1.131 + }
1.132 + }
1.133 }