You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2018/04/01 13:09:29 UTC

[1/4] incubator-weex git commit: [WEEX-270][iOS]WXListComponent should add reload type of data update

Repository: incubator-weex
Updated Branches:
  refs/heads/master 28d776877 -> 808c818a0


[WEEX-270][iOS]WXListComponent should add reload type of data update

Currently WXListComponent data update only supports insertRows. This can't be satisfied under some drop-down loading scenes. For example, the pulldown load needs to be positioned to the original position. When the tableView is still decaling and inserts and tries to fix the position, the cell will blink. Because when deceiring, the externally modified contentOffset will be re-edited by the internal implementation of tableView, altering contentOffset alternately will cause flicker problems. If you use the tableView reloadData this is not a problem, so you need to support the WXListComponent in the drop-down restore location scene to add the reload attribute.

feat:270


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/9f75e24e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/9f75e24e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/9f75e24e

Branch: refs/heads/master
Commit: 9f75e24ef14810d5a0fa47b8c10fe7018b35ffc5
Parents: 0bc243d
Author: jianjun.mjj <ji...@alibaba-inc.com>
Authored: Fri Mar 30 09:55:52 2018 +0800
Committer: jianjun.mjj <ji...@alibaba-inc.com>
Committed: Fri Mar 30 09:55:52 2018 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Component/WXListComponent.m | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/9f75e24e/ios/sdk/WeexSDK/Sources/Component/WXListComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXListComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXListComponent.m
index cdf4be2..159f0a4 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXListComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXListComponent.m
@@ -119,6 +119,8 @@
     // Only accessed on main thread
     NSMutableArray<WXSectionComponent *> *_completedSections;
     NSUInteger _previousLoadMoreRowNumber;
+    // insert & reload & batch
+    NSString *_updataType;
     
     BOOL _isUpdating;
     NSMutableArray<void(^)(void)> *_updates;
@@ -131,6 +133,7 @@
         _sections = [NSMutableArray array];
         _completedSections = [NSMutableArray array];
         _reloadInterval = attributes[@"reloadInterval"] ? [WXConvert CGFloat:attributes[@"reloadInterval"]]/1000 : 0;
+        _updataType = [WXConvert NSString:attributes[@"updataType"]]?:@"insert";
         [self fixFlicker];
     }
     
@@ -182,6 +185,9 @@
     if (attributes[@"reloadInterval"]) {
         _reloadInterval = [WXConvert CGFloat:attributes[@"reloadInterval"]] / 1000;
     }
+    if (attributes[@"updataType"]) {
+        _updataType = [WXConvert NSString:attributes[@"updataType"]];
+    }
 }
 
 - (void)setContentSize:(CGSize)contentSize
