Skip to content

Commit

Permalink
#310: Improved accessoryInline Complication. Renders the BG values no…
Browse files Browse the repository at this point in the history
…w even if there is not much space. For watchfaces with enough space, the age of the bg value is displayed as well. Optimized for iOS 18.
  • Loading branch information
dhermanns committed Oct 23, 2024
1 parent 93287ae commit 94b5db1
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 87 deletions.
Binary file added .DS_Store
Binary file not shown.
48 changes: 23 additions & 25 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ GEM
base64
nkf
rexml
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.932.0)
aws-sdk-core (3.196.1)
aws-partitions (1.968.0)
aws-sdk-core (3.201.5)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.81.0)
aws-sdk-core (~> 3, >= 3.193.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.151.0)
aws-sdk-core (~> 3, >= 3.194.0)
aws-sdk-kms (1.88.0)
aws-sdk-core (~> 3, >= 3.201.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.159.0)
aws-sdk-core (~> 3, >= 3.201.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.8)
aws-sigv4 (1.8.0)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.9.1)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
base64 (0.2.0)
Expand Down Expand Up @@ -61,15 +61,15 @@ GEM
faraday-httpclient (1.0.1)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (1.0.1)
faraday-net_http (1.0.2)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday (~> 1.0)
fastimage (2.3.1)
fastlane (2.220.0)
fastlane (2.222.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
Expand Down Expand Up @@ -148,14 +148,14 @@ GEM
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
highline (2.0.3)
http-cookie (1.0.5)
http-cookie (1.0.7)
domain_name (~> 0.5)
httpclient (2.8.3)
jmespath (1.6.2)
json (2.7.2)
jwt (2.8.1)
jwt (2.8.2)
base64
mini_magick (4.12.0)
mini_magick (4.13.2)
mini_mime (1.1.5)
multi_json (1.15.0)
multipart-post (2.4.1)
Expand All @@ -165,15 +165,15 @@ GEM
optparse (0.5.0)
os (1.1.4)
plist (3.7.1)
public_suffix (5.0.5)
public_suffix (5.1.1)
rake (13.2.1)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.2.8)
strscan (>= 3.0.9)
rexml (3.3.6)
strscan
rouge (2.0.7)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
Expand All @@ -196,18 +196,16 @@ GEM
tty-spinner (0.9.3)
tty-cursor (~> 0.7)
uber (0.1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.9.1)
unf (0.2.0)
unicode-display_width (2.5.0)
word_wrap (1.0.0)
xcodeproj (1.24.0)
xcodeproj (1.25.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)
rexml (>= 3.3.2, < 4.0)
xcpretty (0.3.0)
rouge (~> 2.0.7)
xcpretty-travis-formatter (1.0.1)
Expand Down
8 changes: 4 additions & 4 deletions fastlane/Appfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ apple_id("[email protected]") # Your Apple email address

# You can uncomment the lines below and add your own
# team selection in case you're in multiple teams
team_name "etrada GmbH"
team_id "118795774"
team_name "SPORTMEO LTD"
team_id "127329692"

itc_team_name "etrada GmbH"
itc_team_id "118795774"
itc_team_name "SPORTMEO LTD"
itc_team_id "127329692"

# For more information about the Appfile, see:
# https://docs.fastlane.tools/advanced/#appfile
2 changes: 1 addition & 1 deletion nightguard Complication/nightguard_Complication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct NightguardEntryView : View {

@Environment(\.widgetFamily) var widgetFamily
var entry: NightscoutDataEntry

var body: some View {
switch widgetFamily {
case .accessoryCorner:
Expand Down
2 changes: 1 addition & 1 deletion nightguard WatchKit App/ExtensionDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ class ExtensionDelegate: NSObject, WKApplicationDelegate {
func applicationDidBecomeActive() {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
AppState.isUIActive = true
NotificationCenter.default.post(name: .refreshDataOnAppBecameActive, object: nil)
}

func applicationWillEnterForeground() {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
NotificationCenter.default.post(name: .refreshDataOnAppBecameActive, object: nil)
}

func applicationWillResignActive() {
Expand Down
2 changes: 1 addition & 1 deletion nightguard WatchKit App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>904</string>
<string>911</string>
<key>CLKComplicationPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).ComplicationController</string>
<key>NSAppTransportSecurity</key>
Expand Down
19 changes: 1 addition & 18 deletions nightguard WatchKit App/views/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ struct MainView: View {
init(mainViewModel: MainViewModel) {

self.viewModel = mainViewModel

//UserDefaultsRepository.units.value = Units.mmol
updateUnits()
viewModel.refreshData(forceRefresh: true, moveToLatestValue: true)
}

Expand All @@ -52,7 +49,7 @@ struct MainView: View {
}

var body: some View {
// TimelineView(EveryMinuteTimelineSchedule()) { context in

VStack() {
HStack(spacing: 5, content: {
Text(UnitsConverter.mgdlToDisplayUnits(
Expand Down Expand Up @@ -205,20 +202,6 @@ struct MainView: View {
.onReceive(refreshDataOnAppBecameActiveNotification) { _ in
viewModel.refreshData(forceRefresh: false, moveToLatestValue: false)
}
//}
}

fileprivate func updateUnits() {

/*NightscoutService.singleton.readStatus { (result: NightscoutRequestResult<Units>) in

switch result {
case .data(let units):
UserDefaultsRepository.units.value = units
case .error(_):
print("Unable to determine units on the watch. Using the synced values from the ios app.")
}
}*/
}
}

Expand Down
2 changes: 1 addition & 1 deletion nightguard Widget Extension/AccessoryCircularView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct AccessoryCircularView : View {
Text("\(calculateAgeInMinutes(fromDouble: entry.lastBGValues.first?.timestamp ?? Date.now.timeIntervalSinceNow-3600))m")
Text("\(entry.lastBGValues.first?.value ?? "??")")
.foregroundColor(
Color(UIColorChanger.getBgColor(entry.lastBGValues.first?.value ?? "999")))
Color.cyan)
Text("\(entry.lastBGValues.first?.delta ?? "?")")
.foregroundColor(
Color(UIColorChanger.getDeltaLabelColor(Float(entry.lastBGValues.first?.delta ?? "99") ?? 99.0)))
Expand Down
18 changes: 15 additions & 3 deletions nightguard Widget Extension/AccessoryInlineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,21 @@ struct AccessoryInlineView : View {
var entry: NightscoutDataEntry

var body: some View {

//AccessoryWidgetBackground() not supported in this Widget Family
Text("| \(Date(timeIntervalSince1970:entry.lastBGValues.first?.timestamp ?? (Date.now.timeIntervalSinceNow - 3600) / 1000).toLocalTimeString()) " + "\(entry.lastBGValues.first?.value ?? "?")\(entry.lastBGValues.first?.delta ?? "?")")
.widgetAccentable(true)
.unredacted()
ZStack {
let bgValue = entry.lastBGValues.first
if let bgValue = bgValue {

Text("\(String(bgValue.value)) \(bgValue.delta) \(bgValue.arrow) \(Date.now.addingTimeInterval(-(Date.now.timeIntervalSince1970 - (bgValue.timestamp / 1000))), style: .timer)")
#if os(watchOS)
.foregroundColor(Color(entry.sgvColor))
#endif
} else {
Text("--:-- --- -")
}
}
.widgetAccentable(true)
.unredacted()
}
}
Loading

0 comments on commit 94b5db1

Please sign in to comment.