Skip to content

Commit

Permalink
[menu-bar] Add support for showing dock icon while windows are opened (
Browse files Browse the repository at this point in the history
…#50)

* [menu-bar] Add support for showing dock icon while windows are opened

* Add changelog entry
  • Loading branch information
gabrieldonadel committed Sep 18, 2023
1 parent 36615bf commit e1ae045
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

### 🎉 New features

- Show dock icon while windows are opened. ([#50](https://github.com/expo/orbit/pull/50) by [@gabrieldonadel](https://github.com/gabrieldonadel))

### 🐛 Bug fixes

### 💡 Others
Expand Down
7 changes: 7 additions & 0 deletions apps/menu-bar/macos/ExpoMenuBar-macOS/WindowNavigator.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ - (instancetype)init {

- (void)openWindow:(NSString *)moduleName options:(NSDictionary *)options {
dispatch_async(dispatch_get_main_queue(), ^{
if(self->_windowsMap.count == 0){
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
}

NSWindow *window = self->_windowsMap[moduleName];
NSString *title = options[@"title"] ?: moduleName;

Expand All @@ -50,6 +54,9 @@ - (void)openWindow:(NSString *)moduleName options:(NSDictionary *)options {

newWindow.deallocCallback = ^{
[self->_windowsMap removeObjectForKey:moduleName];
if(self->_windowsMap.count == 0){
[NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];
}
};

RCTBridge *bridge = [((AppDelegate *)[NSApp delegate])bridge];
Expand Down

0 comments on commit e1ae045

Please sign in to comment.