Skip to content

Commit

Permalink
Merge pull request #3 from mulot/developpement
Browse files Browse the repository at this point in the history
Developpement
  • Loading branch information
mulot committed Jun 8, 2022
2 parents 299e43c + 1921c35 commit 03645d8
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 39 deletions.
40 changes: 20 additions & 20 deletions BeatTime.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = VNLK894MAE;
INFOPLIST_FILE = "$(SRCROOT)/Widget iOS/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.5;
Expand All @@ -973,7 +973,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime.BeatTimeWidgetiOS;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
Expand All @@ -989,7 +989,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = VNLK894MAE;
INFOPLIST_FILE = "$(SRCROOT)/Widget iOS/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.5;
Expand All @@ -998,7 +998,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime.BeatTimeWidgetiOS;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
Expand Down Expand Up @@ -1066,7 +1066,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_ASSET_PATHS = "\"WatchOS WatchKit Extension/Preview Content\"";
DEVELOPMENT_TEAM = VNLK894MAE;
ENABLE_PREVIEWS = YES;
Expand All @@ -1076,7 +1076,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime.watchkitapp.watchkitextension;
PRODUCT_NAME = "${TARGET_NAME}";
SDKROOT = watchos;
Expand All @@ -1092,7 +1092,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_ASSET_PATHS = "\"WatchOS WatchKit Extension/Preview Content\"";
DEVELOPMENT_TEAM = VNLK894MAE;
ENABLE_PREVIEWS = YES;
Expand All @@ -1102,7 +1102,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime.watchkitapp.watchkitextension;
PRODUCT_NAME = "${TARGET_NAME}";
SDKROOT = watchos;
Expand All @@ -1120,11 +1120,11 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = VNLK894MAE;
IBSC_MODULE = BeatTimeWatchOS_WatchKit_Extension;
INFOPLIST_FILE = "$(SRCROOT)/WatchOS WatchKit App/Info.plist";
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime.watchkitapp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
Expand All @@ -1141,11 +1141,11 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = VNLK894MAE;
IBSC_MODULE = BeatTimeWatchOS_WatchKit_Extension;
INFOPLIST_FILE = "$(SRCROOT)/WatchOS WatchKit App/Info.plist";
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime.watchkitapp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
Expand All @@ -1161,9 +1161,9 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = VNLK894MAE;
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime;
PRODUCT_NAME = BeatTime;
SDKROOT = iphoneos;
Expand All @@ -1175,9 +1175,9 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = VNLK894MAE;
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime;
PRODUCT_NAME = BeatTime;
SDKROOT = iphoneos;
Expand All @@ -1193,7 +1193,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_ASSET_PATHS = "\"iOS/Preview Content\"";
DEVELOPMENT_TEAM = VNLK894MAE;
ENABLE_PREVIEWS = YES;
Expand All @@ -1203,7 +1203,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
Expand All @@ -1219,7 +1219,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_ASSET_PATHS = "\"iOS/Preview Content\"";
DEVELOPMENT_TEAM = VNLK894MAE;
ENABLE_PREVIEWS = YES;
Expand All @@ -1229,7 +1229,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
Expand Down
Binary file not shown.
34 changes: 32 additions & 2 deletions BeatTime/BeatTime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,38 @@ class BeatTime: NSObject {

if let beattime = Double(beats) {
if (beattime >= 0 && beattime <= 1000) {
seconds = beattime / 1000 * 86400 - BeatTime.UTCplus1Offset
return(Date(timeIntervalSinceReferenceDate: seconds))
seconds = beattime / 1000 * 86400
let date = Date()
let calendar = Calendar.current
var dateComponents = DateComponents()
dateComponents.year = calendar.component(.year, from: date)
dateComponents.month = calendar.component(.month, from: date)
dateComponents.day = calendar.component(.day, from: date)
dateComponents.timeZone = TimeZone(abbreviation: "CET")
dateComponents.hour = 1 // UTC+1 Offset
dateComponents.minute = 0
/*
if (TimeZone.autoupdatingCurrent.isDaylightSavingTime()) {
print("Daylight On")
}
else {
print("Daylight Off")
}
*/

if let someDateTime = calendar.date(from: dateComponents) {
//let secondsSinceRefDate = someDateTime.timeIntervalSinceReferenceDate + BeatTime.UTCplus1Offset + seconds
let secondsSinceRefDate = someDateTime.timeIntervalSinceReferenceDate + seconds
/*
print("Start Date: \(someDateTime)")
print("Date converted: \(Date(timeIntervalSinceReferenceDate: secondsSinceRefDate))")
print("Date ref: ", Date(timeIntervalSinceReferenceDate: Date.timeIntervalSinceReferenceDate))
print("beats converted seconds: \(seconds) hours: \(Int(seconds/3600)) minutes: \(Int(seconds)%3600/60)")
print("seconds since Ref UTC Date: \(Date.timeIntervalSinceReferenceDate)")
print("converted seconds since Ref UTC Date: \(secondsSinceRefDate)\n")
*/
return(Date(timeIntervalSinceReferenceDate: secondsSinceRefDate))
}
}
}
return(Date())
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ Apps are coded in Swift language using AppKit/Cocoa (macOS), SwiftUI, WidgetKit,
For more information about Swatch Internet Time:
https://en.wikipedia.org/wiki/Swatch_Internet_Time

What's New in version 1.1:
- Fix a bug in converting Beats to local time
- Beats time font size adapts to screen size
- Circle gradients following the local sun light
- Option to disable the back circle and to chose its color
- Circle animations
What's New in version 1.2:
- Extra large complications for Apple Watch
- Corner complication for Apple Watch
- Fix dayligth issue in .beats to local time convert mode

<a href="https://www.buymeacoffee.com/0TC98Sk" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "watch",
"role" : "notificationCenter",
"scale" : "2x",
"size" : "33x33",
"subtype" : "45mm"
},
{
"filename" : "BeatTime App Icon-WatchOS-80.png",
"idiom" : "watch",
Expand All @@ -46,6 +53,13 @@
"size" : "44x44",
"subtype" : "40mm"
},
{
"idiom" : "watch",
"role" : "appLauncher",
"scale" : "2x",
"size" : "46x46",
"subtype" : "41mm"
},
{
"filename" : "BeatTime App Icon-WatchOS-100.png",
"idiom" : "watch",
Expand All @@ -54,6 +68,13 @@
"size" : "50x50",
"subtype" : "44mm"
},
{
"idiom" : "watch",
"role" : "appLauncher",
"scale" : "2x",
"size" : "51x51",
"subtype" : "45mm"
},
{
"filename" : "BeatTime App Icon-WatchOS-172.png",
"idiom" : "watch",
Expand All @@ -78,6 +99,13 @@
"size" : "108x108",
"subtype" : "44mm"
},
{
"idiom" : "watch",
"role" : "quickLook",
"scale" : "2x",
"size" : "117x117",
"subtype" : "45mm"
},
{
"filename" : "BeatTime App Icon-WatchOS-1024.png",
"idiom" : "watch-marketing",
Expand Down
6 changes: 3 additions & 3 deletions WatchOS WatchKit Extension/BeatTimeApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct ConvertView: View {
VStack {
HStack {
Picker(selection: $selection[0], label: Text(".beats")) {
ForEach(0..<self.clock[0].1.count) { index in
ForEach(0..<self.clock[0].1.count, id:\.self) { index in
Text(verbatim: "@" + self.clock[0].1[index])
.tag(self.clock[0].1[index])
}
Expand All @@ -100,13 +100,13 @@ struct ConvertView: View {
}
HStack {
Picker("Hours", selection: $selection[1]) {
ForEach(0..<self.clock[1].1.count) { index in
ForEach(0..<self.clock[1].1.count, id:\.self) { index in
Text(verbatim: self.clock[1].1[index])
.tag(self.clock[1].1[index])
}
}.font(.title.bold())
Picker("Minutes", selection: $selection[2]) {
ForEach(0..<self.clock[2].1.count) { index in
ForEach(0..<self.clock[2].1.count, id:\.self) { index in
Text(verbatim: self.clock[2].1[index])
.tag(self.clock[2].1[index])
}
Expand Down
25 changes: 17 additions & 8 deletions WatchOS WatchKit Extension/ComplicationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import ClockKit

extension ComplicationController {
func makeTemplate(for beatTime: String, complication: CLKComplication) -> CLKComplicationTemplate? {
var beatProvider = CLKSimpleTextProvider(
let beatProvider = CLKSimpleTextProvider(
text: "@" + beatTime,
shortText: beatTime)

switch complication.family {
case .circularSmall:
// Create a template from the circular small family.
return CLKComplicationTemplateCircularSmallSimpleText(textProvider: beatProvider)
return CLKComplicationTemplateCircularSmallRingText(textProvider: beatProvider, fillFraction: (Float(beatTime)!/1000), ringStyle: CLKComplicationRingStyle.closed)
case .modularSmall:
// Create a template from the modular small family.
return CLKComplicationTemplateModularSmallRingText(textProvider: beatProvider, fillFraction: (Float(beatTime)!/1000), ringStyle: CLKComplicationRingStyle.closed)
Expand All @@ -25,22 +25,31 @@ extension ComplicationController {
let dateProvider = CLKSimpleTextProvider(
text: "Local time " + DateFormatter.localizedString(from: Date(), dateStyle: .none, timeStyle: .short),
shortText: DateFormatter.localizedString(from: Date(), dateStyle: .none, timeStyle: .short))
return CLKComplicationTemplateModularLargeStandardBody(headerTextProvider: CLKSimpleTextProvider(text: "@Beats"), body1TextProvider: beatProvider, body2TextProvider: dateProvider)
return CLKComplicationTemplateModularLargeStandardBody(headerTextProvider: CLKSimpleTextProvider(text: ".Beats"), body1TextProvider: beatProvider, body2TextProvider: dateProvider)
case .utilitarianSmall:
// Create a template from the utilitarian small family.
beatProvider = CLKSimpleTextProvider(
text: "@" + beatTime,
shortText: "@")
return CLKComplicationTemplateUtilitarianSmallRingText(textProvider: beatProvider, fillFraction: (Float(beatTime)!/1000), ringStyle: CLKComplicationRingStyle.closed)
case .utilitarianSmallFlat:
// Create a template from the utilitarian small flat family.
return CLKComplicationTemplateUtilitarianSmallFlat(textProvider: beatProvider)
case .graphicCircular:
// Create a template from the graphic Circular family.
//beatProvider = CLKSimpleTextProvider(text: beatTime)
return CLKComplicationTemplateGraphicCircularClosedGaugeText(gaugeProvider: CLKSimpleGaugeProvider(style: CLKGaugeProviderStyle.fill, gaugeColor: gaugeColor, fillFraction: (Float(beatTime)!/1000)), centerTextProvider: beatProvider)
case .graphicRectangular:
// Create a template from the graphic Rectangular family.
return CLKComplicationTemplateGraphicRectangularTextGauge(headerTextProvider: CLKSimpleTextProvider(text: "@Beats"), body1TextProvider: beatProvider, gaugeProvider: CLKSimpleGaugeProvider(style: CLKGaugeProviderStyle.fill, gaugeColor: gaugeColor, fillFraction: (Float(beatTime)!/1000)))
return CLKComplicationTemplateGraphicRectangularTextGauge(headerTextProvider: CLKSimpleTextProvider(text: ".Beats"), body1TextProvider: beatProvider, gaugeProvider: CLKSimpleGaugeProvider(style: CLKGaugeProviderStyle.fill, gaugeColor: gaugeColor, fillFraction: (Float(beatTime)!/1000)))
case .graphicCorner:
// Create a template from the graphic Corner family.
return CLKComplicationTemplateGraphicCornerGaugeText(gaugeProvider: CLKSimpleGaugeProvider(style: CLKGaugeProviderStyle.fill, gaugeColor: gaugeColor, fillFraction: (Float(beatTime)!/1000)), outerTextProvider: beatProvider)
case .extraLarge:
// Create a template from the extra large watch face.
//beatProvider = CLKSimpleTextProvider(text: beatTime)
return CLKComplicationTemplateExtraLargeRingText(textProvider: beatProvider, fillFraction: (Float(beatTime)!/1000), ringStyle: CLKComplicationRingStyle.closed)
case .graphicExtraLarge:
// Create a template from the graphic extra large watch face.
//beatProvider = CLKSimpleTextProvider(text: beatTime)
return CLKComplicationTemplateGraphicExtraLargeCircularClosedGaugeText(gaugeProvider: CLKSimpleGaugeProvider(style: CLKGaugeProviderStyle.fill, gaugeColor: gaugeColor, fillFraction: (Float(beatTime)!/1000)), centerTextProvider: beatProvider)
default:
return nil
}
Expand All @@ -55,7 +64,7 @@ class ComplicationController: NSObject, CLKComplicationDataSource {

func getComplicationDescriptors(handler: @escaping ([CLKComplicationDescriptor]) -> Void) {
let descriptors = [
CLKComplicationDescriptor(identifier: "org.mulot.beattime.BeatTimeWatchOS", displayName: "Beats Time", supportedFamilies: [.circularSmall, .modularSmall, .modularLarge, .utilitarianSmall, .utilitarianSmallFlat, .graphicCircular, .graphicRectangular]),
CLKComplicationDescriptor(identifier: "org.mulot.beattime.BeatTimeWatchOS", displayName: "Beats Time", supportedFamilies: [.circularSmall, .modularSmall, .modularLarge, .utilitarianSmall, .utilitarianSmallFlat, .graphicCircular, .graphicRectangular, .graphicCorner, .extraLarge, .graphicExtraLarge]),
// Multiple complication support can be added here with more descriptors
]

Expand Down

0 comments on commit 03645d8

Please sign in to comment.