yayy notifs!!

made the about app icon better
This commit is contained in:
neon443
2025-05-06 21:03:53 +01:00
parent f8f5cdde26
commit b88bc11b36
5 changed files with 66 additions and 1 deletions

View File

@@ -16,6 +16,7 @@
A920C2BE2D24021A00E4F9B1 /* SFSymbolsPicker in Frameworks */ = {isa = PBXBuildFile; productRef = A920C2BD2D24021A00E4F9B1 /* SFSymbolsPicker */; };
A920C2C12D2403CA00E4F9B1 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A920C2C02D2403CA00E4F9B1 /* ContentView.swift */; };
A93BC0942D2B18A3002E8BBD /* StatsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A93BC0932D2B18A3002E8BBD /* StatsView.swift */; };
A949F8022DCAA0440064DCA0 /* NearFutureIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = A949F8012DCAA0440064DCA0 /* NearFutureIcon.png */; };
A973B26C2DC551310028F8A2 /* ImportView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A973B26B2DC551310028F8A2 /* ImportView.swift */; };
A973B2702DC552EB0028F8A2 /* ExportView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A973B26F2DC552EB0028F8A2 /* ExportView.swift */; };
A973B2712DC553050028F8A2 /* ExportView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A973B26F2DC552EB0028F8A2 /* ExportView.swift */; };
@@ -77,6 +78,7 @@
A920C2B72D2401A300E4F9B1 /* AddEventView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddEventView.swift; sourceTree = "<group>"; };
A920C2C02D2403CA00E4F9B1 /* ContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
A93BC0932D2B18A3002E8BBD /* StatsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatsView.swift; sourceTree = "<group>"; };
A949F8012DCAA0440064DCA0 /* NearFutureIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = NearFutureIcon.png; path = NearFuture/Assets.xcassets/AppIcon.appiconset/NearFutureIcon.png; sourceTree = SOURCE_ROOT; };
A973B26B2DC551310028F8A2 /* ImportView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImportView.swift; sourceTree = "<group>"; };
A973B26F2DC552EB0028F8A2 /* ExportView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExportView.swift; sourceTree = "<group>"; };
A977CC912DBBB48000DED8C0 /* ArchiveView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArchiveView.swift; sourceTree = "<group>"; };
@@ -139,6 +141,7 @@
isa = PBXGroup;
children = (
A90FDE222DC0D4310012790C /* Config.xcconfig */,
A949F8002DCAA0340064DCA0 /* Resources */,
A920C2862D24011400E4F9B1 /* NearFuture */,
A979F6082D270AF00094C0B3 /* NearFutureWidgets */,
A980FC382D93FB2B006A778F /* NearFutureTests */,
@@ -190,6 +193,14 @@
path = "Preview Content";
sourceTree = "<group>";
};
A949F8002DCAA0340064DCA0 /* Resources */ = {
isa = PBXGroup;
children = (
A949F8012DCAA0440064DCA0 /* NearFutureIcon.png */,
);
path = Resources;
sourceTree = "<group>";
};
A979F58A2D2700680094C0B3 /* NearFutureWidgets */ = {
isa = PBXGroup;
children = (
@@ -341,6 +352,7 @@
buildActionMask = 2147483647;
files = (
A920C2922D24011A00E4F9B1 /* Preview Assets.xcassets in Resources */,
A949F8022DCAA0440064DCA0 /* NearFutureIcon.png in Resources */,
A920C28E2D24011A00E4F9B1 /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;

View File

@@ -6,6 +6,7 @@
//
import SwiftUI
import UserNotifications
import SwiftData
enum Field {
@@ -73,6 +74,7 @@ struct ContentView: View {
}
}
.padding(.horizontal)
if filteredEvents.isEmpty && !searchInput.isEmpty {
HelpView(searchInput: $searchInput, focusedField: focusedField)
} else {
@@ -129,6 +131,11 @@ struct ContentView: View {
AddEventButton(showingAddEventView: $showingAddEventView)
}
}
.onAppear() {
Task {
notifsGranted = await requestNotifs()
}
}
}
}
.tabItem {

View File

@@ -9,6 +9,7 @@ import Foundation
import SwiftData
import SwiftUI
import WidgetKit
import UserNotifications
//@Model
//final class Item {
@@ -423,3 +424,19 @@ func plu(_ inp: Int) -> String {
public enum importError: Error {
case invalidB64
}
func requestNotifs() async -> Bool {
let result = try? await UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .carPlay, .sound])
return result ?? false
}
func scheduleNotif() {
let content = UNMutableNotificationContent()
content.title = "hi"
content.subtitle = "sss"
content.sound = .default
let identifier = UUID().uuidString
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false)
let request = UNNotificationRequest(identifier: identifier, content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request)
}

View File

@@ -2,6 +2,10 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.aps-environment</key>
<string>development</string>
<key>com.apple.developer.icloud-container-identifiers</key>
<array/>
<key>com.apple.developer.ubiquity-kvstore-identifier</key>

View File

@@ -17,6 +17,7 @@ struct SettingsView: View {
@State private var localCountEqualToiCloud: Bool = false
@State private var icloudCountEqualToLocal: Bool = false
@State private var importStr: String = ""
@State private var notifsGranted: Bool = false
func updateStatus() {
let vm = viewModel
@@ -67,6 +68,25 @@ struct SettingsView: View {
}
}
}
NavigationLink() {
List {
if !notifsGranted {
Button("Request Notifications") {
Task {
notifsGranted = await requestNotifs()
}
}
Text("\(Image(systemName: "xmark")) Notifications disabled for Near Future")
.foregroundStyle(.red)
} else {
Text("\(Image(systemName: "checkmark")) Notifications enabled for Near Future")
.foregroundStyle(.green)
}
}
} label: {
Image(systemName: "bell.badge.fill")
Text("Notifications")
}
NavigationLink() {
iCloudSettingsView(
viewModel: viewModel,
@@ -146,6 +166,11 @@ struct SettingsView: View {
}
}
}
.onAppear() {
Task {
notifsGranted = await requestNotifs()
}
}
.scrollContentBackground(.hidden)
.navigationTitle("Settings")
.apply {