mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-07 04:23:29 +00:00
* wip for iDevices * Working HardwareModel Info for iOS * wip * Merge 'main' into 'mob-hw-info-overview' * Half-Working `get_volume()` * Objective c bridge to talk to FS * Working objc bridge The bridge works now, and we can now access the iOS file system using the native objective-c APIs instead for proper values, including on the simulator. * Isolate `icrate` for `ios` deployments only * Working Stats for Android * Clean Up + `pnpm format` * Fix to FSInfoResult Type Due to the RNFS fork change, I had to change the types to make it so it doesn't fail building and CI. * iOS Device Name Fix
36 lines
958 B
TypeScript
36 lines
958 B
TypeScript
import { DependencyList } from 'react';
|
|
import { HotkeyCallback, Options, useHotkeys } from 'react-hotkeys-hook';
|
|
|
|
interface UseKeyBindOptions extends Options {
|
|
repeatable?: boolean;
|
|
}
|
|
|
|
type UseKeyBindOptionsOrDependencyArray = UseKeyBindOptions | DependencyList;
|
|
|
|
export const useKeybind = (
|
|
keys: string | string[] | string[][],
|
|
callback: HotkeyCallback,
|
|
options?: UseKeyBindOptionsOrDependencyArray,
|
|
dependencies?: UseKeyBindOptionsOrDependencyArray
|
|
) => {
|
|
const keyCombination = Array.isArray(keys)
|
|
? Array.isArray(keys[0])
|
|
? keys.map((k) => (k as string[]).join('+'))
|
|
: keys.join('+')
|
|
: keys;
|
|
|
|
const repeatable =
|
|
typeof options === 'object' && 'repeatable' in options
|
|
? options.repeatable
|
|
: typeof dependencies === 'object' && 'repeatable' in dependencies
|
|
? dependencies.repeatable
|
|
: false;
|
|
|
|
return useHotkeys(
|
|
keyCombination,
|
|
(e, k) => (repeatable || !e.repeat) && callback(e, k),
|
|
options,
|
|
dependencies
|
|
);
|
|
};
|