Skip to content

fix: iOS old architecture crash #906

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

Merged
merged 1 commit into from
Mar 22, 2025
Merged
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
39 changes: 36 additions & 3 deletions ios/RNDatePickerManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,49 @@ @implementation RNDatePickerManager
// Keep: Required for RN built in Event Emitter Calls.
}

- (NSDate *)convertToNSDate:(id)input {
if (!input) return nil;
std::string isoString = [input UTF8String];
NSString *nsString = [NSString stringWithUTF8String:isoString.c_str()];
NSISO8601DateFormatter *isoFormatter = [[NSISO8601DateFormatter alloc] init];
isoFormatter.formatOptions = NSISO8601DateFormatWithInternetDateTime | NSISO8601DateFormatWithFractionalSeconds;
NSDate *date = [isoFormatter dateFromString:nsString];
return date;
}

- (UIView *)view
{
return [RNDatePicker new];
}

RCT_EXPORT_VIEW_PROPERTY(text, NSString)
RCT_EXPORT_VIEW_PROPERTY(date, NSString)

RCT_CUSTOM_VIEW_PROPERTY(date, id, RNDatePicker)
{
NSDate *date = [self convertToNSDate:json];
if (date) {
[(RNDatePicker *)view setDate:date];
}
}

RCT_EXPORT_VIEW_PROPERTY(locale, NSLocale)
RCT_EXPORT_VIEW_PROPERTY(minimumDate, NSString)
RCT_EXPORT_VIEW_PROPERTY(maximumDate, NSString)

RCT_CUSTOM_VIEW_PROPERTY(minimumDate, id, RNDatePicker)
{
NSDate *date = [self convertToNSDate:json];
if (date) {
[(RNDatePicker *)view setMinimumDate:date];
}
}

RCT_CUSTOM_VIEW_PROPERTY(maximumDate, id, RNDatePicker)
{
NSDate *date = [self convertToNSDate:json];
if (date) {
[(RNDatePicker *)view setMaximumDate:date];
}
}

RCT_EXPORT_VIEW_PROPERTY(minuteInterval, NSInteger)
RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
RCT_REMAP_VIEW_PROPERTY(mode, datePickerMode, UIDatePickerMode)
Expand Down
Loading