mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: default tabs
This commit is contained in:
@@ -5,14 +5,14 @@ import { Property } from '../core/properties';
|
||||
|
||||
@CSSType('ActivityIndicator')
|
||||
export class ActivityIndicatorBase extends View implements ActivityIndicatorDefinition {
|
||||
public busy: boolean;
|
||||
public busy: boolean;
|
||||
}
|
||||
|
||||
ActivityIndicatorBase.prototype.recycleNativeView = 'auto';
|
||||
|
||||
export const busyProperty = new Property<ActivityIndicatorBase, boolean>({
|
||||
name: 'busy',
|
||||
defaultValue: false,
|
||||
valueConverter: booleanConverter,
|
||||
name: 'busy',
|
||||
defaultValue: false,
|
||||
valueConverter: booleanConverter,
|
||||
});
|
||||
busyProperty.register(ActivityIndicatorBase);
|
||||
|
||||
@@ -5,52 +5,52 @@ import { Color } from '../../color';
|
||||
export * from './activity-indicator-common';
|
||||
|
||||
export class ActivityIndicator extends ActivityIndicatorBase {
|
||||
nativeViewProtected: android.widget.ProgressBar;
|
||||
nativeViewProtected: android.widget.ProgressBar;
|
||||
|
||||
public createNativeView() {
|
||||
const progressBar = new android.widget.ProgressBar(this._context);
|
||||
progressBar.setVisibility(android.view.View.INVISIBLE);
|
||||
progressBar.setIndeterminate(true);
|
||||
public createNativeView() {
|
||||
const progressBar = new android.widget.ProgressBar(this._context);
|
||||
progressBar.setVisibility(android.view.View.INVISIBLE);
|
||||
progressBar.setIndeterminate(true);
|
||||
|
||||
return progressBar;
|
||||
}
|
||||
return progressBar;
|
||||
}
|
||||
|
||||
[busyProperty.getDefault](): boolean {
|
||||
return false;
|
||||
}
|
||||
[busyProperty.setNative](value: boolean) {
|
||||
if (this.visibility === Visibility.VISIBLE) {
|
||||
this.nativeViewProtected.setVisibility(value ? android.view.View.VISIBLE : android.view.View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
[busyProperty.getDefault](): boolean {
|
||||
return false;
|
||||
}
|
||||
[busyProperty.setNative](value: boolean) {
|
||||
if (this.visibility === Visibility.VISIBLE) {
|
||||
this.nativeViewProtected.setVisibility(value ? android.view.View.VISIBLE : android.view.View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
[visibilityProperty.getDefault](): Visibility {
|
||||
return Visibility.HIDDEN;
|
||||
}
|
||||
[visibilityProperty.setNative](value: Visibility) {
|
||||
switch (value) {
|
||||
case Visibility.VISIBLE:
|
||||
this.nativeViewProtected.setVisibility(this.busy ? android.view.View.VISIBLE : android.view.View.INVISIBLE);
|
||||
break;
|
||||
case Visibility.HIDDEN:
|
||||
this.nativeViewProtected.setVisibility(android.view.View.INVISIBLE);
|
||||
break;
|
||||
case Visibility.COLLAPSE:
|
||||
this.nativeViewProtected.setVisibility(android.view.View.GONE);
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Invalid visibility value: ${value}. Valid values are: "${Visibility.VISIBLE}", "${Visibility.HIDDEN}", "${Visibility.COLLAPSE}".`);
|
||||
}
|
||||
}
|
||||
[visibilityProperty.getDefault](): Visibility {
|
||||
return Visibility.HIDDEN;
|
||||
}
|
||||
[visibilityProperty.setNative](value: Visibility) {
|
||||
switch (value) {
|
||||
case Visibility.VISIBLE:
|
||||
this.nativeViewProtected.setVisibility(this.busy ? android.view.View.VISIBLE : android.view.View.INVISIBLE);
|
||||
break;
|
||||
case Visibility.HIDDEN:
|
||||
this.nativeViewProtected.setVisibility(android.view.View.INVISIBLE);
|
||||
break;
|
||||
case Visibility.COLLAPSE:
|
||||
this.nativeViewProtected.setVisibility(android.view.View.GONE);
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Invalid visibility value: ${value}. Valid values are: "${Visibility.VISIBLE}", "${Visibility.HIDDEN}", "${Visibility.COLLAPSE}".`);
|
||||
}
|
||||
}
|
||||
|
||||
[colorProperty.getDefault](): number {
|
||||
return -1;
|
||||
}
|
||||
[colorProperty.setNative](value: number | Color) {
|
||||
if (value instanceof Color) {
|
||||
this.nativeViewProtected.getIndeterminateDrawable().setColorFilter(value.android, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
} else {
|
||||
this.nativeViewProtected.getIndeterminateDrawable().clearColorFilter();
|
||||
}
|
||||
}
|
||||
[colorProperty.getDefault](): number {
|
||||
return -1;
|
||||
}
|
||||
[colorProperty.setNative](value: number | Color) {
|
||||
if (value instanceof Color) {
|
||||
this.nativeViewProtected.getIndeterminateDrawable().setColorFilter(value.android, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
} else {
|
||||
this.nativeViewProtected.getIndeterminateDrawable().clearColorFilter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,18 +4,18 @@
|
||||
* Represents a UI widget which displays a progress indicator hinting the user for some background operation running.
|
||||
*/
|
||||
export class ActivityIndicator extends View {
|
||||
/**
|
||||
* Gets the native [android widget](http://developer.android.com/reference/android/widget/ProgressBar.html) that represents the user interface for this component. Valid only when running on Android OS.
|
||||
*/
|
||||
android: any /* android.widget.ProgressBar */;
|
||||
/**
|
||||
* Gets the native [android widget](http://developer.android.com/reference/android/widget/ProgressBar.html) that represents the user interface for this component. Valid only when running on Android OS.
|
||||
*/
|
||||
android: any /* android.widget.ProgressBar */;
|
||||
|
||||
/**
|
||||
* Gets the native iOS [UIActivityIndicatorView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIActivityIndicatorView_Class/index.html) that represents the user interface for this component. Valid only when running on iOS.
|
||||
*/
|
||||
ios: any /* UIActivityIndicatorView */;
|
||||
/**
|
||||
* Gets the native iOS [UIActivityIndicatorView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIActivityIndicatorView_Class/index.html) that represents the user interface for this component. Valid only when running on iOS.
|
||||
*/
|
||||
ios: any /* UIActivityIndicatorView */;
|
||||
|
||||
/**
|
||||
* Gets or sets a value indicating whether the widget is currently displaying progress.
|
||||
*/
|
||||
busy: boolean;
|
||||
/**
|
||||
* Gets or sets a value indicating whether the widget is currently displaying progress.
|
||||
*/
|
||||
busy: boolean;
|
||||
}
|
||||
|
||||
@@ -8,46 +8,46 @@ export * from './activity-indicator-common';
|
||||
const majorVersion = ios.MajorVersion;
|
||||
|
||||
export class ActivityIndicator extends ActivityIndicatorBase {
|
||||
nativeViewProtected: UIActivityIndicatorView;
|
||||
nativeViewProtected: UIActivityIndicatorView;
|
||||
|
||||
private _activityIndicatorViewStyle = majorVersion <= 12 || !UIActivityIndicatorViewStyle.Medium ? UIActivityIndicatorViewStyle.Gray : UIActivityIndicatorViewStyle.Medium;
|
||||
private _activityIndicatorViewStyle = majorVersion <= 12 || !UIActivityIndicatorViewStyle.Medium ? UIActivityIndicatorViewStyle.Gray : UIActivityIndicatorViewStyle.Medium;
|
||||
|
||||
createNativeView() {
|
||||
const viewStyle = this._activityIndicatorViewStyle;
|
||||
const view = UIActivityIndicatorView.alloc().initWithActivityIndicatorStyle(viewStyle);
|
||||
view.hidesWhenStopped = true;
|
||||
createNativeView() {
|
||||
const viewStyle = this._activityIndicatorViewStyle;
|
||||
const view = UIActivityIndicatorView.alloc().initWithActivityIndicatorStyle(viewStyle);
|
||||
view.hidesWhenStopped = true;
|
||||
|
||||
return view;
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
get ios(): UIActivityIndicatorView {
|
||||
return this.nativeViewProtected;
|
||||
}
|
||||
get ios(): UIActivityIndicatorView {
|
||||
return this.nativeViewProtected;
|
||||
}
|
||||
|
||||
[busyProperty.getDefault](): boolean {
|
||||
if ((<any>this.nativeViewProtected).isAnimating) {
|
||||
return (<any>this.nativeViewProtected).isAnimating();
|
||||
} else {
|
||||
return this.nativeViewProtected.animating;
|
||||
}
|
||||
}
|
||||
[busyProperty.setNative](value: boolean) {
|
||||
let nativeView = this.nativeViewProtected;
|
||||
if (value) {
|
||||
nativeView.startAnimating();
|
||||
} else {
|
||||
nativeView.stopAnimating();
|
||||
}
|
||||
[busyProperty.getDefault](): boolean {
|
||||
if ((<any>this.nativeViewProtected).isAnimating) {
|
||||
return (<any>this.nativeViewProtected).isAnimating();
|
||||
} else {
|
||||
return this.nativeViewProtected.animating;
|
||||
}
|
||||
}
|
||||
[busyProperty.setNative](value: boolean) {
|
||||
let nativeView = this.nativeViewProtected;
|
||||
if (value) {
|
||||
nativeView.startAnimating();
|
||||
} else {
|
||||
nativeView.stopAnimating();
|
||||
}
|
||||
|
||||
if (nativeView.hidesWhenStopped) {
|
||||
this.requestLayout();
|
||||
}
|
||||
}
|
||||
if (nativeView.hidesWhenStopped) {
|
||||
this.requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
[colorProperty.getDefault](): UIColor {
|
||||
return this.nativeViewProtected.color;
|
||||
}
|
||||
[colorProperty.setNative](value: UIColor | Color) {
|
||||
this.nativeViewProtected.color = value instanceof Color ? value.ios : value;
|
||||
}
|
||||
[colorProperty.getDefault](): UIColor {
|
||||
return this.nativeViewProtected.color;
|
||||
}
|
||||
[colorProperty.setNative](value: UIColor | Color) {
|
||||
this.nativeViewProtected.color = value instanceof Color ? value.ios : value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user