diff options
author | Vitaly Takmazov | 2023-04-26 19:49:01 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-04-26 19:49:01 +0300 |
commit | edfa752df766726c93bc5a1bd5c4a8bcb014f831 (patch) | |
tree | 5872b53d6f7ba5f1e6144ff3ce4c84637b632d44 /Juick/ViewControllers | |
parent | 9ca85a0132ed9d33dac586e05a048ffcff9b7843 (diff) |
Contextual actions and message recommendations
* ellipsis image require iOS 13
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]; |