diff --git a/SignalMessaging/Views/OWSSearchBar.m b/SignalMessaging/Views/OWSSearchBar.m index e081b0273..3f9f66be3 100644 --- a/SignalMessaging/Views/OWSSearchBar.m +++ b/SignalMessaging/Views/OWSSearchBar.m @@ -56,17 +56,21 @@ NS_ASSUME_NONNULL_BEGIN { OWSAssertIsOnMainThread(); - self.searchBarStyle = UISearchBarStyleMinimal; - self.backgroundColor = Theme.searchBarBackgroundColor; self.barTintColor = Theme.backgroundColor; self.barStyle = Theme.barStyle; - self.searchBarStyle = Theme.searchBarStyle; + + // Hide searchBar border. + // Alternatively we could hide the border by using `UISearchBarStyleMinimal`, but that causes an issue when toggling + // from light -> dark -> light theme wherein the textField background color appears darker than it should + // (regardless of our re-setting textfield.backgroundColor below). + self.backgroundImage = [UIImage new]; [self traverseViewHierarchyWithVisitor:^(UIView *view) { if ([view isKindOfClass:[UITextField class]]) { UITextField *textField = (UITextField *)view; - textField.keyboardAppearance - = (Theme.isDarkThemeEnabled ? UIKeyboardAppearanceDark : UIKeyboardAppearanceDefault); + textField.backgroundColor = Theme.searchFieldBackgroundColor; + textField.textColor = Theme.primaryColor; + textField.keyboardAppearance = Theme.keyboardAppearance; } }]; } diff --git a/SignalMessaging/categories/Theme.h b/SignalMessaging/categories/Theme.h index 937a79ff4..d4b1fbb88 100644 --- a/SignalMessaging/categories/Theme.h +++ b/SignalMessaging/categories/Theme.h @@ -47,8 +47,7 @@ extern NSString *const ThemeDidChangeNotification; #pragma mark - @property (class, readonly, nonatomic) UIBarStyle barStyle; -@property (class, readonly, nonatomic) UISearchBarStyle searchBarStyle; -@property (class, readonly, nonatomic) UIColor *searchBarBackgroundColor; +@property (class, readonly, nonatomic) UIColor *searchFieldBackgroundColor; @property (class, readonly, nonatomic) UIBlurEffect *barBlurEffect; @property (class, readonly, nonatomic) UIKeyboardAppearance keyboardAppearance; diff --git a/SignalMessaging/categories/Theme.m b/SignalMessaging/categories/Theme.m index fff3faa5c..d8268e934 100644 --- a/SignalMessaging/categories/Theme.m +++ b/SignalMessaging/categories/Theme.m @@ -143,29 +143,16 @@ NSString *const ThemeKeyThemeEnabled = @"ThemeKeyThemeEnabled"; return Theme.isDarkThemeEnabled ? UIKeyboardAppearanceDark : UIKeyboardAppearanceDefault; } -#pragma mark - +#pragma mark - Search Bar + (UIBarStyle)barStyle { - if (Theme.isDarkThemeEnabled) { - return UIBarStyleDefault; - } else { - return UIBarStyleDefault; - } -} - -+ (UISearchBarStyle)searchBarStyle -{ - if (Theme.isDarkThemeEnabled) { - return UISearchBarStyleProminent; - } else { - return UISearchBarStyleMinimal; - } + return Theme.isDarkThemeEnabled ? UIBarStyleBlack : UIBarStyleDefault; } -+ (UIColor *)searchBarBackgroundColor ++ (UIColor *)searchFieldBackgroundColor { - return Theme.backgroundColor; + return Theme.isDarkThemeEnabled ? Theme.offBackgroundColor : UIColor.ows_light10Color; } #pragma mark -