mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-20 22:50:11 -04:00
* fix(UI): remove the swift code that was causing the top bar to show when the window is maximized * fix(UI): limit the keybind handler to the `$libraryId` layout The keybind handler is how we get MacOS menu bar events to the front-end, and to navigate to the settings page correctly we need the current library UUID. We should hide/disable the settings button (and any future buttons that require a library/certain state - e.g. during onboarding) from the menu bar. * chore(swift): remove unused function * fix(UI): git didn't detect hook rename * fix(deps): revert tauri version downgrade Was probably caused by a bad merge * fix(UI): remove rounding of window borders on macos This was allowing the borders to still show on MacOS, despite the app being fully maximized. This doesn't impact non-maximized styling of the app, as we have native window decorations enabled within the Tauri config (well, that's my best guess as to why this fixes the issue). * fix(UI): conditionally enable/disable menu items on macos This is dependent on whether a library is present or not. If there's no library, we disable things such as copy/paste/select all. * fix(UI): try and conditionally show the border radius I think some cached files aren't being rebuilt correctly as this *should* work fine, it uses the same conditions as the traffic lights do to determine if we're fullscreen or not. * remove copy/select all/paste as they have uses outside of the explorer * feat(UI): overhaul native macos menu * fix: add toast for quick rescan and free up the ctrl+r keybind * more menu rearrangements * update menu further * add comment about rounded edges * some polish * add working overview redirect * fix(UI): correct border edges when non-maximized, and full corners when maximized * cleanup event handling * add media view and disable non-working buttons * fix(UI): raise sidebar on fullscreen to prevent empty corner * adjust settings padding when maximized on macos * failed sidebar animation * rm old stuff * fix(UI): better transitions (i'm learning!) * add comment about why new library is disabled during onboarding * make the settings page static and `pt-6` * add mock-up library selector in menu * `maximized` -> `fullScreen` * fix animation when fullscreening * clippy * change animation to 300ms --------- Co-authored-by: ameer2468 <33054370+ameer2468@users.noreply.github.com>
88 lines
3.3 KiB
TypeScript
88 lines
3.3 KiB
TypeScript
import { createContext, useContext, type PropsWithChildren } from 'react';
|
|
import { auth } from '@sd/client';
|
|
|
|
export type OperatingSystem = 'browser' | 'linux' | 'macOS' | 'windows' | 'unknown';
|
|
|
|
// Platform represents the underlying native layer the app is running on.
|
|
// This could be Tauri or web.
|
|
export type Platform = {
|
|
platform: 'web' | 'tauri'; // This represents the specific platform implementation
|
|
getThumbnailUrlByThumbKey: (thumbKey: string[]) => string;
|
|
getFileUrl: (libraryId: string, locationLocalId: number, filePathId: number) => string;
|
|
getFileUrlByPath: (path: string) => string;
|
|
openLink: (url: string) => void;
|
|
// Tauri patches `window.confirm` to return `Promise` not `bool`
|
|
confirm(msg: string, cb: (result: boolean) => void): void;
|
|
getOs?(): Promise<OperatingSystem>;
|
|
openDirectoryPickerDialog?(opts?: { title?: string; multiple: false }): Promise<null | string>;
|
|
openDirectoryPickerDialog?(opts?: {
|
|
title?: string;
|
|
multiple?: boolean;
|
|
}): Promise<null | string | string[]>;
|
|
openFilePickerDialog?(): Promise<null | string | string[]>;
|
|
saveFilePickerDialog?(opts?: { title?: string; defaultPath?: string }): Promise<string | null>;
|
|
showDevtools?(): void;
|
|
openPath?(path: string): void;
|
|
openLogsDir?(): void;
|
|
userHomeDir?(): Promise<string>;
|
|
// Opens a file path with a given ID
|
|
openFilePaths?(library: string, ids: number[]): any;
|
|
openEphemeralFiles?(paths: string[]): any;
|
|
revealItems?(
|
|
library: string,
|
|
items: (
|
|
| { Location: { id: number } }
|
|
| { FilePath: { id: number } }
|
|
| { Ephemeral: { path: string } }
|
|
)[]
|
|
): Promise<unknown>;
|
|
getFilePathOpenWithApps?(library: string, ids: number[]): Promise<unknown>;
|
|
reloadWebview?(): Promise<unknown>;
|
|
getEphemeralFilesOpenWithApps?(paths: string[]): Promise<unknown>;
|
|
openFilePathWith?(library: string, fileIdsAndAppUrls: [number, string][]): Promise<unknown>;
|
|
openEphemeralFileWith?(pathsAndUrls: [string, string][]): Promise<unknown>;
|
|
refreshMenuBar?(): Promise<unknown>;
|
|
setMenuBarItemState?(id: string, enabled: boolean): Promise<unknown>;
|
|
lockAppTheme?(themeType: 'Auto' | 'Light' | 'Dark'): any;
|
|
updater?: {
|
|
useSnapshot: () => UpdateStore;
|
|
checkForUpdate(): Promise<Update | null>;
|
|
installUpdate(): Promise<any>;
|
|
runJustUpdatedCheck(onViewChangelog: () => void): Promise<void>;
|
|
};
|
|
auth: auth.ProviderConfig;
|
|
landingApiOrigin: string;
|
|
};
|
|
|
|
export type Update = { version: string; body: string | null };
|
|
export type UpdateStore =
|
|
| { status: 'idle' }
|
|
| { status: 'loading' }
|
|
| { status: 'error' }
|
|
| { status: 'updateAvailable'; update: Update }
|
|
| { status: 'noUpdateAvailable' }
|
|
| { status: 'installing' };
|
|
|
|
// Keep this private and use through helpers below
|
|
const context = createContext<Platform>(undefined!);
|
|
|
|
// is a hook which allows you to fetch information about the current platform from the React context.
|
|
export function usePlatform(): Platform {
|
|
const ctx = useContext(context);
|
|
if (!ctx)
|
|
throw new Error(
|
|
"The 'PlatformProvider' has not been mounted above the current 'usePlatform' call."
|
|
);
|
|
|
|
return ctx;
|
|
}
|
|
|
|
// provides the platform context to the rest of the app through React context.
|
|
// Mount it near the top of your component tree.
|
|
export function PlatformProvider({
|
|
platform,
|
|
children
|
|
}: PropsWithChildren<{ platform: Platform }>) {
|
|
return <context.Provider value={platform}>{children}</context.Provider>;
|
|
}
|