mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
1.8 KiB
Matlab
84 lines
1.8 KiB
Matlab
7 years ago
|
//
|
||
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "OWSSearchBar.h"
|
||
|
#import "Theme.h"
|
||
|
#import "UIView+OWS.h"
|
||
|
|
||
|
NS_ASSUME_NONNULL_BEGIN
|
||
|
|
||
|
@implementation OWSSearchBar
|
||
|
|
||
|
- (instancetype)init
|
||
|
{
|
||
|
if (self = [super init]) {
|
||
|
[self ows_configure];
|
||
|
}
|
||
|
|
||
|
return self;
|
||
|
}
|
||
|
|
||
|
- (instancetype)initWithFrame:(CGRect)frame
|
||
|
{
|
||
|
if (self = [super initWithFrame:frame]) {
|
||
|
[self ows_configure];
|
||
|
}
|
||
|
|
||
|
return self;
|
||
|
}
|
||
|
|
||
|
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder
|
||
|
{
|
||
|
if (self = [super initWithCoder:aDecoder]) {
|
||
|
[self ows_configure];
|
||
|
}
|
||
|
|
||
|
return self;
|
||
|
}
|
||
|
|
||
|
- (void)ows_configure
|
||
|
{
|
||
|
[self ows_applyTheme];
|
||
|
|
||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||
|
selector:@selector(themeDidChange:)
|
||
|
name:ThemeDidChangeNotification
|
||
|
object:nil];
|
||
|
}
|
||
|
|
||
|
- (void)dealloc
|
||
|
{
|
||
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||
|
}
|
||
|
|
||
|
- (void)ows_applyTheme
|
||
|
{
|
||
|
OWSAssertIsOnMainThread();
|
||
|
|
||
|
self.searchBarStyle = UISearchBarStyleMinimal;
|
||
|
self.backgroundColor = Theme.searchBarBackgroundColor;
|
||
|
self.barTintColor = Theme.backgroundColor;
|
||
|
self.barStyle = Theme.barStyle;
|
||
|
self.searchBarStyle = Theme.searchBarStyle;
|
||
|
|
||
|
[self traverseViewHierarchyWithVisitor:^(UIView *view) {
|
||
|
if ([view isKindOfClass:[UITextField class]]) {
|
||
|
UITextField *textField = (UITextField *)view;
|
||
|
textField.keyboardAppearance
|
||
|
= (Theme.isDarkThemeEnabled ? UIKeyboardAppearanceDark : UIKeyboardAppearanceDefault);
|
||
|
}
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
- (void)themeDidChange:(NSNotification *)notification
|
||
|
{
|
||
|
OWSAssertIsOnMainThread();
|
||
|
|
||
|
[self ows_applyTheme];
|
||
|
}
|
||
|
|
||
|
@end
|
||
|
|
||
|
NS_ASSUME_NONNULL_END
|