Created
April 15, 2019 11:07
-
-
Save itinance/555a8e49e49116eb8626f8e2e84981f5 to your computer and use it in GitHub Desktop.
Revisions
-
itinance created this gist
Apr 15, 2019 .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,37 @@ #pragma mark - Timeline Population - (void)getCurrentTimelineEntryForComplication:(CLKComplication *)complication withHandler:(void(^)(CLKComplicationTimelineEntry * __nullable))handler { ExtensionDelegate* myDelegate = (ExtensionDelegate*)[[WKExtension sharedExtension] delegate]; if (complication.family == CLKComplicationFamilyModularSmall) { [myDelegate fetchRate:^(NSDictionary * data, NSError * _Nullable error) { Rate* rate = [data valueForKey:@"btc"]; NSDate* now = [NSDate date]; NSString* valueString = rate == nil ? @"?" : rate.value; CLKComplicationTemplateModularSmallStackText* textTemplate = [[CLKComplicationTemplateModularSmallStackText alloc] init]; textTemplate.line1TextProvider = [CLKSimpleTextProvider textProviderWithText:@"BTC -> USD" shortText:@"BTC -> USD"]; textTemplate.line2TextProvider = [CLKSimpleTextProvider textProviderWithText:valueString shortText:valueString]; textTemplate.tintColor = [UIColor whiteColor]; // Create the entry. CLKComplicationTimelineEntry* entry = nil; entry = [CLKComplicationTimelineEntry entryWithDate:now complicationTemplate:textTemplate]; handler(entry); }]; } handler(nil); } }