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,8 +20,11 @@ class RefreshableDemo extends Panel {
|
||||
width: 30,
|
||||
height: 30,
|
||||
imageBase64: icon_refresh,
|
||||
}).also(v => refreshImage = v),
|
||||
]), {
|
||||
}).also(v => {
|
||||
refreshImage = v
|
||||
}),
|
||||
]),
|
||||
{
|
||||
startAnimation: () => {
|
||||
log('startAnimation')
|
||||
},
|
||||
|
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,11 +129,13 @@ - (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 (CGAffineTransformEqualToTransform(child.transform, CGAffineTransformIdentity)) {
|
||||
if ([child isKindOfClass:[DoricLayoutContainer class]]
|
||||
|| childConfig.widthSpec == DoricLayoutWrapContent
|
||||
|| childConfig.heightSpec == DoricLayoutWrapContent) {
|
||||
@ -152,6 +154,9 @@ - (CGSize)sizeContent:(CGSize)size {
|
||||
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,6 +254,7 @@ - (CGSize)sizeContent:(CGSize)size {
|
||||
childConfig = [DoricLayoutConfig new];
|
||||
}
|
||||
CGSize childSize = CGSizeMake(child.width, child.height);
|
||||
if (CGAffineTransformEqualToTransform(child.transform, CGAffineTransformIdentity)) {
|
||||
if ([child isKindOfClass:[DoricLayoutContainer class]]
|
||||
|| childConfig.widthSpec == DoricLayoutWrapContent
|
||||
|| childConfig.heightSpec == DoricLayoutWrapContent) {
|
||||
@ -264,6 +273,9 @@ - (CGSize)sizeContent:(CGSize)size {
|
||||
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;
|
||||
contentWeight += childConfig.weight;
|
||||
@ -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,6 +386,7 @@ - (CGSize)sizeContent:(CGSize)size {
|
||||
childConfig = [DoricLayoutConfig new];
|
||||
}
|
||||
CGSize childSize = CGSizeMake(child.width, child.height);
|
||||
if (CGAffineTransformEqualToTransform(child.transform, CGAffineTransformIdentity)) {
|
||||
if ([child isKindOfClass:[DoricLayoutContainer class]]
|
||||
|| childConfig.widthSpec == DoricLayoutWrapContent
|
||||
|| childConfig.heightSpec == DoricLayoutWrapContent) {
|
||||
@ -389,6 +405,10 @@ - (CGSize)sizeContent:(CGSize)size {
|
||||
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