-
-
Notifications
You must be signed in to change notification settings - Fork 408
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
feat: Add set first day week android #902
feat: Add set first day week android #902
Conversation
…est due to horizontal scroll
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I like this!! :)
especially the detailed description. Makes it delightful to read code when I'm given context and screenshots and so on. Thank you, really :)
<ThemedText style={styles.textLabel}> | ||
firstDayOfWeek (android only) | ||
</ThemedText> | ||
<View style={styles.firstDayOfWeekContainer}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mentioned you needed to add scrolling. Can we make this more compact in terms of height?
I'd prefer if we can avoid scrolling because it's annoying to think about it when maintaining tests.
Also the code seems fit to be replaced by a array.map
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First off, thank you for the lovely comments you've made, they made my day! 😄
Now, with regards to this, Ive implemented a FlatList design for selecting the DAY_OF_WEEK
variable (similar to the "timezone" FlatList further down) but, sadly, it seems most of the tests would still need to have some level of scrolling to access the UI elements... Either way I will push the changes shortly and you can check them out!
I've gone through most of the tests and I think it might be reasonable to implement a "ScrollToElement" function that allows you to scroll to the necessary UI element before interacting with it. This would also reduce the size and repetitiveness of some of the tests and hopefully aid with maintainability. I was thinking of maybe creating a separate PR going over them and addressing some of the issues. Let me know what you think!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me, though if we can avoid scrolling, that'd be best imho. I see that now we run in iphone 14. A low-effort fix could be just bumping to a larger device.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will revert the changes to the tests that add scrolling and see if I can find a valid device for iOS and Android that will pass the tests without scrolling, will get back to you shortly
…tiveness and changed example App firstDayOfWeek selector to a FlatList
# [8.1.0](v8.0.1...v8.1.0) (2024-06-03) ### Features * **android:** enable customizing first day of week ([#902](#902)) ([3b63563](3b63563))
🎉 This issue has been resolved in version 8.1.0 🎉 If this package helps you, consider sponsoring us! 🚀 |
Summary
This feature provides the optional firstDayOfWeek functionality to the DatePicker on Android (currently only available in Windows). I was looking for tasks to get started with in the project and I saw this was a pending issue #196, so I decided to implement it.
Although the issue itself is quite old, hopefully it is still useful for someone.
How did you implement the solution?
As suggested in the issue thread, https://developer.android.com/reference/android/widget/DatePicker#setFirstDayOfWeek(int) provides the functionality to the Android DatePicker so that is what was used to implement it. The rest was simply bridging the props from React Native component to Android.
The
firstDayOfWeek
prop accepts theDAY_OF_WEEK
constant to set the first day of the week.NOTE: The
DAY_OF_WEEK
constant was used for consistency between the original Windows implementation and the new Android one. This does however mean that once the prop is parsed in the Android component it adds a +1 to it since the integers for setFirstDayOfWeek are 1-indexed instead of 0-indexed.closes #196
Test Plan
Some examples of the UI changes when selecting different firstDayOfWeek:
(Ran e2e tests for release on an emulated Pixel 6 Pro with API 30 and phone TZ set to Prague)
What's required for testing (prerequisites)?
e2e tests have been added to the project checking the functionality. These detox tests are only run on Android.
What are the steps to reproduce (after prerequisites)?
I have added a row of buttons to the example App which allow swapping the
firstDayOfWeek
for any day of the week. These are used in the e2e tests. I have also added a line to the upper info section of the example App which shows the currentfirstDayOfWeek
value (defaults to Sunday).Comments
Some of the included changes modify existing e2e tests as they seem to have stopped working due to the UI changes done to the example App. Some of these changes include:
.multiTap(2)
instead of.tap()
to some tests as they occasionally failed. I suspect this is caused by the button trying to be tapped being inside a horizontal scrollview that doesn't finish scrolling before the tap on the button is triggered.As a side note, I have seen that there are a few e2e tests that fail on iOS (even on master) when I test them locally, specifically those that use the
spinner
implementation of theDateTimePicker
.Compatibility
Checklist
README.md
example/App.js
)