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

Add Support for Live Widget Data #26

Merged
merged 5 commits into from
Oct 6, 2020
Merged

Add Support for Live Widget Data #26

merged 5 commits into from
Oct 6, 2020

Conversation

Tornquist
Copy link
Owner

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 with 00:00:00 and just set a background color to mask the unneeded 0'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:

  • Under 1 minute: 0:xx
  • Under 10 minutes: x:xx
  • Under 1 hour: xx:xx
  • Under 10 hours: x:xx:xx
  • Under 100 hours: 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 live Text 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 into TimeEntry. Some SwiftUI rendering is processed in advance of actual display (0-30s) so the exact time that a TimeQuantity will occur (for future measurements) is needed to display all items properly.

In this implementation the displayed value will break at 10 min, 1 hr, and
10 hours and requires the timeline to be reloaded at those points
Store time in all quantity objects for exact offsets. While the refresh dates
are honored for user-facing refreshes, the widgets appear to be loaded 0-30s
in advance which means dynamic Date() offsets in TimeQuantity.activeRelativeDate
will be a few seconds off from the exact measurement.

By storing the date the quantity was measured (or will be measured) tightly
coupled with the value this issue is resolved.
… inside

the actual TimelineEntry, the today TimeQuantity and the week TimeQuantity
@codecov
Copy link

codecov bot commented Oct 4, 2020

Codecov Report

Merging #26 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #26   +/-   ##
=======================================
  Coverage   91.46%   91.46%           
=======================================
  Files          16       16           
  Lines        1676     1676           
=======================================
  Hits         1533     1533           
  Misses        143      143           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81287b1...45ba261. Read the comment docs.

@Tornquist
Copy link
Owner Author

👍

@Tornquist Tornquist merged commit 15beeca into master Oct 6, 2020
@Tornquist Tornquist deleted the live-widget-data branch October 6, 2020 15:01
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.

1 participant