RCTRefreshControlManager.m 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #import <React/RCTUIManager.h>
  8. #import "RCTRefreshControl.h"
  9. #import "RCTRefreshControlManager.h"
  10. #import "RCTRefreshableProtocol.h"
  11. @implementation RCTRefreshControlManager
  12. RCT_EXPORT_MODULE()
  13. - (UIView *)view
  14. {
  15. return [RCTRefreshControl new];
  16. }
  17. RCT_EXPORT_VIEW_PROPERTY(onRefresh, RCTDirectEventBlock)
  18. RCT_EXPORT_VIEW_PROPERTY(refreshing, BOOL)
  19. RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor)
  20. RCT_EXPORT_VIEW_PROPERTY(title, NSString)
  21. RCT_EXPORT_VIEW_PROPERTY(titleColor, UIColor)
  22. RCT_EXPORT_METHOD(setNativeRefreshing : (nonnull NSNumber *)viewTag toRefreshing : (BOOL)refreshing)
  23. {
  24. [self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
  25. UIView *view = viewRegistry[viewTag];
  26. if ([view conformsToProtocol:@protocol(RCTRefreshableProtocol)]) {
  27. [(id<RCTRefreshableProtocol>)view setRefreshing:refreshing];
  28. } else {
  29. RCTLogError(@"view must conform to protocol RCTRefreshableProtocol");
  30. }
  31. }];
  32. }
  33. @end