-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
Custom storage for shortcuts #139
base: main
Are you sure you want to change the base?
Conversation
This adds a protocol to allow for custom storage. It will default to UserDefaults unless anything else has been specified prior to calling KeyboardShortcuts.initialize()
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.
Comments about additional comment and border effects covering
@@ -137,7 +138,11 @@ public enum KeyboardShortcuts { | |||
guard !isInitialized else { | |||
return | |||
} | |||
|
|||
|
|||
if storageProvider == nil { |
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.
I suggest that a 'else' statement should be added to this 'if' just in case. This will help cover border effects.
@@ -277,29 +282,28 @@ public enum KeyboardShortcuts { | |||
You would usually not need this as the user would be the one setting the shortcut in a settings user-interface, but it can be useful when, for example, migrating from a different keyboard shortcuts package. | |||
*/ | |||
public static func setShortcut(_ shortcut: Shortcut?, for name: Name) { |
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.
Adding comments about the parameters will help the understanding of this method.
This has been correctly done in 'Name.swift' 👍🏻
Related to #18, I've tried to implement a protocol to allow for custom storage implementations. It still defaults to using UserDefaults unless anything else has been specified before running
KeyboardShortcuts.initialize()
.You can consider this WIP, since it would probably be nice to add more tests etc, and documentation with examples how to use it.