chore: cleanup

This commit is contained in:
Nathan Walker
2020-07-06 14:25:11 -07:00
parent 94cf5c4706
commit 6336eac4b5
477 changed files with 59087 additions and 74961 deletions

View File

@@ -1,19 +1,18 @@
import { ActivityIndicator as ActivityIndicatorDefinition } from ".";
import { View, CSSType } from "../core/view";
import { booleanConverter } from "../core/view-base";
import { Property } from "../core/properties";
import { ActivityIndicator as ActivityIndicatorDefinition } from '.';
import { View, CSSType } from '../core/view';
import { booleanConverter } from '../core/view-base';
import { Property } from '../core/properties';
@CSSType("ActivityIndicator")
export class ActivityIndicatorBase extends View
implements ActivityIndicatorDefinition {
public busy: boolean;
@CSSType('ActivityIndicator')
export class ActivityIndicatorBase extends View implements ActivityIndicatorDefinition {
public busy: boolean;
}
ActivityIndicatorBase.prototype.recycleNativeView = "auto";
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);

View File

@@ -1,80 +1,56 @@
import {
ActivityIndicatorBase,
busyProperty,
} from "./activity-indicator-common";
import {
colorProperty,
visibilityProperty,
Visibility,
} from "../styling/style-properties";
import { Color } from "../../color";
import { ActivityIndicatorBase, busyProperty } from './activity-indicator-common';
import { colorProperty, visibilityProperty, Visibility } from '../styling/style-properties';
import { Color } from '../../color';
export * from "./activity-indicator-common";
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();
}
}
}

View File

@@ -1,21 +1,21 @@
import { View } from "../core/view";
import { View } from '../core/view';
/**
* 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;
}

View File

@@ -1,62 +1,53 @@
import {
ActivityIndicatorBase,
busyProperty,
} from "./activity-indicator-common";
import { colorProperty } from "../styling/style-properties";
import { Color } from "../../color";
import { ios } from "../../utils/utils";
import { ActivityIndicatorBase, busyProperty } from './activity-indicator-common';
import { colorProperty } from '../styling/style-properties';
import { Color } from '../../color';
import { ios } from '../../utils';
export * from "./activity-indicator-common";
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;
}
}