-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add mmol watchapp units support. Add modularLarge complication. Change complication time to relative time. #379
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| { | ||
| "supported complication families" : { | ||
| "3" : "CFB33AC2-7CD0-43A0-804F-F9A0EEC37480.json", | ||
| "6" : "E87B02EB-57B2-4E9D-B371-E0BA2DD55C19.json", | ||
| "4" : "B922BD0B-9601-45C9-B84D-ECB9C8235322.json", | ||
| "0" : "69B78E1F-415D-4E9E-8E56-E486517658FC.json", | ||
| "7" : "AB5AF86D-FF8F-493B-A738-4BB590C8A45E.json" | ||
| "3" : "F70B3898-9EF6-4BA6-AD7D-61EA7783B2B5.json", | ||
| "1" : "FC51C664-9919-4173-A297-0D6338B87700.json", | ||
| "6" : "60480B57-87A4-4073-814A-6D2DBB98F7FF.json", | ||
| "4" : "470CF733-7F65-4BEA-853B-68D49378EA44.json", | ||
| "0" : "645E4A29-EC77-49F2-BC35-42F2CDC6DD2D.json", | ||
| "7" : "21849667-AD99-4107-BDAE-64914E038CA6.json" | ||
| }, | ||
| "client ID" : "com.loudnate.Loop.watchkitapp.watchkitextension" | ||
| "client ID" : "com.walker0.Loop.watchkitapp.watchkitextension" | ||
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,14 +81,19 @@ final class ComplicationController: NSObject, CLKComplicationDataSource { | |
| let template: CLKComplicationTemplate? | ||
|
|
||
| let glucoseText = CLKSimpleTextProvider.localizableTextProvider(withStringsFileTextKey: "120↘︎", shortTextKey: "120") | ||
| let timeText = CLKTimeTextProvider(date: Date()) | ||
| let timeText = CLKRelativeDateTextProvider(date: Date(), style: .natural, units: .minute) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this fit on the smaller complications?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe it does. It is reactive to available space so it should fit. I haven't ever been able to get the utilitarian large complication to work to test that one, nor have I looked into why. This change definitely works for modular small as well as the large version though. |
||
|
|
||
| switch complication.family { | ||
| case .modularSmall: | ||
| let modularSmall = CLKComplicationTemplateModularSmallStackText() | ||
| modularSmall.line1TextProvider = glucoseText | ||
| modularSmall.line2TextProvider = timeText | ||
| template = modularSmall | ||
| case .modularLarge: | ||
| let modularSmall = CLKComplicationTemplateModularLargeTallBody() | ||
| modularSmall.bodyTextProvider = glucoseText | ||
| modularSmall.headerTextProvider = timeText | ||
| template = modularSmall | ||
| case .circularSmall: | ||
| let circularSmall = CLKComplicationTemplateCircularSmallSimpleText() | ||
| circularSmall.textProvider = glucoseText | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,28 +45,33 @@ final class StatusInterfaceController: WKInterfaceController, ContextUpdatable { | |
| loopTimer.setHidden(true) | ||
| loopHUDImage.setLoopImage(.Unknown) | ||
| } | ||
|
|
||
| guard let glucose = context?.glucose, | ||
| let unit = context?.preferredGlucoseUnit | ||
| else { | ||
| glucoseLabel.setHidden(true) | ||
|
||
| eventualGlucoseLabel.setHidden(true) | ||
| return | ||
| } | ||
|
|
||
| let numberFormatter = NumberFormatter() | ||
| let formatter = NumberFormatter.glucoseFormatter(for: unit) | ||
|
|
||
| if let glucose = context?.glucose, let unit = context?.preferredGlucoseUnit { | ||
| let glucoseValue = glucose.doubleValue(for: unit) | ||
| if let glucoseValue = formatter.string(from: NSNumber(value: glucose.doubleValue(for: unit))){ | ||
| let trend = context?.glucoseTrend?.symbol ?? "" | ||
|
|
||
| self.glucoseLabel.setText((numberFormatter.string(from: NSNumber(value: glucoseValue)) ?? "") + trend) | ||
| self.glucoseLabel.setText(glucoseValue + trend) | ||
| self.glucoseLabel.setHidden(false) | ||
| } else { | ||
| glucoseLabel.setHidden(true) | ||
| } | ||
|
|
||
| if let eventualGlucose = context?.eventualGlucose, let unit = context?.preferredGlucoseUnit { | ||
| let glucoseValue = eventualGlucose.doubleValue(for: unit) | ||
|
|
||
| self.eventualGlucoseLabel.setText(numberFormatter.string(from: NSNumber(value: glucoseValue))) | ||
| if let eventualGlucose = context?.eventualGlucose { | ||
| let glucoseValue = formatter.string(from: NSNumber(value: eventualGlucose.doubleValue(for: unit))) | ||
| self.eventualGlucoseLabel.setText(glucoseValue) | ||
| self.eventualGlucoseLabel.setHidden(false) | ||
| } else { | ||
| eventualGlucoseLabel.setHidden(true) | ||
| } | ||
|
|
||
| // TODO: Other elements | ||
| statusLabel.setHidden(true) | ||
| graphImage.setHidden(true) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These need to be reverted.