feat:add switch for Android and iOS

This commit is contained in:
pengfei.zhou
2020-03-13 13:01:21 +08:00
committed by osborn
parent a6df529f8f
commit 4359eec700
23 changed files with 708 additions and 83 deletions

View File

@@ -42,9 +42,30 @@ export interface IImage extends IView {
imageBase64?: string
scaleType?: ScaleType
isBlur?: boolean
/**
* Display while image is loading
* Local file name
*/
placeHolderImage?: string
/**
* Display while image is loading
* Color
* This priority is lower than placeHolderImage
*/
placeHolderColor?: Color
/**
* Display while image is failed to load
* It can be file name in local path
*/
errorImage?: string
/**
* Display while image is failed to load
* Color
* This priority is lower than errorImage
*/
errorColor?: Color
loadCallback?: (image: { width: number; height: number } | undefined) => void
}
@@ -65,33 +86,15 @@ export class Image extends View implements IImage {
@Property
isBlur?: boolean
/**
* Display while image is loading
* Local file name
*/
@Property
placeHolderImage?: string
/**
* Display while image is loading
* Color
* This priority is lower than placeHolderImage
*/
@Property
placeHolderColor?: Color
/**
* Display while image is failed to load
* It can be file name in local path
*/
@Property
errorImage?: string
/**
* Display while image is failed to load
* Color
* This priority is lower than errorImage
*/
@Property
errorColor?: Color

View File

@@ -23,4 +23,5 @@ export * from './refreshable'
export * from './flowlayout'
export * from './input'
export * from './nestedSlider'
export * from './draggable'
export * from './draggable'
export * from './switch'

View File

@@ -1,3 +1,18 @@
/*
* Copyright [2019] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Superview, View, Property, IView } from "../ui/view";
import { Stack, IStack } from "./layouts";
import { layoutConfig } from "../util/layoutconfig";

View File

@@ -0,0 +1,67 @@
/*
* Copyright [2019] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { View, Property, IView } from "../ui/view";
import { Color } from "../util/color";
import { layoutConfig } from "../util/index.util";
export interface ISwitch extends IView {
/**
* True is on ,false is off,defalut is off.
*/
state?: boolean
/**
* Switch change callback
*/
onSwitch?: (state: boolean) => void
onTintColor?: Color
offTintColor?: Color
thumbTintColor?: Color
}
export class Switch extends View {
/**
* True is on ,false is off,defalut is off.
*/
@Property
state?: boolean
@Property
onSwitch?: (state: boolean) => void
@Property
offTintColor?: Color
@Property
onTintColor?: Color
@Property
thumbTintColor?: Color
}
export function switchView(config: ISwitch) {
const ret = new Switch
ret.layoutConfig = layoutConfig().just()
ret.width = 50
ret.height = 30
for (let key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
}
return ret
}