-
Notifications
You must be signed in to change notification settings - Fork 146
AppKitNavigation - Navigation #213
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
Open
Mx-Iris
wants to merge
17
commits into
pointfreeco:main
Choose a base branch
from
MxIris-Library-Forks:appkit-navigation-navigation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e2c5db4
Common
Mx-Iris 0c61b63
Remove unused code
Mx-Iris c2bdb0d
Remove unused code
Mx-Iris 82c7737
Merge branch 'main' into appkit-navigation-common
stephencelis 8e5e4e6
Integrate custom transaction
stephencelis 2b91081
address fatal error
stephencelis cad947b
Round out animation
stephencelis e863c54
Update Package.swift
mbrandonw 00ed18a
Update Package@swift-6.0.swift
mbrandonw df6eda7
Support AppKit Navigation
Mx-Iris 04b6e54
Merge branch 'main' into appkit-navigation-navigation
Mx-Iris 2228ad1
Update Sources/AppKitNavigationShim/include/shim.h
Mx-Iris 47ac7b3
Update Sources/AppKitNavigation/Navigation/Sheet.swift
Mx-Iris 6111e32
Update Sources/AppKitNavigation/Navigation/ModalSessionContent.swift
Mx-Iris 3832d51
Fixes building errors
Mx-Iris 2479dba
Translate some protocol to internal
Mx-Iris 863c8d2
Completion
Mx-Iris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,36 @@ | ||
#if canImport(AppKit) && !targetEnvironment(macCatalyst) | ||
|
||
import AppKit | ||
|
||
struct AssociatedKeys { | ||
var keys: [AnyHashableMetatype: UnsafeMutableRawPointer] = [:] | ||
|
||
mutating func key<T>(of type: T.Type) -> UnsafeMutableRawPointer { | ||
let key = AnyHashableMetatype(type) | ||
if let associatedKey = keys[key] { | ||
return associatedKey | ||
} else { | ||
let associatedKey = malloc(1)! | ||
keys[key] = associatedKey | ||
return associatedKey | ||
} | ||
} | ||
} | ||
|
||
struct AnyHashableMetatype: Hashable { | ||
static func == (lhs: AnyHashableMetatype, rhs: AnyHashableMetatype) -> Bool { | ||
return lhs.base == rhs.base | ||
} | ||
|
||
let base: Any.Type | ||
|
||
init(_ base: Any.Type) { | ||
self.base = base | ||
} | ||
|
||
func hash(into hasher: inout Hasher) { | ||
hasher.combine(ObjectIdentifier(base)) | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
From what I can tell this is a helper that sets up an associated object. Is it doing anything else? If not, I'm inclined to be consistent with the pattern used in UIKitNavigation, where we define dedicated local keys where needed instead of leveraging a dynamic helper. How's that sound?
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.
Again because there is more than one type of object that can navigate, this is mainly used for Observer generic types like Sheet, the classes that can execute it are NSWindow, NSSavePanel, NSAlert, NSPrintPanel.... They are not necessarily of the same type, and each class has a different way of executing a sheet.
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.
Because associated keys are local to each object, does the type need to be encoded into the operation? Wouldn't it work the same to use the same static key instead?
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.
Because of the one-to-many relationship, a class that executes a sheet may have more than one observer (this class is mainly used to store the object that has been executed sheet), the object that is executed by the sheet is indeterminate, it may be NSAlert or NSWindow. Currently, storing the object that is executed by the sheet is mainly to perform cleanup work, if you have a If you have a better idea, let me know! 😄