"Fossies" - the Fresh Open Source Software Archive

Member "jitsi-meet-7688/ios/app/watchos/extension/ComplicationController.swift" (1 Dec 2023, 3394 Bytes) of package /linux/misc/jitsi-meet-7688.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Swift source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2  * Copyright @ 2018-present 8x8, Inc.
    3  * Copyright @ 2017-2018 Atlassian Pty Ltd
    4  *
    5  * Licensed under the Apache License, Version 2.0 (the "License");
    6  * you may not use this file except in compliance with the License.
    7  * You may obtain a copy of the License at
    8  *
    9  *     http://www.apache.org/licenses/LICENSE-2.0
   10  *
   11  * Unless required by applicable law or agreed to in writing, software
   12  * distributed under the License is distributed on an "AS IS" BASIS,
   13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14  * See the License for the specific language governing permissions and
   15  * limitations under the License.
   16  */
   17 
   18 import ClockKit
   19 
   20 
   21 class ComplicationController: NSObject, CLKComplicationDataSource {
   22 
   23     // MARK: - Timeline Configuration
   24 
   25     func getSupportedTimeTravelDirections(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimeTravelDirections) -> Void) {
   26         handler([])
   27     }
   28 
   29     func getPrivacyBehavior(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationPrivacyBehavior) -> Void) {
   30         handler(.showOnLockScreen)
   31     }
   32 
   33     // MARK: - Timeline Population
   34 
   35     func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {
   36         // Call the handler with the current timeline entry
   37         getLocalizableSampleTemplate(for: complication) {template in
   38             guard let template = template else {
   39                 handler(nil)
   40                 return
   41             }
   42             handler(CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template))
   43         }
   44     }
   45 
   46     func getTimelineEntries(for complication: CLKComplication, before date: Date, limit: Int, withHandler handler: @escaping ([CLKComplicationTimelineEntry]?) -> Void) {
   47         // Call the handler with the timeline entries prior to the given date
   48         handler(nil)
   49     }
   50 
   51     func getTimelineEntries(for complication: CLKComplication, after date: Date, limit: Int, withHandler handler: @escaping ([CLKComplicationTimelineEntry]?) -> Void) {
   52         // Call the handler with the timeline entries after to the given date
   53         handler(nil)
   54     }
   55 
   56     // MARK: - Placeholder Templates
   57 
   58     func getLocalizableSampleTemplate(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTemplate?) -> Void) {
   59         // This method will be called once per supported complication, and the results will be cached
   60 
   61         let imageProvider = CLKImageProvider(onePieceImage: UIImage(named: "jitsi")!)
   62         if complication.family == .circularSmall {
   63             let small = CLKComplicationTemplateCircularSmallRingImage()
   64             small.imageProvider = imageProvider
   65             small.ringStyle = .closed
   66             small.fillFraction = 0
   67             handler(small)
   68         } else if complication.family == .utilitarianSmall {
   69             let utilitarian = CLKComplicationTemplateUtilitarianSmallSquare()
   70             utilitarian.imageProvider = imageProvider
   71             handler(utilitarian)
   72         } else if complication.family == .modularSmall {
   73             let modular = CLKComplicationTemplateModularSmallRingImage()
   74             modular.imageProvider = imageProvider
   75             modular.ringStyle = .closed
   76             modular.fillFraction = 0
   77             handler(modular)
   78         }
   79     }
   80 
   81 }