From 1d7001e01a34bf4099bb9f3d2de826905b742bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Tue, 13 Jun 2023 15:11:12 +0800 Subject: [PATCH] demo: add SliderStyleDemo --- doric-demo/src/SliderStyleDemo.ts | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 doric-demo/src/SliderStyleDemo.ts diff --git a/doric-demo/src/SliderStyleDemo.ts b/doric-demo/src/SliderStyleDemo.ts new file mode 100644 index 00000000..8bed4d50 --- /dev/null +++ b/doric-demo/src/SliderStyleDemo.ts @@ -0,0 +1,37 @@ +import { Group, Panel, gravity, LayoutSpec, vlayout, slider, slideItem, layoutConfig, modal, stack } from "doric"; +import { colors } from "./utils"; + +@Entry +class SliderStyleDemo extends Panel { + build(rootView: Group): void { + let pager = slider({ + itemCount: 12, + renderPage: (idx) => { + return slideItem(stack([], { + width: Environment.screenWidth * 307 / 375, + height: Environment.screenWidth * 307 / 375 * 520 / 307, + layoutConfig: layoutConfig() + .configWidth(LayoutSpec.JUST) + .configHeight(LayoutSpec.JUST) + .configAlignment(gravity().center()), + backgroundColor: (colors[++idx % colors.length]) + })) + }, + slideStyle: { type: "gallery", minScale: 480 / 520, minAlpha: 0.5, itemWidth: Environment.screenWidth * 307 / 375 }, + layoutConfig: { + widthSpec: LayoutSpec.MOST, + heightSpec: LayoutSpec.MOST, + weight: 1, + } + }) + + rootView.addChild(vlayout([ + pager, + ]).also(it => { + it.layoutConfig = { + widthSpec: LayoutSpec.MOST, + heightSpec: LayoutSpec.MOST, + } + })) + } +} \ No newline at end of file