RoomVC: Handle live location banner display on user location status change.

This commit is contained in:
SBiOSoftWhare
2022-03-28 10:18:59 +02:00
parent 476729e1bc
commit 019af072eb
2 changed files with 26 additions and 43 deletions
+15 -43
View File
@@ -230,13 +230,6 @@ static CGSize kThreadListBarButtonItemImageSize;
// scroll state just before the layout change, and restore it after the layout.
@property (nonatomic) BOOL wasScrollAtBottomBeforeLayout;
/// 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
@@ -408,6 +401,8 @@ static CGSize kThreadListBarButtonItemImageSize;
[self setupActions];
[self setupUserSuggestionViewIfNeeded];
[self.topBannersStackView vc_removeAllSubviews];
}
- (void)userInterfaceThemeDidChange
@@ -547,6 +542,8 @@ static CGSize kThreadListBarButtonItemImageSize;
notificationTaskProfile = [MXSDKOptions.sharedInstance.profiler startMeasuringTaskWithName:MXTaskProfileNameNotificationsOpenEvent];
}
[self updateTopBanners];
}
- (void)viewWillDisappear:(BOOL)animated
@@ -1526,6 +1523,11 @@ static CGSize kThreadListBarButtonItemImageSize;
missedDiscussionsDotView.hidden = missedDiscussionsBadgeHidden;
}
- (BOOL)shouldShowLiveLocationSharingBannerView
{
return customizedRoomDataSource.isCurrentUserSharingIsLocation;
}
#pragma mark - Internals
- (UIBarButtonItem *)videoCallBarButtonItem
@@ -2419,12 +2421,7 @@ static CGSize kThreadListBarButtonItemImageSize;
{
[self.view bringSubviewToFront:self.topBannersStackView];
[self.topBannersStackView vc_removeAllSubviews];
if (self.shouldShowLiveLocationSharingBannerView)
{
[self showLiveLocationBannerView];
}
[self updateLiveLocationBannerViewVisibility];
}
#pragma mark - Jitsi
@@ -4415,6 +4412,11 @@ static CGSize kThreadListBarButtonItemImageSize;
[Analytics.shared trackInteraction:AnalyticsUIElementRoomThreadSummaryItem];
}
- (void)roomDataSourceDidUpdateCurrentUserSharingLocationStatus:(RoomDataSource *)roomDataSource
{
[self updateLiveLocationBannerViewVisibility];
}
#pragma mark - Segues
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
@@ -7411,34 +7413,4 @@ static CGSize kThreadListBarButtonItemImageSize;
[self stopActivityIndicator];
}
#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