Last active
November 20, 2015 04:39
-
-
Save someoneAnyone/e01a9ed39c233791fc08 to your computer and use it in GitHub Desktop.
Revisions
-
someoneAnyone revised this gist
Nov 20, 2015 . 1 changed file with 5 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,10 +16,11 @@ let complicationFamily = complication.family let sampleDisplayName = model.displayName let sampleSGV = model.sgvStringWithEmoji let sampleDelta = model.deltaString let sampleRaw = model.rawString // only if available. let sampleRawShort = "100 : C" switch complicationFamily { -
someoneAnyone renamed this gist
Nov 20, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
someoneAnyone created this gist
Nov 20, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,151 @@ // MARK: - Timeline Population func getCurrentTimelineEntryForComplication(complication: CLKComplication, withHandler handler: ((CLKComplicationTimelineEntry?) -> Void)) { // Call the handler with the current timeline entry #if DEBUG print(">>> Entering \(__FUNCTION__) <<<") print("complication family: \(complication.family)") #endif // let myDelegate = WKExtension.sharedExtension().delegate as! ExtensionDelegate // var data : Dictionary = myDelegate.myComplicationData[ComplicationCurrentEntry]! var entry : CLKComplicationTimelineEntry? let now = NSDate() let complicationFamily = complication.family let sampleDisplayName = "Benny" let sampleSGV = "100 \(Direction.Flat.emojiForDirection)" let sampleDelta = "+11 mg/dl" let sampleRaw = "R: 100 : Clean" let sampleRawShort = "100 : C" switch complicationFamily { case .ModularSmall: // CLKComplicationTemplateModularSmallStackImage // CLKComplicationTemplateModularSmallStackText let modularTemplate = CLKComplicationTemplateModularSmallStackText() modularTemplate.line1TextProvider = CLKSimpleTextProvider(text: sampleSGV) modularTemplate.line2TextProvider = CLKSimpleTextProvider(text: sampleDelta) // Create the entry. entry = CLKComplicationTimelineEntry(date: now, complicationTemplate: modularTemplate) case .ModularLarge: // CLKComplicationTemplateModularLargeColumns // CLKComplicationTemplateModularLargeStandardBody let modularTemplate = CLKComplicationTemplateModularLargeStandardBody() modularTemplate.headerTextProvider = CLKSimpleTextProvider(text: sampleDisplayName) modularTemplate.body1TextProvider = CLKSimpleTextProvider(text: sampleDelta) modularTemplate.body2TextProvider = CLKSimpleTextProvider(text: sampleRaw, shortText: sampleRawShort) // Create the entry. entry = CLKComplicationTimelineEntry(date: now, complicationTemplate: modularTemplate) case .UtilitarianSmall: // CLKComplicationTemplateUtilitarianSmallFlat let utilitarianSmall = CLKComplicationTemplateUtilitarianSmallFlat() utilitarianSmall.textProvider = CLKSimpleTextProvider(text: sampleSGV) // Create the entry. entry = CLKComplicationTimelineEntry(date: now, complicationTemplate: utilitarianSmall) case .UtilitarianLarge: // CLKComplicationTemplateUtilitarianLargeFlat let utilitarianLarge = CLKComplicationTemplateUtilitarianLargeFlat() utilitarianLarge.textProvider = CLKSimpleTextProvider(text: sampleDisplayName + " " + sampleSGV + " " + sampleDelta + " " + sampleRaw) entry = CLKComplicationTimelineEntry(date: now, complicationTemplate: utilitarianLarge) case .CircularSmall: let circularSmall = CLKComplicationTemplateCircularSmallStackText() circularSmall.line1TextProvider = CLKSimpleTextProvider(text: sampleSGV) circularSmall.line2TextProvider = CLKSimpleTextProvider(text: sampleDelta) entry = CLKComplicationTimelineEntry(date: now, complicationTemplate: circularSmall) } handler(entry) } func getTimelineEntriesForComplication(complication: CLKComplication, beforeDate date: NSDate, limit: Int, withHandler handler: (([CLKComplicationTimelineEntry]?) -> Void)) { // Call the handler with the timeline entries prior to the given date handler(nil) } func getTimelineEntriesForComplication(complication: CLKComplication, afterDate date: NSDate, limit: Int, withHandler handler: (([CLKComplicationTimelineEntry]?) -> Void)) { // Call the handler with the timeline entries after to the given date handler(nil) } // MARK: - Update Scheduling func getNextRequestedUpdateDateWithHandler(handler: (NSDate?) -> Void) { // Call the handler with the date when you would next like to be given the opportunity to update your complication content handler(nextUpdateRequest); } // MARK: - Placeholder Templates func getPlaceholderTemplateForComplication(complication: CLKComplication, withHandler handler: (CLKComplicationTemplate?) -> Void) { // This method will be called once per supported complication, and the results will be cached #if DEBUG print(">>> Entering \(__FUNCTION__) <<<") print("complication family: \(complication.family)") #endif let sampleDisplayName = "Nightscout" let sampleSGV = "---" let sampleDelta = "- --/--" let sampleRaw = "--- : ---" let sampleRawShort = "100 : C" var template : CLKComplicationTemplate? let complicationFamily = complication.family switch complicationFamily { case .ModularSmall: // CLKComplicationTemplateModularSmallStackImage // CLKComplicationTemplateModularSmallStackText let modularTemplate = CLKComplicationTemplateModularSmallStackText() modularTemplate.line1TextProvider = CLKSimpleTextProvider(text: sampleSGV) modularTemplate.line2TextProvider = CLKSimpleTextProvider(text: sampleDelta) template = modularTemplate case .ModularLarge: // CLKComplicationTemplateModularLargeColumns // CLKComplicationTemplateModularLargeStandardBody let modularTemplate = CLKComplicationTemplateModularLargeStandardBody() modularTemplate.headerTextProvider = CLKSimpleTextProvider(text: sampleDisplayName) modularTemplate.body1TextProvider = CLKSimpleTextProvider(text: sampleDelta) modularTemplate.body2TextProvider = CLKSimpleTextProvider(text: sampleRaw, shortText: sampleRawShort) template = modularTemplate case .UtilitarianSmall: // CLKComplicationTemplateUtilitarianSmallFlat let utilitarianSmall = CLKComplicationTemplateUtilitarianSmallFlat() utilitarianSmall.textProvider = CLKSimpleTextProvider(text: sampleSGV) template = utilitarianSmall case .UtilitarianLarge: // CLKComplicationTemplateUtilitarianLargeFlat let utilitarianLarge = CLKComplicationTemplateUtilitarianLargeFlat() utilitarianLarge.textProvider = CLKSimpleTextProvider(text: sampleDisplayName + " " + sampleSGV + " " + sampleDelta + " " + sampleRaw) template = utilitarianLarge case .CircularSmall: let circularSmall = CLKComplicationTemplateCircularSmallStackText() circularSmall.line1TextProvider = CLKSimpleTextProvider(text: sampleSGV) circularSmall.line2TextProvider = CLKSimpleTextProvider(text: sampleDelta) template = circularSmall } handler(template) }