本文整理匯總了TypeScript中tns-core-modules/ui/core/view.Property類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Property類的具體用法?TypeScript Property怎麽用?TypeScript Property使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Property類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
/// <reference path="./and-ts-lib/types.d.ts" />
import { WebImageCommon, srcProperty, isLoadingProperty } from './web-image-cache.common';
import { StretchMapping as stretchMap } from './and-ts-lib/stretch-mapping';
import { Helpers as helpers } from './and-ts-lib/helpers';
import * as application from 'tns-core-modules/application';
import * as appSettings from 'tns-core-modules/application-settings';
import { Property, booleanConverter } from 'tns-core-modules/ui/core/view';
let roundedProperty = new Property<WebImageCommon, boolean>({
name: "rounded",
defaultValue: false,
valueConverter: booleanConverter,
affectsLayout: true
}),
placeholderProperty = new Property<WebImageCommon, string>({
name: "placeholder",
defaultValue: undefined,
valueConverter: function(v) {
return v;
},
affectsLayout: true
}),
placeholderStretchProperty = new Property<WebImageCommon, string>({
name: "placeholderStretch",
defaultValue: stretchMap.get('none'),
valueConverter: function(v) {
return v;
},
affectsLayout: true
示例2: constructor
import { View, Property } from 'tns-core-modules/ui/core/view';
export class GifCommon extends View {
public src: string;
constructor() {
super();
}
}
export const srcProperty = new Property<GifCommon, string>({
name: 'src',
defaultValue: ''
});
srcProperty.register(GifCommon);
export const headersProperty = new Property<GifCommon, any>({
name: 'headers'
});
headersProperty.register(GifCommon);
export const isLoadingProperty = new Property<GifCommon, boolean>({
name: 'isLoading',
defaultValue: false
});
isLoadingProperty.register(GifCommon);
示例3:
import { Property, View } from 'tns-core-modules/ui/core/view';
import { Stretch } from 'tns-core-modules/ui/enums';
export const imageUriProperty = new Property<ImageCacheItBase, any>({
name: 'imageUri'
});
export const placeHolderProperty = new Property<ImageCacheItBase, string>({
name: 'placeHolder'
});
export const errorHolderProperty = new Property<ImageCacheItBase, string>({
name: 'errorHolder'
});
export const resizeProperty = new Property<ImageCacheItBase, string>({
name: 'resize'
});
export const stretchProperty = new Property<ImageCacheItBase, Stretch>({
name: 'stretch'
});
export class ImageCacheItBase extends View {
public imageUri: any;
public placeHolder: string;
public errorHolder: string;
public resize: string;
public stretch: Stretch;
}
export type Stretch = 'none' | 'fill' | 'aspectFill' | 'aspectFit';
imageUriProperty.register(ImageCacheItBase);
placeHolderProperty.register(ImageCacheItBase);
errorHolderProperty.register(ImageCacheItBase);
示例4: isAvailable
cameraPosition: CameraPositionType;
saveToGallery: boolean;
quality: Quality;
thumbnailCount: number;
fill: boolean;
public static isAvailable(): boolean {
return false;
}
public static requestPermissions(explanation?: string): Promise<any> {
return Promise.resolve();
}
}
export const fillProperty = new Property<AdvancedVideoViewBase, boolean>({
name: 'fill',
defaultValue: false
});
export const thumbnailCountProperty = new Property<AdvancedVideoViewBase, number>({
name: 'thumbnailCount',
defaultValue: 1
});
export const qualityProperty = new Property<AdvancedVideoViewBase, any>({
name: 'quality',
defaultValue: Quality.MAX_480P
});
export const cameraPositionProperty = new Property<AdvancedVideoViewBase,
CameraPositionType>({
name: 'cameraPosition',
defaultValue: 'back'
});
示例5: boolParse
export function boolParse(value: any) {
if (types.isString(value)) {
switch (value.toLowerCase()) {
case 'yes':
return true;
default:
return false;
}
} else if (types.isBoolean(value)) {
return value;
}
return false;
}
export const srcProperty = new Property<TNSPSPDFView, string>({
name: 'src'
});
export const documentTitleProperty = new Property<TNSPSPDFView, string>({
name: 'documentTitle'
});
export const selectedIndexProperty = new Property<TNSPSPDFView, number>({
name: 'selectedIndex',
defaultValue: 0
});
export class TNSPSPDFView extends View {
src: string;
progress: number;
documentTitle: string;
selectedIndex: number;
示例6: constructor
import { View, Property } from "tns-core-modules/ui/core/view";
import * as utils from "tns-core-modules/utils/utils";
import * as types from "tns-core-modules/utils/types"
// This is used for definition purposes only, it does not generate JavaScript for it.
import * as definition from "./svg";
var SRC = "src";
var IMAGE_SOURCE = "imageSource";
var LOAD_MODE = "loadMode";
var SYNC = "sync";
var ASYNC = "async";
var ISLOADING = "isLoading";
export const srcProperty = new Property<SVGImage, boolean>({ name: SRC, defaultValue: undefined, valueChanged: (target, oldValue, newValue) => target._createImageSourceFromSrc() });
export const imageSourceProperty = new Property<SVGImage, definition.ImageSourceSVG>({ name: IMAGE_SOURCE, defaultValue: undefined });
export const isLoadingProperty = new Property<SVGImage, boolean>({ name: ISLOADING, defaultValue: false });
export const loadModeProperty = new Property<SVGImage, string>({ name: LOAD_MODE, defaultValue: SYNC });
export class SVGImage extends View implements definition.SVGImage {
src: any;
imageSource: definition.ImageSourceSVG;
isLoading: boolean;
loadMode: "sync" | "async";
constructor(options?: definition.Options) {
// super(options);
super();
}
/**