diff options
Diffstat (limited to 'Juick/ViewControllers')
-rw-r--r-- | Juick/ViewControllers/MessagesViewController.m | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Juick/ViewControllers/MessagesViewController.m b/Juick/ViewControllers/MessagesViewController.m index 804b47b..12f8176 100644 --- a/Juick/ViewControllers/MessagesViewController.m +++ b/Juick/ViewControllers/MessagesViewController.m @@ -16,6 +16,7 @@ #import "ThreadViewController.h" #import "BlogViewController.h" #import "User+UIView.h" +#import "API.h" NSString* const messageCellIdentifier = @"messageCell"; @@ -202,6 +203,22 @@ NSString* const messageCellIdentifier = @"messageCell"; } } +- (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath { + Message *msg = [self.messages objectAtIndex:indexPath.row]; + UIContextualAction *moreAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleNormal title:@"More" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) { + }]; + moreAction.image = [UIImage systemImageNamed:@"ellipsis.circle"]; + UIContextualAction *likeAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleNormal title:@"Recommend" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) { + [[AppDelegate shared].api likeMessageWithId:msg.mid callback:^(BOOL result) { + completionHandler(YES); + }]; + }]; + likeAction.backgroundColor = [UIColor colorNamed:@"Funny"]; + NSArray *actions = msg.rid == 0 ? @[likeAction, moreAction] : @[moreAction]; + UISwipeActionsConfiguration *configuration = [UISwipeActionsConfiguration configurationWithActions:actions]; + return configuration; +} + - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil]; |