comparison LazyBearWatchOS Extension/ComplicationController.swift @ 429:e4ca9898b79b

Add WatchOS Target
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Sat, 19 Jun 2021 16:20:58 +0200
parents
children
comparison
equal deleted inserted replaced
428:8c58ce834d95 429:e4ca9898b79b
1 //
2 // ComplicationController.swift
3 // LazyBearWatchOS Extension
4 //
5 // Created by Dennis Concepción Martín on 19/6/21.
6 //
7
8 import ClockKit
9
10
11 class ComplicationController: NSObject, CLKComplicationDataSource {
12
13 // MARK: - Complication Configuration
14
15 func getComplicationDescriptors(handler: @escaping ([CLKComplicationDescriptor]) -> Void) {
16 let descriptors = [
17 CLKComplicationDescriptor(identifier: "complication", displayName: "LazyBear", supportedFamilies: CLKComplicationFamily.allCases)
18 // Multiple complication support can be added here with more descriptors
19 ]
20
21 // Call the handler with the currently supported complication descriptors
22 handler(descriptors)
23 }
24
25 func handleSharedComplicationDescriptors(_ complicationDescriptors: [CLKComplicationDescriptor]) {
26 // Do any necessary work to support these newly shared complication descriptors
27 }
28
29 // MARK: - Timeline Configuration
30
31 func getTimelineEndDate(for complication: CLKComplication, withHandler handler: @escaping (Date?) -> Void) {
32 // Call the handler with the last entry date you can currently provide or nil if you can't support future timelines
33 handler(nil)
34 }
35
36 func getPrivacyBehavior(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationPrivacyBehavior) -> Void) {
37 // Call the handler with your desired behavior when the device is locked
38 handler(.showOnLockScreen)
39 }
40
41 // MARK: - Timeline Population
42
43 func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {
44 // Call the handler with the current timeline entry
45 handler(nil)
46 }
47
48 func getTimelineEntries(for complication: CLKComplication, after date: Date, limit: Int, withHandler handler: @escaping ([CLKComplicationTimelineEntry]?) -> Void) {
49 // Call the handler with the timeline entries after the given date
50 handler(nil)
51 }
52
53 // MARK: - Sample Templates
54
55 func getLocalizableSampleTemplate(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTemplate?) -> Void) {
56 // This method will be called once per supported complication, and the results will be cached
57 handler(nil)
58 }
59 }