WordPress-iOS
                                
                                 WordPress-iOS copied to clipboard
                                
                                    WordPress-iOS copied to clipboard
                            
                            
                            
                        Stats Traffic date picker
Fixes #22382
Add the Stats Traffic date picker.
I have some thoughts on what might need to be changed or improved:
- Shorten the date format, e.g. "Jan 14, 2024 - Jan 20, 2024" is too long
- Improve timezone handling: If it's Saturday in the site's timezone but still Friday night for the user, should the picker allow the user to pick Saturday? I think it make sense but I'll check how WP.com handles this and bring this up for discussion on Slack
[!NOTE] The changes in
SiteStatsDashboardViewController.swiftare just for testing and might be modified before merging.
To test
Enable the feature flag: swipe right on any screen (h/t to @staskus for telling me about this), tap Feature Flags, enable Stats Traffic Tab. Then open the Stats Traffic tab.
Day selection
- Go back and forth between different days
- You shouldn't be able to go to future dates
Week selection
- Switch to "By week"
- Go back and forth between different calendar weeks (Monday to Sunday, inclusive)
- The current week may include future days, but it should prevent you from going to the next week after that
Month selection
- Switch to "By month"
- Go back and forth between different calendar months (e.g. Jan 1-31st)
- The current month may include future days, but it should prevent you from going to the next month after that
Year selection
- Switch to "By year"
- Go back and forth between different calendar years (e.g. Jan 1 to Dec 31, 2024)
- The current year may include future days, but it should prevent you from going to the next year after that
Switching periods
- Switch to "By week"
- Go to a given week
- Switch to "By day"
- The date the picker lands on should be the start of the week shown previously
Regression Notes
- Potential unintended areas of impact
This is a new date picker, not yet integrated into the app. I don't see any potential unintended areas of impact.
- What I did to test those areas of impact (or what existing automated tests I relied on)
Not applicable.
- What automated tests I added (or what prevented me from doing so)
I manually tested the new date picker and added unit tests.
PR submission checklist:
- [x] I have completed the Regression Notes.
- [x] I have considered adding unit tests for my changes.
- [x] I have considered adding accessibility improvements for my changes.
- [x] I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txtif necessary.
UI Changes testing checklist:
- [x] Portrait and landscape orientations.
- [x] Light and dark modes.
- [x] Fonts: Larger, smaller and bold text.
- [x] High contrast.
- [x] VoiceOver.
- [x] Languages with large words or with letters/accents not frequently used in English.
- [x] Right-to-left languages. (Even if translation isnβt complete, formatting should still respect the right-to-left layout)
- [x] iPhone and iPad.
- [ ] Multi-tasking: Split view and Slide over. (iPad)
 π² You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
π² You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
| App Name |  WordPress Alpha | |
| Configuration | Release-Alpha | |
| Build Number | pr22400-18b7d4b | |
| Version | 24.3 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 18b7d4b5b993ba175eef2168360a1679d8be9f44 | |
| App Center Build | WPiOS - One-Offs #8997 | 
 π² You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
π² You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
| App Name |  Jetpack Alpha | |
| Configuration | Release-Alpha | |
| Build Number | pr22400-18b7d4b | |
| Version | 24.3 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 18b7d4b5b993ba175eef2168360a1679d8be9f44 | |
| App Center Build | jetpack-installable-builds #8035 | 
π @staskus, a heads-up: the date picker is working functionally, but visually isn't quite there yet. It also needs localization, testing, etc.
π Thanks for the review comments, @staskus! I should have considered re-using some of the existing logic, so I'll see what can be done there. Yes, you're right about the date format in the designs; it shows how to represent the different periods, so I will update it to match.
I'm going to bump this to the next release because we'll be code freezing 24.3 today and it seems like this has not been approved yet.
It doesn't seem the case, but if it's very important that this makes it into this release, let me know and we'll organize a new beta once ready.
π Hey @staskus, this should be working now. Thanks for all the great feedback; I think I've incorporated it all in.
I added analytics, fixed the design and date formats, connected the date picker to the site's date, and refactored to use the existing date methods.
I haven't gone back and re-tested it all yet. If you have time, I'd appreciate your testing of this, but if not, I'll come back here and re-test everything tomorrow.
I found a corner-case issue that combines these two requirements:
The current month may include future days, but it should prevent you from going to the next month after that The date the picker lands on should be the date you were in beforehand
- Select By month
- Come back a couple of months to November, 2023
- Select By Year
- Confirm 2023 is shown
- Go forward to 2024
- Select by month
- Now the data loads for November, 2024 which is an unexistent future Month
Thanks for catching that. I've made a separate issue for it: https://github.com/wordpress-mobile/jetpack-issue-repo/issues/19
Enabling auto-merge now