diff --git a/Riot/Modules/Room/RoomViewController.h b/Riot/Modules/Room/RoomViewController.h index de52c4978..1dcb69ece 100644 --- a/Riot/Modules/Room/RoomViewController.h +++ b/Riot/Modules/Room/RoomViewController.h @@ -277,6 +277,12 @@ didRequestEditForPollWithStartEvent:(MXEvent *)startEvent; */ - (void)roomViewControllerDidStopLoading:(RoomViewController *)roomViewController; +/// User tap live location sharing stop action +- (void)roomViewControllerDidStopLiveLocationSharing:(RoomViewController *)roomViewController; + +/// User tap live location sharing banner +- (void)roomViewControllerDidTapLiveLocationSharingBanner:(RoomViewController *)roomViewController; + @end NS_ASSUME_NONNULL_END diff --git a/Riot/Modules/Room/RoomViewController.m b/Riot/Modules/Room/RoomViewController.m index 12fb57ec8..75a21b43c 100644 --- a/Riot/Modules/Room/RoomViewController.m +++ b/Riot/Modules/Room/RoomViewController.m @@ -223,6 +223,13 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; // scroll state just before the layout change, and restore it after the layout. @property (nonatomic) BOOL shouldScrollToBottomAfterLayout; +/// Handles all banners that should be displayed at the top of the timeline but that should not scroll with the timeline +@property (weak, nonatomic, nullable) IBOutlet UIStackView *topBannersStackView; + +@property (nonatomic) BOOL shouldShowLiveLocationSharingBannerView; + +@property (nonatomic, weak) LiveLocationSharingBannerView *liveLocationSharingBannerView; + @end @implementation RoomViewController @@ -2380,6 +2387,18 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; [suggestionsViewController didMoveToParentViewController:self]; } +- (void)updateTopBanners +{ + [self.view bringSubviewToFront:self.topBannersStackView]; + + [self.topBannersStackView vc_removeAllSubviews]; + + if (self.shouldShowLiveLocationSharingBannerView) + { + [self showLiveLocationBannerView]; + } +} + #pragma mark - Jitsi - (void)showJitsiCallWithWidget:(Widget*)widget @@ -7323,5 +7342,34 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; [self stopActivityIndicator]; } -@end +#pragma mark - Live location sharing +- (void)showLiveLocationBannerView +{ + if (self.liveLocationSharingBannerView) + { + return; + } + + LiveLocationSharingBannerView *bannerView = [LiveLocationSharingBannerView instantiate]; + + [bannerView updateWithTheme:ThemeService.shared.theme]; + + MXWeakify(self); + + bannerView.didTapBackground = ^{ + MXStrongifyAndReturnIfNil(self); + [self.delegate roomViewControllerDidTapLiveLocationSharingBanner:self]; + }; + + bannerView.didTapStopButton = ^{ + MXStrongifyAndReturnIfNil(self); + [self.delegate roomViewControllerDidStopLiveLocationSharing:self]; + }; + + [self.topBannersStackView addArrangedSubview:bannerView]; + + self.liveLocationSharingBannerView = bannerView; +} + +@end diff --git a/Riot/Modules/Room/RoomViewController.xib b/Riot/Modules/Room/RoomViewController.xib index e8b8bfd6e..783146c29 100644 --- a/Riot/Modules/Room/RoomViewController.xib +++ b/Riot/Modules/Room/RoomViewController.xib @@ -13,7 +13,6 @@ - @@ -32,6 +31,7 @@ + @@ -41,8 +41,25 @@ - - + + + + + + + + + + + + + @@ -192,6 +209,7 @@ + @@ -200,17 +218,19 @@ + + - +