Skip to content
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

fix: 🐛 use correct formatting for section titles in exercise detail view #62

Conversation

SpacyRicochet
Copy link
Contributor

@SpacyRicochet SpacyRicochet commented Oct 6, 2024

Introduces a relativeString method as a Date extension to perform the necessary formatting

Fixes the headers in the ExerciseDetailView to display correct relative strings for the dates

Adds more set entries to the preview model container for exercises

Specifies two previews for ExerciseDetailView, one for an empty view and one for a view with entries

closes: #36


Notes

After some investigation, I couldn't figure out how to use reference(to:allowedFields:maxFieldCount:thresholdField:) properly, especially since it looks like a very new API which is horribly documented.

Instead, I opted to for a combination of formatters, depending on the difference between now and the section date;

  1. If the section date is today, we specify "Today" to be used. I opted for a localized string here, because the standard relative formatting uses "Now", which doesn't fit as well.
  2. If the section date is three days or less away, we use relative formatting. The three days is arbitrary, but it should be good enough for our purposes.
  3. After that, we show the date without the year. The year is obvious information which doesn't need to be repeated.
  4. Unless it's actually a different year, where it starts making sense to also show the year.

Introduces a relativeString method as a Date extension to perform the necessary formatting

Fixes the headers in the ExerciseDetailView to display correct relative strings for the dates

Adds more set entries to the preview model container for exercises

Specifies two previews for ExerciseDetailView, one for an empty view and one for a view with entries

Refs: heyjaywilson#36
@SpacyRicochet SpacyRicochet changed the title Fix section titles in ExerciseDetailView fix: 🐛 use correct formatting for section titles in exercise detail view Oct 6, 2024
@github-actions github-actions bot changed the title fix: 🐛 use correct formatting for section titles in exercise detail view fix: 🐛 use correct formatting for section titles in exercise detail view Oct 6, 2024
@SpacyRicochet SpacyRicochet changed the title fix: 🐛 use correct formatting for section titles in exercise detail view fix: 🐛 #36 Use correct formatting for section titles in exercise detail view Oct 6, 2024
@heyjaywilson heyjaywilson changed the title fix: 🐛 #36 Use correct formatting for section titles in exercise detail view fix: 🐛 use correct formatting for section titles in exercise detail view Oct 16, 2024
@SpacyRicochet
Copy link
Contributor Author

@heyjaywilson I see that the PR title validation fails, but I can't figure out why exactly. Do you know?

@heyjaywilson
Copy link
Owner

heyjaywilson commented Oct 20, 2024

@SpacyRicochet I adjusted to not include the issue number in the title. That's just a personal preference. I'd rather not have it in the title and close the issue via description.

The title needs to follow conventional commit formatting. So your first title didn't do that. It was Fix section titles... where it should be fix: section titles. Other than that, I have an action that adds the shortcode for the emoji.

@heyjaywilson heyjaywilson merged commit dfc137a into heyjaywilson:main Oct 20, 2024
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Section titles in exercise detail view should not say "in # days" since they were done in the past
3 participants