@@ -899,9 +905,13 @@
 - (void)_insertTableViewCellAtIndexPath:(NSIndexPath *)indexPath keepScrollPosition:(BOOL)keepScrollPosition animation:(UITableViewRowAnimation)animation
 {
     [self _performUpdates:^{
-        [_tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:animation];
+        if ([_updataType  isEqual: @"reload"]) {
+            [_tableView reloadData];
+        } else {
+            [_tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:animation];
+        }
     } withKeepScrollPosition:keepScrollPosition adjustmentBlock:^CGFloat(NSIndexPath *top) {
-        if ([indexPath compare:top] <= 0) {
+        if (([indexPath compare:top] <= 0) || [_updataType  isEqual: @"reload"]) {
             return [self tableView:_tableView heightForRowAtIndexPath:indexPath];
         } else {
             return 0.0;


[3/4] incubator-weex git commit: Merge branch 'im_drop_down' of https://github.com/bbmjja8123/incubator-weex into merge-pull-request-master

Posted by ac...@apache.org.
Merge branch 'im_drop_down' of https://github.com/bbmjja8123/incubator-weex into merge-pull-request-master


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/939bb19f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/939bb19f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/939bb19f

Branch: refs/heads/master
Commit: 939bb19f7e48332de006de3f6401ee8bbbce412a
Parents: 069fea2 c192766
Author: acton393 <zh...@gmail.com>
Authored: Sun Apr 1 21:08:23 2018 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Sun Apr 1 21:08:23 2018 +0800

----------------------------------------------------------------------
 .../WeexSDK/Sources/Component/WXListComponent.m | 14 +++++-
 .../Sources/Component/WXRefreshComponent.h      |  2 +
 .../Sources/Component/WXRefreshComponent.m      | 41 ++++++++++++---
 .../Sources/Component/WXScrollerComponent.m     | 53 +++++++++++++++++++-
 .../Sources/Protocol/WXScrollerProtocol.h       |  1 +
 5 files changed, 100 insertions(+), 11 deletions(-)
----------------------------------------------------------------------



[4/4] incubator-weex git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-weex into merge-pull-request-master

Posted by ac...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-weex into merge-pull-request-master


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/808c818a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/808c818a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/808c818a

Branch: refs/heads/master
Commit: 808c818a003a3317b140f90180df8a8c3a661818
Parents: 939bb19 28d7768
Author: acton393 <zh...@gmail.com>
Authored: Sun Apr 1 21:08:49 2018 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Sun Apr 1 21:08:49 2018 +0800

----------------------------------------------------------------------
 android/playground/app/build.gradle | 4 ++--
 android/sdk/build.gradle            | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------



[2/4] incubator-weex git commit: [WEEX-271][iOS]Extend the pulldown WXRefreshComponent to support immediate load of the appear

Posted by ac...@apache.org.
[WEEX-271][iOS]Extend the pulldown WXRefreshComponent to support immediate load of the appear

WXRefreshComponent current only support the ②, shuold add new type of①.

// ①refreshForAppear: load more when refresh component begin appear(if scroll is dragging or decelerating, should delay)

 // ②refreshForWholeVisible: load more until the whole refresh component visible

NSString *_refreshType;

Improvement:271


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/c1927668
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/c1927668
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/c1927668

Branch: refs/heads/master
Commit: c1927668c72a81981ecf8dcb3046b4237fd8bc86
Parents: 9f75e24
Author: bbmjja8123 <bb...@163.com>
Authored: Fri Mar 30 10:27:05 2018 +0800
Committer: bbmjja8123 <bb...@163.com>
Committed: Fri Mar 30 10:27:05 2018 +0800

----------------------------------------------------------------------
 .../Sources/Component/WXRefreshComponent.h      |  2 +
 .../Sources/Component/WXRefreshComponent.m      | 41 ++++++++++++---
 .../Sources/Component/WXScrollerComponent.m     | 53 +++++++++++++++++++-
 .../Sources/Protocol/WXScrollerProtocol.h       |  1 +
 4 files changed, 88 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c1927668/ios/sdk/WeexSDK/Sources/Component/WXRefreshComponent.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXRefreshComponent.h b/ios/sdk/WeexSDK/Sources/Component/WXRefreshComponent.h
index a2c2b31..5fabfec 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXRefreshComponent.h
+++ b/ios/sdk/WeexSDK/Sources/Component/WXRefreshComponent.h
@@ -31,4 +31,6 @@
 
 - (void)pullingdown:(NSDictionary*)param;
 
+- (void)setIndicatorHidden:(BOOL)hidden;
+
 @end

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c1927668/ios/sdk/WeexSDK/Sources/Component/WXRefreshComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXRefreshComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXRefreshComponent.m
index 67d2602..99876f4 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXRefreshComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXRefreshComponent.m
@@ -148,15 +148,33 @@
     if (scrollerProtocol == nil || !_initFinished)
         return;
     
-    CGPoint offset = [scrollerProtocol contentOffset];
-    if (_displayState) {
-        offset.y = -self.calculatedFrame.size.height;
-        [_indicator start];
+    if ([scrollerProtocol respondsToSelector:@selector(refreshType)] &&
+        [[scrollerProtocol refreshType] isEqualToString:@"refreshForAppear"]) {
+        UIEdgeInsets inset = [scrollerProtocol contentInset];
+        inset.top = self.calculatedFrame.size.height;
+        if (_displayState) {
+            if ([_indicator.view isHidden]) {
+                [_indicator.view setHidden:NO];
+            }
+            [_indicator start];
+        } else {
+            [_indicator stop];
+        }
+        [scrollerProtocol setContentInset:inset];
     } else {
-        offset.y = 0;
-        [_indicator stop];
+        CGPoint offset = [scrollerProtocol contentOffset];
+        if (_displayState) {
+            offset.y = -self.calculatedFrame.size.height;
+            if ([_indicator.view isHidden]) {
+                [_indicator.view setHidden:NO];
+            }
+            [_indicator start];
+        } else {
+            offset.y = 0;
+            [_indicator stop];
+        }
+        [scrollerProtocol setContentOffset:offset animated:YES];
     }
-    [scrollerProtocol setContentOffset:offset animated:YES];
   
 }
 
@@ -165,4 +183,13 @@
     return _displayState;
 }
 
+- (void)setIndicatorHidden:(BOOL)hidden {
+    [_indicator.view setHidden:hidden];
+    if (!hidden) {
+        [_indicator start];
+    } else {
+        [_indicator stop];
+    }
+}
+
 @end

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c1927668/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m
index b0c8dae..c6f13a1 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m
@@ -72,6 +72,10 @@
     BOOL _scrollable;
     NSString * _alwaysScrollableVertical;
     NSString * _alwaysScrollableHorizontal;
+    
+    // refreshForAppear: load more when refresh component begin appear(if scroll is dragging or decelerating, should delay)
+    // refreshForWholeVisible: load more until the whole refresh component visible
+    NSString *_refreshType;
 
     // vertical & horizontal
     WXScrollDirection _scrollDirection;
@@ -132,6 +136,7 @@ WX_EXPORT_METHOD(@selector(resetLoadmore))
         if (attributes[@"alwaysScrollableHorizontal"]) {
             _alwaysScrollableHorizontal = [WXConvert NSString:attributes[@"alwaysScrollableHorizontal"]];
         }
+        _refreshType = [WXConvert NSString:attributes[@"refreshType"]]?:@"refreshForWholeVisible";
         _pagingEnabled = attributes[@"pagingEnabled"] ? [WXConvert BOOL:attributes[@"pagingEnabled"]] : NO;
         _loadMoreOffset = attributes[@"loadmoreoffset"] ? [WXConvert WXPixelType:attributes[@"loadmoreoffset"] scaleFactor:self.weexInstance.pixelScaleFactor] : 0;
         _loadmoreretry = attributes[@"loadmoreretry"] ? [WXConvert NSUInteger:attributes[@"loadmoreretry"]] : 0;
@@ -263,6 +268,11 @@ WX_EXPORT_METHOD(@selector(resetLoadmore))
         _alwaysScrollableVertical = [WXConvert NSString:attributes[@"alwaysScrollableVertical"]];
         ((UIScrollView*)self.view).alwaysBounceVertical = [WXConvert BOOL:_alwaysScrollableVertical];
     }
+    
+    if (attributes[@"refreshType"]) {
+        _refreshType = [WXConvert NSString:attributes[@"refreshType"]];
+    }
+    
     if (attributes[@"offsetAccuracy"]) {
         _offsetAccuracy = [WXConvert WXPixelType:attributes[@"offsetAccuracy"] scaleFactor:self.weexInstance.pixelScaleFactor];
     }
@@ -535,9 +545,18 @@ WX_EXPORT_METHOD(@selector(resetLoadmore))
     return _scrollDirection;
 }
 
+- (NSString*)refreshType
+{
+    return _refreshType;
+}
+
 #pragma mark UIScrollViewDelegate
 - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
 {
+    if ([_refreshType isEqualToString:@"refreshForAppear"] && _refreshComponent) {
+        [_refreshComponent setIndicatorHidden:NO];
+    }
+    
     if (_scrollStartEvent) {
         CGFloat scaleFactor = self.weexInstance.pixelScaleFactor;
         NSDictionary *contentSizeData = @{@"width":[NSNumber numberWithFloat:scrollView.contentSize.width / scaleFactor],@"height":[NSNumber numberWithFloat:scrollView.contentSize.height / scaleFactor]};
@@ -642,14 +661,34 @@ WX_EXPORT_METHOD(@selector(resetLoadmore))
         }
     }
 }
+
+- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
+{
+    if ([_refreshType isEqualToString:@"refreshForAppear"]) {
+        if(targetContentOffset == nil)
+            return;
+        CGPoint offset = *targetContentOffset;
+        if(velocity.y <= 0) {
+            // drop down
+            if( offset.y <= _refreshComponent.calculatedFrame.size.height ) {
+                [self loadMoreIfNeed];
+            }
+        } else if (velocity.y > 0) {
+            // drop up
+        }
+    }
+}
+
 - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
 {
     [_loadingComponent.view setHidden:NO];
     [_refreshComponent.view setHidden:NO];
     
     //refresh
-    if (_refreshComponent && scrollView.contentOffset.y < 0 && scrollView.contentOffset.y + _refreshComponent.calculatedFrame.size.height < _refreshComponent.calculatedFrame.origin.y) {
-        [_refreshComponent refresh];
+    if ([_refreshType isEqualToString:@"refreshForWholeVisible"]) {
+        if (_refreshComponent && scrollView.contentOffset.y < 0 && scrollView.contentOffset.y + _refreshComponent.calculatedFrame.size.height < _refreshComponent.calculatedFrame.origin.y) {
+            [_refreshComponent refresh];
+        }
     }
     
     //loading
@@ -663,6 +702,16 @@ WX_EXPORT_METHOD(@selector(resetLoadmore))
     }
 }
 
+- (void)loadMoreIfNeed
+{
+    WXScrollerComponnetView* scrollView = (WXScrollerComponnetView *)self.view;
+    if (scrollView.isDragging || scrollView.isTracking || scrollView.isDecelerating) {
+        [self performSelector:@selector(loadMoreIfNeed) withObject:nil afterDelay:0.1];
+        return;
+    }
+    [_refreshComponent refresh];
+}
+
 - (void)handleAppear
 {
     if (![self isViewLoaded]) {

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c1927668/ios/sdk/WeexSDK/Sources/Protocol/WXScrollerProtocol.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Protocol/WXScrollerProtocol.h b/ios/sdk/WeexSDK/Sources/Protocol/WXScrollerProtocol.h
index ae8428a..86ec39d 100644
--- a/ios/sdk/WeexSDK/Sources/Protocol/WXScrollerProtocol.h
+++ b/ios/sdk/WeexSDK/Sources/Protocol/WXScrollerProtocol.h
@@ -72,5 +72,6 @@
 
 - (WXScrollDirection)scrollDirection;
 
+- (NSString*)refreshType;
 @end