Skip to content

Commit

Permalink
V3.1.0 Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermanns committed Oct 7, 2020
1 parent f296b1c commit 43942d7
Show file tree
Hide file tree
Showing 26 changed files with 417 additions and 182 deletions.
26 changes: 19 additions & 7 deletions nightguard WatchKit App/Base.lproj/Interface.storyboard
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="17156" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="zZT-1m-QPq">
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="17156" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="AgC-eL-Hgc">
<device id="watch44"/>
<dependencies>
<deployment identifier="watchOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="17034"/>
</dependencies>
Expand All @@ -11,7 +12,18 @@
<objects>
<hostingController id="zZT-1m-QPq" customClass="HostingController" customModule="nightguard"/>
</objects>
<point key="canvasLocation" x="-70" y="-321"/>
<point key="canvasLocation" x="-129" y="-607"/>
</scene>
<!--Action Button Controller-->
<scene sceneID="bxz-Z6-DaQ">
<objects>
<controller id="ymg-17-TBh" customClass="ActionButtonController" customModule="nightguard">
<connections>
<segue destination="wky-cb-ykJ" kind="relationship" relationship="nextPage" id="oPp-bk-zxe"/>
</connections>
</controller>
</objects>
<point key="canvasLocation" x="102" y="-321"/>
</scene>
<!--Interface Controller-->
<scene sceneID="aou-V4-d1y">
Expand Down Expand Up @@ -203,7 +215,7 @@
</connections>
</controller>
</objects>
<point key="canvasLocation" x="-70" y="-44.5"/>
<point key="canvasLocation" x="-129" y="-321"/>
</scene>
<!--InfoInterfaceController-->
<scene sceneID="uNG-cf-2tk">
Expand Down Expand Up @@ -266,7 +278,7 @@
</connections>
</controller>
</objects>
<point key="canvasLocation" x="166.51282051282053" y="-44.025641025641029"/>
<point key="canvasLocation" x="339" y="-321"/>
</scene>
<!--SnoozeInterfaceController-->
<scene sceneID="Wo6-eU-PUk">
Expand Down Expand Up @@ -350,7 +362,7 @@
</connections>
</controller>
</objects>
<point key="canvasLocation" x="409" y="-44"/>
<point key="canvasLocation" x="-392" y="-321"/>
</scene>
<!--Static Notification Interface Controller-->
<scene sceneID="AEw-b0-oYE">
Expand All @@ -366,14 +378,14 @@
</connections>
</notificationController>
</objects>
<point key="canvasLocation" x="-70" y="281"/>
<point key="canvasLocation" x="-129" y="102"/>
</scene>
<!--Notification Controller-->
<scene sceneID="ZPc-GJ-vnh">
<objects>
<controller id="4sK-HA-Art" customClass="NotificationController" customModule="nightguard" customModuleProvider="target"/>
</objects>
<point key="canvasLocation" x="167" y="281"/>
<point key="canvasLocation" x="110" y="102"/>
</scene>
</scenes>
<resources>
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>$(CURRENT_PROJECT_VERSION)</string>
<string>614</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down
23 changes: 23 additions & 0 deletions nightguard WatchKit Extension/ActionButtonController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// ActionController.swift
// nightguard WatchKit Extension
//
// Created by Dirk Hermanns on 05.10.20.
// Copyright © 2020 private. All rights reserved.
//

import WatchKit
import Foundation
import SwiftUI

class ActionButtonController: WKHostingController<ActionButtonView> {
override var body: ActionButtonView {
return ActionButtonView()
}
}

struct ActionButtonController_Previews: PreviewProvider {
static var previews: some View {
/*@START_MENU_TOKEN@*/Text("Hello, World!")/*@END_MENU_TOKEN@*/
}
}
44 changes: 44 additions & 0 deletions nightguard WatchKit Extension/ActionButtonView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// ContentView.swift
// nightguard WatchKit Extension
//
// Created by Dirk Hermanns on 08.09.20.
// Copyright © 2020 private. All rights reserved.
//

