AgentSkillsCN

search-ui

搜索应用 UI 架构——Compose 组件层级(SearchTheme、MainActivity、SettingsActivity),基于枚举的导航模式(无需 Navigation Component),采用 Material 3 动态主题系统,可复用的设置组件(SettingsGroup、SettingsSwitch、SettingsSliderRow、SettingsNavigationRow)。

SKILL.md
--- frontmatter
name: search-ui
description: Search app UI architecture - Compose component hierarchy (SearchTheme, MainActivity, SettingsActivity), enum-based navigation pattern (no Navigation Component), dynamic theme system with Material 3, reusable settings components (SettingsGroup, SettingsSwitch, SettingsSliderRow, SettingsNavigationRow).

UI Architecture

Component Hierarchy

code
┌─────────────────────────────────────────────────────────────────┐
│                        SearchTheme                              │
│   (Dynamic colors, typography, shapes)                          │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│   MainActivity                    SettingsActivity              │
│   ┌─────────────────────┐        ┌─────────────────────────┐   │
│   │                     │        │                         │   │
│   │  ┌───────────────┐  │        │  AnimatedContent        │   │
│   │  │ SearchField   │  │        │  (screen transitions)   │   │
│   │  └───────────────┘  │        │                         │   │
│   │                     │        │  ┌───────────────────┐  │   │
│   │  ┌───────────────┐  │        │  │ GeneralSettings   │  │   │
│   │  │RecentAppsList │  │        │  │ Screen            │  │   │
│   │  └───────────────┘  │        │  └───────────────────┘  │   │
│   │                     │        │           or            │   │
│   │  ┌───────────────┐  │        │  ┌───────────────────┐  │   │
│   │  │  ItemsList    │  │        │  │ WebSearchSettings │  │   │
│   │  │  (results)    │  │        │  │ Screen            │  │   │
│   │  └───────────────┘  │        │  └───────────────────┘  │   │
│   │                     │        │           or            │   │
│   │  ┌───────────────┐  │        │  ┌───────────────────┐  │   │
│   │  │ContactAction  │  │        │  │ ...other screens  │  │   │
│   │  │Sheet          │  │        │  └───────────────────┘  │   │
│   │  └───────────────┘  │        │                         │   │
│   │                     │        │                         │   │
│   └─────────────────────┘        └─────────────────────────┘   │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Navigation Pattern

Settings uses enum-based screen state navigation (no Navigation Component):

kotlin
// Location: SettingsActivity.kt

private enum class Screen {
    Home, Providers, Appearance, Behavior, Aliases, Ranking,
    WebSearch, FileSearch, TextUtilities, AppSearch, ProviderList,
    SystemSettings, ContactsSettings, BackupRestore, TermuxSettings
}

@Composable
fun SettingsNavigation() {
    var currentScreen by remember { mutableStateOf(Screen.Home) }
    
    AnimatedContent(targetState = currentScreen) { screen ->
        when (screen) {
            Screen.Home -> GeneralSettingsScreen(
                onNavigate = { currentScreen = it }
            )
            Screen.Providers -> ProvidersSettingsScreen(...)
            Screen.WebSearch -> WebSearchSettingsScreen(...)
            // ... other screens
        }
    }
}

Theme System

kotlin
// Location: ui/theme/Theme.kt

@Composable
fun SearchTheme(
    darkTheme: Boolean = isSystemInDarkTheme(),
    dynamicColor: Boolean = true,
    content: @Composable () -> Unit
) {
    val colorScheme = when {
        dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
            if (darkTheme) dynamicDarkColorScheme(context)
            else dynamicLightColorScheme(context)
        }
        darkTheme -> DarkColorScheme
        else -> LightColorScheme
    }
    
    MaterialTheme(
        colorScheme = colorScheme,
        typography = Typography,
        content = content
    )
}

Theme Files

FilePurpose
ui/theme/Theme.ktSearchTheme, dynamic colors
ui/theme/Color.ktColor definitions
ui/theme/Type.ktTypography
ui/theme/MotionLocals.ktAnimation preferences

Reusable Settings Components

Located in ui/components/settings/:

ComponentPurpose
SettingsGroupGroups related settings with a header
SettingsSwitchToggle switch with label and description
SettingsSliderRowSlider for numeric values
SettingsNavigationRowClickable row that navigates to sub-screen
SettingsTextFieldText input field for settings

Usage Example

kotlin
@Composable
fun ExampleSettingsScreen() {
    Column {
        SettingsGroup(title = "General") {
            SettingsSwitch(
                title = "Enable Feature",
                description = "Description of what this does",
                checked = isEnabled,
                onCheckedChange = { /* update */ }
            )
            
            SettingsSliderRow(
                title = "Value",
                value = sliderValue,
                onValueChange = { /* update */ },
                valueRange = 0f..100f
            )
            
            SettingsNavigationRow(
                title = "Sub-settings",
                onClick = { onNavigate(Screen.SubSettings) }
            )
        }
    }
}

Main UI Components

Located in ui/components/:

ComponentPurposeLocation
SearchFieldSearch input fieldcomponents/SearchField.kt
ItemsListSearch results listcomponents/ItemsList.kt
RecentAppsListRecent apps horizontal listcomponents/RecentAppsList.kt
ContactActionSheetContact actions bottom sheetcomponents/ContactActionSheet.kt
BottomSheetGeneric bottom sheetcomponents/BottomSheet.kt

Related Skills

  • search-overview - Overall architecture
  • search-guides - Adding new settings screens