Set text-field and text-view tintColor to textColor (iOS) (fixes #4357) EXTENDED (#4549)

* set text-field and text-view tintColor to textColor (#4357)

* Rest tint color
This commit is contained in:
Alexander Vakrilov
2017-07-25 11:22:21 +03:00
committed by GitHub
parent 4bd3a94873
commit 5a660a6eda
3 changed files with 26 additions and 22 deletions

View File

@@ -6,14 +6,14 @@
<Label text="TextView:" />
<TextView hint="nothing" fontSize="18" />
<TextView hint="placeholder-color" style="placeholder-color: green;" fontSize="18" />
<TextView hint="color" style="color: blue;" fontSize="18" />
<TextView hint="both" style="color: blue; placeholder-color: green;" fontSize="18" />
<TextView hint="color" style="color: brown;" fontSize="18" />
<TextView hint="both" style="color: brown; placeholder-color: green;" fontSize="18" />
<Label text="TextField:" />
<TextField hint="nothing" fontSize="18" />
<TextField hint="placeholder-color" style="placeholder-color: green;" fontSize="18" />
<TextField hint="color" style="color: blue;" fontSize="18" />
<TextField hint="both" style="color: blue; placeholder-color: green;" fontSize="18" />
<TextField hint="color" style="color: brown;" fontSize="18" />
<TextField hint="both" style="color: brown; placeholder-color: green;" fontSize="18" />
<StackLayout orientation="horizontal">
<Button id="btnSetText" text="set text" tap="setText" width="80"/>

View File

@@ -1,4 +1,4 @@
import {
import {
TextFieldBase, secureProperty, textProperty, hintProperty, colorProperty, placeholderColorProperty,
Length, paddingTopProperty, paddingRightProperty, paddingBottomProperty, paddingLeftProperty, _updateCharactersInRangeReplacementString, Color, layout
} from "./text-field-common";
@@ -48,7 +48,7 @@ class UITextFieldDelegateImpl extends NSObject implements UITextFieldDelegate {
this.firstEdit = false;
const owner = this._owner.get();
if (owner) {
textProperty.nativeValueChange(owner, '');
textProperty.nativeValueChange(owner, '');
}
return true;
@@ -82,7 +82,7 @@ class UITextFieldDelegateImpl extends NSObject implements UITextFieldDelegate {
else {
if (range.location <= textField.text.length) {
const newText = NSString.stringWithString(textField.text).stringByReplacingCharactersInRangeWithString(range, replacementString);
textProperty.nativeValueChange(owner, newText);
textProperty.nativeValueChange(owner, newText);
}
}
}
@@ -181,21 +181,23 @@ export class TextField extends TextFieldBase {
this.nativeView.secureTextEntry = value;
}
[colorProperty.getDefault](): UIColor {
[colorProperty.getDefault](): { textColor: UIColor, tintColor: UIColor } {
// return this.nativeView.tintColor;
return this.nativeView.textColor;
console.log("----> TextField: colorProperty.getDefault: " + this.nativeView.textColor)
return {
textColor: this.nativeView.textColor,
tintColor: this.nativeView.tintColor
};
}
[colorProperty.setNative](value: UIColor | Color) {
// NOTE: Do we need this code? We have placeholderColor.
// let nativeValue = this.nativeView;
// if (this.isShowingHint && value) {
// nativeValue.textColor = value.colorWithAlphaComponent(0.22);
// } else {
// nativeValue.textColor = value;
// nativeValue.tintColor = value;
// }
let color = value instanceof Color ? value.ios : value;
this.nativeView.textColor = color;
[colorProperty.setNative](value: Color | { textColor: UIColor, tintColor: UIColor }) {
if (value instanceof Color) {
let color = value instanceof Color ? value.ios : value;
this.nativeView.textColor = color;
this.nativeView.tintColor = color;
} else {
this.nativeView.textColor = value.textColor;
this.nativeView.tintColor = value.tintColor;
}
}
[placeholderColorProperty.getDefault](): UIColor {

View File

@@ -135,7 +135,7 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
if (placeholderColor) {
this.nativeView.textColor = placeholderColor.ios;
} else if (color) {
// Use semi-transparent vesion of color for back-compatibility
// Use semi-transparent version of color for back-compatibility
this.nativeView.textColor = color.ios.colorWithAlphaComponent(0.22);
} else {
this.nativeView.textColor = UIColor.blackColor.colorWithAlphaComponent(0.22);
@@ -145,8 +145,10 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
if (color) {
this.nativeView.textColor = color.ios;
this.nativeView.tintColor = color.ios;
} else {
this.nativeView.textColor = UIColor.blackColor;
this.nativeView.textColor = null;
this.nativeView.tintColor = null;
}
}
}