Skip to content

Commit

Permalink
Merge pull request #9 from mulot/swiftdatanotifs
Browse files Browse the repository at this point in the history
Swiftdatanotifs
  • Loading branch information
mulot authored Aug 23, 2024
2 parents cc12940 + 9f7f194 commit 0d4b31f
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 61 deletions.
70 changes: 38 additions & 32 deletions BeatTime.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_TEAM = VNLK894MAE;
GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -975,15 +975,15 @@
"@executable_path/../../Frameworks",
"@executable_path/../../../../Frameworks",
);
MARKETING_VERSION = 1.3;
MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime.watchkitapp.BeatTimeWidgetWatchOS;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 9.1;
WATCHOS_DEPLOYMENT_TARGET = 10.0;
};
name = Debug;
};
Expand All @@ -994,7 +994,7 @@
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_TEAM = VNLK894MAE;
GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -1007,7 +1007,7 @@
"@executable_path/../../Frameworks",
"@executable_path/../../../../Frameworks",
);
MARKETING_VERSION = 1.3;
MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime.watchkitapp.BeatTimeWidgetWatchOS;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
Expand All @@ -1016,7 +1016,7 @@
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 4;
VALIDATE_PRODUCT = YES;
WATCHOS_DEPLOYMENT_TARGET = 9.1;
WATCHOS_DEPLOYMENT_TARGET = 10.0;
};
name = Release;
};
Expand Down Expand Up @@ -1083,16 +1083,16 @@
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CODE_SIGN_ENTITLEMENTS = BeatTimeWidgetiOSExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_TEAM = VNLK894MAE;
INFOPLIST_FILE = "$(SRCROOT)/Widget iOS/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.5;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.3;
MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime.BeatTimeWidgetiOS;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
Expand All @@ -1112,16 +1112,16 @@
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CODE_SIGN_ENTITLEMENTS = BeatTimeWidgetiOSExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_TEAM = VNLK894MAE;
INFOPLIST_FILE = "$(SRCROOT)/Widget iOS/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.5;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.3;
MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime.BeatTimeWidgetiOS;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
Expand Down Expand Up @@ -1197,21 +1197,21 @@
ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_TEAM = VNLK894MAE;
INFOPLIST_FILE = "$(SRCROOT)/WatchOS WatchKit App/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.3;
MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime.watchkitapp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 7.4;
WATCHOS_DEPLOYMENT_TARGET = 10.0;
};
name = Debug;
};
Expand All @@ -1223,33 +1223,33 @@
ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_TEAM = VNLK894MAE;
INFOPLIST_FILE = "$(SRCROOT)/WatchOS WatchKit App/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.3;
MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime.watchkitapp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 4;
VALIDATE_PRODUCT = YES;
WATCHOS_DEPLOYMENT_TARGET = 7.4;
WATCHOS_DEPLOYMENT_TARGET = 10.0;
};
name = Release;
};
947C5658264814F2007E6B4A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 6;
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_TEAM = VNLK894MAE;
IPHONEOS_DEPLOYMENT_TARGET = 14.5;
MARKETING_VERSION = 1.2;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime;
PRODUCT_NAME = BeatTime;
SDKROOT = iphoneos;
Expand All @@ -1261,10 +1261,10 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 6;
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_TEAM = VNLK894MAE;
IPHONEOS_DEPLOYMENT_TARGET = 14.5;
MARKETING_VERSION = 1.2;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime;
PRODUCT_NAME = BeatTime;
SDKROOT = iphoneos;
Expand All @@ -1280,18 +1280,19 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_ASSET_PATHS = "\"iOS/Preview Content\"";
DEVELOPMENT_TEAM = VNLK894MAE;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = "$(SRCROOT)/iOS/Info.plist";
INFOPLIST_KEY_CFBundleDisplayName = BeatTime;
IPHONEOS_DEPLOYMENT_TARGET = 14.5;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.3;
MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
Expand All @@ -1307,18 +1308,19 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_ASSET_PATHS = "\"iOS/Preview Content\"";
DEVELOPMENT_TEAM = VNLK894MAE;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = "$(SRCROOT)/iOS/Info.plist";
INFOPLIST_KEY_CFBundleDisplayName = BeatTime;
IPHONEOS_DEPLOYMENT_TARGET = 14.5;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.3;
MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = org.mulot.beattime;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
Expand Down Expand Up @@ -1435,14 +1437,15 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.5;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
MACOSX_DEPLOYMENT_TARGET = 11.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
WATCHOS_DEPLOYMENT_TARGET = 10.0;
};
name = Debug;
};
Expand Down Expand Up @@ -1494,13 +1497,14 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.5;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
MACOSX_DEPLOYMENT_TARGET = 11.1;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
WATCHOS_DEPLOYMENT_TARGET = 10.0;
};
name = Release;
};
Expand All @@ -1520,6 +1524,7 @@
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/MacOS/Info.plist";
INFOPLIST_KEY_CFBundleDisplayName = BeatTime;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
Expand Down Expand Up @@ -1548,6 +1553,7 @@
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/MacOS/Info.plist";
INFOPLIST_KEY_CFBundleDisplayName = BeatTime;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
Expand Down
25 changes: 18 additions & 7 deletions WatchOS WatchKit Extension/BeatTimeApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import SwiftUI
import os
import SwiftData

