---
# System prepended metadata

title: Untitled

---

```
func collectionView(_ collectionView: UICollectionView, editActionsForItemAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) -> [SwipeAction]? {

    guard orientation == .right else { return nil }
    // 判斷留言是不是自己，如果是自己，顯示刪除，如果不是，顯示檢舉
    // 如果照片擁有者是自己，顯示刪除跟檢舉
    //guard let isyourSelf = data.value[indexPath.item].data.roleDbid else { return }

    //如果照片擁有者是自己，顯示刪除跟檢舉
    if data.value[indexPath.item].data.imageDbid == imagedata.imageDbid {

        let deleteAction = SwipeAction(style: .destructive, title: "Delete") { action, indexPath in
        // handle action by updating model with deletion
        PKCLogger.shared.debug("Delete")
        guard let item = self.data.value[indexPath.item].data.id else { return }

        _ = UserInteractionServices.shared.deletecommentdataAPI(id: item).done({ (_) in
            self.fetchCommentDataAPI()
        })

        action.fulfill(with: .delete)
    }

    let reportAction = SwipeAction(style: .destructive, title: "Report") { action, indexPath in
        // handle action by updating model with deletion
        PKCLogger.shared.debug("report")
        //guard let item = self.data.value[indexPath.item].data.id else { return }

        action.fulfill(with: .reset)
    }

    // customize the action appearance
        deleteAction.image = #imageLiteral(resourceName: "iconIconDeleteConfirm")
        deleteAction.backgroundColor = #colorLiteral(red: 0.9215686275, green: 0.2509803922, blue: 0.3921568627, alpha: 1)

        reportAction.image = #imageLiteral(resourceName: "iconDeleteCopy")
        reportAction.backgroundColor = #colorLiteral(red: 0.1098039216, green: 0.0431372549, blue: 0.262745098, alpha: 1)

    return [deleteAction, reportAction]

    }

    //判斷留言是不是自己，如果是自己，顯示刪除，如果不是，顯示檢舉
    if data.value[indexPath.item].data.roleDbid != data.value[indexPath.item].data.roleDbid {

    } else {

    }

}
```