UI System Architecture
Inkdown uses a bridge pattern to provide a consistent UI API across different platforms (Desktop/Web vs Mobile/React Native) while allowing for platform-specific implementations.Overview
The UI architecture ensures that plugins and core logic can create user interface elements like modals, settings, notices, and lists without knowing whether they are running in a DOM environment (React) or a native environment (React Native).Core Abstractions
1. UIBridge
Location:packages/core/src/ui/UIBridge.ts
The UIBridge is the entry point for all platform-specific UI operations.
2. IUIProvider
The provider interface defines methods to create UI element implementations.3. Implementation Interfaces
Each UI component has a corresponding interface that platform providers must implement.IModalImpl
ISettingImpl
INoticeImpl
Usage in Plugins
Plugins use high-level classes provided by@inkdown/core which wrap the bridge calls.
Creating a Modal
Creating Settings
Creating Notices
Platform Registration
Platforms register their specific UI strategies at startup.Desktop (Tauri/React)
Mobile (React Native - Future)
Platform Implementations
DOMUIProvider (Desktop/Web)
RNUIProvider (Mobile - Future)
Component Component APIs
Modal
Setting
Notice
Styling
UI components use CSS variables for theming:Best Practices
1. Always Use Abstractions
Never access DOM directly in plugins:2. Clean Up Resources
Always clean up inonClose() or onunload():
3. Use Type Safety
Leverage TypeScript for type safety:Related Documentation
- Architecture Overview - High-level architecture
- Plugin Development - Creating plugins with UI
- Theme System - Styling UI components
