mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
Fix nativeView issues
Fix Listeners base class
This commit is contained in:
@ -3,31 +3,31 @@
|
||||
export * from "./activity-indicator-common";
|
||||
|
||||
export class ActivityIndicator extends ActivityIndicatorBase {
|
||||
nativeView: android.widget.ProgressBar;
|
||||
_progressBar: android.widget.ProgressBar;
|
||||
|
||||
public _createUI() {
|
||||
this.nativeView = new android.widget.ProgressBar(this._context);
|
||||
this.nativeView.setVisibility(android.view.View.INVISIBLE);
|
||||
this.nativeView.setIndeterminate(true);
|
||||
this._progressBar = new android.widget.ProgressBar(this._context);
|
||||
this._progressBar.setVisibility(android.view.View.INVISIBLE);
|
||||
this._progressBar.setIndeterminate(true);
|
||||
}
|
||||
|
||||
get android(): android.widget.ProgressBar {
|
||||
return this.nativeView;
|
||||
return this._progressBar;
|
||||
}
|
||||
|
||||
get [busyProperty.native](): boolean {
|
||||
return this.nativeView.getVisibility() === android.view.View.VISIBLE;
|
||||
return this._progressBar.getVisibility() === android.view.View.VISIBLE;
|
||||
}
|
||||
set [busyProperty.native](value: boolean) {
|
||||
this.nativeView.setVisibility(value ? android.view.View.VISIBLE : android.view.View.INVISIBLE);
|
||||
this._progressBar.setVisibility(value ? android.view.View.VISIBLE : android.view.View.INVISIBLE);
|
||||
}
|
||||
|
||||
get [visibilityProperty.native](): number {
|
||||
return this.nativeView.getVisibility();
|
||||
return this._progressBar.getVisibility();
|
||||
}
|
||||
set [visibilityProperty.native](value: number) {
|
||||
this.busy = value === android.view.View.VISIBLE;
|
||||
this.nativeView.setVisibility(value);
|
||||
this._progressBar.setVisibility(value);
|
||||
}
|
||||
|
||||
get [colorProperty.native](): number {
|
||||
@ -35,10 +35,10 @@ export class ActivityIndicator extends ActivityIndicatorBase {
|
||||
}
|
||||
set [colorProperty.native](value: number) {
|
||||
if (value < 0) {
|
||||
this.nativeView.getIndeterminateDrawable().clearColorFilter();
|
||||
this._progressBar.getIndeterminateDrawable().clearColorFilter();
|
||||
}
|
||||
else {
|
||||
this.nativeView.getIndeterminateDrawable().setColorFilter(value, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
this._progressBar.getIndeterminateDrawable().setColorFilter(value, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
}
|
||||
}
|
@ -6,8 +6,9 @@
|
||||
export * from "./button-common";
|
||||
|
||||
@Interfaces([android.view.View.OnClickListener])
|
||||
class ClickListener implements android.view.View.OnClickListener {
|
||||
class ClickListener extends java.lang.Object implements android.view.View.OnClickListener {
|
||||
constructor(public owner: WeakRef<Button>) {
|
||||
super();
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
@ -20,19 +21,19 @@ class ClickListener implements android.view.View.OnClickListener {
|
||||
}
|
||||
|
||||
export class Button extends ButtonBase {
|
||||
nativeView: android.widget.Button;
|
||||
_button: android.widget.Button;
|
||||
private _isPressed: boolean;
|
||||
private _transformationMethod;
|
||||
private _highlightedHandler: (args: TouchGestureEventData) => void;
|
||||
|
||||
get android(): android.widget.Button {
|
||||
return this.nativeView;
|
||||
return this._button;
|
||||
}
|
||||
|
||||
public _createUI() {
|
||||
let weakRef = new WeakRef(this);
|
||||
this.nativeView = new android.widget.Button(this._context);
|
||||
this.nativeView.setOnClickListener(new ClickListener(weakRef));
|
||||
this._button = new android.widget.Button(this._context);
|
||||
this._button.setOnClickListener(new ClickListener(weakRef));
|
||||
}
|
||||
|
||||
public _setFormattedTextPropertyToNative(value: FormattedString) {
|
||||
@ -48,7 +49,7 @@ export class Button extends ButtonBase {
|
||||
}
|
||||
}
|
||||
|
||||
this.nativeView.setText(newText);
|
||||
this._button.setText(newText);
|
||||
}
|
||||
|
||||
@PseudoClassHandler("normal", "highlighted", "pressed", "active")
|
||||
|
@ -10,6 +10,20 @@ let cssSymbolPropertyMap = {};
|
||||
let inheritableProperties = new Array<InheritedProperty<any, any>>();
|
||||
let inheritableCssProperties = new Array<InheritedCssProperty<any, any>>();
|
||||
|
||||
function print(map) {
|
||||
let symbols = (<any>Object).getOwnPropertySymbols(map);
|
||||
for (let symbol of symbols) {
|
||||
const prop = map[symbol];
|
||||
if (!prop.registered) {
|
||||
console.log(`Property ${prop.name} not Registered!!!!!`);
|
||||
}
|
||||
}
|
||||
}
|
||||
export function printUnregisteredProperties(): void {
|
||||
print(symbolPropertyMap);
|
||||
print(cssSymbolPropertyMap)
|
||||
}
|
||||
|
||||
const enum ValueSource {
|
||||
Default = 0,
|
||||
Inherited = 1,
|
||||
@ -650,6 +664,7 @@ export class InheritedCssProperty<T extends Style, U> extends CssProperty<T, U>
|
||||
}
|
||||
|
||||
export class ShorthandProperty<T extends Style> {
|
||||
private registered: boolean;
|
||||
private readonly setLocalValue: (value: string) => void;
|
||||
private readonly setCssValue: (value: string) => void;
|
||||
|
||||
@ -721,6 +736,10 @@ export class ShorthandProperty<T extends Style> {
|
||||
}
|
||||
|
||||
public register(cls: { prototype: T }): void {
|
||||
if (this.registered) {
|
||||
throw new Error(`Property ${this.name} already registered.`);
|
||||
}
|
||||
this.registered = true;
|
||||
Object.defineProperty(cls.prototype, this.name, this.localValueDescriptor);
|
||||
Object.defineProperty(cls.prototype, this.cssName, this.cssValueDescriptor);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import { Background } from "ui/styling/background";
|
||||
import {
|
||||
ViewBase, getEventOrGestureName, Observable, EventData, Style,
|
||||
Property, InheritedProperty, CssProperty, ShorthandProperty, InheritedCssProperty,
|
||||
gestureFromString, isIOS, traceEnabled, traceWrite, traceCategories, traceNotifyEvent
|
||||
gestureFromString, isIOS, traceEnabled, traceWrite, traceCategories, traceNotifyEvent, printUnregisteredProperties
|
||||
} from "./view-base";
|
||||
import { observe as gestureObserve, GesturesObserver, GestureTypes, GestureEventData } from "ui/gestures";
|
||||
import { Font, parseFont } from "ui/styling/font";
|
||||
@ -931,11 +931,6 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public _shouldApplyStyleHandlers() {
|
||||
// If we have native view we are ready to apply style handelr;
|
||||
return !!this._nativeView;
|
||||
}
|
||||
|
||||
public focus(): boolean {
|
||||
return undefined;
|
||||
}
|
||||
@ -1456,10 +1451,12 @@ function convertToTransform(value: string): [CssProperty<any, any>, any][] {
|
||||
|
||||
// Background properties.
|
||||
export const backgroundInternalProperty = new CssProperty<Style, Background>({ name: "backgroundInternal", cssName: "_backgroundInternal", defaultValue: Background.default });
|
||||
backgroundInternalProperty.register(Style);
|
||||
|
||||
let pattern: RegExp = /url\(('|")(.*?)\1\)/;
|
||||
export const backgroundImageProperty = new CssProperty<Style, string>({
|
||||
name: "backgroundImage", cssName: "background-image", valueChanged: (target, oldValue, newValue) => {
|
||||
|
||||
let style = target;
|
||||
let currentBackground = target.backgroundInternal;
|
||||
let url: string = newValue;
|
||||
@ -1505,6 +1502,7 @@ backgroundImageProperty.register(Style);
|
||||
|
||||
export const backgroundColorProperty = new CssProperty<Style, Color>({
|
||||
name: "backgroundColor", cssName: "background-color", valueChanged: (target, newValue) => {
|
||||
printUnregisteredProperties();
|
||||
let background = target.backgroundInternal;
|
||||
target.backgroundInternal = background.withColor(newValue);
|
||||
}, equalityComparer: Color.equals, valueConverter: (value) => new Color(value)
|
||||
|
@ -23,8 +23,9 @@ const VIEW_GROUP = "_viewGroup";
|
||||
|
||||
// TODO: Move this class into widgets.
|
||||
@Interfaces([android.view.View.OnTouchListener])
|
||||
class DisableUserInteractionListener implements android.view.View.OnTouchListener {
|
||||
class DisableUserInteractionListener extends java.lang.Object implements android.view.View.OnTouchListener {
|
||||
constructor() {
|
||||
super();
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
@ -34,8 +35,9 @@ class DisableUserInteractionListener implements android.view.View.OnTouchListene
|
||||
}
|
||||
|
||||
@Interfaces([android.view.View.OnTouchListener])
|
||||
class TouchListener implements android.view.View.OnTouchListener {
|
||||
class TouchListener extends java.lang.Object implements android.view.View.OnTouchListener {
|
||||
constructor(private owner: WeakRef<View>) {
|
||||
super();
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
@ -223,6 +225,8 @@ export class View extends ViewCommon {
|
||||
this._nativeView.setLayoutParams(new org.nativescript.widgets.CommonLayoutParams());
|
||||
}
|
||||
|
||||
this.nativeView = this._nativeView;
|
||||
|
||||
if (traceEnabled) {
|
||||
traceNotifyEvent(this, "_onContextChanged");
|
||||
}
|
||||
@ -1079,11 +1083,11 @@ export class CustomLayoutView extends View implements CustomLayoutViewDefinition
|
||||
public _addViewToNativeVisualTree(child: ViewCommon, atIndex: number = -1): boolean {
|
||||
super._addViewToNativeVisualTree(child);
|
||||
|
||||
if (this.nativeView && child.nativeView) {
|
||||
if (this._nativeView && child.nativeView) {
|
||||
if (traceEnabled) {
|
||||
traceWrite(`${this}.nativeView.addView(${child}.nativeView, ${atIndex})`, traceCategories.VisualTreeEvents);
|
||||
}
|
||||
this._nativeView.addView(child._nativeView, atIndex);
|
||||
this._nativeView.addView(child.nativeView, atIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
8
tns-core-modules/ui/core/view.d.ts
vendored
8
tns-core-modules/ui/core/view.d.ts
vendored
@ -126,11 +126,6 @@ declare module "ui/core/view" {
|
||||
* A View occupies a rectangular area on the screen and is responsible for drawing and layouting of all UI components within.
|
||||
*/
|
||||
export abstract class View extends ViewBase implements ApplyXmlAttributes {
|
||||
/**
|
||||
* Get the nativeView created for this object.
|
||||
*/
|
||||
public nativeView: any;
|
||||
|
||||
/**
|
||||
* Gets the android-specific native instance that lies behind this proxy. Will be available if running on an Android platform.
|
||||
*/
|
||||
@ -609,9 +604,6 @@ declare module "ui/core/view" {
|
||||
_onDetached(force?: boolean): void;
|
||||
_createUI(): void;
|
||||
|
||||
_shouldApplyStyleHandlers();
|
||||
// _checkMetadataOnPropertyChanged(metadata: dependencyObservable.PropertyMetadata);
|
||||
|
||||
_updateLayout(): void;
|
||||
|
||||
/**
|
||||
|
@ -6,8 +6,9 @@
|
||||
export * from "./date-picker-common";
|
||||
|
||||
@Interfaces([android.widget.DatePicker.OnDateChangedListener])
|
||||
class DateChangedListener implements android.widget.DatePicker.OnDateChangedListener {
|
||||
class DateChangedListener extends java.lang.Object implements android.widget.DatePicker.OnDateChangedListener {
|
||||
constructor(public owner: WeakRef<DatePicker>) {
|
||||
super()
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
@ -42,7 +43,7 @@ class DateChangedListener implements android.widget.DatePicker.OnDateChangedList
|
||||
export class DatePicker extends DatePickerBase {
|
||||
private _android: android.widget.DatePicker;
|
||||
public _listener: android.widget.DatePicker.OnDateChangedListener;
|
||||
public nativeView: android.widget.DatePicker;
|
||||
public _datePicker: android.widget.DatePicker;
|
||||
|
||||
get android(): android.widget.DatePicker {
|
||||
return this._android;
|
||||
@ -56,48 +57,48 @@ export class DatePicker extends DatePickerBase {
|
||||
}
|
||||
|
||||
private updateNativeDate(): void {
|
||||
let year = typeof this.year === "number" ? this.year : this.nativeView.getYear();
|
||||
let month = typeof this.month === "number" ? (this.month - 1) : this.nativeView.getMonth();
|
||||
let day = typeof this.day === "number" ? this.day : this.nativeView.getDayOfMonth();
|
||||
let year = typeof this.year === "number" ? this.year : this._datePicker.getYear();
|
||||
let month = typeof this.month === "number" ? (this.month - 1) : this._datePicker.getMonth();
|
||||
let day = typeof this.day === "number" ? this.day : this._datePicker.getDayOfMonth();
|
||||
this.date = new Date(year, month, day);
|
||||
}
|
||||
|
||||
get [yearProperty.native](): number {
|
||||
return this.nativeView.getYear();
|
||||
return this._datePicker.getYear();
|
||||
}
|
||||
set [yearProperty.native](value: number) {
|
||||
let picker = this.nativeView;
|
||||
let picker = this._datePicker;
|
||||
if (picker.getYear() !== value) {
|
||||
this.updateNativeDate();
|
||||
}
|
||||
}
|
||||
|
||||
get [monthProperty.native](): number {
|
||||
return this.nativeView.getMonth();
|
||||
return this._datePicker.getMonth();
|
||||
}
|
||||
set [monthProperty.native](value: number) {
|
||||
let picker = this.nativeView;
|
||||
let picker = this._datePicker;
|
||||
if (picker.getMonth() !== (value - 1)) {
|
||||
this.updateNativeDate();
|
||||
}
|
||||
}
|
||||
|
||||
get [dayProperty.native](): number {
|
||||
return this.nativeView.getDayOfMonth();
|
||||
return this._datePicker.getDayOfMonth();
|
||||
}
|
||||
set [dayProperty.native](value: number) {
|
||||
let picker = this.nativeView;
|
||||
let picker = this._datePicker;
|
||||
if (picker.getDayOfMonth() !== value) {
|
||||
this.updateNativeDate();
|
||||
}
|
||||
}
|
||||
|
||||
get [dateProperty.native](): Date {
|
||||
let picker = this.nativeView;
|
||||
let picker = this._datePicker;
|
||||
return new Date(picker.getYear(), picker.getMonth(), picker.getDayOfMonth());
|
||||
}
|
||||
set [dateProperty.native](value: Date) {
|
||||
let picker = this.nativeView;
|
||||
let picker = this._datePicker;
|
||||
if (picker.getDayOfMonth() !== value.getDay()
|
||||
|| picker.getMonth() !== value.getMonth()
|
||||
|| picker.getYear() !== value.getFullYear()) {
|
||||
@ -106,10 +107,10 @@ export class DatePicker extends DatePickerBase {
|
||||
}
|
||||
|
||||
get [maxDateProperty.native](): Date {
|
||||
return this.nativeView.getMaxDate();
|
||||
return this._datePicker.getMaxDate();
|
||||
}
|
||||
set [maxDateProperty.native](value: Date) {
|
||||
let picker = this.nativeView;
|
||||
let picker = this._datePicker;
|
||||
let newValue = value.getTime();
|
||||
if (picker.getMaxDate() !== newValue) {
|
||||
picker.setMaxDate(newValue);
|
||||
@ -117,10 +118,10 @@ export class DatePicker extends DatePickerBase {
|
||||
}
|
||||
|
||||
get [minDateProperty.native](): Date {
|
||||
return this.nativeView.getMinDate();
|
||||
return this._datePicker.getMinDate();
|
||||
}
|
||||
set [minDateProperty.native](value: Date) {
|
||||
let picker = this.nativeView;
|
||||
let picker = this._datePicker;
|
||||
let newValue = value.getTime();
|
||||
if (picker.getMinDate() !== newValue) {
|
||||
picker.setMinDate(newValue);
|
||||
|
@ -8,8 +8,9 @@
|
||||
import { ad } from "utils/utils";
|
||||
|
||||
@Interfaces([android.text.TextWatcher])
|
||||
class TextWatcher implements android.text.TextWatcher {
|
||||
class TextWatcher extends java.lang.Object implements android.text.TextWatcher {
|
||||
constructor(private owner: WeakRef<EditableTextBase>) {
|
||||
super();
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
@ -56,8 +57,9 @@ class TextWatcher implements android.text.TextWatcher {
|
||||
let dismissKeyboardTimeoutId: number;
|
||||
|
||||
@Interfaces([android.view.View.OnFocusChangeListener])
|
||||
class FocusChangeListener implements android.view.View.OnFocusChangeListener {
|
||||
class FocusChangeListener extends java.lang.Object implements android.view.View.OnFocusChangeListener {
|
||||
constructor(private owner: WeakRef<EditableTextBase>) {
|
||||
super();
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
@ -92,8 +94,9 @@ class FocusChangeListener implements android.view.View.OnFocusChangeListener {
|
||||
}
|
||||
|
||||
@Interfaces([android.widget.TextView.OnEditorActionListener])
|
||||
class EditorActionListener implements android.widget.TextView.OnEditorActionListener {
|
||||
class EditorActionListener extends java.lang.Object implements android.widget.TextView.OnEditorActionListener {
|
||||
constructor(private owner: WeakRef<EditableTextBase>) {
|
||||
super();
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
@ -133,7 +136,6 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
private _keyListenerCache: android.text.method.KeyListener;
|
||||
private _focusChangeListener: android.view.View.OnFocusChangeListener;
|
||||
private _editorActionListener: android.widget.TextView.OnEditorActionListener;
|
||||
public nativeView: android.widget.EditText;
|
||||
|
||||
get android(): android.widget.EditText {
|
||||
return this._android;
|
||||
@ -180,21 +182,21 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
}
|
||||
|
||||
public dismissSoftInput() {
|
||||
ad.dismissSoftInput(this._nativeView);
|
||||
ad.dismissSoftInput(this._android);
|
||||
}
|
||||
|
||||
public focus(): boolean {
|
||||
let result = super.focus();
|
||||
|
||||
if (result) {
|
||||
ad.showSoftInput(this._nativeView);
|
||||
ad.showSoftInput(this._android);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private _setInputType(inputType): void {
|
||||
let nativeView = this.nativeView;
|
||||
let nativeView = this._android;
|
||||
nativeView.setInputType(inputType);
|
||||
|
||||
// setInputType will change the keyListener so we should cache it again
|
||||
@ -210,15 +212,15 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
}
|
||||
|
||||
get [textProperty.native](): string {
|
||||
return this.nativeView.getText();
|
||||
return this._android.getText();
|
||||
}
|
||||
set [textProperty.native](value: string) {
|
||||
let newValue = value + '';
|
||||
this.nativeView.setText(newValue, android.widget.TextView.BufferType.EDITABLE);
|
||||
this._android.setText(newValue, android.widget.TextView.BufferType.EDITABLE);
|
||||
}
|
||||
|
||||
get [keyboardTypeProperty.native](): "datetime" | "phone" | "number" | "url" | "email" | string {
|
||||
let inputType = this.nativeView.getInputType();
|
||||
let inputType = this._android.getInputType();
|
||||
switch (inputType) {
|
||||
case android.text.InputType.TYPE_CLASS_DATETIME | android.text.InputType.TYPE_DATETIME_VARIATION_NORMAL:
|
||||
return "datetime";
|
||||
@ -276,7 +278,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
}
|
||||
|
||||
get [returnKeyTypeProperty.native](): "done" | "next" | "go" | "search" | "send" | string {
|
||||
let ime = this.nativeView.getImeOptions();
|
||||
let ime = this._android.getImeOptions();
|
||||
switch (ime) {
|
||||
case android.view.inputmethod.EditorInfo.IME_ACTION_DONE:
|
||||
return "done";
|
||||
@ -329,19 +331,19 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
}
|
||||
|
||||
get [editableProperty.native](): boolean {
|
||||
return !!this.nativeView.getKeyListener();
|
||||
return !!this._android.getKeyListener();
|
||||
}
|
||||
set [editableProperty.native](value: boolean) {
|
||||
if (value) {
|
||||
this.nativeView.setKeyListener(this._keyListenerCache);
|
||||
this._android.setKeyListener(this._keyListenerCache);
|
||||
}
|
||||
else {
|
||||
this.nativeView.setKeyListener(null);
|
||||
this._android.setKeyListener(null);
|
||||
}
|
||||
}
|
||||
|
||||
get [autocapitalizationTypeProperty.native](): "none" | "words" | "sentences" | "allCharacters" | string {
|
||||
let inputType = this.nativeView.getInputType();
|
||||
let inputType = this._android.getInputType();
|
||||
if ((inputType & android.text.InputType.TYPE_TEXT_FLAG_CAP_WORDS) === android.text.InputType.TYPE_TEXT_FLAG_CAP_WORDS) {
|
||||
return "words";
|
||||
} else if ((inputType & android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES) === android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES) {
|
||||
@ -353,7 +355,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
}
|
||||
}
|
||||
set [autocapitalizationTypeProperty.native](value: string) {
|
||||
let inputType = this.nativeView.getInputType();
|
||||
let inputType = this._android.getInputType();
|
||||
inputType = inputType & ~28672; //28672 (0x00070000) 13,14,15bits (111 0000 0000 0000)
|
||||
|
||||
switch (value) {
|
||||
@ -384,7 +386,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
}
|
||||
|
||||
get [autocorrectProperty.native](): boolean {
|
||||
let autocorrect = this.nativeView.getInputType();
|
||||
let autocorrect = this._android.getInputType();
|
||||
if ((autocorrect & android.text.InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) === android.text.InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) {
|
||||
return true;
|
||||
}
|
||||
@ -392,7 +394,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
return false;
|
||||
}
|
||||
set [autocorrectProperty.native](value: boolean) {
|
||||
let inputType = this.nativeView.getInputType();
|
||||
let inputType = this._android.getInputType();
|
||||
switch (value) {
|
||||
case true:
|
||||
inputType = inputType | android.text.InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
|
||||
@ -413,20 +415,20 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
|
||||
}
|
||||
|
||||
get [hintProperty.native](): string {
|
||||
return this.nativeView.getHint();
|
||||
return this._android.getHint();
|
||||
}
|
||||
set [hintProperty.native](value: string) {
|
||||
this.nativeView.setHint(value + '');
|
||||
this._android.setHint(value + '');
|
||||
}
|
||||
|
||||
get [placeholderColorProperty.native](): android.content.res.ColorStateList {
|
||||
return this.nativeView.getHintTextColors();
|
||||
return this._android.getHintTextColors();
|
||||
}
|
||||
set [placeholderColorProperty.native](value: Color | android.content.res.ColorStateList) {
|
||||
if (value instanceof Color) {
|
||||
this.nativeView.setHintTextColor(value.android);
|
||||
this._android.setHintTextColor(value.android);
|
||||
} else {
|
||||
this.nativeView.setHintTextColor(value);
|
||||
this._android.setHintTextColor(value);
|
||||
}
|
||||
}
|
||||
}
|
@ -161,8 +161,9 @@ export class Image extends ImageBase {
|
||||
}
|
||||
|
||||
@Interfaces([org.nativescript.widgets.image.Worker.OnImageLoadedListener])
|
||||
class ImageLoadedListener implements org.nativescript.widgets.image.Worker.OnImageLoadedListener {
|
||||
class ImageLoadedListener extends java.lang.Object implements org.nativescript.widgets.image.Worker.OnImageLoadedListener {
|
||||
constructor(private owner: WeakRef<Image>) {
|
||||
super();
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,9 @@ import { ItemsSource } from "ui/list-picker";
|
||||
export * from "./list-picker-common";
|
||||
|
||||
@Interfaces([android.widget.NumberPicker.Formatter])
|
||||
class Formatter implements android.widget.NumberPicker.Formatter {
|
||||
class Formatter extends java.lang.Object implements android.widget.NumberPicker.Formatter {
|
||||
constructor(private owner: WeakRef<ListPicker>) {
|
||||
super();
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
@ -20,8 +21,9 @@ class Formatter implements android.widget.NumberPicker.Formatter {
|
||||
}
|
||||
|
||||
@Interfaces([android.widget.NumberPicker.OnValueChangeListener])
|
||||
class ValueChangeListener implements android.widget.NumberPicker.OnValueChangeListener {
|
||||
class ValueChangeListener extends java.lang.Object implements android.widget.NumberPicker.OnValueChangeListener {
|
||||
constructor(private owner: WeakRef<ListPicker>) {
|
||||
super();
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,9 @@ const LOADMOREITEMS = ListViewBase.loadMoreItemsEvent;
|
||||
const ITEMTAP = ListViewBase.itemTapEvent;
|
||||
|
||||
@Interfaces([android.widget.AdapterView.OnItemClickListener])
|
||||
class ItemClickListener implements android.widget.AdapterView.OnItemClickListener {
|
||||
class ItemClickListener extends java.lang.Object implements android.widget.AdapterView.OnItemClickListener {
|
||||
constructor(private owner: WeakRef<ListView>) {
|
||||
super();
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,9 @@ const SEARCHTEXT = Symbol("searchText");
|
||||
const QUERY = Symbol("query");
|
||||
|
||||
@Interfaces([android.widget.SearchView.OnQueryTextListener])
|
||||
class QueryTextListener implements android.widget.SearchView.OnQueryTextListener {
|
||||
class QueryTextListener extends java.lang.Object implements android.widget.SearchView.OnQueryTextListener {
|
||||
constructor(private owner: WeakRef<SearchBar>) {
|
||||
super();
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
@ -44,8 +45,9 @@ class QueryTextListener implements android.widget.SearchView.OnQueryTextListener
|
||||
}
|
||||
|
||||
@Interfaces([android.widget.SearchView.OnCloseListener])
|
||||
class CloseListener implements android.widget.SearchView.OnCloseListener {
|
||||
class CloseListener extends java.lang.Object implements android.widget.SearchView.OnCloseListener {
|
||||
constructor(private owner: WeakRef<SearchBar>) {
|
||||
super();
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
|
@ -46,10 +46,10 @@ function setBackground(view: android.view.View, background: android.graphics.dra
|
||||
}
|
||||
|
||||
export class SegmentedBarItem extends SegmentedBarItemBase {
|
||||
private _nativeView: android.widget.TextView;
|
||||
private _textView: android.widget.TextView;
|
||||
|
||||
public setNativeView(textView: android.widget.TextView): void {
|
||||
this._nativeView = textView;
|
||||
this._textView = textView;
|
||||
applyNativeSetters(this);
|
||||
if (this.titleDirty) {
|
||||
this._update();
|
||||
@ -67,7 +67,7 @@ export class SegmentedBarItem extends SegmentedBarItemBase {
|
||||
// titleTextView.setText(this.title || "");
|
||||
// }
|
||||
|
||||
let tv = this._nativeView;
|
||||
let tv = this._textView;
|
||||
if (tv) {
|
||||
let title = this.title;
|
||||
title = (title === null || title === undefined) ? "" : title;
|
||||
@ -79,22 +79,22 @@ export class SegmentedBarItem extends SegmentedBarItemBase {
|
||||
}
|
||||
|
||||
get [colorProperty.native](): number {
|
||||
return this._nativeView.getCurrentTextColor();
|
||||
return this._textView.getCurrentTextColor();
|
||||
}
|
||||
set [colorProperty.native](value: Color | number) {
|
||||
let color = typeof value === "Color" ? value.android : value;
|
||||
this._nativeView.setTextColor(color);
|
||||
this._textView.setTextColor(color);
|
||||
}
|
||||
|
||||
get [fontInternalProperty.native](): { typeface: android.graphics.Typeface, fontSize: number } {
|
||||
let textView = this._nativeView;
|
||||
let textView = this._textView;
|
||||
return {
|
||||
typeface: textView.getTypeface(),
|
||||
fontSize: textView.getTextSize()
|
||||
};
|
||||
}
|
||||
set [fontInternalProperty.native](value: Font | { typeface: android.graphics.Typeface, fontSize: number }) {
|
||||
let tv = this._nativeView;
|
||||
let tv = this._textView;
|
||||
if (value instanceof Font) {
|
||||
tv.setTypeface(value.getAndroidTypeface());
|
||||
tv.setTextSize(value.fontSize);
|
||||
@ -105,11 +105,11 @@ export class SegmentedBarItem extends SegmentedBarItemBase {
|
||||
}
|
||||
|
||||
get [selectedBackgroundColorProperty.native](): android.graphics.drawable.Drawable {
|
||||
let viewGroup = <android.view.ViewGroup>this._nativeView.getParent();
|
||||
let viewGroup = <android.view.ViewGroup>this._textView.getParent();
|
||||
return viewGroup.getBackground();
|
||||
}
|
||||
set [selectedBackgroundColorProperty.native](value: Color | android.graphics.drawable.Drawable) {
|
||||
let viewGroup = <android.view.ViewGroup>this._nativeView.getParent();
|
||||
let viewGroup = <android.view.ViewGroup>this._textView.getParent();
|
||||
if (value instanceof Color) {
|
||||
let color = value.android;
|
||||
let backgroundDrawable = viewGroup.getBackground();
|
||||
@ -133,8 +133,9 @@ export class SegmentedBarItem extends SegmentedBarItemBase {
|
||||
}
|
||||
|
||||
@Interfaces([android.widget.TabHost.OnTabChangeListener])
|
||||
class TabChangeListener implements android.widget.TabHost.OnTabChangeListener {
|
||||
class TabChangeListener extends java.lang.Object implements android.widget.TabHost.OnTabChangeListener {
|
||||
constructor(private owner: WeakRef<SegmentedBar>) {
|
||||
super();
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
@ -147,8 +148,9 @@ class TabChangeListener implements android.widget.TabHost.OnTabChangeListener {
|
||||
}
|
||||
|
||||
@Interfaces([android.widget.TabHost.TabContentFactory])
|
||||
class TabContentFactory implements android.widget.TabHost.TabContentFactory {
|
||||
class TabContentFactory extends java.lang.Object implements android.widget.TabHost.TabContentFactory {
|
||||
constructor(private owner: WeakRef<SegmentedBar>) {
|
||||
super();
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,9 @@
|
||||
export * from "./slider-common";
|
||||
|
||||
@Interfaces([android.widget.SeekBar.OnSeekBarChangeListener])
|
||||
class SeekBarChangeListener implements android.widget.SeekBar.OnSeekBarChangeListener {
|
||||
class SeekBarChangeListener extends java.lang.Object implements android.widget.SeekBar.OnSeekBarChangeListener {
|
||||
constructor(private owner: WeakRef<Slider>) {
|
||||
super();
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,9 @@ import { View, layout, Color, Property, colorProperty, backgroundColorProperty,
|
||||
export * from "ui/core/view";
|
||||
|
||||
@Interfaces([android.widget.CompoundButton.OnCheckedChangeListener])
|
||||
class CheckedChangeListener implements android.widget.CompoundButton.OnCheckedChangeListener {
|
||||
class CheckedChangeListener extends java.lang.Object implements android.widget.CompoundButton.OnCheckedChangeListener {
|
||||
constructor(private owner: WeakRef<Switch>) {
|
||||
super();
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
|
@ -63,30 +63,30 @@ class TextTransformation extends android.text.method.ReplacementTransformationMe
|
||||
|
||||
export class TextBase extends TextBaseCommon {
|
||||
_transformationMethod: any;
|
||||
nativeView: android.widget.TextView;
|
||||
_nativeView: android.widget.TextView;
|
||||
|
||||
public _setFormattedTextPropertyToNative(value: FormattedString) {
|
||||
// TODO: Check if there is an option to force call the transformation method without
|
||||
// creating new native instance.
|
||||
if (this.nativeView) {
|
||||
this.nativeView.setTransformationMethod(new TextTransformation(this.text, value, this.style.textTransform));
|
||||
if (this._nativeView) {
|
||||
this._nativeView.setTransformationMethod(new TextTransformation(this.text, value, this.style.textTransform));
|
||||
}
|
||||
|
||||
let newText = value ? value._formattedText : null;
|
||||
if (this.nativeView) {
|
||||
this.nativeView.setText(newText);
|
||||
if (this._nativeView) {
|
||||
this._nativeView.setText(newText);
|
||||
}
|
||||
}
|
||||
|
||||
get [textProperty.native](): string {
|
||||
return this.nativeView.getText();
|
||||
return this._nativeView.getText();
|
||||
}
|
||||
set [textProperty.native](value: string) {
|
||||
if (value === null || value === undefined) {
|
||||
value = "";
|
||||
}
|
||||
|
||||
this.nativeView.setText(value);
|
||||
this._nativeView.setText(value);
|
||||
}
|
||||
|
||||
get [formattedTextProperty.native](): FormattedString {
|
||||
@ -97,25 +97,25 @@ export class TextBase extends TextBaseCommon {
|
||||
}
|
||||
|
||||
get [colorProperty.native](): android.content.res.ColorStateList {
|
||||
return this.nativeView.getTextColors();
|
||||
return this._nativeView.getTextColors();
|
||||
}
|
||||
set [colorProperty.native](value: Color | android.content.res.ColorStateList) {
|
||||
if (value instanceof Color) {
|
||||
this.nativeView.setTextColor(value.android);
|
||||
this._nativeView.setTextColor(value.android);
|
||||
} else {
|
||||
this.nativeView.setTextColor(value);
|
||||
this._nativeView.setTextColor(value);
|
||||
}
|
||||
}
|
||||
|
||||
get [fontInternalProperty.native](): { typeface: android.graphics.Typeface, fontSize: number } {
|
||||
let textView = this.nativeView;
|
||||
let textView = this._nativeView;
|
||||
return {
|
||||
typeface: textView.getTypeface(),
|
||||
fontSize: textView.getTextSize()
|
||||
};
|
||||
}
|
||||
set [fontInternalProperty.native](value: Font | { typeface: android.graphics.Typeface, fontSize: number }) {
|
||||
let textView = this.nativeView;
|
||||
let textView = this._nativeView;
|
||||
|
||||
let typeface: android.graphics.Typeface;
|
||||
let fontSize: number;
|
||||
@ -131,7 +131,7 @@ export class TextBase extends TextBaseCommon {
|
||||
}
|
||||
|
||||
get [textAlignmentProperty.native](): string {
|
||||
let textGravity = this.nativeView.getGravity() & android.view.View.TEXT_ALIGNMENT_GRAVITY;
|
||||
let textGravity = this._nativeView.getGravity() & android.view.View.TEXT_ALIGNMENT_GRAVITY;
|
||||
switch (textGravity) {
|
||||
case android.view.Gravity.LEFT:
|
||||
return "left";
|
||||
@ -147,16 +147,16 @@ export class TextBase extends TextBaseCommon {
|
||||
}
|
||||
}
|
||||
set [textAlignmentProperty.native](value: string) {
|
||||
let verticalGravity = this.nativeView.getGravity() & android.view.Gravity.VERTICAL_GRAVITY_MASK;
|
||||
let verticalGravity = this._nativeView.getGravity() & android.view.Gravity.VERTICAL_GRAVITY_MASK;
|
||||
switch (value) {
|
||||
case "left":
|
||||
this.nativeView.setGravity(android.view.Gravity.LEFT | verticalGravity);
|
||||
this._nativeView.setGravity(android.view.Gravity.LEFT | verticalGravity);
|
||||
break;
|
||||
case "center":
|
||||
this.nativeView.setGravity(android.view.Gravity.CENTER_HORIZONTAL | verticalGravity);
|
||||
this._nativeView.setGravity(android.view.Gravity.CENTER_HORIZONTAL | verticalGravity);
|
||||
break;
|
||||
case "right":
|
||||
this.nativeView.setGravity(android.view.Gravity.RIGHT | verticalGravity);
|
||||
this._nativeView.setGravity(android.view.Gravity.RIGHT | verticalGravity);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -179,9 +179,9 @@ export class TextBase extends TextBaseCommon {
|
||||
}
|
||||
|
||||
if (values.indexOf("none") === -1) {
|
||||
this.nativeView.setPaintFlags(flags);
|
||||
this._nativeView.setPaintFlags(flags);
|
||||
} else {
|
||||
this.nativeView.setPaintFlags(0);
|
||||
this._nativeView.setPaintFlags(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,16 +196,16 @@ export class TextBase extends TextBaseCommon {
|
||||
return "normal";
|
||||
}
|
||||
set [whiteSpaceProperty.native](value: "normal" | "nowrap") {
|
||||
let nativeView = this.nativeView;
|
||||
let nativeView = this._nativeView;
|
||||
let nowrap = value === "nowrap";
|
||||
nativeView.setSingleLine(nowrap);
|
||||
nativeView.setEllipsize(nowrap ? android.text.TextUtils.TruncateAt.END : null);
|
||||
}
|
||||
|
||||
get [letterSpacingProperty.native](): number {
|
||||
return org.nativescript.widgets.ViewHelper.getLetterspacing(this.nativeView);
|
||||
return org.nativescript.widgets.ViewHelper.getLetterspacing(this._nativeView);
|
||||
}
|
||||
set [letterSpacingProperty.native](value: number) {
|
||||
org.nativescript.widgets.ViewHelper.setLetterspacing(this.nativeView, value);
|
||||
org.nativescript.widgets.ViewHelper.setLetterspacing(this._nativeView, value);
|
||||
}
|
||||
}
|
@ -3,8 +3,9 @@
|
||||
export * from "./time-picker-common";
|
||||
|
||||
@Interfaces([android.widget.TimePicker.OnTimeChangedListener])
|
||||
class TimeChangedListener implements android.widget.TimePicker.OnTimeChangedListener {
|
||||
class TimeChangedListener extends java.lang.Object implements android.widget.TimePicker.OnTimeChangedListener {
|
||||
constructor(public owner: WeakRef<TimePicker>) {
|
||||
super();
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
@ -19,13 +20,13 @@ class TimeChangedListener implements android.widget.TimePicker.OnTimeChangedList
|
||||
}
|
||||
|
||||
export class TimePicker extends TimePickerBase {
|
||||
public nativeView: android.widget.TimePicker;
|
||||
public _timePicker: android.widget.TimePicker;
|
||||
private _listener: android.widget.TimePicker.OnTimeChangedListener;
|
||||
|
||||
public _createUI() {
|
||||
this.nativeView = new android.widget.TimePicker(this._context);
|
||||
this._timePicker = new android.widget.TimePicker(this._context);
|
||||
this._listener = this._listener || new TimeChangedListener(new WeakRef(this));
|
||||
this.nativeView.setOnTimeChangedListener(this._listener);
|
||||
this._timePicker.setOnTimeChangedListener(this._listener);
|
||||
|
||||
let c = java.util.Calendar.getInstance();
|
||||
if (this.hour === 0) {
|
||||
@ -59,7 +60,7 @@ export class TimePicker extends TimePickerBase {
|
||||
}
|
||||
|
||||
get [timeProperty.native](): Date {
|
||||
let nativeView = this.nativeView;
|
||||
let nativeView = this._timePicker;
|
||||
return new Date(0, 0, 0, nativeView.getCurrentHour().intValue(), nativeView.getCurrentMinute().intValue());
|
||||
}
|
||||
set [timeProperty.native](value: Date) {
|
||||
@ -67,14 +68,14 @@ export class TimePicker extends TimePickerBase {
|
||||
}
|
||||
|
||||
get [minuteProperty.native](): number {
|
||||
return this.nativeView.getCurrentMinute().intValue();
|
||||
return this._timePicker.getCurrentMinute().intValue();
|
||||
}
|
||||
set [minuteProperty.native](value: number) {
|
||||
this._setNativeValueSilently(this.hour, value);
|
||||
}
|
||||
|
||||
get [hourProperty.native](): number {
|
||||
return this.nativeView.getCurrentHour().intValue()
|
||||
return this._timePicker.getCurrentHour().intValue()
|
||||
}
|
||||
set [hourProperty.native](value: number) {
|
||||
this._setNativeValueSilently(value, this.minute);
|
||||
|
Reference in New Issue
Block a user