Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. import ClockKit
  2.  
  3. class ComplicationController: NSObject, CLKComplicationDataSource {
  4.  
  5. // MARK: - Timeline Configuration
  6.  
  7. func getSupportedTimeTravelDirections(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimeTravelDirections) -> Void) {
  8. handler(CLKComplicationTimeTravelDirections())
  9. }
  10.  
  11. func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {
  12. if complication.family == .circularSmall {
  13.  
  14. let template = CLKComplicationTemplateCircularSmallRingImage()
  15. template.imageProvider = CLKImageProvider(onePieceImage: UIImage(named: "Circular")!)
  16. let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
  17. handler(timelineEntry)
  18.  
  19. } else if complication.family == .utilitarianSmall {
  20.  
  21. let template = CLKComplicationTemplateUtilitarianSmallRingImage()
  22. template.imageProvider = CLKImageProvider(onePieceImage: UIImage(named: "Utilitarian")!)
  23. let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
  24. handler(timelineEntry)
  25.  
  26. } else if complication.family == .modularSmall {
  27.  
  28. let template = CLKComplicationTemplateModularSmallRingImage()
  29. template.imageProvider = CLKImageProvider(onePieceImage: UIImage(named: "Modular")!)
  30. let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
  31. handler(timelineEntry)
  32.  
  33. } else {
  34.  
  35. handler(nil)
  36. }
  37. }
  38.  
  39. func getLocalizableSampleTemplate(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTemplate?) -> Void) {
  40. switch complication.family {
  41.  
  42. case .circularSmall:
  43. let image = UIImage(named: "Circular")
  44. let template = CLKComplicationTemplateCircularSmallSimpleImage()
  45. template.imageProvider = CLKImageProvider(onePieceImage: image!)
  46. handler(template)
  47. case .utilitarianSmall:
  48. let image = UIImage(named: "Utilitarian")
  49. let template = CLKComplicationTemplateUtilitarianSmallSquare()
  50. template.imageProvider = CLKImageProvider(onePieceImage: image!)
  51. handler(template)
  52. case .modularSmall:
  53. let image = UIImage(named: "Modular")
  54. let template = CLKComplicationTemplateModularSmallSimpleImage()
  55. template.imageProvider = CLKImageProvider(onePieceImage: image!)
  56. handler(template)
  57. default:
  58. handler(nil)
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement