Remove bubbles background from search screens (#5601)

Co-authored-by: Arnaud Ringenbach <arnaud.ringenbach@niji.fr>
This commit is contained in:
aringenbach
2022-02-16 15:37:56 +01:00
committed by GitHub
parent 4d89f64d38
commit 4e27be3b98
11 changed files with 5 additions and 293 deletions
@@ -105,9 +105,6 @@
[self initWithTitles:titles viewControllers:viewControllers defaultSelected:0];
[super viewDidLoad];
// Add the Riot background image when search bar is empty
[self addBackgroundImageViewToView:self.view];
// Initialize here the data sources if a matrix session has been already set.
[self initializeDataSources];
@@ -118,18 +115,6 @@
[super showSearch:NO];
}
- (void)userInterfaceThemeDidChange
{
[super userInterfaceThemeDidChange];
UIImageView *backgroundImageView = self.backgroundImageView;
if (backgroundImageView)
{
UIImage *image = [MXKTools paintImage:backgroundImageView.image withColor:ThemeService.shared.theme.matrixSearchBackgroundImageTintColor];
backgroundImageView.image = image;
}
}
- (void)destroy
{
[super destroy];
@@ -178,9 +163,6 @@
{
[super viewDidAppear:animated];
// Here the actual view size is available, check the background image display if any
[self checkAndShowBackgroundImage];
if (self.splitViewController && !self.splitViewController.isCollapsed)
{
// In case of split view controller where the primary and secondary view controllers are displayed side-by-side onscreen,
@@ -189,13 +171,6 @@
}
}
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
[self checkAndShowBackgroundImage];
}
- (UIStatusBarStyle)preferredStatusBarStyle
{
return ThemeService.shared.theme.statusBarStyle;
@@ -326,15 +301,6 @@
#pragma mark - Override MXKViewController
- (void)setKeyboardHeight:(CGFloat)keyboardHeight
{
[self setKeyboardHeightForBackgroundImage:keyboardHeight];
[super setKeyboardHeight:keyboardHeight];
[self checkAndShowBackgroundImage];
}
- (void)startActivityIndicator
{
// Redirect the operation to the currently displayed VC
@@ -352,58 +318,6 @@
}
}
#pragma mark - Override UIViewController+VectorSearch
- (void)setKeyboardHeightForBackgroundImage:(CGFloat)keyboardHeight
{
[super setKeyboardHeightForBackgroundImage:keyboardHeight];
if (keyboardHeight > 0)
{
[self checkAndShowBackgroundImage];
}
}
// Check conditions before displaying the background
- (void)checkAndShowBackgroundImage
{
// Note: This background is hidden when keyboard is dismissed.
// The other conditions depend on the current selected view controller.
if (self.selectedViewController == recentsViewController)
{
self.backgroundImageView.hidden = YES;
}
else if (self.selectedViewController == messagesSearchViewController)
{
self.backgroundImageView.hidden = ((messagesSearchDataSource.serverCount != 0) || !messagesSearchViewController.noResultsLabel.isHidden || (self.keyboardHeight == 0));
}
else if (self.selectedViewController == peopleSearchViewController)
{
self.backgroundImageView.hidden = (([peopleSearchViewController.contactsTableView numberOfSections] != 0) || (self.keyboardHeight == 0));
}
else if (self.selectedViewController == filesSearchViewController)
{
self.backgroundImageView.hidden = ((filesSearchDataSource.serverCount != 0) || !filesSearchViewController.noResultsLabel.isHidden || (self.keyboardHeight == 0));
}
else
{
self.backgroundImageView.hidden = (self.keyboardHeight == 0);
}
if (!self.backgroundImageView.hidden)
{
[self.backgroundImageView layoutIfNeeded];
[self.selectedViewController.view layoutIfNeeded];
// Check whether there is enough space to display this background
// For example, in landscape with the iPhone 5 & 6 screen size, the backgroundImageView must be hidden.
if (self.backgroundImageView.frame.origin.y < 0 || (self.selectedViewController.view.frame.size.height - self.backgroundImageViewBottomConstraint.constant) < self.backgroundImageView.frame.size.height)
{
self.backgroundImageView.hidden = YES;
}
}
}
#pragma mark - Override SegmentedViewController
- (void)setSelectedIndex:(NSUInteger)selectedIndex
@@ -463,7 +377,6 @@
if (self.searchBar.text.length)
{
recentsDataSource.hideRecents = NO;
self.backgroundImageView.hidden = YES;
// Forward the search request to the data source
if (self.selectedViewController == recentsViewController)
@@ -524,8 +437,6 @@
[filesSearchDataSource searchMessages:nil force:NO];
}
}
[self checkAndShowBackgroundImage];
}
#pragma mark - UISearchBarDelegate