From def0bfea27365864fd3dacbae1c0f84cd97bb753 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Fri, 13 Nov 2020 10:18:48 -0600 Subject: [PATCH] Add menu separators to article view context menu. --- iOS/Article/WebViewController.swift | 34 +++++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/iOS/Article/WebViewController.swift b/iOS/Article/WebViewController.swift index ca3c0ff8e..40d910ba8 100644 --- a/iOS/Article/WebViewController.swift +++ b/iOS/Article/WebViewController.swift @@ -282,25 +282,35 @@ extension WebViewController: UIContextMenuInteractionDelegate { return UIContextMenuConfiguration(identifier: nil, previewProvider: contextMenuPreviewProvider) { [weak self] suggestedActions in guard let self = self else { return nil } - var actions = [UIAction]() + + var menus = [UIMenu]() + var navActions = [UIAction]() if let action = self.prevArticleAction() { - actions.append(action) + navActions.append(action) } if let action = self.nextArticleAction() { - actions.append(action) + navActions.append(action) } - if let action = self.toggleReadAction() { - actions.append(action) + if !navActions.isEmpty { + menus.append(UIMenu(title: "", options: .displayInline, children: navActions)) } - actions.append(self.toggleStarredAction()) - if let action = self.nextUnreadArticleAction() { - actions.append(action) - } - actions.append(self.toggleArticleExtractorAction()) - actions.append(self.shareAction()) - return UIMenu(title: "", children: actions) + var toggleActions = [UIAction]() + if let action = self.toggleReadAction() { + toggleActions.append(action) + } + toggleActions.append(self.toggleStarredAction()) + menus.append(UIMenu(title: "", options: .displayInline, children: toggleActions)) + + if let action = self.nextUnreadArticleAction() { + menus.append(UIMenu(title: "", options: .displayInline, children: [action])) + } + + menus.append(UIMenu(title: "", options: .displayInline, children: [self.toggleArticleExtractorAction()])) + menus.append(UIMenu(title: "", options: .displayInline, children: [self.shareAction()])) + + return UIMenu(title: "", children: menus) } }