diff --git a/Riot/Assets/Images.xcassets/Search/Contents.json b/Riot/Assets/Images.xcassets/Search/Contents.json index da4a164c9..73c00596a 100644 --- a/Riot/Assets/Images.xcassets/Search/Contents.json +++ b/Riot/Assets/Images.xcassets/Search/Contents.json @@ -1,6 +1,6 @@ { "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/Riot/Assets/Images.xcassets/Search/search_bg.imageset/Contents.json b/Riot/Assets/Images.xcassets/Search/search_bg.imageset/Contents.json deleted file mode 100644 index 568f8cb3f..000000000 --- a/Riot/Assets/Images.xcassets/Search/search_bg.imageset/Contents.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "filename" : "search_bg.png", - "scale" : "1x" - }, - { - "idiom" : "universal", - "filename" : "search_bg@2x.png", - "scale" : "2x" - }, - { - "idiom" : "universal", - "filename" : "search_bg@3x.png", - "scale" : "3x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/Riot/Assets/Images.xcassets/Search/search_bg.imageset/search_bg.png b/Riot/Assets/Images.xcassets/Search/search_bg.imageset/search_bg.png deleted file mode 100644 index b78748b04..000000000 Binary files a/Riot/Assets/Images.xcassets/Search/search_bg.imageset/search_bg.png and /dev/null differ diff --git a/Riot/Assets/Images.xcassets/Search/search_bg.imageset/search_bg@2x.png b/Riot/Assets/Images.xcassets/Search/search_bg.imageset/search_bg@2x.png deleted file mode 100644 index 284358c5e..000000000 Binary files a/Riot/Assets/Images.xcassets/Search/search_bg.imageset/search_bg@2x.png and /dev/null differ diff --git a/Riot/Assets/Images.xcassets/Search/search_bg.imageset/search_bg@3x.png b/Riot/Assets/Images.xcassets/Search/search_bg.imageset/search_bg@3x.png deleted file mode 100644 index 4525d4f5a..000000000 Binary files a/Riot/Assets/Images.xcassets/Search/search_bg.imageset/search_bg@3x.png and /dev/null differ diff --git a/Riot/Categories/UIViewController+RiotSearch.h b/Riot/Categories/UIViewController+RiotSearch.h index db29e0183..ac95a4139 100644 --- a/Riot/Categories/UIViewController+RiotSearch.h +++ b/Riot/Categories/UIViewController+RiotSearch.h @@ -33,15 +33,6 @@ */ @property (nonatomic, readonly) BOOL searchBarHidden; -/** - The Riot empty search background image (champagne bubbles). - The image adapts its width to its parent view width. - Its bottom is aligned to the top of the keyboard. - */ -@property (nonatomic, readonly) UIImageView *backgroundImageView; - -@property (nonatomic, readonly) NSLayoutConstraint *backgroundImageViewBottomConstraint; - /** Show/Hide the search bar. @@ -50,18 +41,4 @@ - (void)showSearch:(BOOL)animated; - (void)hideSearch:(BOOL)animated; -/** - Initialise `backgroundImageView` and add it to the passed parent view. - - @param view the view to add `backgroundImageView` to. - */ -- (void)addBackgroundImageViewToView:(UIView*)view; - -/** - Provide the new height of the keyboard to align `backgroundImageView` - - @param keyboardHeight the keyboard height. - */ -- (void)setKeyboardHeightForBackgroundImage:(CGFloat)keyboardHeight; - @end diff --git a/Riot/Categories/UIViewController+RiotSearch.m b/Riot/Categories/UIViewController+RiotSearch.m index eef17866e..76d3af972 100644 --- a/Riot/Categories/UIViewController+RiotSearch.m +++ b/Riot/Categories/UIViewController+RiotSearch.m @@ -38,10 +38,6 @@ @property (nonatomic) UIBarButtonItem *backupLeftBarButtonItem; @property (nonatomic) UIBarButtonItem *backupRightBarButtonItem; -// The Riot empty search background image (champagne bubbles) -@property (nonatomic) UIImageView *backgroundImageView; -@property (nonatomic) NSLayoutConstraint *backgroundImageViewBottomConstraint; - @end @implementation UIViewControllerRiotSearchInternals @@ -70,16 +66,6 @@ return self.searchInternals.searchBarHidden; } -- (UIImageView*)backgroundImageView -{ - return self.searchInternals.backgroundImageView; -} - -- (NSLayoutConstraint *)backgroundImageViewBottomConstraint -{ - return self.searchInternals.backgroundImageViewBottomConstraint; -} - - (void)showSearch:(BOOL)animated { if (self.searchInternals.searchBarHidden) @@ -134,80 +120,6 @@ } } -- (void)addBackgroundImageViewToView:(UIView*)view -{ - UIImage *searchBgImage = [MXKTools paintImage:AssetImages.searchBg.image withColor:ThemeService.shared.theme.matrixSearchBackgroundImageTintColor]; - UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:searchBgImage]; - backgroundImageView.translatesAutoresizingMaskIntoConstraints = NO; - - [view addSubview:backgroundImageView]; - - // Keep it at left - NSLayoutConstraint *leftConstraint = [NSLayoutConstraint constraintWithItem:view - attribute:NSLayoutAttributeLeading - relatedBy:NSLayoutRelationEqual - toItem:backgroundImageView - attribute:NSLayoutAttributeLeading - multiplier:1.0 - constant:0]; - // Same width as parent - NSLayoutConstraint *widthConstraint = [NSLayoutConstraint constraintWithItem:view - attribute:NSLayoutAttributeWidth - relatedBy:NSLayoutRelationEqual - toItem:backgroundImageView - attribute:NSLayoutAttributeWidth - multiplier:1.0f - constant:0.0f]; - - // Keep the image aspect ratio - NSLayoutConstraint *aspectRatioConstraint = [NSLayoutConstraint - constraintWithItem:backgroundImageView - attribute:NSLayoutAttributeHeight - relatedBy:NSLayoutRelationEqual - toItem:backgroundImageView - attribute:NSLayoutAttributeWidth - multiplier:(backgroundImageView.frame.size.height / backgroundImageView.frame.size.width) - constant:0]; - - // Set its position according to its bottom - NSLayoutConstraint *bottomConstraint = [NSLayoutConstraint constraintWithItem:view - attribute:NSLayoutAttributeBottom - relatedBy:NSLayoutRelationEqual - toItem:backgroundImageView - attribute:NSLayoutAttributeBottom - multiplier:1.0f - constant:216]; - - [NSLayoutConstraint activateConstraints:@[leftConstraint, - widthConstraint, - aspectRatioConstraint, - bottomConstraint - ]]; - - self.searchInternals.backgroundImageView = backgroundImageView; - self.searchInternals.backgroundImageViewBottomConstraint = bottomConstraint; - - // It will be showed once the keyboard appears - backgroundImageView.hidden = YES; -} - -- (void)setKeyboardHeightForBackgroundImage:(CGFloat)keyboardHeight -{ - // keyboardHeight = 0 means no keyboard - if (keyboardHeight > 0) - { - self.searchInternals.backgroundImageView.hidden = NO; - - // 60 = 18 + 42 from the Riot design - self.searchInternals.backgroundImageViewBottomConstraint.constant = keyboardHeight - 60; - } - else - { - // Hide the search - self.searchInternals.backgroundImageView.hidden = YES; - } -} - #pragma mark - UISearchBarDelegate - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar2 diff --git a/Riot/Generated/Images.swift b/Riot/Generated/Images.swift index c74649f96..1f2851068 100644 --- a/Riot/Generated/Images.swift +++ b/Riot/Generated/Images.swift @@ -214,7 +214,6 @@ internal class Asset: NSObject { internal static let fileMusicIcon = ImageAsset(name: "file_music_icon") internal static let filePhotoIcon = ImageAsset(name: "file_photo_icon") internal static let fileVideoIcon = ImageAsset(name: "file_video_icon") - internal static let searchBg = ImageAsset(name: "search_bg") internal static let searchIcon = ImageAsset(name: "search_icon") internal static let secretsRecoveryKey = ImageAsset(name: "secrets_recovery_key") internal static let secretsRecoveryPassphrase = ImageAsset(name: "secrets_recovery_passphrase") diff --git a/Riot/Modules/GlobalSearch/UnifiedSearchViewController.m b/Riot/Modules/GlobalSearch/UnifiedSearchViewController.m index 78eeaa4b7..f701d8b08 100644 --- a/Riot/Modules/GlobalSearch/UnifiedSearchViewController.m +++ b/Riot/Modules/GlobalSearch/UnifiedSearchViewController.m @@ -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 diff --git a/Riot/Modules/Room/Search/RoomSearchViewController.m b/Riot/Modules/Room/Search/RoomSearchViewController.m index 214f3f497..8a16c463d 100644 --- a/Riot/Modules/Room/Search/RoomSearchViewController.m +++ b/Riot/Modules/Room/Search/RoomSearchViewController.m @@ -73,10 +73,7 @@ [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]; @@ -87,13 +84,6 @@ { [super userInterfaceThemeDidChange]; - UIImageView *backgroundImageView = self.backgroundImageView; - if (backgroundImageView) - { - UIImage *image = [MXKTools paintImage:backgroundImageView.image withColor:ThemeService.shared.theme.matrixSearchBackgroundImageTintColor]; - backgroundImageView.image = image; - } - // Match the search bar color to the navigation bar color as it extends slightly outside the frame. self.searchBar.backgroundColor = ThemeService.shared.theme.baseColor; } @@ -227,15 +217,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 @@ -283,48 +264,6 @@ [self.navigationController popViewControllerAnimated:YES]; } -- (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 == messagesSearchViewController) - { - self.backgroundImageView.hidden = ((messagesSearchDataSource.serverCount != 0) || !messagesSearchViewController.noResultsLabel.isHidden || (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 @@ -341,8 +280,6 @@ { if (self.searchBar.text.length) { - self.backgroundImageView.hidden = YES; - // Forward the search request to the data source if (self.selectedViewController == messagesSearchViewController) { @@ -383,8 +320,6 @@ [filesSearchDataSource searchMessages:nil force:NO]; } } - - [self checkAndShowBackgroundImage]; } @end diff --git a/changelog.d/5471.change b/changelog.d/5471.change new file mode 100644 index 000000000..195a7737f --- /dev/null +++ b/changelog.d/5471.change @@ -0,0 +1 @@ +Search: remove bubbles background