feat:sync lost changes

This commit is contained in:
pengfei.zhou 2019-12-04 18:15:41 +08:00
parent 4a8aaebbc7
commit 82c338bf76
5 changed files with 26 additions and 10 deletions

View File

@ -1,5 +1,5 @@
import { Panel, Group, vlayout, image, layoutConfig, ScaleType, refreshable, Color, pullable, stack, Image, Refreshable, TranslationAnimation, loge, log } from "doric"; import { Panel, Group, vlayout, image, layoutConfig, ScaleType, refreshable, Color, pullable, stack, Image, Refreshable, TranslationAnimation, loge, log, list, listItem, text } from "doric";
import { title, icon_refresh } from "./utils"; import { title, icon_refresh, colors } from "./utils";
@Entry @Entry
class MyDemo extends Panel { class MyDemo extends Panel {
@ -11,7 +11,7 @@ class MyDemo extends Panel {
onRefresh: () => { onRefresh: () => {
refreshed.setRefreshing(context, false) refreshed.setRefreshing(context, false)
}, },
header: pullable(context, header: pullable(
stack([]).apply({ stack([]).apply({
backgroundColor: Color.RED, backgroundColor: Color.RED,
layoutConfig: layoutConfig().exactly(), layoutConfig: layoutConfig().exactly(),
@ -25,11 +25,21 @@ class MyDemo extends Panel {
}, },
setPullingDistance: (distance: number) => { setPullingDistance: (distance: number) => {
headerImage.scaleX = headerImage.scaleY = (headerImage.height + distance * 2) / headerImage.height headerImage.scaleX = headerImage.scaleY = (headerImage.height + distance * 2) / headerImage.height
log(`Header Image scaleY:${headerImage.scaleY},height:${headerImage.height},distance:${distance}`)
}, },
}), }),
content: vlayout([]).apply({ content: list({
backgroundColor: Color.YELLOW, itemCount: 20,
renderItem: (idx) => {
return listItem(text({
text: `Item :${idx}`,
layoutConfig: layoutConfig().exactly(),
width: root.width,
height: 50,
textColor: Color.WHITE,
backgroundColor: colors[idx % colors.length],
}))
}
}).apply({
}), }),
}).apply({ }).apply({
layoutConfig: layoutConfig().atmost(), layoutConfig: layoutConfig().atmost(),

View File

@ -31,6 +31,12 @@ class CounterView extends ViewHolder<CountModel> {
widthSpec: LayoutSpec.WRAP_CONTENT, widthSpec: LayoutSpec.WRAP_CONTENT,
heightSpec: LayoutSpec.WRAP_CONTENT, heightSpec: LayoutSpec.WRAP_CONTENT,
}, },
padding: {
left: 10,
right: 10,
top: 10,
bottom: 10,
},
shadow: { shadow: {
color: Color.parse("#00ff00"), color: Color.parse("#00ff00"),
opacity: 0.5, opacity: 0.5,

View File

@ -91,7 +91,7 @@ class ListPanel extends Panel {
}) })
}) })
}, },
header: rotatedArrow(context), header: rotatedArrow(),
content: list({ content: list({
itemCount: 0, itemCount: 0,
renderItem: () => new ListItem, renderItem: () => new ListItem,

View File

@ -13,7 +13,7 @@ class RefreshableDemo extends Panel {
refreshView.setRefreshing(context, false) refreshView.setRefreshing(context, false)
}, 5000) }, 5000)
}, },
header: pullable(context, header: pullable(
stack([ stack([
image({ image({
layoutConfig: layoutConfig().exactly().m({ top: 50, bottom: 10, }), layoutConfig: layoutConfig().exactly().m({ top: 50, bottom: 10, }),

View File

@ -48,9 +48,9 @@ export function title(str: string) {
}) })
} }
export function rotatedArrow(context: BridgeContext) { export function rotatedArrow() {
let refreshImage: Image let refreshImage: Image
return pullable(context, return pullable(
stack([ stack([
image({ image({
layoutConfig: layoutConfig().exactly().m({ top: 50, bottom: 10, }), layoutConfig: layoutConfig().exactly().m({ top: 50, bottom: 10, }),