mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add command to set date on RCTDatePickerManager
Summary: We are moving away from setNativeProps, this adds necessary method on native to leverage commands API Reviewed By: shergin Differential Revision: D17787877 fbshipit-source-id: 8f06cdd85c96bce4ea9bb7a8cd5f6c1a1d68b20a
This commit is contained in:
committed by
Facebook Github Bot
parent
62cbdceedd
commit
f580409919
@@ -11,6 +11,7 @@
|
||||
#import "RCTDatePicker.h"
|
||||
#import "RCTEventDispatcher.h"
|
||||
#import "UIView+React.h"
|
||||
#import <React/RCTUIManager.h>
|
||||
|
||||
@implementation RCTConvert(UIDatePicker)
|
||||
|
||||
@@ -41,4 +42,22 @@ RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
|
||||
RCT_REMAP_VIEW_PROPERTY(mode, datePickerMode, UIDatePickerMode)
|
||||
RCT_REMAP_VIEW_PROPERTY(timeZoneOffsetInMinutes, timeZone, NSTimeZone)
|
||||
|
||||
RCT_EXPORT_METHOD(setNativeDate : (nonnull NSNumber *)viewTag toDate : (NSDate *)date)
|
||||
{
|
||||
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
UIView *view = viewRegistry[viewTag];
|
||||
|
||||
if ([view isKindOfClass:[RCTDatePicker class]]) {
|
||||
[(RCTDatePicker *)view setDate:date];
|
||||
} else {
|
||||
UIView *subview = view.subviews.firstObject;
|
||||
if ([subview isKindOfClass:[RCTDatePicker class]]) {
|
||||
[(RCTDatePicker *)subview setDate:date];
|
||||
} else {
|
||||
RCTLogError(@"view type must be RCTPicker");
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user