chore(react/collections): reintroduce calendar title & type touch bar

This commit is contained in:
Elian Doran
2025-09-06 14:59:57 +03:00
parent 4c20ac0b1c
commit 1917c04baf
4 changed files with 61 additions and 13 deletions

View File

@@ -26,6 +26,15 @@ interface ButtonProps {
enabled?: boolean;
}
interface SegmentedControlProps {
mode: "single" | "buttons";
segments: {
label: string;
}[];
selectedIndex?: number;
onChange?: (selectedIndex: number, isSelected: boolean) => void;
}
interface TouchBarContextApi {
addItem(item: TouchBarItem): void;
TouchBar: typeof Electron.TouchBar;
@@ -72,6 +81,8 @@ export default function TouchBar({ children }: TouchBarProps) {
}
});
console.log("Touch bar state", isFocused, items);
return (
<TouchBarContext.Provider value={api}>
{children}
@@ -119,3 +130,17 @@ export function TouchBarButton({ label, click, enabled }: ButtonProps) {
return <></>;
}
export function TouchBarSegmentedControl({ mode, segments, selectedIndex, onChange }: SegmentedControlProps) {
const api = useContext(TouchBarContext);
if (api) {
const item = new api.TouchBar.TouchBarSegmentedControl({
mode, segments, selectedIndex,
change: onChange
});
api.addItem(item);
}
return <></>;
}