-
-
Notifications
You must be signed in to change notification settings - Fork 396
fixing android whitespace error #873
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
Conversation
general idea, not tested nor compiled
|
I have made some changes to get this working. Here is a diff, let me know if you want a PR Main change is that the argument is a NOTE: I don't code in ObjC, got Chat GPT to help me make it compile :) So no doubt there is probably a more correct way to do this. But tested and works for me # https://github.com/henninghall/react-native-date-picker/pull/873
diff --git a/src/fabric/RNDatePickerNativeComponent.ts b/src/fabric/RNDatePickerNativeComponent.ts
index 8f9d67e5fdcad8e83c75cdaa861bed777d676951..456439e573260a7c795cba7bcb6a2e4c4b9b4ad0 100644
--- a/src/fabric/RNDatePickerNativeComponent.ts
+++ b/src/fabric/RNDatePickerNativeComponent.ts
@@ -13,9 +13,9 @@ type DateEvent = {
export interface NativeProps extends ViewProps {
locale?: string
- date: Double
- maximumDate?: Double
- minimumDate?: Double
+ date: string
+ maximumDate?: string
+ minimumDate?: string
minuteInterval?: Int32
mode?: WithDefault<'date' | 'time' | 'datetime', 'datetime'>
onChange: BubblingEventHandler<DateEvent>
diff --git a/ios/RNDatePicker.mm b/ios/RNDatePicker.mm
--- a/ios/RNDatePicker.mm
+++ b/ios/RNDatePicker.mm
@@ -48,9 +48,11 @@
}
#endif
-NSDate* unixMillisToNSDate (double unixMillis) {
- double time = unixMillis/1000.0;
- return [NSDate dateWithTimeIntervalSince1970: time];
+NSDate *iso8601StringToNSDate(const std::string &iso8601String) {
+ NSString *nsString = [NSString stringWithUTF8String:iso8601String.c_str()];
+ NSISO8601DateFormatter *isoFormatter = [[NSISO8601DateFormatter alloc] init];
+ NSDate *date = [isoFormatter dateFromString:nsString];
+ return date;
}
#ifdef RCT_NEW_ARCH_ENABLED
@@ -101,7 +103,7 @@
// date
if(oldViewProps.date != newViewProps.date) {
- [_picker setDate: unixMillisToNSDate(newViewProps.date)];
+ [_picker setDate: iso8601StringToNSDate(newViewProps.date)];
}
// locale
@@ -113,12 +115,12 @@
// maximumDate
if(oldViewProps.maximumDate != newViewProps.maximumDate) {
- [_picker setMaximumDate: unixMillisToNSDate(newViewProps.maximumDate)];
+ [_picker setMaximumDate: iso8601StringToNSDate(newViewProps.maximumDate)];
}
// minimumDate
if(oldViewProps.minimumDate != newViewProps.minimumDate) {
- [_picker setMinimumDate: unixMillisToNSDate(newViewProps.minimumDate)];
+ [_picker setMinimumDate: iso8601StringToNSDate(newViewProps.minimumDate)];
}
// setMinuteInterval
diff --git a/ios/RNDatePickerManager.mm b/ios/RNDatePickerManager.mm
--- a/ios/RNDatePickerManager.mm
+++ b/ios/RNDatePickerManager.mm
@@ -36,10 +36,10 @@
}
RCT_EXPORT_VIEW_PROPERTY(text, NSString)
-RCT_EXPORT_VIEW_PROPERTY(date, NSDate)
+RCT_EXPORT_VIEW_PROPERTY(date, NSString)
RCT_EXPORT_VIEW_PROPERTY(locale, NSLocale)
-RCT_EXPORT_VIEW_PROPERTY(minimumDate, NSDate)
-RCT_EXPORT_VIEW_PROPERTY(maximumDate, NSDate)
+RCT_EXPORT_VIEW_PROPERTY(minimumDate, NSString)
+RCT_EXPORT_VIEW_PROPERTY(maximumDate, NSString)
RCT_EXPORT_VIEW_PROPERTY(minuteInterval, NSInteger)
RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
RCT_REMAP_VIEW_PROPERTY(mode, datePickerMode, UIDatePickerMode) |
|
I am waiting for this PR fix. Would greatly appreciate if someone got this completed and merged! |
|
thanks @johnf, this fix is released in v5.0.9 |
|
hey folks, after updating to 5.0.9 (on Paper) i got plenty of issues with the stacktrace below. The app won't crash, it will just stuck and will never display the picker. Downgrading to 5.0.8 fixes the issue. The PR name is very misleading, the changes are on iOS side!! |
Fixes a runtime android error visible on recent version of react native and expo with new architecture enabled.
Fixes #840