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

@@ -1686,12 +1686,7 @@ var Image = /** @class */ (function (_super) {
], Image.prototype, "placeHolderImage", void 0);
__decorate$4([
Property,
__metadata$4("design:type", Color
/**
* Display while image is failed to load
* It can be file name in local path
*/
)
__metadata$4("design:type", Color)
], Image.prototype, "placeHolderColor", void 0);
__decorate$4([
Property,
@@ -2523,6 +2518,66 @@ function draggable(views, config) {
return ret;
}
var __extends$d = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$d = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") { r = Reflect.decorate(decorators, target, key, desc); }
else { for (var i = decorators.length - 1; i >= 0; i--) { if (d = decorators[i]) { r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; } } }
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata$d = (undefined && undefined.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") { return Reflect.metadata(k, v); }
};
var Switch = /** @class */ (function (_super) {
__extends$d(Switch, _super);
function Switch() {
return _super !== null && _super.apply(this, arguments) || this;
}
__decorate$d([
Property,
__metadata$d("design:type", Boolean)
], Switch.prototype, "state", void 0);
__decorate$d([
Property,
__metadata$d("design:type", Function)
], Switch.prototype, "onSwitch", void 0);
__decorate$d([
Property,
__metadata$d("design:type", Color)
], Switch.prototype, "offTintColor", void 0);
__decorate$d([
Property,
__metadata$d("design:type", Color)
], Switch.prototype, "onTintColor", void 0);
__decorate$d([
Property,
__metadata$d("design:type", Color)
], Switch.prototype, "thumbTintColor", void 0);
return Switch;
}(View));
function switchView(config) {
var ret = new Switch;
ret.layoutConfig = layoutConfig().just();
ret.width = 50;
ret.height = 30;
for (var key in config) {
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
}
return ret;
}
function modal(context) {
return {
toast: function (msg, gravity) {
@@ -3038,7 +3093,7 @@ var Provider = /** @class */ (function () {
return Provider;
}());
var __extends$d = (undefined && undefined.__extends) || (function () {
var __extends$e = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@@ -3079,7 +3134,7 @@ var ViewModel = /** @class */ (function () {
return ViewModel;
}());
var VMPanel = /** @class */ (function (_super) {
__extends$d(VMPanel, _super);
__extends$e(VMPanel, _super);
function VMPanel() {
return _super !== null && _super.apply(this, arguments) || this;
}
@@ -3129,6 +3184,7 @@ exports.SlideItem = SlideItem;
exports.Slider = Slider;
exports.Stack = Stack;
exports.Superview = Superview;
exports.Switch = Switch;
exports.TOP = TOP;
exports.Text = Text;
exports.TranslationAnimation = TranslationAnimation;
@@ -3168,6 +3224,7 @@ exports.slider = slider;
exports.stack = stack;
exports.statusbar = statusbar;
exports.storage = storage;
exports.switchView = switchView;
exports.take = take;
exports.takeAlso = takeAlso;
exports.takeIf = takeIf;

View File

@@ -1252,12 +1252,7 @@ __decorate$4([
], Image.prototype, "placeHolderImage", void 0);
__decorate$4([
Property,
__metadata$4("design:type", Color
/**
* Display while image is failed to load
* It can be file name in local path
*/
)
__metadata$4("design:type", Color)
], Image.prototype, "placeHolderColor", void 0);
__decorate$4([
Property,
@@ -1884,6 +1879,48 @@ function draggable(views, config) {
return ret;
}
var __decorate$d = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata$d = (undefined && undefined.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
class Switch extends View {
}
__decorate$d([
Property,
__metadata$d("design:type", Boolean)
], Switch.prototype, "state", void 0);
__decorate$d([
Property,
__metadata$d("design:type", Function)
], Switch.prototype, "onSwitch", void 0);
__decorate$d([
Property,
__metadata$d("design:type", Color)
], Switch.prototype, "offTintColor", void 0);
__decorate$d([
Property,
__metadata$d("design:type", Color)
], Switch.prototype, "onTintColor", void 0);
__decorate$d([
Property,
__metadata$d("design:type", Color)
], Switch.prototype, "thumbTintColor", void 0);
function switchView(config) {
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;
}
function modal(context) {
return {
toast: (msg, gravity = Gravity.Bottom) => {
@@ -2375,6 +2412,7 @@ exports.SlideItem = SlideItem;
exports.Slider = Slider;
exports.Stack = Stack;
exports.Superview = Superview;
exports.Switch = Switch;
exports.TOP = TOP;
exports.Text = Text;
exports.TranslationAnimation = TranslationAnimation;
@@ -2414,6 +2452,7 @@ exports.slider = slider;
exports.stack = stack;
exports.statusbar = statusbar;
exports.storage = storage;
exports.switchView = switchView;
exports.take = take;
exports.takeAlso = takeAlso;
exports.takeIf = takeIf;

View File

@@ -2711,12 +2711,7 @@ __decorate$4([
], Image.prototype, "placeHolderImage", void 0);
__decorate$4([
Property,
__metadata$4("design:type", Color
/**
* Display while image is failed to load
* It can be file name in local path
*/
)
__metadata$4("design:type", Color)
], Image.prototype, "placeHolderColor", void 0);
__decorate$4([
Property,
@@ -3343,6 +3338,48 @@ function draggable(views, config) {
return ret;
}
var __decorate$d = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata$d = (undefined && undefined.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
class Switch extends View {
}
__decorate$d([
Property,
__metadata$d("design:type", Boolean)
], Switch.prototype, "state", void 0);
__decorate$d([
Property,
__metadata$d("design:type", Function)
], Switch.prototype, "onSwitch", void 0);
__decorate$d([
Property,
__metadata$d("design:type", Color)
], Switch.prototype, "offTintColor", void 0);
__decorate$d([
Property,
__metadata$d("design:type", Color)
], Switch.prototype, "onTintColor", void 0);
__decorate$d([
Property,
__metadata$d("design:type", Color)
], Switch.prototype, "thumbTintColor", void 0);
function switchView(config) {
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;
}
function modal(context) {
return {
toast: (msg, gravity = Gravity.Bottom) => {
@@ -3969,6 +4006,7 @@ exports.SlideItem = SlideItem;
exports.Slider = Slider;
exports.Stack = Stack;
exports.Superview = Superview;
exports.Switch = Switch;
exports.TOP = TOP;
exports.Text = Text;
exports.TranslationAnimation = TranslationAnimation;
@@ -4008,6 +4046,7 @@ exports.slider = slider;
exports.stack = stack;
exports.statusbar = statusbar;
exports.storage = storage;
exports.switchView = switchView;
exports.take = take;
exports.takeAlso = takeAlso;
exports.takeIf = takeIf;

60
doric-js/index.d.ts vendored
View File

@@ -78,6 +78,7 @@ declare module 'doric/lib/src/widget/index.widget' {
export * from 'doric/lib/src/widget/input';
export * from 'doric/lib/src/widget/nestedSlider';
export * from 'doric/lib/src/widget/draggable';
export * from 'doric/lib/src/widget/switch';
}
declare module 'doric/lib/src/native/index.native' {
@@ -498,21 +499,6 @@ declare module 'doric/lib/src/widget/image' {
imageBase64?: string;
scaleType?: ScaleType;
isBlur?: boolean;
placeHolderImage?: string;
placeHolderColor?: Color;
errorImage?: string;
errorColor?: Color;
loadCallback?: (image: {
width: number;
height: number;
} | undefined) => void;
}
export class Image extends View implements IImage {
imageUrl?: string;
imagePath?: string;
imageRes?: string;
scaleType?: ScaleType;
isBlur?: boolean;
/**
* Display while image is loading
* Local file name
@@ -540,6 +526,21 @@ declare module 'doric/lib/src/widget/image' {
height: number;
} | undefined) => void;
}
export class Image extends View implements IImage {
imageUrl?: string;
imagePath?: string;
imageRes?: string;
scaleType?: ScaleType;
isBlur?: boolean;
placeHolderImage?: string;
placeHolderColor?: Color;
errorImage?: string;
errorColor?: Color;
loadCallback?: (image: {
width: number;
height: number;
} | undefined) => void;
}
export function image(config: IImage): Image;
}
@@ -811,6 +812,35 @@ declare module 'doric/lib/src/widget/draggable' {
export function draggable(views: View | View[], config?: IDraggable): Draggable;
}
declare module 'doric/lib/src/widget/switch' {
import { View, IView } from "doric/lib/src/ui/view";
import { Color } from "doric/lib/src/util/color";
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.
*/
state?: boolean;
onSwitch?: (state: boolean) => void;
offTintColor?: Color;
onTintColor?: Color;
thumbTintColor?: Color;
}
export function switchView(config: ISwitch): Switch;
}
declare module 'doric/lib/src/native/modal' {
import { BridgeContext } from "doric/lib/src/runtime/global";
import { Gravity } from "doric/lib/src/util/gravity";

View File

@@ -22,21 +22,6 @@ export interface IImage extends IView {
imageBase64?: string;
scaleType?: ScaleType;
isBlur?: boolean;
placeHolderImage?: string;
placeHolderColor?: Color;
errorImage?: string;
errorColor?: Color;
loadCallback?: (image: {
width: number;
height: number;
} | undefined) => void;
}
export declare class Image extends View implements IImage {
imageUrl?: string;
imagePath?: string;
imageRes?: string;
scaleType?: ScaleType;
isBlur?: boolean;
/**
* Display while image is loading
* Local file name
@@ -64,4 +49,19 @@ export declare class Image extends View implements IImage {
height: number;
} | undefined) => void;
}
export declare class Image extends View implements IImage {
imageUrl?: string;
imagePath?: string;
imageRes?: string;
scaleType?: ScaleType;
isBlur?: boolean;
placeHolderImage?: string;
placeHolderColor?: Color;
errorImage?: string;
errorColor?: Color;
loadCallback?: (image: {
width: number;
height: number;
} | undefined) => void;
}
export declare function image(config: IImage): Image;

View File

@@ -59,12 +59,7 @@ __decorate([
], Image.prototype, "placeHolderImage", void 0);
__decorate([
Property,
__metadata("design:type", Color
/**
* Display while image is failed to load
* It can be file name in local path
*/
)
__metadata("design:type", Color)
], Image.prototype, "placeHolderColor", void 0);
__decorate([
Property,

View File

@@ -9,3 +9,4 @@ export * from './flowlayout';
export * from './input';
export * from './nestedSlider';
export * from './draggable';
export * from './switch';

View File

@@ -24,3 +24,4 @@ export * from './flowlayout';
export * from './input';
export * from './nestedSlider';
export * from './draggable';
export * from './switch';

View File

@@ -7,6 +7,21 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
/*
* 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 } from "../ui/view";
import { Stack } from "./layouts";
import { layoutConfig } from "../util/layoutconfig";

26
doric-js/lib/src/widget/switch.d.ts vendored Normal file
View File

@@ -0,0 +1,26 @@
import { View, IView } from "../ui/view";
import { Color } from "../util/color";
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 declare class Switch extends View {
/**
* True is on ,false is off,defalut is off.
*/
state?: boolean;
onSwitch?: (state: boolean) => void;
offTintColor?: Color;
onTintColor?: Color;
thumbTintColor?: Color;
}
export declare function switchView(config: ISwitch): Switch;

View File

@@ -0,0 +1,59 @@
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
/*
* 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 } from "../ui/view";
import { Color } from "../util/color";
import { layoutConfig } from "../util/index.util";
export class Switch extends View {
}
__decorate([
Property,
__metadata("design:type", Boolean)
], Switch.prototype, "state", void 0);
__decorate([
Property,
__metadata("design:type", Function)
], Switch.prototype, "onSwitch", void 0);
__decorate([
Property,
__metadata("design:type", Color)
], Switch.prototype, "offTintColor", void 0);
__decorate([
Property,
__metadata("design:type", Color)
], Switch.prototype, "onTintColor", void 0);
__decorate([
Property,
__metadata("design:type", Color)
], Switch.prototype, "thumbTintColor", void 0);
export function switchView(config) {
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;
}

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
}