feat(touch_bar): use icon for new note

This commit is contained in:
Elian Doran 2025-03-08 11:51:55 +02:00
parent a170bec3db
commit 3358b405e9
No known key found for this signature in database

View File

@ -3,10 +3,12 @@ import Component from "../components/component.js";
export default class TouchBarWidget extends Component {
nativeImage: typeof import("electron").nativeImage;
remote: typeof import("@electron/remote");
constructor() {
super();
this.nativeImage = utils.dynamicRequire("electron").nativeImage;
this.remote = utils.dynamicRequire("@electron/remote") as typeof import("@electron/remote");
this.#setTouchBar();
}
@ -14,22 +16,24 @@ export default class TouchBarWidget extends Component {
#setTouchBar() {
const touchBarData = this.#buildTouchBar();
this.remote.getCurrentWindow().setTouchBar(touchBarData);
console.log("Setting touch bar", touchBarData);
}
#buildTouchBar() {
const { nativeImage } = this;
const { TouchBar } = this.remote;
const { TouchBarButton } = this.remote.TouchBar;
const items = [
new TouchBarButton({
label: "New note",
icon: nativeImage.createFromNamedImage("NSTouchBarAddDetailTemplate", [-1, 0, 1]),
click: () => {
console.log("New note pressed.");
}
})
];
return new this.remote.TouchBar({
console.log("Update ", items);
return new TouchBar({
items
});
}