66 lines
2.8 KiB
TypeScript
66 lines
2.8 KiB
TypeScript
import type { PluginListenerHandle } from '@capacitor/core';
|
|
|
|
/**
|
|
* Colors are CSS color strings resolved on the web side from the chat theme
|
|
* variables, so the native bar matches light/dark mode and the in-app palette.
|
|
*/
|
|
export interface NativeInputTheme {
|
|
/** Bar / text field background. From `--chat-input-bg`. */
|
|
inputBackground?: string;
|
|
/** Text + caret color. From `--chat-input-text`. */
|
|
text?: string;
|
|
/** Placeholder color. */
|
|
placeholder?: string;
|
|
/** Accent used for the "+" button. From `--accent`. */
|
|
accent?: string;
|
|
/** Send button background. From `--chat-sent-bg`. */
|
|
sendBackground?: string;
|
|
/** Send button glyph color. From `--chat-sent-text`. */
|
|
sendText?: string;
|
|
/** Whether the app is currently in dark mode (drives the glass/blur tint). */
|
|
dark?: boolean;
|
|
}
|
|
|
|
export interface PresentOptions {
|
|
/** Identifies the active chat so re-presents for a different chat reset text. */
|
|
chatId: string;
|
|
placeholder?: string;
|
|
/** Pre-fill text (e.g. a half-typed draft when re-mounting). */
|
|
text?: string;
|
|
/** When false, the field is read-only and the send button is disabled. */
|
|
canSend?: boolean;
|
|
theme?: NativeInputTheme;
|
|
}
|
|
|
|
export interface NativeInputPlugin {
|
|
/** Create + show the native input bar pinned above the keyboard. */
|
|
present(options: PresentOptions): Promise<void>;
|
|
/** Remove the native input bar. */
|
|
dismiss(): Promise<void>;
|
|
setText(options: { text: string }): Promise<void>;
|
|
getText(): Promise<{ text: string }>;
|
|
focus(): Promise<void>;
|
|
blur(): Promise<void>;
|
|
setPlaceholder(options: { placeholder: string }): Promise<void>;
|
|
setEnabled(options: { enabled: boolean }): Promise<void>;
|
|
setTheme(options: { theme: NativeInputTheme }): Promise<void>;
|
|
/** Hide/show without tearing down (e.g. when navigating away briefly). */
|
|
setVisible(options: { visible: boolean }): Promise<void>;
|
|
|
|
/** Fires on every text edit. */
|
|
addListener(eventName: 'inputChange', listenerFunc: (data: { text: string }) => void): Promise<PluginListenerHandle>;
|
|
/** Fires when the user taps send / hits the send key. */
|
|
addListener(eventName: 'send', listenerFunc: (data: { text: string }) => void): Promise<PluginListenerHandle>;
|
|
/** Fires when the "+" attach button is tapped. */
|
|
addListener(eventName: 'attach', listenerFunc: () => void): Promise<PluginListenerHandle>;
|
|
/** Fires on focus / blur of the native field. */
|
|
addListener(eventName: 'focusChange', listenerFunc: (data: { focused: boolean }) => void): Promise<PluginListenerHandle>;
|
|
/**
|
|
* Fires when the space the bar (and keyboard) occupies changes, in CSS px,
|
|
* so the web layout can pad its scroll area / position the reply strip.
|
|
*/
|
|
addListener(eventName: 'heightChange', listenerFunc: (data: { bottomInset: number }) => void): Promise<PluginListenerHandle>;
|
|
|
|
removeAllListeners(): Promise<void>;
|
|
}
|