feat:fix transform and layoutcontainer conflict
This commit is contained in:
parent
3c04e7cde1
commit
a41036c91d
@ -1,6 +1,5 @@
|
||||
import { Group, Panel, List, text, gravity, Color, Stack, LayoutSpec, list, NativeCall, listItem, log, vlayout, Gravity, hlayout, Text, refreshable, Refreshable, ListItem } from "doric";
|
||||
import { rotatedArrow, colors } from "./utils";
|
||||
import { isObject } from "util";
|
||||
@Entry
|
||||
class ListPanel extends Panel {
|
||||
build(rootView: Group): void {
|
||||
|
@ -20,18 +20,21 @@ class RefreshableDemo extends Panel {
|
||||
width: 30,
|
||||
height: 30,
|
||||
imageBase64: icon_refresh,
|
||||
}).also(v => refreshImage = v),
|
||||
]), {
|
||||
startAnimation: () => {
|
||||
log('startAnimation')
|
||||
},
|
||||
stopAnimation: () => {
|
||||
log('stopAnimation')
|
||||
},
|
||||
setProgressRotation: (rotation: number) => {
|
||||
refreshImage.setRotation(context, rotation)
|
||||
},
|
||||
}),
|
||||
}).also(v => {
|
||||
refreshImage = v
|
||||
}),
|
||||
]),
|
||||
{
|
||||
startAnimation: () => {
|
||||
log('startAnimation')
|
||||
},
|
||||
stopAnimation: () => {
|
||||
log('stopAnimation')
|
||||
},
|
||||
setProgressRotation: (rotation: number) => {
|
||||
refreshImage.setRotation(context, rotation)
|
||||
},
|
||||
}),
|
||||
content: scroller(vlayout([
|
||||
title("Refreshable Demo"),
|
||||
label('start Refresh').apply({
|
||||
|
File diff suppressed because one or more lines are too long
@ -5,7 +5,7 @@
|
||||
#import "DoricRefreshableNode.h"
|
||||
#import "Doric.h"
|
||||
|
||||
@interface DoricRefreshableNode ()
|
||||
@interface DoricRefreshableNode () <DoricSwipePullingDelegate>
|
||||
@property(nonatomic, strong) DoricViewNode *contentNode;
|
||||
@property(nonatomic, copy) NSString *contentViewId;
|
||||
@property(nonatomic, strong) DoricViewNode *headerNode;
|
||||
@ -14,7 +14,10 @@ @interface DoricRefreshableNode ()
|
||||
|
||||
@implementation DoricRefreshableNode
|
||||
- (DoricSwipeRefreshLayout *)build {
|
||||
return [DoricSwipeRefreshLayout new];
|
||||
return [[DoricSwipeRefreshLayout new] also:^(DoricSwipeRefreshLayout *it) {
|
||||
it.swipePullingDelegate = self;
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)blendView:(DoricSwipeRefreshLayout *)view forPropName:(NSString *)name propValue:(id)prop {
|
||||
@ -138,4 +141,17 @@ - (void)blendHeader {
|
||||
- (void)blendSubNode:(NSDictionary *)subModel {
|
||||
[[self subNodeWithViewId:subModel[@"id"]] blend:subModel[@"props"]];
|
||||
}
|
||||
|
||||
- (void)startAnimation {
|
||||
[self.headerNode callJSResponse:@"startAnimation", nil];
|
||||
}
|
||||
|
||||
- (void)stopAnimation {
|
||||
[self.headerNode callJSResponse:@"stopAnimation", nil];
|
||||
}
|
||||
|
||||
- (void)setProgressRotation:(CGFloat)rotation {
|
||||
[self.headerNode callJSResponse:@"setProgressRotation", @(rotation), nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -129,28 +129,33 @@ - (CGSize)sizeContent:(CGSize)size {
|
||||
if (child.isHidden) {
|
||||
continue;
|
||||
}
|
||||
|
||||
DoricLayoutConfig *childConfig = child.layoutConfig;
|
||||
if (!childConfig) {
|
||||
childConfig = [DoricLayoutConfig new];
|
||||
}
|
||||
CGSize childSize = CGSizeMake(child.width, child.height);
|
||||
if ([child isKindOfClass:[DoricLayoutContainer class]]
|
||||
|| childConfig.widthSpec == DoricLayoutWrapContent
|
||||
|| childConfig.heightSpec == DoricLayoutWrapContent) {
|
||||
childSize = [child sizeThatFits:CGSizeMake(size.width, size.height - contentHeight)];
|
||||
}
|
||||
if (childConfig.widthSpec == DoricLayoutExact) {
|
||||
childSize.width = child.width;
|
||||
} else if (childConfig.widthSpec == DoricLayoutAtMost) {
|
||||
childSize.width = size.width;
|
||||
}
|
||||
if (childConfig.heightSpec == DoricLayoutExact) {
|
||||
childSize.height = child.height;
|
||||
} else if (childConfig.heightSpec == DoricLayoutAtMost) {
|
||||
childSize.height = size.height - contentHeight;
|
||||
}
|
||||
if (childConfig.weight) {
|
||||
childSize.height = child.height;
|
||||
if (CGAffineTransformEqualToTransform(child.transform, CGAffineTransformIdentity)) {
|
||||
if ([child isKindOfClass:[DoricLayoutContainer class]]
|
||||
|| childConfig.widthSpec == DoricLayoutWrapContent
|
||||
|| childConfig.heightSpec == DoricLayoutWrapContent) {
|
||||
childSize = [child sizeThatFits:CGSizeMake(size.width, size.height - contentHeight)];
|
||||
}
|
||||
if (childConfig.widthSpec == DoricLayoutExact) {
|
||||
childSize.width = child.width;
|
||||
} else if (childConfig.widthSpec == DoricLayoutAtMost) {
|
||||
childSize.width = size.width;
|
||||
}
|
||||
if (childConfig.heightSpec == DoricLayoutExact) {
|
||||
childSize.height = child.height;
|
||||
} else if (childConfig.heightSpec == DoricLayoutAtMost) {
|
||||
childSize.height = size.height - contentHeight;
|
||||
}
|
||||
if (childConfig.weight) {
|
||||
childSize.height = child.height;
|
||||
}
|
||||
} else {
|
||||
childSize = child.bounds.size;
|
||||
}
|
||||
contentWidth = MAX(contentWidth, childSize.width + childConfig.margin.left + childConfig.margin.right);
|
||||
contentHeight = MAX(contentHeight, childSize.height + childConfig.margin.top + childConfig.margin.bottom);
|
||||
@ -167,6 +172,9 @@ - (void)layout:(CGSize)targetSize {
|
||||
if (child.isHidden) {
|
||||
continue;
|
||||
}
|
||||
if (!CGAffineTransformEqualToTransform(child.transform, CGAffineTransformIdentity)) {
|
||||
continue;
|
||||
}
|
||||
DoricLayoutConfig *childConfig = child.layoutConfig;
|
||||
if (!childConfig) {
|
||||
childConfig = [DoricLayoutConfig new];
|
||||
@ -246,23 +254,27 @@ - (CGSize)sizeContent:(CGSize)size {
|
||||
childConfig = [DoricLayoutConfig new];
|
||||
}
|
||||
CGSize childSize = CGSizeMake(child.width, child.height);
|
||||
if ([child isKindOfClass:[DoricLayoutContainer class]]
|
||||
|| childConfig.widthSpec == DoricLayoutWrapContent
|
||||
|| childConfig.heightSpec == DoricLayoutWrapContent) {
|
||||
childSize = [child sizeThatFits:CGSizeMake(size.width, size.height - contentHeight)];
|
||||
}
|
||||
if (childConfig.widthSpec == DoricLayoutExact) {
|
||||
childSize.width = child.width;
|
||||
} else if (childConfig.widthSpec == DoricLayoutAtMost) {
|
||||
childSize.width = size.width;
|
||||
}
|
||||
if (childConfig.heightSpec == DoricLayoutExact) {
|
||||
childSize.height = child.height;
|
||||
} else if (childConfig.heightSpec == DoricLayoutAtMost) {
|
||||
childSize.height = size.height - contentHeight;
|
||||
}
|
||||
if (childConfig.weight) {
|
||||
childSize.height = child.height;
|
||||
if (CGAffineTransformEqualToTransform(child.transform, CGAffineTransformIdentity)) {
|
||||
if ([child isKindOfClass:[DoricLayoutContainer class]]
|
||||
|| childConfig.widthSpec == DoricLayoutWrapContent
|
||||
|| childConfig.heightSpec == DoricLayoutWrapContent) {
|
||||
childSize = [child sizeThatFits:CGSizeMake(size.width, size.height - contentHeight)];
|
||||
}
|
||||
if (childConfig.widthSpec == DoricLayoutExact) {
|
||||
childSize.width = child.width;
|
||||
} else if (childConfig.widthSpec == DoricLayoutAtMost) {
|
||||
childSize.width = size.width;
|
||||
}
|
||||
if (childConfig.heightSpec == DoricLayoutExact) {
|
||||
childSize.height = child.height;
|
||||
} else if (childConfig.heightSpec == DoricLayoutAtMost) {
|
||||
childSize.height = size.height - contentHeight;
|
||||
}
|
||||
if (childConfig.weight) {
|
||||
childSize.height = child.height;
|
||||
}
|
||||
} else {
|
||||
childSize = child.bounds.size;
|
||||
}
|
||||
contentWidth = MAX(contentWidth, childSize.width + childConfig.margin.left + childConfig.margin.right);
|
||||
contentHeight += childSize.height + self.space + childConfig.margin.top + childConfig.margin.bottom;
|
||||
@ -294,6 +306,9 @@ - (void)layout:(CGSize)targetSize {
|
||||
if (child.isHidden) {
|
||||
continue;
|
||||
}
|
||||
if (!CGAffineTransformEqualToTransform(child.transform, CGAffineTransformIdentity)) {
|
||||
continue;
|
||||
}
|
||||
DoricLayoutConfig *childConfig = child.layoutConfig;
|
||||
if (!childConfig) {
|
||||
childConfig = [DoricLayoutConfig new];
|
||||
@ -371,24 +386,29 @@ - (CGSize)sizeContent:(CGSize)size {
|
||||
childConfig = [DoricLayoutConfig new];
|
||||
}
|
||||
CGSize childSize = CGSizeMake(child.width, child.height);
|
||||
if ([child isKindOfClass:[DoricLayoutContainer class]]
|
||||
|| childConfig.widthSpec == DoricLayoutWrapContent
|
||||
|| childConfig.heightSpec == DoricLayoutWrapContent) {
|
||||
childSize = [child sizeThatFits:CGSizeMake(size.width - contentWidth, size.height)];
|
||||
}
|
||||
if (childConfig.widthSpec == DoricLayoutExact) {
|
||||
childSize.width = child.width;
|
||||
} else if (childConfig.widthSpec == DoricLayoutAtMost) {
|
||||
childSize.width = size.width - contentWidth;
|
||||
}
|
||||
if (childConfig.heightSpec == DoricLayoutExact) {
|
||||
childSize.height = child.height;
|
||||
} else if (childConfig.heightSpec == DoricLayoutAtMost) {
|
||||
childSize.height = size.height;
|
||||
}
|
||||
if (childConfig.weight) {
|
||||
childSize.width = child.width;
|
||||
if (CGAffineTransformEqualToTransform(child.transform, CGAffineTransformIdentity)) {
|
||||
if ([child isKindOfClass:[DoricLayoutContainer class]]
|
||||
|| childConfig.widthSpec == DoricLayoutWrapContent
|
||||
|| childConfig.heightSpec == DoricLayoutWrapContent) {
|
||||
childSize = [child sizeThatFits:CGSizeMake(size.width - contentWidth, size.height)];
|
||||
}
|
||||
if (childConfig.widthSpec == DoricLayoutExact) {
|
||||
childSize.width = child.width;
|
||||
} else if (childConfig.widthSpec == DoricLayoutAtMost) {
|
||||
childSize.width = size.width - contentWidth;
|
||||
}
|
||||
if (childConfig.heightSpec == DoricLayoutExact) {
|
||||
childSize.height = child.height;
|
||||
} else if (childConfig.heightSpec == DoricLayoutAtMost) {
|
||||
childSize.height = size.height;
|
||||
}
|
||||
if (childConfig.weight) {
|
||||
childSize.width = child.width;
|
||||
}
|
||||
} else {
|
||||
childSize = child.bounds.size;
|
||||
}
|
||||
|
||||
contentWidth += childSize.width + self.space + childConfig.margin.left + childConfig.margin.right;
|
||||
contentHeight = MAX(contentHeight, childSize.height + childConfig.margin.top + childConfig.margin.bottom);
|
||||
contentWeight += childConfig.weight;
|
||||
@ -421,6 +441,9 @@ - (void)layout:(CGSize)targetSize {
|
||||
if (child.isHidden) {
|
||||
continue;
|
||||
}
|
||||
if (!CGAffineTransformEqualToTransform(child.transform, CGAffineTransformIdentity)) {
|
||||
continue;
|
||||
}
|
||||
DoricLayoutConfig *childConfig = child.layoutConfig;
|
||||
if (!childConfig) {
|
||||
childConfig = [DoricLayoutConfig new];
|
||||
|
@ -233,7 +233,11 @@ - (NSNumber *)getHeight {
|
||||
}
|
||||
|
||||
- (void)setRotation:(NSNumber *)rotation {
|
||||
self.view.transform = CGAffineTransformRotate(self.view.transform, M_PI * rotation.floatValue * 2);
|
||||
if (rotation.floatValue == 0) {
|
||||
self.view.transform = CGAffineTransformIdentity;
|
||||
} else {
|
||||
self.view.transform = CGAffineTransformMakeRotation(M_PI * rotation.floatValue * 2);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSNumber *)getRotation {
|
||||
|
@ -3,7 +3,6 @@ import { List } from "./list";
|
||||
import { Scroller } from "./scroller";
|
||||
import { BridgeContext } from "../runtime/global";
|
||||
import { layoutConfig } from "./declarative";
|
||||
import { Image } from "./widgets";
|
||||
|
||||
export interface IRefreshable extends IView {
|
||||
content: List | Scroller
|
||||
|
Reference in New Issue
Block a user