66 lines
2.2 KiB
TypeScript
66 lines
2.2 KiB
TypeScript
import type { PluginListenerHandle } from '@capacitor/core';
|
|
|
|
/** A network row rendered in the sidebar. Shapes match `global.networks`. */
|
|
export interface SidebarNetwork {
|
|
id: number;
|
|
name: string;
|
|
abbreviation: string;
|
|
logo?: string | null;
|
|
displayOrder?: number;
|
|
data?: {
|
|
announcements?: { text: string }[];
|
|
members?: { id: number }[];
|
|
};
|
|
}
|
|
|
|
export interface SidebarProfile {
|
|
id: number;
|
|
first_name?: string;
|
|
last_name?: string;
|
|
email?: string;
|
|
image_path?: string | null;
|
|
}
|
|
|
|
export interface SidebarData {
|
|
/** Origin that serves the UI (quill.js, Sidebar.js, host page). */
|
|
uiOrigin: string;
|
|
/** Origin that serves images (logos, avatars). */
|
|
serverOrigin: string;
|
|
profile: SidebarProfile;
|
|
networks: SidebarNetwork[];
|
|
currentNetworkId?: number | null;
|
|
/** Current theme key: light | parchment | dark | red. */
|
|
theme?: string;
|
|
/** Whether the current user may create networks. */
|
|
canCreateNetwork?: boolean;
|
|
}
|
|
|
|
/** An action forwarded from the sidebar's content web view to the main app. */
|
|
export interface SidebarAction {
|
|
type: 'selectNetwork' | 'openProfile' | 'createNetwork' | 'setTheme' | 'logout';
|
|
abbreviation?: string;
|
|
value?: string;
|
|
}
|
|
|
|
export interface NativeSidebarPlugin {
|
|
/** Create (pre-warm) the drawer if needed and push the latest data into it. */
|
|
setData(data: SidebarData): Promise<void>;
|
|
/** Update just the theme (key) without re-sending all data. */
|
|
setTheme(options: { theme: string }): Promise<void>;
|
|
/** Animate the drawer open. */
|
|
open(): Promise<void>;
|
|
/** Animate the drawer closed. */
|
|
close(): Promise<void>;
|
|
/** Enable/disable the edge-drag gesture (disabled on deep routes). */
|
|
setEnabled(options: { enabled: boolean }): Promise<void>;
|
|
/** Tear down the drawer entirely. */
|
|
dismiss(): Promise<void>;
|
|
|
|
/** Fires when the user taps something in the sidebar content. */
|
|
addListener(eventName: 'action', listenerFunc: (data: SidebarAction) => void): Promise<PluginListenerHandle>;
|
|
/** Fires when the drawer finishes opening/closing. */
|
|
addListener(eventName: 'stateChange', listenerFunc: (data: { open: boolean }) => void): Promise<PluginListenerHandle>;
|
|
|
|
removeAllListeners(): Promise<void>;
|
|
}
|