Merge pull request #3366 from NativeScript/cankov/modules30-ios-button-fixes

Make some Button tests pass for iOS
This commit is contained in:
Panayot Cankov
2016-12-27 14:55:40 +02:00
committed by GitHub
2 changed files with 15 additions and 6 deletions

View File

@@ -21,6 +21,10 @@ export class Button extends ButtonBase {
this.nativeView.addTargetActionForControlEvents(this._tapHandler, "tap", UIControlEvents.TouchUpInside); this.nativeView.addTargetActionForControlEvents(this._tapHandler, "tap", UIControlEvents.TouchUpInside);
} }
get ios() {
return this.nativeView;
}
public onUnloaded() { public onUnloaded() {
super.onUnloaded(); super.onUnloaded();
if (this._stateChangedHandler) { if (this._stateChangedHandler) {

View File

@@ -3,8 +3,10 @@
textTransformProperty, letterSpacingProperty, colorProperty, fontInternalProperty, Font, Color, FormattedString, textTransformProperty, letterSpacingProperty, colorProperty, fontInternalProperty, Font, Color, FormattedString,
TextDecoration, TextAlignment, TextTransform TextDecoration, TextAlignment, TextTransform
} from "./text-base-common"; } from "./text-base-common";
import * as utils from "utils/utils";
export * from "./text-base-common"; export * from "./text-base-common";
export class TextBase extends TextBaseCommon { export class TextBase extends TextBaseCommon {
public nativeView: UITextField | UITextView | UILabel | UIButton; public nativeView: UITextField | UITextView | UILabel | UIButton;
@@ -56,20 +58,23 @@ export class TextBase extends TextBaseCommon {
} }
//Color //Color
get [colorProperty.native](): UIColor { get [colorProperty.native](): Color {
let nativeView = this.nativeView; let nativeView = this.nativeView;
if (nativeView instanceof UIButton) { if (nativeView instanceof UIButton) {
return nativeView.titleColorForState(UIControlState.Normal); return utils.ios.getColor(nativeView.titleColorForState(UIControlState.Normal));
} else { } else {
return nativeView.textColor; return utils.ios.getColor(nativeView.textColor);
} }
} }
set [colorProperty.native](value: UIColor) { set [colorProperty.native](value: Color) {
console.log("Setting native color: " + value);
let nativeView = this.nativeView; let nativeView = this.nativeView;
if (nativeView instanceof UIButton) { if (nativeView instanceof UIButton) {
nativeView.setTitleColorForState(value, UIControlState.Normal); if (value instanceof UIColor) {
nativeView.setTitleColorForState(value.ios, UIControlState.Normal);
}
} else { } else {
nativeView.textColor = value; nativeView.textColor = value.ios;
} }
} }