FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fixed: SearchBar.textFieldHintColor not respected on iOS by hamorphis · Pull Request #2313 · NativeScript/NativeScript · GitHub

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ts  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
35 changes: 21 additions & 14 deletions tns-core-modules/ui/search-bar/search-bar.ios.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as typesModule from "utils/types";
import style = require("ui/styling/style");
import view = require("ui/core/view");
import font = require("ui/styling/font");
import { Color } from "color";

var types: typeof typesModule;
function ensureTypes() {
Expand All @@ -21,27 +22,22 @@ function onTextPropertyChanged(data: dependencyObservable.PropertyChangeData) {
(<proxy.PropertyMetadata>common.SearchBar.textProperty.metadata).onSetNativeValue = onTextPropertyChanged;

function onTextFieldBackgroundColorPropertyChanged(data: dependencyObservable.PropertyChangeData) {
var bar = <SearchBar>data.object;
var color = require("color");
if (data.newValue instanceof color.Color) {
var tf = (<any>bar)._textField;
if (tf) {
tf.backgroundColor = data.newValue.ios;
if (data.newValue instanceof Color) {
let bar = <SearchBar>data.object;
if (bar._textField) {
bar._textField.backgroundColor = data.newValue.ios;
}
}
}

(<proxy.PropertyMetadata>common.SearchBar.textFieldBackgroundColorProperty.metadata).onSetNativeValue = onTextFieldBackgroundColorPropertyChanged;

function onTextFieldHintColorPropertyChanged(data: dependencyObservable.PropertyChangeData) {
// This should be in a Try Catch in case Apple eliminates which ever method in the future;
try {
// TODO; convert this code into NativeScript Code
/* if ([textField respondsToSelector:@selector(setAttributedPlaceholder:)]) {
textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:textField.placeholder attributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}];
} */
} catch (Err) {
// Do Nothing
if (data.newValue instanceof Color) {
let bar = <SearchBar>data.object;
if (bar._placeholderLabel) {
bar._placeholderLabel.textColor = data.newValue.ios;
}
}
}

Expand Down Expand Up @@ -115,6 +111,7 @@ export class SearchBar extends common.SearchBar {
private _ios: UISearchBar;
private _delegate;
private __textField: UITextField;
private __placeholderLabel: UILabel;

constructor() {
super();
Expand Down Expand Up @@ -149,6 +146,16 @@ export class SearchBar extends common.SearchBar {

return this.__textField;
}

get _placeholderLabel(): UILabel {
if (!this.__placeholderLabel) {
if (this._textField){
this.__placeholderLabel = this._textField.valueForKey("placeholderLabel");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is this private API?
If so we should not check-in it.

}
}

return this.__placeholderLabel;
}
}

export class SearchBarStyler implements style.Styler {
Expand Down

Back | FazBrowse Home | New Git URL