Skip to content

Conversation

@IsThisPaul
Copy link
Contributor

@IsThisPaul IsThisPaul commented Apr 6, 2023

Problem 1:
G7 Setting screen shows sensor expiration time as too broad in some situations. (ie. shows "Expires in 1 week" when there are in fact "9 days, 23 hours" remaining

Solution 1:
Update date formatter of sensor expiration timer to use DateComponentsFormatter, formatter.allowedUnits, and formatter.maximumUnitCount to display 2 more appropriate granular date units for more accuracy (ie. "Sensor expires - 8 days, 22 hours" or "4 hours, 27 minutes")

Problem 2:
G7 Setting screen Sensor Start, Sensor Expiration, and Grace Period End displays are a bit difficult to read at a glance as they do not show a day of week or (in the case of locales where it's the standard) AM or PM.

Solution 2:
Update date/time display formatter to include an abbreviated day of week, as well as appropriate 24H or AM/PM display through the setting of formatter.locale, and use of setLocalizedDateFormatFromTemplate to ensure localized display of date and time (setLocalizedDateFormatFromTemplate ensures day and month display in preferred order as well as handles 24hr vs AM/PM display)

moved expiration timer to DateComponentsFormatter to allow more granular control over date units displayed
@ps2
Copy link
Contributor

ps2 commented Apr 21, 2023

Fixes display of sensor expiration timer in G7 settings screen.

Please describe what the problem being fixed here is.

Fixes "expires in 1 week" display on new sensors.

Again, please describe why this is an issue and what is being changed to fix it.


formatter.dateStyle = .short
formatter.timeStyle = .short
formatter.dateFormat = "E, MMM d, h:mm a"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prefer not to specify date formats, so we can benefit from built in iOS locale support. Some locales do not prefer am/pm.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the use of the following satisfy this?:
formatter.locale = Locale.current
formatter.setLocalizedDateFormatFromTemplate("E, MMM d, hh:mm")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work on small screens? Can you please check on iPhone SE?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have an actual SE device to test this on. Simulator doesn't connect to real G7. Open to suggestions or help on how to test on SE.

IsThisPaul and others added 2 commits April 21, 2023 12:58
Set locale and use setLocalizedDateFormatFromTemplate in date formatter for sensor date displays
@IsThisPaul
Copy link
Contributor Author

I've updated the description and pushed a commit to correct (hopefully) the localization issue.

@IsThisPaul IsThisPaul requested a review from ps2 April 25, 2023 17:20
.foregroundColor(color(for: viewModel.progressBarState.labelColor))

Spacer()
var sessionLengthFormatter: DateComponentsFormatter = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View composition shouldn't have significant blocks of non-view code; it makes it harder to see what is layout and what is logic. And the old durationFormatter is still left in the code, unused. Probably better to move the contents of this formatter block up to where durationFormatter was defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this. Moved sessionLengthFormatter out of view. Removed durationFormatter.

Moved sessionLengthFormatter out of view
Removed original durationFormatter
@IsThisPaul IsThisPaul requested a review from ps2 April 26, 2023 20:07
@ps2 ps2 merged commit 3781e2e into LoopKit:main Apr 28, 2023
@ps2
Copy link
Contributor

ps2 commented Apr 28, 2023

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants