-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add button for dev menu #42
Conversation
@jakub-gonet is attempting to deploy a commit to the software-mansion Team on Vercel. To accomplish this, @jakub-gonet needs to request access to the Team. Afterwards, an owner of the Team is required to accept their membership request. If you're already a member of the respective Vercel Team, make sure that your Personal Vercel Account is connected to your GitHub account. |
if (platform === Platform.IOS) { | ||
this.devtools.send("rnp_iosDevMenu"); | ||
} else { | ||
await (this.device as AndroidEmulatorDevice).openDevMenu(); | ||
} |
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.
- This should live in
metro.ts
ideally. - Can't be method on
DeviceBase
because needs devtools to send an event – no need to add it into method signature nor class state. - Polimorphism failed me here but
if
never disappoint.
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.
Looks good, added some minor comments inline. Please address these before merging.
@@ -130,6 +130,14 @@ export function PreviewAppWrapper({ children, ...rest }) { | |||
newRoute && push(newRoute); | |||
}); | |||
|
|||
agent._bridge.addListener("rnp_iosDevMenu", (_payload) => { |
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 changed the prefix we use recently for commands to RNIDE_
IIRC. Can you update it here
<SettingsDropdown project={project} disabled={devicesNotFound}> | ||
<SettingsDropdown | ||
project={project} | ||
isDeviceRunning={projectState.status === "running"} |
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.
maybe not worth adding extra parameter given we already pass project down
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.
We'd need to call getProjectState()
which returns a promise which is harder to work with so I opted to use the status if we have it there.
@@ -281,6 +281,13 @@ export class Project implements Disposable, MetroDelegate, ProjectInterface { | |||
this.deviceSession?.openNavigation(navigationItemID); | |||
} | |||
|
|||
public async openDevMenu() { | |||
const currentDevice = this.projectState.selectedDevice; | |||
if (currentDevice !== undefined) { |
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.
why do we need this check? Seems like the device session implementation should deal with this type of edge cases and here should should just delegate it to it
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 had a hard time structuring this code. We'd need to pass selectedDevice
to device session. We could also add platform()
callback to DeviceBase
which would be really convenient but it kinda defeats the purpose of subclassing.
Initially I thought this wasn't the best idea but right now seems like not bad solution.
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.
The best solution would be to create openDevMenu
in BaseDevice
but in case of iOS it'd need devtools
which I don't like.
c621475
to
125f678
Compare
@@ -37,6 +37,10 @@ export class AndroidEmulatorDevice extends DeviceBase { | |||
super(); | |||
} | |||
|
|||
public platform(): Platform { |
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.
change to public get platform
125f678
to
d8e2f11
Compare
Adds a button in IDE settings that opens dev menu. On iOs it uses native module to open it, on Android we spawn adb process and send
KEYCODE_MENU
(code 82) to the emulator.Resolves #30.
android.mov
ios.mov