Merge branch 'feature/slider' into 'master'

Feature/slider



See merge request !19
This commit is contained in:
pengfeizhou
2019-11-20 19:17:57 +08:00
12 changed files with 203 additions and 44 deletions

View File

@@ -7,4 +7,5 @@ export default [
'src/LayoutDemo',
'src/EffectsDemo',
'src/ImageDemo',
'src/ModalDemo',
]

View File

@@ -13,7 +13,7 @@ class CounterView extends ViewHolder<CountModel> {
text({
textSize: 40,
layoutConfig: {
alignment: new Gravity().center(),
alignment: Gravity.Center,
widthSpec: LayoutSpec.WRAP_CONTENT,
heightSpec: LayoutSpec.WRAP_CONTENT,
},
@@ -27,7 +27,7 @@ class CounterView extends ViewHolder<CountModel> {
},
corners: 5,
layoutConfig: {
alignment: new Gravity().center(),
alignment: Gravity.Center,
widthSpec: LayoutSpec.WRAP_CONTENT,
heightSpec: LayoutSpec.WRAP_CONTENT,
},
@@ -43,9 +43,9 @@ class CounterView extends ViewHolder<CountModel> {
it.width = 200
it.height = 200
it.space = 20
it.gravity = new Gravity().center()
it.gravity = Gravity.Center
it.layoutConfig = {
alignment: new Gravity().center()
alignment: Gravity.Center
}
it.border = {
width: 1,

View File

@@ -1,5 +1,5 @@
import { Group, Panel, Text, text, gravity, Color, Stack, LayoutSpec, vlayout, hlayout, scroller, IVLayout, IHLayout, layoutConfig } from "doric";
import { Group, Panel, Text, text, gravity, Color, Stack, LayoutSpec, vlayout, hlayout, scroller, IVLayout, IHLayout, layoutConfig, Gravity } from "doric";
import { colors } from "./utils";
@@ -14,7 +14,7 @@ function boxStr(str: string, idx = 0) {
return (new Text).also(it => {
it.width = it.height = 20
it.text = str
it.textColor = Color.parse('#ffffff')
it.textColor = Color.WHITE
it.bgColor = colors[idx || 0]
})
}
@@ -38,7 +38,7 @@ class EffectsDemo extends Panel {
width: 100,
height: 100
}),]).apply({
gravity: gravity().center(),
gravity: Gravity.Center,
space: 10,
} as IVLayout),
vlayout([
@@ -56,7 +56,7 @@ class EffectsDemo extends Panel {
bottom: 5,
})
}),]).apply({
gravity: gravity().center(),
gravity: Gravity.Center,
space: 10,
} as IVLayout),
vlayout([
@@ -69,7 +69,7 @@ class EffectsDemo extends Panel {
bottom: 10
})
}),]).apply({
gravity: gravity().center(),
gravity: Gravity.Center,
space: 10,
} as IVLayout),
vlayout([
@@ -88,7 +88,7 @@ class EffectsDemo extends Panel {
bottom: 10
})
}),]).apply({
gravity: gravity().center(),
gravity: Gravity.Center,
space: 10,
} as IVLayout),
]).apply({ space: 20 } as IHLayout),
@@ -109,7 +109,7 @@ class EffectsDemo extends Panel {
bottom: 5,
})
}),]).apply({
gravity: gravity().center(),
gravity: Gravity.Center,
space: 10,
} as IVLayout),
vlayout([
@@ -132,7 +132,7 @@ class EffectsDemo extends Panel {
bottom: 10
})
}),]).apply({
gravity: gravity().center(),
gravity: Gravity.Center,
space: 10,
} as IVLayout),
vlayout([
@@ -152,7 +152,7 @@ class EffectsDemo extends Panel {
bottom: 10
})
}),]).apply({
gravity: gravity().center(),
gravity: Gravity.Center,
space: 10,
} as IVLayout),
vlayout([
@@ -178,7 +178,7 @@ class EffectsDemo extends Panel {
bottom: 5,
})
}),]).apply({
gravity: gravity().center(),
gravity: Gravity.Center,
space: 10,
} as IVLayout),
]).apply({ space: 20 } as IHLayout),
@@ -202,7 +202,7 @@ class EffectsDemo extends Panel {
bottom: 10,
})
}),]).apply({
gravity: gravity().center(),
gravity: Gravity.Center,
space: 10,
} as IVLayout),
vlayout([
@@ -224,7 +224,7 @@ class EffectsDemo extends Panel {
bottom: 10,
})
}),]).apply({
gravity: gravity().center(),
gravity: Gravity.Center,
space: 10,
} as IVLayout),
vlayout([
@@ -246,7 +246,7 @@ class EffectsDemo extends Panel {
bottom: 10,
})
}),]).apply({
gravity: gravity().center(),
gravity: Gravity.Center,
space: 10,
} as IVLayout),
vlayout([
@@ -268,7 +268,7 @@ class EffectsDemo extends Panel {
bottom: 10,
})
}),]).apply({
gravity: gravity().center(),
gravity: Gravity.Center,
space: 10,
} as IVLayout),
]).apply({ space: 20 } as IHLayout),
@@ -285,7 +285,7 @@ class EffectsDemo extends Panel {
bottom: 5,
})
}),]).apply({
gravity: gravity().center(),
gravity: Gravity.Center,
space: 10,
} as IVLayout),
vlayout([
@@ -302,7 +302,7 @@ class EffectsDemo extends Panel {
bottom: 5,
})
}),]).apply({
gravity: gravity().center(),
gravity: Gravity.Center,
space: 10,
} as IVLayout),
vlayout([
@@ -319,7 +319,7 @@ class EffectsDemo extends Panel {
bottom: 5,
})
}),]).apply({
gravity: gravity().center(),
gravity: Gravity.Center,
space: 10,
} as IVLayout),
vlayout([
@@ -336,7 +336,7 @@ class EffectsDemo extends Panel {
bottom: 5,
})
}),]).apply({
gravity: gravity().center(),
gravity: Gravity.Center,
space: 10,
} as IVLayout),
vlayout([
@@ -353,7 +353,7 @@ class EffectsDemo extends Panel {
bottom: 5,
})
}),]).apply({
gravity: gravity().center(),
gravity: Gravity.Center,
space: 10,
} as IVLayout),
]).apply({ space: 20 } as IHLayout),

