Skip to content

Commit

Permalink
feat(ios): pull header feature to set refresh time (#695)
Browse files Browse the repository at this point in the history
feat(ios): pull header feature to set refresh time
  • Loading branch information
ozonelmy authored Apr 16, 2021
1 parent 74e4f43 commit ea4fb6d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
9 changes: 9 additions & 0 deletions ios/sdk/component/footerrefresh/HippyFooterRefreshManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ @implementation HippyFooterRefreshManager
}
// clang-format on

// clang-format off
HIPPY_EXPORT_METHOD(collapsePullFooterWithOptions : (nonnull NSNumber *)reactTag options:(NSDictionary *)options) {
[self.bridge.uiManager addUIBlock:^(HippyUIManager *uiManager, NSDictionary<NSNumber *, __kindof UIView *> *viewRegistry) {
HippyRefresh *refreshView = viewRegistry[reactTag];
[refreshView refreshFinishWithOption:options];
}];
}
// clang-format on

// clang-format off
HIPPY_EXPORT_METHOD(expandPullFooter : (nonnull NSNumber *)reactTag) {
[self.bridge.uiManager addUIBlock:^(HippyUIManager *uiManager, NSDictionary<NSNumber *, __kindof UIView *> *viewRegistry) {
Expand Down
7 changes: 0 additions & 7 deletions ios/sdk/component/headerrefresh/HippyHeaderRefresh.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,4 @@ - (void)setStatus:(HippyRefreshStatus)status {
}
}

- (void)refreshFinish {
self.status = HippyRefreshStatusFinishLoading;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.status = HippyRefreshStatusIdle;
});
}

@end
9 changes: 9 additions & 0 deletions ios/sdk/component/headerrefresh/HippyHeaderRefreshManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ @implementation HippyHeaderRefreshManager
}
// clang-format on

// clang-format off
HIPPY_EXPORT_METHOD(collapsePullHeaderWithOptions : (nonnull NSNumber *)reactTag options:(NSDictionary *)options) {
[self.bridge.uiManager addUIBlock:^(HippyUIManager *uiManager, NSDictionary<NSNumber *, __kindof UIView *> *viewRegistry) {
HippyRefresh *refreshView = viewRegistry[reactTag];
[refreshView refreshFinishWithOption:options];
}];
}
// clang-format on

- (UIView *)view {
return [[HippyHeaderRefresh alloc] init];
}
Expand Down
1 change: 1 addition & 0 deletions ios/sdk/component/refresh/HippyRefresh.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ typedef NS_ENUM(NSUInteger, HippyRefreshStatus) {

- (void)refresh;
- (void)refreshFinish;
- (void)refreshFinishWithOption:(NSDictionary *)options;

@end
7 changes: 6 additions & 1 deletion ios/sdk/component/refresh/HippyRefresh.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,13 @@ - (void)refresh {
}

- (void)refreshFinish {
[self refreshFinishWithOption:@{@"time": @(2000)}];
}

- (void)refreshFinishWithOption:(NSDictionary *)options {
self.status = HippyRefreshStatusFinishLoading;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
CGFloat time = [options[@"time"] doubleValue] / 1000.f;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(time * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.status = HippyRefreshStatusIdle;
});
}
Expand Down

0 comments on commit ea4fb6d

Please sign in to comment.