Skip to content
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

New feature: pin emulator to the top of the list #70

Open
okwasniewski opened this issue Aug 27, 2023 · 15 comments · May be fixed by #91
Open

New feature: pin emulator to the top of the list #70

okwasniewski opened this issue Aug 27, 2023 · 15 comments · May be fixed by #91
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@okwasniewski
Copy link
Owner

The goal of this issue is to add a new feature that would allow users to "pin" simulators / emulators to the top of its corresponding sections (iOS/Android).

This would require adding a new field in the Device struct and then filtering the list when populating NSMenu so that favorite items are pinned to the top.

@okwasniewski okwasniewski added good first issue Good for newcomers enhancement New feature or request labels Aug 27, 2023
@dnafication
Copy link

@okwasniewski I'd be keen to give it a shot. Do you have any contribution guidelines or documentation on setting up the project the right way? I want to make sure I follow the correct procedures to avoid any potential conflicts. Also, I wanted to mention that I was able to successfully build and run the app without any issues. Looking forward to working with you on this project!

@okwasniewski
Copy link
Owner Author

Hey @dnafication!

I'm happy that you want to contribute! At the moment I don't have any guidelines (maybe it's time to create something 😄). If you've been able to build & run the app without issues then that's great. One guideline that I would like new contributors to follow is to format the code with Xcode built-in formatting tools (CMD+I). Besides that I think it's up to you - I don't want to enforce any strict rules.

@dnafication
Copy link

dnafication commented Oct 24, 2023

Thanks for the response. I do have a design related question. I've noticed that the menu item already show a tick ✔️ based on the device.booted property. What would it look like to add a pin (📌) beside that. Where do you want that pin to appear in the item?

@okwasniewski
Copy link
Owner Author

You could add an emoji next to the item's title. How I see this feature is that from the platform submenu user can select "Pin to top" and this would add the emoji (📌) and also show the emulator on top of each section (separate pins for iOS/Android). You can achieve this by filtering the list of devices.

Be careful when adding something to item's title as actions rely on item title so you can follow the way that the version is added to item title and show the pin only in displayName (Model/Device.swift).

@dnafication
Copy link

dnafication commented Oct 24, 2023

Great! I did manage to add a "Pin simulator" item in the submenu under each device. I am very new to Swift/AppKit/iOS/macOS in general 😄, so pardon me for asking stupid questions. What options do I have to persist user's pinned simulators? I believe the device list is dynamically retrieved every time the menu is loaded. So, we will need a way to track the list of pinned simulators somewhere. Can you suggest any sample code within the application that has similar functionality or some terms that I can google and understand? Appreciate the help!

20231024-192852 screencast

I will update the text to Pin to top

@dnafication
Copy link

Looks like ID is an optional field in Device, might have to use the name property to keep track of the pinned simulators.

@dnafication
Copy link

Pin emoji looks like this:

20231024-195630 screencast

@okwasniewski
Copy link
Owner Author

So regarding how to persist data, you can follow the approach of using UserDefaults. I was thinking about actually persisting the whole emulator list in there and then checking if something has changed. This would allow you to store isPinned property on Device model.

I can work on persisting the items and then on top of that, you could add isPinned there. Regarding ID property - it's optional because for Android we don't always have the ID it's available only when emulator is launched (we only have name - which is unique) but for iOS we have it all the time.

@dnafication
Copy link

Sure. Let me know when you have completed the persistence functionality and then I'll continue with it.

@Garfeild
Copy link
Contributor

Garfeild commented Oct 30, 2023

I was thinking about actually persisting the whole emulator list in there and then checking if something has changed.

I would suggest to not do it. Your source of truth is outside data, e.g. from xcrun. For sure it improve experience at app launch. But you will have to maintain it synchronized.

Regarding optional device id. For favorites you can simple persist list of devices. Since id is optional, you can store combination of the name and device id to cover both Android and iOS, e.g. with format like name:identifier. It will be something like that Pixel_3a_API_34_extension_level_7_arm64-v8a:no-identifier or iPhone 15:8F2CBF93-AEEE-45D3-9BB9-EE9EFADB9906.

@okwasniewski
Copy link
Owner Author

That's a valid point. Let's follow this path and store an array of devices. For android you can store just the name (as it should be unique) and for iOS you can store name:ID (as id will be always there for iOS).

You can follow how CustomCommands are saving data to UserDefaults (CustomCommands/CustomCommandsViewModel.swift)

@dnafication
Copy link

Thanks @Garfeild and @okwasniewski for pointing me the right direction. I'll come up with a PR soon.

@Garfeild
Copy link
Contributor

@dnafication I would suggest to wait until my PR #88 is merged. It will be easier to navigate Menu.swift for your changes.

@okwasniewski
Copy link
Owner Author

@dnafication FYI I've merged #88, so you can continue working on this issue 👍🏻

@dnafication
Copy link

Thanks 🙏

@dnafication dnafication linked a pull request Nov 14, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants