Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BitWatch] add sample code for watchOS complication
- Loading branch information
1 parent
43548ab
commit 3635b43
Showing
9 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
class ComplicationController | ||
# Timeline Configuration | ||
|
||
def getSupportedTimeTravelDirectionsForComplication(complication, withHandler:handler) | ||
handler.call(CLKComplicationTimeTravelDirectionForward|CLKComplicationTimeTravelDirectionBackward) | ||
end | ||
|
||
def getTimelineStartDateForComplication(complication, withHandler:handler) | ||
handler.call(nil) | ||
end | ||
|
||
def getTimelineEndDateForComplication(complication, withHandler:handler) | ||
handler.call(nil) | ||
end | ||
|
||
def getPrivacyBehaviorForComplication(complication, withHandler:handler) | ||
handler.call(CLKComplicationPrivacyBehaviorShowOnLockScreen) | ||
end | ||
|
||
# Timeline Population | ||
|
||
def getCurrentTimelineEntryForComplication(complication, withHandler:handler) | ||
# Call the handler with the current timeline entry | ||
entry = nil | ||
|
||
case complication.family | ||
when CLKComplicationFamilyCircularSmall | ||
image = UIImage.imageNamed("Complication/Circular") | ||
template = CLKComplicationTemplateCircularSmallSimpleImage.new | ||
template.imageProvider = CLKImageProvider.imageProviderWithOnePieceImage(image) | ||
entry = CLKComplicationTimelineEntry.entryWithDate(Time.now, complicationTemplate:template) | ||
|
||
when CLKComplicationFamilyUtilitarianSmall | ||
image = UIImage.imageNamed("Complication/Circular") | ||
template = CLKComplicationTemplateUtilitarianSmallRingImage.new | ||
template.imageProvider = CLKImageProvider.imageProviderWithOnePieceImage(image) | ||
template.ringStyle = CLKComplicationRingStyleClosed | ||
entry = CLKComplicationTimelineEntry.entryWithDate(Time.now, complicationTemplate:template) | ||
|
||
when CLKComplicationFamilyUtilitarianLarge | ||
image = UIImage.imageNamed("Complication/Circular") | ||
template = CLKComplicationTemplateUtilitarianLargeFlat.new | ||
template.textProvider = CLKSimpleTextProvider.textProviderWithText("RubyMotion sample") | ||
template.imageProvider = CLKImageProvider.imageProviderWithOnePieceImage(image) | ||
entry = CLKComplicationTimelineEntry.entryWithDate(Time.now, complicationTemplate:template) | ||
|
||
when CLKComplicationFamilyModularLarge | ||
template = CLKComplicationTemplateModularLargeStandardBody.new | ||
template.headerTextProvider = CLKSimpleTextProvider.textProviderWithText("RubyMotion sample") | ||
template.body1TextProvider = CLKSimpleTextProvider.textProviderWithText("This is Complication sample") | ||
entry = CLKComplicationTimelineEntry.entryWithDate(Time.now, complicationTemplate:template) | ||
|
||
end | ||
|
||
handler.call(entry) | ||
end | ||
|
||
def getTimelineEntriesForComplication(complication, beforeDate:date, limit:limit, withHandler:handler) | ||
# Call the handler with the timeline entries prior to the given date | ||
handler.call(nil) | ||
end | ||
|
||
def getTimelineEntriesForComplication(complication, afterDate:date, limit:limit, withHandler:handler) | ||
# Call the handler with the timeline entries after to the given date | ||
handler.call(nil) | ||
end | ||
|
||
# Placeholder Templates | ||
|
||
def getLocalizableSampleTemplateForComplication(complication, withHandler:handler) | ||
# This method will be called once per supported complication, and the results will be cached | ||
handler.call(nil) | ||
end | ||
|
||
end |
Binary file added
BIN
+1.6 KB
...ts.xcassets/Complication.complicationset/Circular.imageset/Circular_38mm@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.64 KB
...ts.xcassets/Complication.complicationset/Circular.imageset/Circular_42mm@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions
20
...V2/resources/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "watch", | ||
"filename" : "Circular_38mm@2x.png", | ||
"screen-width" : "<=145", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"filename" : "Circular_42mm@2x.png", | ||
"screen-width" : ">145", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
ios/BitWatch/WatchAppV2/resources/Assets.xcassets/Complication.complicationset/Contents.json
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"assets" : [ | ||
{ | ||
"idiom" : "watch", | ||
"filename" : "Circular.imageset", | ||
"role" : "circular" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"filename" : "Extra Large.imageset", | ||
"role" : "extra-large" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"filename" : "Modular.imageset", | ||
"role" : "modular" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"filename" : "Utilitarian.imageset", | ||
"role" : "utilitarian" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...resources/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : "<=145" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">145" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...pV2/resources/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : "<=145" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">145" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...resources/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : "<=145" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">145" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |