From 6bf3b558f5cd1e4f50c830f68bfa444b63ad0036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Wed, 9 Aug 2023 08:38:07 +0200 Subject: [PATCH] Move "Clear Reminder" to inline menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- NextcloudTalk/NCChatViewController.m | 31 +++++++++++++--------- NextcloudTalk/en.lproj/Localizable.strings | 21 ++++++++------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/NextcloudTalk/NCChatViewController.m b/NextcloudTalk/NCChatViewController.m index cf859d777..358ccf826 100644 --- a/NextcloudTalk/NCChatViewController.m +++ b/NextcloudTalk/NCChatViewController.m @@ -4223,9 +4223,9 @@ - (NSArray *)getSetReminderOptionsForMessage:(NCChatMessage *)message void (^setReminderCompletion)(NSError * error) = ^void(NSError *error) { if (error) { - [[JDStatusBarNotificationPresenter sharedPresenter] presentWithText:NSLocalizedString(@"Failed to add reminder", @"") dismissAfterDelay:5.0 includedStyle:JDStatusBarNotificationIncludedStyleError]; + [[JDStatusBarNotificationPresenter sharedPresenter] presentWithText:NSLocalizedString(@"Error occurred when creating a reminder", @"") dismissAfterDelay:5.0 includedStyle:JDStatusBarNotificationIncludedStyleError]; } else { - [[JDStatusBarNotificationPresenter sharedPresenter] presentWithText:NSLocalizedString(@"Successfully added reminder", @"") dismissAfterDelay:5.0 includedStyle:JDStatusBarNotificationIncludedStyleSuccess]; + [[JDStatusBarNotificationPresenter sharedPresenter] presentWithText:NSLocalizedString(@"Reminder was successfully set", @"") dismissAfterDelay:5.0 includedStyle:JDStatusBarNotificationIncludedStyleSuccess]; } }; @@ -4376,27 +4376,34 @@ - (UIContextMenuConfiguration *)tableView:(UITableView *)tableView contextMenuCo __weak typeof(self) weakSelf = self; UIDeferredMenuElement *deferredMenuElement = [UIDeferredMenuElement elementWithUncachedProvider:^(void (^ _Nonnull completion)(NSArray * _Nonnull)) { [[NCAPIController sharedInstance] getReminderForMessage:message withCompletionBlock:^(NSDictionary *responseDict, NSError *error) { + NSMutableArray *menuOptions = [[NSMutableArray alloc] init]; + + [menuOptions addObjectsFromArray:[weakSelf getSetReminderOptionsForMessage:message]]; + if (responseDict && !error) { // There's already an existing reminder set for this message // -> offer a delete option NSInteger timestamp = [[responseDict objectForKey:@"timestamp"] intValue]; NSDate *timestampDate = [NSDate dateWithTimeIntervalSince1970:timestamp]; - UIAction *infoAction = [UIAction actionWithTitle:[NCUtils readableDateTimeFromDate:timestampDate] image:nil identifier:nil handler:^(UIAction *action){ - }]; - infoAction.attributes = UIMenuElementAttributesDisabled; - - UIAction *deleteAction = [UIAction actionWithTitle:NSLocalizedString(@"Delete", @"") image:[UIImage systemImageNamed:@"trash"] identifier:nil handler:^(UIAction *action){ + UIAction *clearAction = [UIAction actionWithTitle:NSLocalizedString(@"Clear reminder", @"") image:[UIImage systemImageNamed:@"trash"] identifier:nil handler:^(UIAction *action){ [[NCAPIController sharedInstance] deleteReminderForMessage:message withCompletionBlock:^(NSError *error) { - [[JDStatusBarNotificationPresenter sharedPresenter] presentWithText:NSLocalizedString(@"Successfully deleted reminder", @"") dismissAfterDelay:5.0 includedStyle:JDStatusBarNotificationIncludedStyleSuccess]; + [[JDStatusBarNotificationPresenter sharedPresenter] presentWithText:NSLocalizedString(@"Reminder was successfully cleared", @"") dismissAfterDelay:5.0 includedStyle:JDStatusBarNotificationIncludedStyleSuccess]; }]; }]; - deleteAction.attributes = UIMenuElementAttributesDestructive; + clearAction.subtitle = [NCUtils readableDateTimeFromDate:timestampDate]; + clearAction.attributes = UIMenuElementAttributesDestructive; - completion(@[infoAction, deleteAction]); - } else { - completion([weakSelf getSetReminderOptionsForMessage:message]); + UIMenu *clearReminder = [UIMenu menuWithTitle:@"" + image:nil + identifier:nil + options:UIMenuOptionsDisplayInline + children:@[clearAction]]; + + [menuOptions addObject:clearReminder]; } + + completion(menuOptions); }]; }]; diff --git a/NextcloudTalk/en.lproj/Localizable.strings b/NextcloudTalk/en.lproj/Localizable.strings index 51b14ef67..54c7fea73 100644 --- a/NextcloudTalk/en.lproj/Localizable.strings +++ b/NextcloudTalk/en.lproj/Localizable.strings @@ -349,6 +349,9 @@ /* No comment provided by engineer. */ "Clear cache" = "Clear cache"; +/* No comment provided by engineer. */ +"Clear reminder" = "Clear reminder"; + /* No comment provided by engineer. */ "Clear status message" = "Clear status message"; @@ -724,12 +727,12 @@ /* No comment provided by engineer. */ "End poll" = "End poll"; +/* No comment provided by engineer. */ +"Error occurred when creating a reminder" = "Error occurred when creating a reminder"; + /* External signaling used */ "External" = "External"; -/* No comment provided by engineer. */ -"Failed to add reminder" = "Failed to add reminder"; - /* No comment provided by engineer. */ "Failed to connect to %@" = "Failed to connect to %@"; @@ -1279,6 +1282,12 @@ /* No comment provided by engineer. */ "Reference API supported?" = "Reference API supported?"; +/* No comment provided by engineer. */ +"Reminder was successfully cleared" = "Reminder was successfully cleared"; + +/* No comment provided by engineer. */ +"Reminder was successfully set" = "Reminder was successfully set"; + /* No comment provided by engineer. */ "Remove" = "Remove"; @@ -1486,12 +1495,6 @@ /* No comment provided by engineer. */ "Submit vote" = "Submit vote"; -/* No comment provided by engineer. */ -"Successfully added reminder" = "Successfully added reminder"; - -/* No comment provided by engineer. */ -"Successfully deleted reminder" = "Successfully deleted reminder"; - /* No comment provided by engineer. */ "Switch account" = "Switch account";