twostraws / ControlRoom

A macOS app to control the Xcode Simulator.
MIT License
5.75k stars 306 forks source link

Expose and add access to simulator locations on disk. Implement drag/drop to copy to sim Files directory #132

Closed erwinmaza closed 3 years ago

erwinmaza commented 3 years ago

Hello @twostraws, and thanks for open sourcing this utility. I found it a great way to practice SwiftUI and learn how to do new things, by breaking, fixing, and expanding on a working app.

This PR's main objective is to make it easy to add files to a simulator's local files directory. There are now 4 ways to accomplish this:

Via the simulator's System tab:

  1. Click Open in Finder to open a finder window at the simulator's File Provider Storage folder on disk.
  2. Click Open in Terminal to open a Terminal window at the simulator's File Provider Storage folder on disk.
  3. Drag a file, or files, or folder(s) on to the Files Path section, then drop to copy the items.

You can also copy the full path to your clipboard.

Via the sidebar:

  1. Select 2 or more simulators in the sidebar, then drag a file, or files, or folder(s) on to the drop target, then drop to copy the items to each selected simulator that is booted.

For drag and drop, I convey success or failure to the user by playing a "success" or "failure" system sound for each file for each simulator. Note: to allow the user to distinguish the different sounds, there is a 1 second delay between copy attempts. This will not scale well if the user drops a large folder structure.

This PR also adds Copy, Open in Finder and Open in Terminal for the simulator's root data path. It also allows you to Copy its Device ID.

I hope you find this functionality useful. Let me know if you'd like to see changes.

Erwin

erwinmaza commented 3 years ago

Screenshots of the new UI including file drop targets

Screen Shot 2021-04-20 at 3 35 13 PM Screen Shot 2021-04-20 at 3 36 05 PM

twostraws commented 3 years ago

This looks like a really nice set of changes! One thing I'm not sure about is the "Files Path" UI – it's in some sort of group box by itself, presumably for the drag and drop. I'm not sure if there's a better way that could be presented?

erwinmaza commented 3 years ago

Thanks Paul.

Yes, the border around the Files Path is intended to convey the size of the drop target. Also it gives visual indication that the drop will succeed by changing color when the dragged files hover over it.

Potentially both of those objectives could be met by using different background colors instead of a border. But the look and hover effects are subjective, and are easy enough to fiddle with by changing this modifier: https://github.com/twostraws/ControlRoom/blob/9a8accae59927b070be07be1d0e1733a6af5e740/ControlRoom/Simulator%20UI/ControlScreens/SystemView.swift#L151

Feel free to adjust that (or any part of this PR) to your liking, as you are probably in the best position to determine what is a better way to present something in your app. I imagine you'll want to apply the same effect to the multi-simulator drop target as well for consistency: https://github.com/twostraws/ControlRoom/blob/9a8accae59927b070be07be1d0e1733a6af5e740/ControlRoom/Main%20Window/SplitLayoutView.swift#L42

twostraws commented 3 years ago

Okay! I'll go ahead and merge this, but if anyone has suggestions for how the layout can be improved I'd love to see them – I think just a little bit of extra styling might go a long way.