feature: pin emulator to the top of the list
This pull request introduces the ability to pin simulators/emulators to the top of the list. It includes changes to the UserDefaults extension to store pinned devices, modifications to the SubMenuItem structure to add a "TogglePinToTop" action, updates to the Device model to include a "pinned" Bool property, and adjustments to the DeviceService for toggling the pinned status.
- Users can now pin/unpin simulators and emulators.
- The pinned status is persistent across application sessions.
Note that the menu items are not being sorted currently. I just wanted to create the PR to get an initial feedback on if I am going in the right direction.
Some thoughts:
- It would nice to be able to change
SubMenuActionItemor the content ofSubMenuActionItembased on the state of the Device. Example:Pin to toplabel and icon could change toUnpin to topbased on the device state. - It would be nice if we could store the device list in a state and updating the state would automatically update the UI.
Please provide your feedback @okwasniewski @Garfeild
Closes #70
Thanks for opening the PR!
Storing this inside of Device model would be beneficial for Raycast extension as it could also sort devices according to pinned ones first. So I think keeping it that way makes sense.
It would nice to be able to change SubMenuActionItem or the content of SubMenuActionItem based on the state of the Device. Example: Pin to top label and icon could change to Unpin to top based on the device state.
I'm not really sure how to achieve this with current refactor of menus. Maybe we could pass the current device to its menu item?
I've quickly launched the app - what I've noticed is that although pinned items are correctly persisted across app launches, they are not sorted. You need to take that into account in populateDevicesMenu method.
I was also thinking about the appearance - maybe we could leverage the mixedStateImage https://developer.apple.com/documentation/appkit/nsmenuitem/1514827-mixedstateimage?language=objc and display pin when device is not launched (because when its launched it has a checkmark).