-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
131 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "info.h" | ||
|
||
bool Info::isDarkMode() { | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
|
||
namespace Info | ||
{ | ||
bool isDarkMode(); | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#import <AppKit/AppKit.h> | ||
#include "info.h" | ||
|
||
bool Info::isDarkMode() { | ||
NSString *darkModeMode = @"Dark"; | ||
NSString *osxMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"]; | ||
// check here if dark mode; | ||
return [darkModeMode isEqualToString:osxMode]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "info_wrap.h" | ||
|
||
Napi::FunctionReference InfoWrap::constructor; | ||
|
||
Napi::Object InfoWrap::init(Napi::Env env, Napi::Object exports) { | ||
Napi::HandleScope scope(env); | ||
char CLASSNAME[] = "Info"; | ||
Napi::Function func = DefineClass(env, CLASSNAME, { | ||
StaticMethod("isDarkMode", &InfoWrapStatic::isDarkMode), | ||
}); | ||
constructor = Napi::Persistent(func); | ||
exports.Set(CLASSNAME, func); | ||
return exports; | ||
} | ||
|
||
|
||
InfoWrap::InfoWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap<InfoWrap>(info) { | ||
Napi::Env env = info.Env(); | ||
Napi::HandleScope scope(env); | ||
} | ||
|
||
Napi::Value InfoWrapStatic::isDarkMode(const Napi::CallbackInfo& info) { | ||
Napi::Env env = info.Env(); | ||
Napi::HandleScope scope(env); | ||
bool isDarkMode = Info::isDarkMode(); | ||
return Napi::Value::From(env, isDarkMode); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
#include <napi.h> | ||
#include <stdlib.h> | ||
#include "info.h" | ||
|
||
class InfoWrap : public Napi::ObjectWrap<InfoWrap>{ | ||
public: | ||
static Napi::Object init(Napi::Env env, Napi::Object exports); | ||
InfoWrap(const Napi::CallbackInfo& info); | ||
~InfoWrap(); | ||
static Napi::FunctionReference constructor; | ||
}; | ||
|
||
|
||
namespace InfoWrapStatic { | ||
Napi::Value isDarkMode(const Napi::CallbackInfo& info); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,59 @@ | ||
import React from 'react'; | ||
import {render} from 'ink'; | ||
import SelectInput from 'ink-select-input'; | ||
import React from "react"; | ||
import { render } from "ink"; | ||
import SelectInput from "ink-select-input"; | ||
|
||
import { AboutPanel } from "./lib/aboutPanel"; | ||
import { Dock } from "./lib/dock"; | ||
import { Info, Dock, AboutPanel } from "./index"; | ||
|
||
const Demo = () => { | ||
const handleSelect = (item: any) => { | ||
switch(item.value) { | ||
case 'hideDock': | ||
switch (item.value) { | ||
case "hideDock": | ||
Dock.hide(); | ||
break; | ||
case 'showDock': | ||
case "showDock": | ||
Dock.show(); | ||
break; | ||
case 'openDefaultAbout': | ||
case "openDefaultAbout": | ||
AboutPanel.open(); | ||
break; | ||
case 'openCustomAbout': | ||
case "openCustomAbout": | ||
AboutPanel.open({ | ||
name: "NodeGUI OS utils", | ||
copyright: "Copyright © NodeGUI 2019", | ||
version: "78.0", | ||
applicationVersion: "78.0.3904.70" | ||
}); | ||
break; | ||
case "isDarkMode": | ||
console.log(Info.isDarkMode()); | ||
break; | ||
} | ||
}; | ||
|
||
const items = [{ | ||
label: 'Hide dock icon', | ||
value: 'hideDock' | ||
}, { | ||
label: 'Show dock icon', | ||
value: 'showDock' | ||
}, { | ||
label: 'Open default about window', | ||
value: 'openDefaultAbout' | ||
}, { | ||
label: 'Open custom about window', | ||
value: 'openCustomAbout' | ||
}]; | ||
const items = [ | ||
{ | ||
label: "Hide dock icon", | ||
value: "hideDock" | ||
}, | ||
{ | ||
label: "Show dock icon", | ||
value: "showDock" | ||
}, | ||
{ | ||
label: "Open default about window", | ||
value: "openDefaultAbout" | ||
}, | ||
{ | ||
label: "Open custom about window", | ||
value: "openCustomAbout" | ||
}, | ||
{ | ||
label: "Check if dark mode", | ||
value: "isDarkMode" | ||
} | ||
]; | ||
|
||
return <SelectInput items={items} onSelect={handleSelect}/>; | ||
return <SelectInput items={items} onSelect={handleSelect} />; | ||
}; | ||
|
||
render(<Demo/>); | ||
render(<Demo />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { Dock } from "./lib/dock"; | ||
export { AboutPanel } from "./lib/aboutPanel"; | ||
export { Info } from "./lib/info"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import addon from "./utils/addon"; | ||
|
||
export class Info { | ||
static isDarkMode(): boolean { | ||
return addon.Info.isDarkMode(); | ||
} | ||
} |