cxfeng1 closed pull request #1813: [WEEX-657][iOS] Add a feature to control the 
offset of list attach to…
URL: https://github.com/apache/incubator-weex/pull/1813
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ios/sdk/WeexSDK/Sources/Component/WXListComponent.mm 
b/ios/sdk/WeexSDK/Sources/Component/WXListComponent.mm
index 854aa3a893..f98f9115d9 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXListComponent.mm
+++ b/ios/sdk/WeexSDK/Sources/Component/WXListComponent.mm
@@ -32,6 +32,14 @@
 #import "WXLoadingComponent.h"
 #import "WXScrollerComponent+Layout.h"
 
+@interface WXListComponent () <UITableViewDataSource, UITableViewDelegate, 
WXCellRenderDelegate, WXHeaderRenderDelegate>
+
+@property (nonatomic, assign) NSUInteger currentTopVisibleSection;
+// Set whether the content offset position all the way to the bottom
+@property (assign, nonatomic) BOOL contentAttachBottom;
+
+@end
+
 @interface WXTableView : UITableView
 
 @end
@@ -79,6 +87,18 @@ - (void)setContentOffset:(CGPoint)contentOffset
     [super setContentOffset:contentOffset];
 }
 
+- (void)setFrame:(CGRect)frame {
+    [super setFrame:frame];
+    if (![self.wx_component isKindOfClass:[WXListComponent class]]) return;
+    BOOL contentAttachBottom = [(WXListComponent *)self.wx_component 
contentAttachBottom];
+    if (contentAttachBottom) {
+        CGFloat offsetHeight = self.contentSize.height - 
CGRectGetHeight(self.bounds);
+        if (offsetHeight >= 0) {
+            [self setContentOffset:CGPointMake(0, offsetHeight) animated:NO];
+        }
+    }
+}
+
 @end
 
 // WXText is a non-public is not permitted
@@ -115,12 +135,6 @@ - (NSString *)description
 }
 @end
 
-@interface WXListComponent () <UITableViewDataSource, UITableViewDelegate, 
WXCellRenderDelegate, WXHeaderRenderDelegate>
-
-@property (nonatomic, assign) NSUInteger currentTopVisibleSection;
-
-@end
-
 @implementation WXListComponent
 {
     __weak UITableView * _tableView;
@@ -145,6 +159,7 @@ - (instancetype)initWithRef:(NSString *)ref type:(NSString 
*)type styles:(NSDict
         _completedSections = [NSMutableArray array];
         _reloadInterval = attributes[@"reloadInterval"] ? [WXConvert 
CGFloat:attributes[@"reloadInterval"]]/1000 : 0;
         _updataType = [WXConvert 
NSString:attributes[@"updataType"]]?:@"insert";
+        _contentAttachBottom = [WXConvert 
BOOL:attributes[@"contentAttachBottom"]];
         [self fixFlicker];
     }
     
@@ -199,6 +214,9 @@ - (void)updateAttributes:(NSDictionary *)attributes
     if (attributes[@"updataType"]) {
         _updataType = [WXConvert NSString:attributes[@"updataType"]];
     }
+    if (attributes[@"contentAttachBottom"]) {
+        _contentAttachBottom = [WXConvert 
BOOL:attributes[@"contentAttachBottom"]];
+    }
 }
 
 - (void)setContentSize:(CGSize)contentSize


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to