[iOS] FindInPage: Clean up iOS 12 and fix Dark Mode bug
The bug occured because the overridesUserInterfaceStyle for this was in the view that contained FindBarViewController's view, and overridesUserInterfaceStyle from a view doesn't propagate down to embedded view controllers. This has probably been around since the Dark Mode migration. Bug: 1222388 Change-Id: If733aa2964da965df8f5e2af77b1b6d05ec8d5a2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2976972 Reviewed-by: Stepan Khapugin <stkhapugin@chromium.org> Commit-Queue: Robbie Gibson <rkgibson@google.com> Cr-Commit-Position: refs/heads/master@{#894656}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
9fece697a0
commit
a0e238734a
ios/chrome/browser/ui/find_bar
@ -12,10 +12,8 @@
|
||||
// in format of "1 of 13", and next/previous/close buttons.
|
||||
@interface FindBarView : UIView
|
||||
|
||||
// Designated initializer. |darkAppearance| makes the background to dark color
|
||||
// and changes font colors to lighter colors.
|
||||
- (instancetype)initWithDarkAppearance:(BOOL)darkAppearance
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
// Designated initializer.
|
||||
- (instancetype)init NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
|
||||
- (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE;
|
||||
|
@ -37,8 +37,6 @@ const CGFloat kButtonLength = 44;
|
||||
// The overlay that shows number of results in format "1 of 13".
|
||||
@property(nonatomic, strong) UILabel* resultsCountLabel;
|
||||
|
||||
@property(nonatomic, assign) BOOL darkMode;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FindBarView
|
||||
@ -48,15 +46,11 @@ const CGFloat kButtonLength = 44;
|
||||
@synthesize nextButton = _nextButton;
|
||||
@synthesize closeButton = _closeButton;
|
||||
@synthesize resultsCountLabel = _resultsCountLabel;
|
||||
@synthesize darkMode = _darkMode;
|
||||
|
||||
#pragma mark - Public
|
||||
|
||||
- (instancetype)initWithDarkAppearance:(BOOL)darkAppearance {
|
||||
- (instancetype)init {
|
||||
self = [super initWithFrame:CGRectZero];
|
||||
if (self) {
|
||||
_darkMode = darkAppearance;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -142,23 +136,16 @@ const CGFloat kButtonLength = 44;
|
||||
]];
|
||||
}
|
||||
|
||||
// Sets the colors for the different subviews, based on the |darkMode|.
|
||||
// Sets the colors for the different subviews.
|
||||
- (void)setupColors {
|
||||
UIColor* inputFieldBackground = color::DarkModeDynamicColor(
|
||||
[UIColor colorNamed:kTextfieldBackgroundColor], self.darkMode,
|
||||
[UIColor colorNamed:kTextfieldBackgroundDarkColor]);
|
||||
UIColor* inputFieldPlaceHolderTextColor = color::DarkModeDynamicColor(
|
||||
[UIColor colorNamed:kTextfieldPlaceholderColor], self.darkMode,
|
||||
[UIColor colorNamed:kTextfieldPlaceholderDarkColor]);
|
||||
UIColor* inputFieldTextColor = color::DarkModeDynamicColor(
|
||||
[UIColor colorNamed:kTextPrimaryColor], self.darkMode,
|
||||
[UIColor colorNamed:kTextPrimaryDarkColor]);
|
||||
UIColor* resultsCountLabelTextColor = color::DarkModeDynamicColor(
|
||||
[UIColor colorNamed:kTextfieldPlaceholderColor], self.darkMode,
|
||||
[UIColor colorNamed:kTextfieldPlaceholderDarkColor]);
|
||||
UIColor* buttonTintColor = color::DarkModeDynamicColor(
|
||||
[UIColor colorNamed:kBlueColor], self.darkMode,
|
||||
[UIColor colorNamed:kBlueDarkColor]);
|
||||
UIColor* inputFieldBackground =
|
||||
[UIColor colorNamed:kTextfieldBackgroundColor];
|
||||
UIColor* inputFieldPlaceHolderTextColor =
|
||||
[UIColor colorNamed:kTextfieldPlaceholderColor];
|
||||
UIColor* inputFieldTextColor = [UIColor colorNamed:kTextPrimaryColor];
|
||||
UIColor* resultsCountLabelTextColor =
|
||||
[UIColor colorNamed:kTextfieldPlaceholderColor];
|
||||
UIColor* buttonTintColor = [UIColor colorNamed:kBlueColor];
|
||||
|
||||
self.inputField.backgroundColor = inputFieldBackground;
|
||||
NSString* placeholder = [self.inputField placeholder];
|
||||
|
@ -21,7 +21,9 @@
|
||||
|
||||
- (instancetype)initWithDarkAppearance:(BOOL)darkAppearance {
|
||||
if (self = [super initWithNibName:nil bundle:nil]) {
|
||||
_darkAppearance = darkAppearance;
|
||||
self.overrideUserInterfaceStyle = darkAppearance
|
||||
? UIUserInterfaceStyleDark
|
||||
: UIUserInterfaceStyleUnspecified;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -29,7 +31,7 @@
|
||||
#pragma mark - UIView
|
||||
|
||||
- (void)loadView {
|
||||
self.view = [[FindBarView alloc] initWithDarkAppearance:self.darkAppearance];
|
||||
self.view = [[FindBarView alloc] init];
|
||||
self.view.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user