//let notificationCenter = UNUserNotificationCenter.current()
let manager = LocalNotificationManager()
Expand All @@ -24,9 +25,10 @@ struct BeatTimeApp: App {
ContentView()
ConvertView()
AlarmView()
.modelContainer(for: Notification.self)
}.tabViewStyle(PageTabViewStyle())
}.onChange(of: scenePhase) { (phase) in
switch phase {
}.onChange(of: scenePhase) { oldPhase, newPhase in
switch newPhase {
case .inactive:
logger.debug("Scene became inactive.")
case .active:
Expand Down Expand Up @@ -117,8 +119,8 @@ struct ConvertView: View {
}.font(.title.bold())
}

}.onChange(of: selection) { time in
updateClock(time)
}.onChange(of: selection) { oldTime, newTime in
updateClock(newTime)
}
}

Expand Down Expand Up @@ -165,10 +167,12 @@ struct AlarmView: View {

func setNotification(msg: String, date: Date) -> Void {
if (date.timeIntervalSinceNow < 0) {
manager.addNotification(title: msg, time: 86400 + date.timeIntervalSinceNow, date: date.addingTimeInterval(86400))
let notif = Notification(id: UUID().uuidString, title: msg, timer: 86400 + date.timeIntervalSinceNow, date: date.addingTimeInterval(86400))
manager.addNotification(notif: notif)
}
else {
manager.addNotification(title: msg, time: date.timeIntervalSinceNow, date: date)
let notif = Notification(id: UUID().uuidString, title: msg, timer: date.timeIntervalSinceNow, date: date)
manager.addNotification(notif: notif)
}
}

Expand All @@ -184,8 +188,15 @@ struct AlarmView: View {
.font(.title.bold())
}
HStack {
Text(DateFormatter.localizedString(from: BeatTime.date(beats: selection), dateStyle: .short, timeStyle: .short))
let date = BeatTime.date(beats: selection)
if (date.timeIntervalSinceNow < 0) {
Text(DateFormatter.localizedString(from: date.addingTimeInterval(86400), dateStyle: .short, timeStyle: .short))
.font(.title3.bold())
}
else {
Text(DateFormatter.localizedString(from: date, dateStyle: .short, timeStyle: .short))
.font(.title3.bold())
}
}
Button("Set notif ", action: {
self.setNotification(msg: "@\(selection) .beats", date: BeatTime.date(beats: selection))
Expand Down
6 changes: 4 additions & 2 deletions Widget/BeatTimeWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ struct GaugeWidget : View {
Text(entry.beat)
}
#if os(iOS) || os(watchOS)
.widgetBackground(Color.white)
//.widgetBackground(Color.white)
.widgetBackground(Color("WidgetBackground"))
#endif
}
}
Expand Down Expand Up @@ -215,7 +216,8 @@ struct RectangularsWidget : View {
}
}
#if os(iOS) || os(watchOS)
.widgetBackground(Color.white)
//.widgetBackground(Color.white)
.widgetBackground(Color("WidgetBackground"))
#endif
}
}
Expand Down
Loading

0 comments on commit 0d4b31f

Please sign in to comment.