import SwiftUI
import SpriteKit
import Combine

struct ActionButtonView: View {

@State private var snoozeModalIsPresented = false

init() {}

var body: some View {
VStack() {
HStack(spacing: 5, content: {
if #available(watchOSApplicationExtension 7.0, *) {
Button("Snooze", action: {
self.snoozeModalIsPresented.toggle()
}).fullScreenCover(isPresented: self.$snoozeModalIsPresented, content: {
SnoozeModalView(isPresented: self.$snoozeModalIsPresented)
})
}
Button("Aktualisieren", action: {
print("Button")
})
})
}
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
.edgesIgnoringSafeArea(.bottom)
.focusable(false)
}
}

struct ActionButtonView_Previews: PreviewProvider {
static var previews: some View {
ContentView(mainViewModel: MainViewModel())
}
}
8 changes: 4 additions & 4 deletions nightguard WatchKit Extension/ComplicationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ComplicationController: NSObject, CLKComplicationDataSource {
modTemplate.line1TextProvider = CLKSimpleTextProvider(text: "\(currentNightscoutData.hourAndMinutes)")
modTemplate.line1TextProvider.tintColor = UIColorChanger.getBgColor(
UnitsConverter.mgdlToDisplayUnits(currentNightscoutData.sgv))
modTemplate.line2TextProvider = CLKSimpleTextProvider(text: "\(UnitsConverter.mgdlToDisplayUnits(currentNightscoutData.sgv))\(UnitsConverter.mgdlToDisplayUnits(currentNightscoutData.bgdeltaString))\(currentNightscoutData.bgdeltaArrow)")
modTemplate.line2TextProvider = CLKSimpleTextProvider(text: "\(UnitsConverter.mgdlToDisplayUnits(currentNightscoutData.sgv))\(UnitsConverter.mgdlToDisplayUnitsWithSign(currentNightscoutData.bgdeltaString))\(currentNightscoutData.bgdeltaArrow)")
}
template = modTemplate
case .modularLarge:
Expand Down Expand Up @@ -176,7 +176,7 @@ class ComplicationController: NSObject, CLKComplicationDataSource {

// Display 11:24 113+2
func getOneBigLine(_ data : NightscoutData) -> String {
return "\(data.hourAndMinutes) \(UnitsConverter.mgdlToDisplayUnits(data.sgv))\(UnitsConverter.mgdlToDisplayUnits(data.bgdeltaString))\(data.bgdeltaArrow)"
return "\(data.hourAndMinutes) \(UnitsConverter.mgdlToDisplayUnits(data.sgv))\(UnitsConverter.mgdlToDisplayUnitsWithSign(data.bgdeltaString))\(data.bgdeltaArrow)"
}

// Display 11:24
Expand All @@ -186,12 +186,12 @@ class ComplicationController: NSObject, CLKComplicationDataSource {

// Displays 113 ↗ +2
func getOneLine(_ data : NightscoutData) -> String {
return "\(getSgvAndArrow(data, " "))\t\(UnitsConverter.mgdlToDisplayUnits(data.bgdeltaString))"
return "\(getSgvAndArrow(data, " "))\t\(UnitsConverter.mgdlToDisplayUnitsWithSign(data.bgdeltaString))"
}

// Displays 113↗+2
func getOneShortLine(_ data : NightscoutData) -> String {
return "\(getSgvAndArrow(data, ""))\(UnitsConverter.mgdlToDisplayUnits(data.bgdeltaString))"
return "\(getSgvAndArrow(data, ""))\(UnitsConverter.mgdlToDisplayUnitsWithSign(data.bgdeltaString))"
}

func getSgvAndArrow(_ data: NightscoutData, _ separator: String) -> String {
Expand Down
28 changes: 18 additions & 10 deletions nightguard WatchKit Extension/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

import SwiftUI
import SpriteKit
import Combine

struct ContentView: View {

@State var crownValue = 0.1
@ObservedObject var viewModel: MainViewModel

let chartScene: SKScene

init(mainViewModel: MainViewModel) {

self.viewModel = mainViewModel
Expand All @@ -31,21 +31,18 @@ struct ContentView: View {
// Apple Watch 42mm
sceneHeight = 145.0
}

chartScene = ChartScene(size: CGSize(width: screenBounds.width, height: sceneHeight),
newCanvasWidth: screenBounds.width * 6, useContrastfulColors: false)
}
}

var body: some View {
VStack() {
HStack(spacing: 5, content: {
Text(UnitsConverter.toDisplayUnits(
Text(UnitsConverter.mgdlToDisplayUnits(
viewModel.nightscoutData?.sgv ?? "---"))
.foregroundColor(viewModel.sgvColor)
.font(.system(size: 45))
.font(.system(size: 40))
.frame(alignment: .topLeading)
VStack() {
Text(UnitsConverter.toDisplayDeltaUnits(
Text(UnitsConverter.mgdlToDisplayUnits(
viewModel.nightscoutData?.bgdeltaString ?? "?"))
.foregroundColor(viewModel.sgvDeltaColor)
.font(.system(size: 12))
Expand Down Expand Up @@ -103,14 +100,25 @@ struct ContentView: View {
}.frame(minWidth: 0,
maxWidth: .infinity)
VStack() {
SpriteView(scene: chartScene)
if #available(watchOSApplicationExtension 7.0, *) {
SpriteView(scene: viewModel.skScene!)
} else {
// Fallback on earlier versions
}
}.frame(minWidth: 0,
maxWidth: .infinity,
minHeight: 0,
maxHeight: .infinity)
}
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
.edgesIgnoringSafeArea(.bottom)
.focusable(false)
.digitalCrownRotation($crownValue, from: 0.1, through: 5.0, sensitivity: .low, isContinuous: false, isHapticFeedbackEnabled: true)
.onAppear() {

}.onReceive(Just(crownValue)) { output in
print(output) // Here is the answer.
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion nightguard WatchKit Extension/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>$(CURRENT_PROJECT_VERSION)</string>
<string>614</string>
<key>CLKComplicationPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).ComplicationController</string>
<key>CLKComplicationSupportedFamilies</key>
Expand Down
5 changes: 3 additions & 2 deletions nightguard WatchKit Extension/InterfaceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ class InterfaceController: WKInterfaceController, WKCrownDelegate {
UnitsConverter.mgdlToDisplayUnits(currentNightscoutData.sgv)))

self.deltaLabel.setText(
UnitsConverter.mgdlToDisplayUnits(currentNightscoutData.bgdeltaString))
UnitsConverter.mgdlToDisplayUnitsWithSign(currentNightscoutData.bgdeltaString))
self.deltaArrowLabel.setText(currentNightscoutData.bgdeltaArrow)
self.deltaLabel.setTextColor(UIColorChanger.getDeltaLabelColor(
UnitsConverter.mgdlToDisplayUnits(currentNightscoutData.bgdelta)))
Expand Down Expand Up @@ -485,7 +485,8 @@ class InterfaceController: WKInterfaceController, WKCrownDelegate {

let temporaryTargetData = NightscoutCacheService.singleton.getTemporaryTargetData()
if temporaryTargetData.activeUntilDate.remainingMinutes() > 0 {
self.temporaryTargetLabel.setText("TT \(UnitsConverter.toDisplayUnits(temporaryTargetData.targetTop)) \(temporaryTargetData.activeUntilDate.remainingMinutes())m")
self.temporaryTargetLabel.setText(
"TT \(UnitsConverter.mgdlToDisplayUnits(String(describing: temporaryTargetData.targetTop))) \(temporaryTargetData.activeUntilDate.remainingMinutes())m")
} else {
self.temporaryTargetLabel.setText("TT --")
}
Expand Down
Loading

0 comments on commit 43942d7

Please sign in to comment.