From 6879db44722dea42443b5b81ea1c382896383e47 Mon Sep 17 00:00:00 2001 From: Kiryl Kaveryn Date: Sat, 6 Jul 2024 16:09:27 +0400 Subject: [PATCH] [ios] refactor the ActivityViewController: set creational methods to nonnull Signed-off-by: Kiryl Kaveryn --- .../BookmarksList/BookmarksListViewController.swift | 2 +- .../Bookmarks/Categories/BMCView/BMCViewController.swift | 2 +- iphone/Maps/Classes/Share/MWMActivityViewController.h | 8 ++++---- iphone/Maps/UI/PlacePage/PlacePageInteractor.swift | 6 ++---- .../UI/PlacePage/PlacePageManager/MWMPlacePageManager.mm | 5 ----- .../PlacePageManager/MWMPlacePageManagerHelper.mm | 4 ---- 6 files changed, 8 insertions(+), 19 deletions(-) diff --git a/iphone/Maps/Bookmarks/BookmarksList/BookmarksListViewController.swift b/iphone/Maps/Bookmarks/BookmarksList/BookmarksListViewController.swift index 53c323eb24..9b3f005eb9 100644 --- a/iphone/Maps/Bookmarks/BookmarksList/BookmarksListViewController.swift +++ b/iphone/Maps/Bookmarks/BookmarksList/BookmarksListViewController.swift @@ -246,7 +246,7 @@ extension BookmarksListViewController: IBookmarksListView { message: L("share_bookmarks_email_body")) { (_, _, _, _) in completion() } - shareController?.present(inParentViewController: self, anchorView: self.toolBar) + shareController.present(inParentViewController: self, anchorView: self.toolBar) } func showError(title: String, message: String) { diff --git a/iphone/Maps/Bookmarks/Categories/BMCView/BMCViewController.swift b/iphone/Maps/Bookmarks/Categories/BMCView/BMCViewController.swift index 4489d6991f..a4bcc969c8 100644 --- a/iphone/Maps/Bookmarks/Categories/BMCView/BMCViewController.swift +++ b/iphone/Maps/Bookmarks/Categories/BMCView/BMCViewController.swift @@ -87,7 +87,7 @@ final class BMCViewController: MWMViewController { { [weak self] _, _, _, _ in self?.viewModel?.finishShareCategory() } - shareController?.present(inParentViewController: self, anchorView: anchorView) + shareController.present(inParentViewController: self, anchorView: anchorView) case .emptyCategory: MWMAlertViewController.activeAlert().presentInfoAlert(L("bookmarks_error_title_share_empty"), text: L("bookmarks_error_message_share_empty")) diff --git a/iphone/Maps/Classes/Share/MWMActivityViewController.h b/iphone/Maps/Classes/Share/MWMActivityViewController.h index 77fa4dc097..6eabdde971 100644 --- a/iphone/Maps/Classes/Share/MWMActivityViewController.h +++ b/iphone/Maps/Classes/Share/MWMActivityViewController.h @@ -6,13 +6,13 @@ NS_ASSUME_NONNULL_BEGIN NS_SWIFT_NAME(ActivityViewController) @interface MWMActivityViewController : UIActivityViewController -+ (nullable instancetype)shareControllerForEditorViral; ++ (instancetype)shareControllerForEditorViral; -+ (nullable instancetype)shareControllerForMyPosition:(CLLocationCoordinate2D)location; ++ (instancetype)shareControllerForMyPosition:(CLLocationCoordinate2D)location; -+ (nullable instancetype)shareControllerForPlacePage:(PlacePageData *)data; ++ (instancetype)shareControllerForPlacePage:(PlacePageData *)data; -+ (nullable instancetype)shareControllerForURL:(nullable NSURL *)url ++ (instancetype)shareControllerForURL:(nullable NSURL *)url message:(NSString *)message completionHandler:(nullable UIActivityViewControllerCompletionWithItemsHandler)completionHandler; diff --git a/iphone/Maps/UI/PlacePage/PlacePageInteractor.swift b/iphone/Maps/UI/PlacePage/PlacePageInteractor.swift index 3c9024e27b..2915e0fd46 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageInteractor.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageInteractor.swift @@ -258,10 +258,8 @@ extension PlacePageInteractor: PlacePageHeaderViewControllerDelegate { } func previewDidPressShare(from sourceView: UIView) { - guard let shareViewController = ActivityViewController.share(forPlacePage: placePageData), let mapViewController else { - LOG(.error, "Failed to instantiate ActivityViewController.") - return - } + guard let mapViewController else { return } + let shareViewController = ActivityViewController.share(forPlacePage: placePageData) shareViewController.present(inParentViewController: mapViewController, anchorView: sourceView) } } diff --git a/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManager.mm b/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManager.mm index 9e87bd6b92..56c2166adf 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManager.mm +++ b/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManager.mm @@ -143,11 +143,6 @@ using namespace storage; intermediateIndex:intermediateIndex]; } -- (void)share:(PlacePageData *)data { - MWMActivityViewController * shareVC = [MWMActivityViewController shareControllerForPlacePage:data]; - [shareVC presentInParentViewController:self.ownerViewController anchorView:nil]; // TODO: add anchor for iPad -} - - (void)editPlace { [self.ownerViewController openEditor]; diff --git a/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManagerHelper.mm b/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManagerHelper.mm index ae1124836c..05d2617e83 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManagerHelper.mm +++ b/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManagerHelper.mm @@ -165,10 +165,6 @@ [[MWMMapViewControlsManager manager].placePageManager book:data]; } -+ (void)share:(PlacePageData *)data { - [[MWMMapViewControlsManager manager].placePageManager share:data]; -} - + (void)routeFrom:(PlacePageData *)data { [[MWMMapViewControlsManager manager].placePageManager routeFrom:data]; }