|
| 1 | +class ComplicationController |
| 2 | + # Timeline Configuration |
| 3 | + |
| 4 | + def getSupportedTimeTravelDirectionsForComplication(complication, withHandler:handler) |
| 5 | + handler.call(CLKComplicationTimeTravelDirectionForward|CLKComplicationTimeTravelDirectionBackward) |
| 6 | + end |
| 7 | + |
| 8 | + def getTimelineStartDateForComplication(complication, withHandler:handler) |
| 9 | + handler.call(nil) |
| 10 | + end |
| 11 | + |
| 12 | + def getTimelineEndDateForComplication(complication, withHandler:handler) |
| 13 | + handler.call(nil) |
| 14 | + end |
| 15 | + |
| 16 | + def getPrivacyBehaviorForComplication(complication, withHandler:handler) |
| 17 | + handler.call(CLKComplicationPrivacyBehaviorShowOnLockScreen) |
| 18 | + end |
| 19 | + |
| 20 | + # Timeline Population |
| 21 | + |
| 22 | + def getCurrentTimelineEntryForComplication(complication, withHandler:handler) |
| 23 | + # Call the handler with the current timeline entry |
| 24 | + entry = nil |
| 25 | + |
| 26 | + case complication.family |
| 27 | + when CLKComplicationFamilyCircularSmall |
| 28 | + image = UIImage.imageNamed("Complication/Circular") |
| 29 | + template = CLKComplicationTemplateCircularSmallSimpleImage.new |
| 30 | + template.imageProvider = CLKImageProvider.imageProviderWithOnePieceImage(image) |
| 31 | + entry = CLKComplicationTimelineEntry.entryWithDate(Time.now, complicationTemplate:template) |
| 32 | + |
| 33 | + when CLKComplicationFamilyUtilitarianSmall |
| 34 | + image = UIImage.imageNamed("Complication/Circular") |
| 35 | + template = CLKComplicationTemplateUtilitarianSmallRingImage.new |
| 36 | + template.imageProvider = CLKImageProvider.imageProviderWithOnePieceImage(image) |
| 37 | + template.ringStyle = CLKComplicationRingStyleClosed |
| 38 | + entry = CLKComplicationTimelineEntry.entryWithDate(Time.now, complicationTemplate:template) |
| 39 | + |
| 40 | + when CLKComplicationFamilyUtilitarianLarge |
| 41 | + image = UIImage.imageNamed("Complication/Circular") |
| 42 | + template = CLKComplicationTemplateUtilitarianLargeFlat.new |
| 43 | + template.textProvider = CLKSimpleTextProvider.textProviderWithText("RubyMotion sample") |
| 44 | + template.imageProvider = CLKImageProvider.imageProviderWithOnePieceImage(image) |
| 45 | + entry = CLKComplicationTimelineEntry.entryWithDate(Time.now, complicationTemplate:template) |
| 46 | + |
| 47 | + when CLKComplicationFamilyModularLarge |
| 48 | + template = CLKComplicationTemplateModularLargeStandardBody.new |
| 49 | + template.headerTextProvider = CLKSimpleTextProvider.textProviderWithText("RubyMotion sample") |
| 50 | + template.body1TextProvider = CLKSimpleTextProvider.textProviderWithText("This is Complication sample") |
| 51 | + entry = CLKComplicationTimelineEntry.entryWithDate(Time.now, complicationTemplate:template) |
| 52 | + |
| 53 | + end |
| 54 | + |
| 55 | + handler.call(entry) |
| 56 | + end |
| 57 | + |
| 58 | + def getTimelineEntriesForComplication(complication, beforeDate:date, limit:limit, withHandler:handler) |
| 59 | + # Call the handler with the timeline entries prior to the given date |
| 60 | + handler.call(nil) |
| 61 | + end |
| 62 | + |
| 63 | + def getTimelineEntriesForComplication(complication, afterDate:date, limit:limit, withHandler:handler) |
| 64 | + # Call the handler with the timeline entries after to the given date |
| 65 | + handler.call(nil) |
| 66 | + end |
| 67 | + |
| 68 | + # Placeholder Templates |
| 69 | + |
| 70 | + def getLocalizableSampleTemplateForComplication(complication, withHandler:handler) |
| 71 | + # This method will be called once per supported complication, and the results will be cached |
| 72 | + handler.call(nil) |
| 73 | + end |
| 74 | + |
| 75 | +end |
0 commit comments