-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
fixing android whitespace error #873
Draft
henninghall
wants to merge
2
commits into
master
Choose a base branch
from
whitespace-error
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
general idea, not tested nor compiled
henninghall
had a problem deploying
to
e2e Android
December 12, 2024 23:59 — with
GitHub Actions
Failure
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a start to solve issue #840
I have limited internet access until end of januari and wont be able to continue working on this until then.
I encourage anyone to pick it up from here, this is the general idea of the solution I am proposing.
(It is mostly pseudo coding, probably wont compile at this state but you can get the idea)