62
demo/src/ModalDemo.ts Normal file
View File

@@ -0,0 +1,62 @@
import { Group, Panel, List, text, gravity, Color, Stack, LayoutSpec, list, NativeCall, listItem, log, vlayout, Gravity, hlayout, Text, scroller, layoutConfig, image, IView, IVLayout, ScaleType, IText, modal } from "doric";
import { colors, label } from "./utils";
@Entry
class ModalDemo extends Panel {
build(rootView: Group): void {
scroller(vlayout([
text({
text: "Modal",
layoutConfig: layoutConfig().w(LayoutSpec.AT_MOST),
textSize: 30,
textColor: Color.WHITE,
bgColor: colors[1],
textAlignment: Gravity.Center,
height: 50,
}),
label('toast on bottom'),
label('Click me').apply({
width: 200,
height: 50,
bgColor: colors[0],
textSize: 30,
textColor: Color.WHITE,
layoutConfig: layoutConfig().exactly(),
onClick: () => {
modal(context).toast('This is a toast.')
}
} as IText),
label('toast on top'),
label('Click me').apply({
width: 200,
height: 50,
bgColor: colors[0],
textSize: 30,
textColor: Color.WHITE,
layoutConfig: layoutConfig().exactly(),
onClick: () => {
modal(context).toast('This is a toast.', Gravity.Top)
}
} as IText),
label('toast on center'),
label('Click me').apply({
width: 200,
height: 50,
bgColor: colors[0],
textSize: 30,
textColor: Color.WHITE,
layoutConfig: layoutConfig().exactly(),
onClick: () => {
modal(context).toast('This is a toast.', Gravity.Center)
}
} as IText),
]).apply({
layoutConfig: layoutConfig().atmost().h(LayoutSpec.WRAP_CONTENT),
gravity: Gravity.Center,
space: 10,
} as IVLayout)).apply({
layoutConfig: layoutConfig().atmost(),
}).in(rootView)
}
}