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 <[email protected]>
Authored: Fri Mar 30 09:55:52 2018 +0800
Committer: jianjun.mjj <[email protected]>
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;

Reply via email to