-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split sync and async API #50
Merged
Merged
Conversation
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
Be-ing
reviewed
Dec 10, 2024
I'll go ahead and merge this. |
madsmtm
reviewed
Jan 1, 2025
Comment on lines
+9
to
+27
let user_defaults: *mut NSObject = msg_send![class!(NSUserDefaults), standardUserDefaults]; | ||
let apple_domain = NSString::from_str("Apple Global Domain"); | ||
let dict: *mut NSObject = msg_send![user_defaults, persistentDomainForName:&*apple_domain]; | ||
|
||
if !dict.is_null() { | ||
let style_key = NSString::from_str("AppleInterfaceStyle"); | ||
let style: *mut NSObject = msg_send![dict, objectForKey:&*style_key]; | ||
|
||
if !style.is_null() { | ||
// Compare with "Dark" | ||
let dark_str = NSString::from_str("Dark"); | ||
let is_dark: bool = msg_send![style, isEqualToString:&*dark_str]; | ||
is_dark | ||
} else { | ||
false | ||
} | ||
} else { | ||
false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip: You can avoid the brittle msg_send!
here by importing NSUserDefaults
from objc2-foundation
(might have to modify Cargo.toml
to include the "NSUserDefaults"
Cargo feature first).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces several changes to the codebase to add support for both synchronous and asynchronous detection and subscription to system theme changes.
The changes include modifications to dependencies, new feature flags, and refactoring of existing code to accommodate the new functionality.
Warning
These are breaking changes, we should consider shipping v2.0.0 after merging this.
Dependency and feature flag updates:
Cargo.toml
: Addedsync
feature flag and updatedpollster
to be optional. Introduced new example paths forsync
and added thecocoa
andobjc
dependencies for macOS support.Refactoring and new functionality:
src/lib.rs
: Moved theMode
enum to a newmode
module and updated thedetect
andsubscribe
functions to support both synchronous and asynchronous operations.src/mode.rs
: Created a new module for theMode
enum and its associated methods.src/platforms/*
: Refactored platform-specific detection and subscription functions to support both synchronous and asynchronous operations. This includes changes in macOS, freedesktop, websys, and windows modules.Example updates:
examples/async.rs
: Added a new asynchronous example demonstrating the use of thedetect
andsubscribe
functions.examples/sync.rs
: Added a new synchronous example demonstrating the use of thedetect
andsubscribe
functions.detect.rs
andnotify.rs
as they were replaced by the newasync.rs
andsync.rs
examples.Fixes: