diff --git a/iphone/Maps/Core/TrackRecorder/TrackRecordingManager.swift b/iphone/Maps/Core/TrackRecorder/TrackRecordingManager.swift index 7d253d5b8..b32dead21 100644 --- a/iphone/Maps/Core/TrackRecorder/TrackRecordingManager.swift +++ b/iphone/Maps/Core/TrackRecorder/TrackRecordingManager.swift @@ -135,6 +135,16 @@ final class TrackRecordingManager: NSObject { completion?(.failure(error)) } } + + func stop(completion: ((StopTrackRecordingResult) -> Void)? = nil) { + unsubscribeFromTrackRecordingProgressUpdates() + trackRecorder.stopTrackRecording() + trackRecordingInfo = .empty() + activityManager?.stop() + notifyObservers() + + completion?(.trackIsEmpty) + } func stopAndSave(withName name: String = "", completion: ((StopTrackRecordingResult) -> Void)? = nil) { unsubscribeFromTrackRecordingProgressUpdates() diff --git a/iphone/Maps/UI/PlacePage/Components/ActionBarViewController.swift b/iphone/Maps/UI/PlacePage/Components/ActionBarViewController.swift index 2632ec188..50f45cdb0 100644 --- a/iphone/Maps/UI/PlacePage/Components/ActionBarViewController.swift +++ b/iphone/Maps/UI/PlacePage/Components/ActionBarViewController.swift @@ -103,6 +103,7 @@ final class ActionBarViewController: UIViewController { } buttons.append(.track) case .trackRecording: + buttons.append(.notSaveTrackRecording) buttons.append(.saveTrackRecording) @unknown default: fatalError() diff --git a/iphone/Maps/UI/PlacePage/PlacePageInteractor.swift b/iphone/Maps/UI/PlacePage/PlacePageInteractor.swift index 22c07d999..18bfecd35 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageInteractor.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageInteractor.swift @@ -292,6 +292,10 @@ extension PlacePageInteractor: ActionBarViewControllerDelegate { self?.presenter?.closeAnimated() } } + case .notSaveTrackRecording: + TrackRecordingManager.shared.stop() { [weak self] result in + self?.presenter?.closeAnimated() + } @unknown default: fatalError() } diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMActionBarButton.h b/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMActionBarButton.h index d8c5f33ab..ae487ca99 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMActionBarButton.h +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMActionBarButton.h @@ -4,6 +4,7 @@ typedef NS_ENUM(NSInteger, MWMActionBarButtonType) { MWMActionBarButtonTypeBookmark, MWMActionBarButtonTypeTrack, MWMActionBarButtonTypeSaveTrackRecording, + MWMActionBarButtonTypeNotSaveTrackRecording, MWMActionBarButtonTypeCall, MWMActionBarButtonTypeDownload, MWMActionBarButtonTypeMore, diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMActionBarButton.m b/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMActionBarButton.m index dd38a97b9..3ead4b7d5 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMActionBarButton.m +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMActionBarButton.m @@ -21,6 +21,8 @@ NSString *titleForButton(MWMActionBarButtonType type, BOOL isSelected) { return L(isSelected ? @"delete" : @"save"); case MWMActionBarButtonTypeSaveTrackRecording: return L(@"save"); + case MWMActionBarButtonTypeNotSaveTrackRecording: + return L(@"delete"); case MWMActionBarButtonTypeRouteFrom: return L(@"p2p_from_here"); case MWMActionBarButtonTypeRouteTo: @@ -114,6 +116,10 @@ NSString *titleForButton(MWMActionBarButtonType type, BOOL isSelected) { case MWMActionBarButtonTypeSaveTrackRecording: [self.button setImage:[UIImage imageNamed:@"ic_placepage_save_track_recording"] forState:UIControlStateNormal]; break; + case MWMActionBarButtonTypeNotSaveTrackRecording: + [self.button setImage:[UIImage systemImageNamed:@"trash.fill" withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:22 weight:UIImageSymbolWeightSemibold]] forState:UIControlStateNormal]; + self.button.coloring = MWMButtonColoringRed; + break; case MWMActionBarButtonTypeRouteFrom: [self.button setImage:[UIImage imageNamed:@"ic_route_from"] forState:UIControlStateNormal]; break;