Tweak tint for search bar icons in dark theme

pull/1/head
Michael Kirk 7 years ago
parent 75bb9b60db
commit 3022f92925

@ -442,6 +442,7 @@
4C4BC6C32102D697004040C9 /* ContactDiscoveryOperationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C4BC6C22102D697004040C9 /* ContactDiscoveryOperationTest.swift */; };
4C63CC00210A620B003AE45C /* SignalTSan.supp in Resources */ = {isa = PBXBuildFile; fileRef = 4C63CBFF210A620B003AE45C /* SignalTSan.supp */; };
4C6F527C20FFE8400097DEEE /* SignalUBSan.supp in Resources */ = {isa = PBXBuildFile; fileRef = 4C6F527B20FFE8400097DEEE /* SignalUBSan.supp */; };
4C858A52212DC5E1001B45D3 /* UIImage+OWS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C858A51212DC5E1001B45D3 /* UIImage+OWS.swift */; };
4CA5F793211E1F06008C2708 /* Toast.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CA5F792211E1F06008C2708 /* Toast.swift */; };
4CB5F26720F6E1E2004D1B42 /* MenuActionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CFF4C0920F55BBA005DA313 /* MenuActionsViewController.swift */; };
4CB5F26920F7D060004D1B42 /* MessageActions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CB5F26820F7D060004D1B42 /* MessageActions.swift */; };
@ -1131,6 +1132,7 @@
4C4BC6C22102D697004040C9 /* ContactDiscoveryOperationTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ContactDiscoveryOperationTest.swift; path = contact/ContactDiscoveryOperationTest.swift; sourceTree = "<group>"; };
4C63CBFF210A620B003AE45C /* SignalTSan.supp */ = {isa = PBXFileReference; lastKnownFileType = text; path = SignalTSan.supp; sourceTree = "<group>"; };
4C6F527B20FFE8400097DEEE /* SignalUBSan.supp */ = {isa = PBXFileReference; lastKnownFileType = text; path = SignalUBSan.supp; sourceTree = "<group>"; };
4C858A51212DC5E1001B45D3 /* UIImage+OWS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+OWS.swift"; sourceTree = "<group>"; };
4CA5F792211E1F06008C2708 /* Toast.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toast.swift; sourceTree = "<group>"; };
4CB5F26820F7D060004D1B42 /* MessageActions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageActions.swift; sourceTree = "<group>"; };
4CC0B59B20EC5F2E00CF6EE0 /* ConversationConfigurationSyncOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationConfigurationSyncOperation.swift; sourceTree = "<group>"; };
@ -1563,6 +1565,7 @@
B97940251832BD2400BD66CB /* UIUtil.h */,
B97940261832BD2400BD66CB /* UIUtil.m */,
45F170D51E315310003FC1F2 /* Weak.swift */,
4C858A51212DC5E1001B45D3 /* UIImage+OWS.swift */,
);
path = utils;
sourceTree = "<group>";
@ -3196,6 +3199,7 @@
34AC09F7211B39B100997B47 /* MediaMessageView.swift in Sources */,
3461293A1FD1B47300532771 /* OWSPreferences.m in Sources */,
34AC09E6211B39B100997B47 /* SelectRecipientViewController.m in Sources */,
4C858A52212DC5E1001B45D3 /* UIImage+OWS.swift in Sources */,
34480B671FD0AA9400BC14EF /* UIFont+OWS.m in Sources */,
346129E61FD5C0C600532771 /* OWSDatabaseMigrationRunner.m in Sources */,
34AC0A11211B39EA00997B47 /* OWSLayerView.swift in Sources */,

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "Search-clear_17x17_@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Search-clear_17x17_@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Search-clear_17x17_@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "UIButtonBarSearch_18x18_@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "UIButtonBarSearch_18x18_@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "UIButtonBarSearch_18x18_@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

@ -5,6 +5,7 @@
#import "OWSSearchBar.h"
#import "Theme.h"
#import "UIView+OWS.h"
#import <SignalMessaging/SignalMessaging-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -56,6 +57,7 @@ NS_ASSUME_NONNULL_BEGIN
{
OWSAssertIsOnMainThread();
UIColor *foregroundColor = Theme.placeholderColor;
self.barTintColor = Theme.backgroundColor;
self.barStyle = Theme.barStyle;
@ -65,6 +67,22 @@ NS_ASSUME_NONNULL_BEGIN
// (regardless of our re-setting textfield.backgroundColor below).
self.backgroundImage = [UIImage new];
if (Theme.isDarkThemeEnabled) {
UIImage *clearImage = [UIImage imageNamed:@"searchbar_clear"];
[self setImage:[clearImage templatedWithColor:foregroundColor]
forSearchBarIcon:UISearchBarIconClear
state:UIControlStateNormal];
UIImage *searchImage = [UIImage imageNamed:@"searchbar_search"];
[self setImage:[searchImage templatedWithColor:foregroundColor]
forSearchBarIcon:UISearchBarIconSearch
state:UIControlStateNormal];
} else {
[self setImage:nil forSearchBarIcon:UISearchBarIconClear state:UIControlStateNormal];
[self setImage:nil forSearchBarIcon:UISearchBarIconSearch state:UIControlStateNormal];
}
[self traverseViewHierarchyWithVisitor:^(UIView *view) {
if ([view isKindOfClass:[UITextField class]]) {
UITextField *textField = (UITextField *)view;

@ -0,0 +1,30 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
import Foundation
extension UIImage {
private func image(with view: UIView) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.isOpaque, 0.0)
defer { UIGraphicsEndImageContext() }
guard let context = UIGraphicsGetCurrentContext() else {
return nil
}
view.layer.render(in: context)
let image = UIGraphicsGetImageFromCurrentImageContext()
return image
}
@objc
public func templated(color: UIColor) -> UIImage? {
let template = self.withRenderingMode(.alwaysTemplate)
let imageView = UIImageView(image: template)
imageView.tintColor = color
return image(with: imageView)
}
}
Loading…
Cancel
Save