iOS:change the way created item view.
This commit is contained in:
parent
05655972e3
commit
f75a6f8071
@ -119,10 +119,10 @@ public class NavBarPlugin extends DoricJavaPlugin {
|
|||||||
final JSObject jsObject = decoder.decode().asObject();
|
final JSObject jsObject = decoder.decode().asObject();
|
||||||
getDoricContext().getDriver().asyncCall(new Callable<Object>() {
|
getDoricContext().getDriver().asyncCall(new Callable<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public Object call() throws Exception {
|
public Object call() {
|
||||||
String viewId = jsObject.getProperty("id").asString().value();
|
String viewId = jsObject.getProperty("id").asString().value();
|
||||||
String type = jsObject.getProperty("type").asString().value();
|
String type = jsObject.getProperty("type").asString().value();
|
||||||
ViewNode node = ViewNode.create(getDoricContext(), type);
|
ViewNode<?> node = ViewNode.create(getDoricContext(), type);
|
||||||
node.setId(viewId);
|
node.setId(viewId);
|
||||||
node.init(new FrameLayout.LayoutParams(0, 0));
|
node.init(new FrameLayout.LayoutParams(0, 0));
|
||||||
node.blend(jsObject.getProperty("props").asObject());
|
node.blend(jsObject.getProperty("props").asObject());
|
||||||
@ -162,10 +162,10 @@ public class NavBarPlugin extends DoricJavaPlugin {
|
|||||||
final JSObject jsObject = decoder.decode().asObject();
|
final JSObject jsObject = decoder.decode().asObject();
|
||||||
getDoricContext().getDriver().asyncCall(new Callable<Object>() {
|
getDoricContext().getDriver().asyncCall(new Callable<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public Object call() throws Exception {
|
public Object call() {
|
||||||
String viewId = jsObject.getProperty("id").asString().value();
|
String viewId = jsObject.getProperty("id").asString().value();
|
||||||
String type = jsObject.getProperty("type").asString().value();
|
String type = jsObject.getProperty("type").asString().value();
|
||||||
ViewNode node = ViewNode.create(getDoricContext(), type);
|
ViewNode<?> node = ViewNode.create(getDoricContext(), type);
|
||||||
node.setId(viewId);
|
node.setId(viewId);
|
||||||
node.init(new FrameLayout.LayoutParams(0, 0));
|
node.init(new FrameLayout.LayoutParams(0, 0));
|
||||||
node.blend(jsObject.getProperty("props").asObject());
|
node.blend(jsObject.getProperty("props").asObject());
|
||||||
@ -205,10 +205,10 @@ public class NavBarPlugin extends DoricJavaPlugin {
|
|||||||
final JSObject jsObject = decoder.decode().asObject();
|
final JSObject jsObject = decoder.decode().asObject();
|
||||||
getDoricContext().getDriver().asyncCall(new Callable<Object>() {
|
getDoricContext().getDriver().asyncCall(new Callable<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public Object call() throws Exception {
|
public Object call() {
|
||||||
String viewId = jsObject.getProperty("id").asString().value();
|
String viewId = jsObject.getProperty("id").asString().value();
|
||||||
String type = jsObject.getProperty("type").asString().value();
|
String type = jsObject.getProperty("type").asString().value();
|
||||||
ViewNode node = ViewNode.create(getDoricContext(), type);
|
ViewNode<?> node = ViewNode.create(getDoricContext(), type);
|
||||||
node.setId(viewId);
|
node.setId(viewId);
|
||||||
node.init(new FrameLayout.LayoutParams(0, 0));
|
node.init(new FrameLayout.LayoutParams(0, 0));
|
||||||
node.blend(jsObject.getProperty("props").asObject());
|
node.blend(jsObject.getProperty("props").asObject());
|
||||||
|
@ -346,7 +346,7 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection
|
|||||||
[collectionView registerClass:[DoricFlowLayoutViewCell class] forCellWithReuseIdentifier:identifier];
|
[collectionView registerClass:[DoricFlowLayoutViewCell class] forCellWithReuseIdentifier:identifier];
|
||||||
DoricFlowLayoutViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
|
DoricFlowLayoutViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
|
||||||
if (!cell.viewNode) {
|
if (!cell.viewNode) {
|
||||||
DoricFlowLayoutItemNode *itemNode = [[DoricFlowLayoutItemNode alloc] initWithContext:self.doricContext];
|
DoricFlowLayoutItemNode *itemNode = (DoricFlowLayoutItemNode *) [DoricViewNode create:self.doricContext withType:@"FlowLayoutItem"];
|
||||||
[itemNode initWithSuperNode:self];
|
[itemNode initWithSuperNode:self];
|
||||||
cell.viewNode = itemNode;
|
cell.viewNode = itemNode;
|
||||||
[cell.contentView addSubview:itemNode.view];
|
[cell.contentView addSubview:itemNode.view];
|
||||||
|
@ -159,7 +159,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
|
|||||||
DoricTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseId ?: @"doriccell"];
|
DoricTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseId ?: @"doriccell"];
|
||||||
if (!cell) {
|
if (!cell) {
|
||||||
cell = [[DoricTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseId ?: @"doriccell"];
|
cell = [[DoricTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseId ?: @"doriccell"];
|
||||||
DoricListItemNode *listItemNode = [[DoricListItemNode alloc] initWithContext:self.doricContext];
|
DoricListItemNode *listItemNode = (DoricListItemNode *) [DoricViewNode create:self.doricContext withType:@"ListItem"];
|
||||||
[listItemNode initWithSuperNode:self];
|
[listItemNode initWithSuperNode:self];
|
||||||
cell.doricListItemNode = listItemNode;
|
cell.doricListItemNode = listItemNode;
|
||||||
cell.backgroundColor = [UIColor clearColor];
|
cell.backgroundColor = [UIColor clearColor];
|
||||||
|
@ -100,15 +100,15 @@ - (void)blendView:(UICollectionView *)view forPropName:(NSString *)name propValu
|
|||||||
|
|
||||||
- (void)afterBlended:(NSDictionary *)props {
|
- (void)afterBlended:(NSDictionary *)props {
|
||||||
bool needToScroll = (self.propLoop && !self.loop)
|
bool needToScroll = (self.propLoop && !self.loop)
|
||||||
|| (![self.renderPageFuncId isEqualToString: self.propRenderPageFuncId])
|
|| (![self.renderPageFuncId isEqualToString:self.propRenderPageFuncId])
|
||||||
|| (self.itemCount == 0 && self.propItemCount > 0);
|
|| (self.itemCount == 0 && self.propItemCount > 0);
|
||||||
|
|
||||||
// handle item count
|
// handle item count
|
||||||
if (self.itemCount != self.propItemCount) {
|
if (self.itemCount != self.propItemCount) {
|
||||||
self.itemCount = self.propItemCount;
|
self.itemCount = self.propItemCount;
|
||||||
[self.view reloadData];
|
[self.view reloadData];
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle render page
|
// handle render page
|
||||||
if ([self.renderPageFuncId isEqualToString:self.propRenderPageFuncId]) {
|
if ([self.renderPageFuncId isEqualToString:self.propRenderPageFuncId]) {
|
||||||
|
|
||||||
@ -118,15 +118,15 @@ - (void)afterBlended:(NSDictionary *)props {
|
|||||||
[self.view reloadData];
|
[self.view reloadData];
|
||||||
self.renderPageFuncId = self.propRenderPageFuncId;
|
self.renderPageFuncId = self.propRenderPageFuncId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle loop
|
// handle loop
|
||||||
self.loop = self.propLoop;
|
self.loop = self.propLoop;
|
||||||
|
|
||||||
__weak typeof(self) _self = self;
|
__weak typeof(self) _self = self;
|
||||||
if (needToScroll) {
|
if (needToScroll) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
__strong typeof(_self) self = _self;
|
__strong typeof(_self) self = _self;
|
||||||
|
|
||||||
[self.view reloadData];
|
[self.view reloadData];
|
||||||
[self.view setContentOffset:CGPointMake(1 * self.view.width, self.view.contentOffset.y) animated:false];
|
[self.view setContentOffset:CGPointMake(1 * self.view.width, self.view.contentOffset.y) animated:false];
|
||||||
});
|
});
|
||||||
@ -159,7 +159,7 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection
|
|||||||
NSDictionary *props = model[@"props"];
|
NSDictionary *props = model[@"props"];
|
||||||
DoricSliderViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"doricCell" forIndexPath:indexPath];
|
DoricSliderViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"doricCell" forIndexPath:indexPath];
|
||||||
if (!cell.doricSlideItemNode) {
|
if (!cell.doricSlideItemNode) {
|
||||||
DoricSlideItemNode *slideItemNode = [[DoricSlideItemNode alloc] initWithContext:self.doricContext];
|
DoricSlideItemNode *slideItemNode = (DoricSlideItemNode *) [DoricViewNode create:self.doricContext withType:@"SlideItem"];
|
||||||
[slideItemNode initWithSuperNode:self];
|
[slideItemNode initWithSuperNode:self];
|
||||||
cell.doricSlideItemNode = slideItemNode;
|
cell.doricSlideItemNode = slideItemNode;
|
||||||
[cell.contentView addSubview:slideItemNode.view];
|
[cell.contentView addSubview:slideItemNode.view];
|
||||||
@ -272,13 +272,13 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
|
|||||||
- (void)slidePage:(NSDictionary *)params withPromise:(DoricPromise *)promise {
|
- (void)slidePage:(NSDictionary *)params withPromise:(DoricPromise *)promise {
|
||||||
NSUInteger pageIndex = [params[@"page"] unsignedIntegerValue];
|
NSUInteger pageIndex = [params[@"page"] unsignedIntegerValue];
|
||||||
BOOL smooth = [params[@"smooth"] boolValue];
|
BOOL smooth = [params[@"smooth"] boolValue];
|
||||||
|
|
||||||
if (self.loop) {
|
if (self.loop) {
|
||||||
[self.view setContentOffset:CGPointMake((pageIndex + 1) * self.view.width, self.view.contentOffset.y) animated:smooth];
|
[self.view setContentOffset:CGPointMake((pageIndex + 1) * self.view.width, self.view.contentOffset.y) animated:smooth];
|
||||||
} else {
|
} else {
|
||||||
[self.view setContentOffset:CGPointMake(pageIndex * self.view.width, self.view.contentOffset.y) animated:smooth];
|
[self.view setContentOffset:CGPointMake(pageIndex * self.view.width, self.view.contentOffset.y) animated:smooth];
|
||||||
}
|
}
|
||||||
|
|
||||||
[promise resolve:nil];
|
[promise resolve:nil];
|
||||||
self.lastPosition = pageIndex;
|
self.lastPosition = pageIndex;
|
||||||
if (self.onPageSelectedFuncId && self.onPageSelectedFuncId.length > 0) {
|
if (self.onPageSelectedFuncId && self.onPageSelectedFuncId.length > 0) {
|
||||||
|
Reference in New Issue
Block a user