Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ios): pull header feature to set refresh time #695

Merged
merged 4 commits into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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