-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔀 Merge pull request #361 from
MrKai77/Luminare
✨ Luminare: New Settings Window + Other Improvements Merging since this is now stable enough for myself to consider this a "development version" (and the branch is called "develop")! Of course, there are still some minor bugs to be fixed, but those can be done in other PRs :D
- Loading branch information
Showing
184 changed files
with
4,811 additions
and
4,284 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ Loop.app | |
*.mode2v3 | ||
*.perspectivev3 | ||
*.xcuserstate | ||
project.xcworkspace | ||
xcuserdata | ||
Loop.zip | ||
Build/ | ||
Build/ |
Large diffs are not rendered by default.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
Loop.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
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,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict/> | ||
</plist> |
33 changes: 33 additions & 0 deletions
33
Loop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
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,33 @@ | ||
{ | ||
"originHash" : "c2a93a9d7a879ed92e3a49ac894535c44c007c6516c13aaedf4acff1c43a7b4a", | ||
"pins" : [ | ||
{ | ||
"identity" : "defaults", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/sindresorhus/Defaults", | ||
"state" : { | ||
"branch" : "main", | ||
"revision" : "38925e3cfacf3fb89a81a35b1cd44fd5a5b7e0fa" | ||
} | ||
}, | ||
{ | ||
"identity" : "menubarextraaccess", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/orchetect/MenuBarExtraAccess", | ||
"state" : { | ||
"revision" : "f5896b47e15e114975897354c7e1082c51a2bffd", | ||
"version" : "1.0.5" | ||
} | ||
}, | ||
{ | ||
"identity" : "sparkle", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/sparkle-project/Sparkle", | ||
"state" : { | ||
"branch" : "2.x", | ||
"revision" : "e9989a8ae7d09c946d07d325d71414024bd1e2dd" | ||
} | ||
} | ||
], | ||
"version" : 3 | ||
} |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// | ||
// AboutViewManager.swift | ||
// AboutViewController.swift | ||
// Loop | ||
// | ||
// Created by Kai Azim on 2023-04-08. | ||
|
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,100 @@ | ||
// | ||
// AppDelegate+UNNotifications.swift | ||
// Loop | ||
// | ||
// Created by Kai Azim on 2024-06-03. | ||
// | ||
|
||
import SwiftUI | ||
import UserNotifications | ||
|
||
extension AppDelegate: UNUserNotificationCenterDelegate { | ||
func userNotificationCenter( | ||
_: UNUserNotificationCenter, | ||
didReceive response: UNNotificationResponse, | ||
withCompletionHandler completionHandler: @escaping () -> () | ||
) { | ||
if response.actionIdentifier == "setIconAction", | ||
let icon = response.notification.request.content.userInfo["icon"] as? String { | ||
IconManager.setAppIcon(to: icon) | ||
} | ||
|
||
completionHandler() | ||
} | ||
|
||
// Implementation is necessary to show notifications even when the app has focus! | ||
func userNotificationCenter( | ||
_: UNUserNotificationCenter, | ||
willPresent _: UNNotification, | ||
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> () | ||
) { | ||
completionHandler([.banner]) | ||
} | ||
|
||
static func requestNotificationAuthorization() { | ||
UNUserNotificationCenter.current().requestAuthorization( | ||
options: [.alert] | ||
) { accepted, error in | ||
if !accepted { | ||
print("User Notification access denied.") | ||
} | ||
|
||
if let error { | ||
print(error) | ||
} | ||
} | ||
} | ||
|
||
private static func registerNotificationCategories() { | ||
let setIconAction = UNNotificationAction( | ||
identifier: "setIconAction", | ||
title: .init(localized: .init("Notification/Set Icon: Action", defaultValue: "Set Current Icon")), | ||
options: .destructive | ||
) | ||
let notificationCategory = UNNotificationCategory( | ||
identifier: "icon_unlocked", | ||
actions: [setIconAction], | ||
intentIdentifiers: [] | ||
) | ||
UNUserNotificationCenter.current().setNotificationCategories([notificationCategory]) | ||
} | ||
|
||
static func areNotificationsEnabled() -> Bool { | ||
let group = DispatchGroup() | ||
group.enter() | ||
|
||
var notificationsEnabled = false | ||
|
||
UNUserNotificationCenter.current().getNotificationSettings { notificationSettings in | ||
notificationsEnabled = notificationSettings.authorizationStatus != UNAuthorizationStatus.denied | ||
group.leave() | ||
} | ||
|
||
group.wait() | ||
return notificationsEnabled | ||
} | ||
|
||
static func sendNotification(_ content: UNMutableNotificationContent) { | ||
let uuidString = UUID().uuidString | ||
let request = UNNotificationRequest( | ||
identifier: uuidString, | ||
content: content, | ||
trigger: nil | ||
) | ||
|
||
requestNotificationAuthorization() | ||
registerNotificationCategories() | ||
|
||
UNUserNotificationCenter.current().add(request) | ||
} | ||
|
||
static func sendNotification(_ title: String, _ body: String) { | ||
let content = UNMutableNotificationContent() | ||
|
||
content.title = title | ||
content.body = body | ||
content.categoryIdentifier = UUID().uuidString | ||
|
||
AppDelegate.sendNotification(content) | ||
} | ||
} |
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
Oops, something went wrong.