KarlContainerUI
Primary Compose UI component for visualizing and interacting with a KARL AI container.
This composable provides a comprehensive visual representation of an active KARL container, displaying real-time learning progress, current predictions, and system status. It serves as the primary interface between users and the AI system, offering transparency into the learning process and immediate access to AI-generated insights.
Component Architecture:
Reactive State Management:
Built on Kotlin StateFlows for efficient, reactive state observation
Automatic recomposition when container state changes
Minimal performance impact through targeted state subscriptions
Thread-safe state updates from background learning processes
Material Design Compliance:
Follows Material Design 3 principles and component guidelines
Adaptive theming support with light/dark mode compatibility
Consistent typography, spacing, and visual hierarchy
Accessible color contrasts and semantic markup
Layout and Presentation:
Flexible column layout that adapts to available space
Minimum height constraints ensure content visibility
Responsive spacing and typography scaling
Clear visual hierarchy emphasizing current predictions
User Experience Features:
Learning Transparency:
Real-time progress indicator showing AI maturity level
Visual feedback for learning milestones and achievements
Clear status indicators for container operational state
Historical progress context for user understanding
Prediction Display:
Prominent display of current AI suggestions and recommendations
Confidence scoring with intuitive visual representation
Prediction type categorization for appropriate user response
Fallback content when no predictions are available
Interactive Elements:
Integration points for user feedback and preference controls
Action buttons for container management (reset, configure)
Instruction input mechanisms for behavior customization
Accessibility support for keyboard and screen reader navigation
Integration Patterns:
MVVM/MVI Architecture:
Designed for integration with modern Android architecture patterns
StateFlow parameters enable clean separation of concerns
ViewModel integration for complex state management scenarios
Support for unidirectional data flow patterns
State Flow Design:
// Example ViewModel integration:
class KarlViewModel : ViewModel() {
private val _predictionState = MutableStateFlow<Prediction?>(null)
val predictionState: StateFlow<Prediction?> = _predictionState.asStateFlow()
private val _progressState = MutableStateFlow(0f)
val progressState: StateFlow<Float> = _progressState.asStateFlow()
fun updateFromContainer(container: KarlContainer) {
viewModelScope.launch {
val prediction = container.getPrediction()
_predictionState.value = prediction
val insights = container.learningEngine.getLearningInsights()
_progressState.value = insights.progressEstimate
}
}
}Dependency Injection:
Compatible with Hilt, Dagger, and other DI frameworks
StateFlow parameters enable testable component design
Mock state injection for preview and testing scenarios
Clear dependency boundaries for modular development
Performance Considerations:
Efficient Recomposition:
StateFlow observation minimizes unnecessary recompositions
Targeted state collection prevents cascade updates
Stable parameter design reduces composition overhead
Lazy evaluation for expensive UI calculations
Memory Management:
StateFlow lifecycle tied to composition lifecycle
Automatic cleanup when component leaves composition
Efficient state subscription management
Memory-conscious prediction and progress caching
Customization and Theming:
Material Theming:
Respects application theme colors and typography
Automatic adaptation to light/dark mode changes
Support for dynamic color schemes (Material You)
Consistent visual language with host application
Layout Customization:
Modifier parameter for layout control and styling
Configurable spacing and sizing parameters
Support for different screen sizes and orientations
Integration with custom design systems
Accessibility Features:
Screen Reader Support:
Semantic content descriptions for all UI elements
Proper heading hierarchy and navigation structure
Dynamic content announcements for state changes
Alternative text for visual progress indicators
Keyboard Navigation:
Tab order optimization for efficient navigation
Focus management for interactive elements
Keyboard shortcuts for common actions
Visual focus indicators for clarity
Usage Examples:
Basic Integration:
@Composable
fun MainScreen(viewModel: KarlViewModel = viewModel()) {
KarlContainerUI(
predictionState = viewModel.predictionState,
learningProgressState = viewModel.progressState
)
}Advanced Customization:
@Composable
fun CustomKarlUI(container: KarlContainer) {
val prediction by container.predictionFlow.collectAsState()
val progress by container.progressFlow.collectAsState()
KarlContainerUI(
predictionState = container.predictionFlow,
learningProgressState = container.progressFlow
)
}Parameters
StateFlow emitting the current AI prediction or suggestion. Provides reactive updates when new predictions are generated or when prediction confidence changes. Null values indicate no current prediction is available.
StateFlow emitting the current learning progress as a normalized value between 0.0 and 1.0. Represents the AI system's maturity and confidence in its learned patterns. Values closer to 1.0 indicate more mature and reliable learning.
See also
For the structure of AI-generated suggestions and recommendations
For the progress visualization component
For core data models used in state flows