Merge branch 'feature/slider' into 'master'
Feature/slider See merge request !23
This commit is contained in:
@@ -8,4 +8,5 @@ export default [
|
||||
'src/EffectsDemo',
|
||||
'src/ImageDemo',
|
||||
'src/ModalDemo',
|
||||
'src/NetworkDemo',
|
||||
]
|
@@ -10,7 +10,7 @@ class ImageDemo extends Panel {
|
||||
layoutConfig: layoutConfig().w(LayoutSpec.AT_MOST),
|
||||
textSize: 30,
|
||||
textColor: Color.WHITE,
|
||||
bgColor: colors[1],
|
||||
bgColor: colors[5],
|
||||
textAlignment: gravity().center(),
|
||||
height: 50,
|
||||
}),
|
||||
@@ -29,18 +29,6 @@ class ImageDemo extends Panel {
|
||||
loadCallback: (ret) => {
|
||||
}
|
||||
}),
|
||||
label('WebP'),
|
||||
image({
|
||||
imageUrl: "https://misc.aotu.io/ONE-SUNDAY/world_cup_2014_42.webp",
|
||||
loadCallback: (ret) => {
|
||||
}
|
||||
}),
|
||||
label('Lossy WebP'),
|
||||
image({
|
||||
imageUrl: "https://misc.aotu.io/ONE-SUNDAY/world_cup_2014_42_lossy.webp",
|
||||
loadCallback: (ret) => {
|
||||
}
|
||||
}),
|
||||
label('ScaleToFill'),
|
||||
image({
|
||||
imageUrl,
|
||||
|
34
demo/src/NetworkDemo.ts
Normal file
34
demo/src/NetworkDemo.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Group, Panel, List, text, gravity, Color, Stack, LayoutSpec, list, NativeCall, listItem, log, vlayout, Gravity, hlayout, Text, scroller, layoutConfig, image, IView, IVLayout, ScaleType, modal, IText, network } from "doric";
|
||||
import { title, label, colors } from "./utils";
|
||||
|
||||
@Entry
|
||||
class NetworkDemo extends Panel {
|
||||
build(rootView: Group): void {
|
||||
scroller(vlayout([
|
||||
title("Network Demo"),
|
||||
label('Click me').apply({
|
||||
width: 200,
|
||||
height: 50,
|
||||
bgColor: colors[0],
|
||||
textSize: 30,
|
||||
textColor: Color.WHITE,
|
||||
layoutConfig: layoutConfig().exactly(),
|
||||
onClick: () => {
|
||||
network(context).get('https://m.baidu.com').then(
|
||||
e => {
|
||||
modal(context).alert(JSON.stringify(e))
|
||||
}
|
||||
).catch(e => {
|
||||
modal(context).toast('Catched:' + JSON.stringify(e))
|
||||
})
|
||||
}
|
||||
} as IText),
|
||||
]).apply({
|
||||
layoutConfig: layoutConfig().atmost().h(LayoutSpec.WRAP_CONTENT),
|
||||
gravity: gravity().center(),
|
||||
space: 10,
|
||||
} as IVLayout)).apply({
|
||||
layoutConfig: layoutConfig().atmost(),
|
||||
}).in(rootView)
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
import { Group, Panel, List, text, gravity, Color, Stack, LayoutSpec, list, NativeCall, listItem, log, vlayout, Gravity, hlayout, slider, slideItem, image, layoutConfig } from "doric";
|
||||
import { Group, Panel, List, text, gravity, Color, Stack, LayoutSpec, list, NativeCall, listItem, log, vlayout, Gravity, hlayout, slider, slideItem, image, layoutConfig, ScaleType } from "doric";
|
||||
import { colors } from "./utils";
|
||||
|
||||
const imageUrls = [
|
||||
@@ -33,7 +33,8 @@ class SliderPanel extends Panel {
|
||||
renderPage: (idx) => {
|
||||
return slideItem(image({
|
||||
imageUrl: imageUrls[idx % imageUrls.length],
|
||||
layoutConfig: layoutConfig().w(LayoutSpec.WRAP_CONTENT).h(LayoutSpec.WRAP_CONTENT).a(gravity().center()),
|
||||
scaleType: ScaleType.ScaleAspectFit,
|
||||
layoutConfig: layoutConfig().w(LayoutSpec.AT_MOST).h(LayoutSpec.AT_MOST).a(gravity().center()),
|
||||
})).also(it => {
|
||||
let start = idx
|
||||
it.onClick = () => {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { Color, text, Stack, Text } from "doric";
|
||||
import { Color, text, Stack, Text, layoutConfig, LayoutSpec, gravity } from "doric";
|
||||
|
||||
export const colors = [
|
||||
"#70a1ff",
|
||||
@@ -33,4 +33,16 @@ export function boxStr(str: string, idx = 0) {
|
||||
it.textColor = Color.WHITE
|
||||
it.bgColor = colors[idx || 0]
|
||||
})
|
||||
}
|
||||
|
||||
export function title(str: string) {
|
||||
return text({
|
||||
text: "Network Demo",
|
||||
layoutConfig: layoutConfig().w(LayoutSpec.AT_MOST),
|
||||
textSize: 30,
|
||||
textColor: Color.WHITE,
|
||||
bgColor: colors[1],
|
||||
textAlignment: gravity().center(),
|
||||
height: 50,
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user