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.
Summary
Instead of refreshing the widget data every 5 minutes while running use the
Text(:,style: .timer)
SwiftUI field to show live time information.This will show live information in the correct format by appending a prefix to the dynamically updating text data.
It is not possible to overlay (
ZStack
) the live data with00:00:00
and just set a background color to mask the unneeded0
's because the live updating Text fields are always full width when used in a widget. When setting the background on a full width object, it colors the entire view instead of just the areas with text.Detailed Implementation
Text(:, style: .timer)
shows information in the format of:0:xx
x:xx
xx:xx
x:xx:xx
xx:xx:xx
For the purposes of the existing time metrics and information, all metrics are shown in the
xx:xx:xx
format. To match the full format, when active timers are displayed using the liveText
objects with a prefix of the additional padding.To make sure that the running and paused time formats match and to avoid issues with incorrect prefixes:
00:0
+1:34
=00:01:34
(happy path)00:0
+10:00
=00:010:00
(at ten min transition)Updates are scheduled in advance to change the
TimelineEntry
data when the display format transitions are scheduled to take place.Other Changes
Remove
TimeStatus
and merge directly intoTimeEntry
. Some SwiftUI rendering is processed in advance of actual display (0-30s) so the exact time that aTimeQuantity
will occur (for future measurements) is needed to display all items properly.