Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
dependencies ▾

Modern-Apps.git / library / ui / AGENTS.md

AGENTS.md13.9 KiBRenderedCodeRaw
1# AGENTS.md — library/ui/ (':library:ui')
2
3> Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `library/ui/` + allowed shared modules. Do not root-scan.
4
5- Gradle: :library:ui / dir: library/ui/
6- Package roots present: ui
7- Entry files: MaActivity.kt, AppScaffold.kt, Icons.kt + icons.tsv (no app MainActivity/Route — this is the shared shell)
8- Deps: :library
9- Network: none — offline-banner connectivity UI lives in `:library:network`
10 (`util/ConnectivityCompose.kt`); network apps depend on it directly
11- Metadata: metadata_data/library-ui.md (absent — libraries have none by design)
12- Rust: no / screenshotTest: no
13
14## Overview
15**Purpose:** All shared Compose chrome for every app — activity shells, scaffolds, theme, icons, messenger, editors, motion. If it renders in more than one app, it lives here.
16**How to use (must-rules, enforced by lint):**
17- Activities extend `MaActivity` (or `MaFragmentActivity` for biometric-gated apps) — override `Content()` + `onCreateBeforeContent()`, never repeat the edge-to-edge/theme shell
18- **Settings pages are strict (owner direction 2026-12-05):** a settings screen is `SettingsPage(title, onNavigateBack, importExport, ds) { … }` from `SettingsPage.kt`, and its body may only compose `SettingsScope` members (`Section`, `Toggle`, `Slider`, `Choice`, `MultiChoice`, `RadioChoice`, `TextInput`, `Stepper`, `ColorChoice`, `Action`, `DestructiveAction`, `Info`, `Footer`, `Divider`). No raw `SettingsRow`/`ListItem`/`Switch`/`Slider`/`OutlinedTextField`/`Button`/divider/spacer UI, and no other form inputs, belong in an app settings page — the DSL members delegate to the shared rows so title/description/padding/trailing-control formatting is identical everywhere. Controls take a value + callback or a `SettingsBinding` built from the app's `<App>Prefs` flows/setters; that prefs owner is the `ds` (`SettingsDataStore`, whose `backupFormat` powers the `importExport = true` backup section via `BackupButtons`) and is the only class opening that app's DataStore. A vocabulary gap is a library change (add a `SettingsScope` member here), never a one-off row in an app.
19- Screens use the `AppScaffold` family (never raw `Scaffold`); icons via the generated `IconXxx()` wrappers (manifest `icons.tsv`, generated at build time by `GenerateIconsTask`; never `Icon()`/`painterResource()`/`material.icons.*` in apps, never hand-edit the generated file — add one manifest line and rebuild); messages via `rememberMessenger()`/`AppMessages` (never `Toast`); motion via the `Motion*` helpers (never raw `animation` at call sites)
20**Areas:** activity shells (`MaActivity.kt`) · scaffolds (`AppScaffold`, `Detail`/`LazyList`/`TabbedPager`/`Setup`, `ListPage`) · theme + tokens (`DynamicTheme`, `Material*`, `Spacing`, `Modifier`, `Motion*`) · `Icons.kt` · messenger (`Messages.kt`) · editors (Html/Markdown/Odf + controllers) · pickers + dialogs (`dialog/`) · game chrome (`game/`) · ODF/doc export (`odf/`) · panorama · permissions + special-access · adaptive/wide layouts (`AdaptiveGrid`, `DesktopMaxWidth`, `PaneMargins`) · connectivity banner (`util/ConnectivityCompose.kt`).
21**Entry points + reading order:** `MaActivity.kt` → `AppScaffold.kt` → `Icons.kt` → `Messages.kt` → `DynamicTheme.kt`, then the area you need.
22**Gotchas:**
23- One public `@Composable` per file, named as the file; closed package roots still apply inside this library
24- Never `imePadding()`/`navigationBarsPadding()`/`systemBarsPadding()` in this library's reusable components: the shared `Scaffold` wrapper owns IME (unconditional `contentWindowInsets ∪ ime`, consumed as `navigationBars ∪ ime` for content, so a stray inset modifier under an AppScaffold-family screen is a no-op). Exceptions that still own their insets: `bottomBar`-slot bars (`EditorBottomBar`, `BottomAppBar` — outside consumed content) and non-Scaffold overlays (`HistoryScrubberCard` — nav-bars only, suppressed with justification)
25- Connectivity UI (`OfflineAware`/`rememberIsOnline`) lives in `:library:network`, not here
26- `MaFragmentActivity(autoSetContent=false)` + `showContent()` is the biometric-gate pattern (passwords, photos)
27
28## Key files
29### Shell + scaffolds — start here
30- com/vayunmathur/library/ui/MaActivity.kt — shared activity shell (incl. `MaFragmentActivity`); installs the custom splash (`installSplashScreen`, never held, no exit animation — the theme in `:library` supplies icon/background) before `super.onCreate`; `deferAfterFirstFrame` queues non-essential startup work past the first drawn frame
31- com/vayunmathur/library/ui/StartupTiming.kt — permanent cold-start marks (activityCreate→firstFrame→fullyDrawn, logged via `Log`) + `FirstFrameGate`/`StartupMarks`/`FullyDrawnGate`; first frame is TTID only, `reportFullyDrawn` fires solely from `StartupTiming.onFullyDrawn`
32- com/vayunmathur/library/ui/FullyDrawn.kt — `FullyDrawnWhen(ready)` composable: signals TTFD once primary content is interactive (drive `ready` from loaded-content state, never first frame)
33- com/vayunmathur/library/ui/AppScaffold.kt
34- com/vayunmathur/library/ui/DetailScaffold.kt
35- com/vayunmathur/library/ui/LazyListScaffold.kt
36- com/vayunmathur/library/ui/TabbedPagerScaffold.kt
37- com/vayunmathur/library/ui/SwipeBetweenRoutes.kt — `Modifier.swipeBetweenRoutes`: horizontal swipe/fling on a content region becomes a sibling-route switch (inner horizontal scrollers and vertical lists win their gestures)
38- com/vayunmathur/library/ui/SwipeRouteHost.kt — sibling-route host: top bar + tab row + bottom bar/FAB rendered outside the swiping content (and outside any hosted `MainNavigation`), so host chrome stays still and only content takes the route transition
39- com/vayunmathur/library/ui/SetupScaffold.kt
40- com/vayunmathur/library/ui/ListPage.kt
41### Theme + tokens
42- com/vayunmathur/library/ui/DynamicTheme.kt
43- com/vayunmathur/library/ui/Icons.kt — hand-written `AppIcon` + `IconNavigation` back buttons; ONLY place (with the generated wrappers) allowed `Icon()`/`painterResource()`
44- com/vayunmathur/library/ui/icons.tsv — icon manifest, the source of truth for every generated `IconXxx()` wrapper (name, kind, Material/drawable/vector source, content description, KDoc)
45- com/vayunmathur/library/ui/IconsCustom.kt — hand-authored `ImageVector`s (`Book2`, lane-guidance vectors, `HelpOutlineVector`) the manifest references as `vector:<name>`
46- com/vayunmathur/library/ui/Messages.kt — messenger + `AppMessages`
47- com/vayunmathur/library/ui/MaterialAliases.kt
48- com/vayunmathur/library/ui/MaterialComponents.kt
49- com/vayunmathur/library/ui/MaterialComponentsExtra.kt
50- com/vayunmathur/library/ui/MaterialFunctions.kt
51- com/vayunmathur/library/ui/Motion.kt — motion helpers (use these, not raw animation)
52- com/vayunmathur/library/ui/MotionValues.kt
53- com/vayunmathur/library/ui/Spacing.kt
54- com/vayunmathur/library/ui/Modifier.kt
55- com/vayunmathur/library/ui/ContentColorOn.kt
56- com/vayunmathur/library/ui/VerticalShape.kt
57- com/vayunmathur/library/ui/DateString.kt
58- com/vayunmathur/library/ui/RememberClock.kt
59### Adaptive + wide layouts
60- com/vayunmathur/library/ui/AdaptiveGrid.kt
61- com/vayunmathur/library/ui/AdaptiveWindow.kt
62- com/vayunmathur/library/ui/DesktopMaxWidth.kt
63- com/vayunmathur/library/ui/PaneMargins.kt
64- com/vayunmathur/library/ui/SwappedContent.kt
65- com/vayunmathur/library/ui/SwappedTopBar.kt
66- com/vayunmathur/library/ui/TopAppBarOverlay.kt
67- com/vayunmathur/library/ui/SafeListItemLayout.kt
68### Common screens + state
69- com/vayunmathur/library/ui/StateScreens.kt
70- com/vayunmathur/library/ui/NoPermissionsScreen.kt
71- com/vayunmathur/library/ui/DashboardSection.kt
72- com/vayunmathur/library/ui/GameCenterScreen.kt
73- com/vayunmathur/library/ui/AchievementNotification.kt
74- com/vayunmathur/library/ui/HistoryScrubber.kt
75- com/vayunmathur/library/ui/SelectionMode.kt
76- com/vayunmathur/library/ui/SwipeActionsBox.kt
77- com/vayunmathur/library/ui/CommonSearchBar.kt
78- com/vayunmathur/library/ui/ScaffoldSearch.kt — scaffold `search` parameter value (screen-level search is declared here, never by placing CommonSearchBar in app content; fatal `ScaffoldSearch` lint)
79- com/vayunmathur/library/ui/OverflowMenu.kt
80- com/vayunmathur/library/ui/ConfirmDialog.kt
81- com/vayunmathur/library/ui/SingleChoiceDialog.kt
82- com/vayunmathur/library/ui/TextInputDialog.kt
83- com/vayunmathur/library/ui/AddToListDialog.kt
84- com/vayunmathur/library/ui/BannerVisibility.kt
85- com/vayunmathur/library/ui/ExpandVisibility.kt
86- com/vayunmathur/library/ui/FadeVisibility.kt
87- com/vayunmathur/library/ui/PopVisibility.kt
88- com/vayunmathur/library/ui/FreeHeightBottomSheet.kt
89- com/vayunmathur/library/ui/FreeHeightSheetState.kt
90### Media viewer
91- com/vayunmathur/library/ui/ZoomState.kt — pure zoom/pan value + anchored pinch, clamp, double-tap math
92- com/vayunmathur/library/ui/ZoomGestures.kt — `zoomGestures()` pinch/pan/double-tap modifier, pager-friendly (photos viewer, appstore screenshots)
93### Forms + settings
94- com/vayunmathur/library/ui/FormComponents.kt
95- com/vayunmathur/library/ui/FormSection.kt
96- com/vayunmathur/library/ui/SettingsPage.kt — the settings host + strict DSL (`SettingsScope`: Section/Toggle/Slider/Choice/MultiChoice/RadioChoice/TextInput/Stepper/ColorChoice/Action/DestructiveAction/Info/Footer/Divider); the only way to build a settings page
97- com/vayunmathur/library/ui/SettingsBinding.kt — `SettingsBinding<T>` + `SettingsDataStore` (`ds`): the persistence seam an app's `<App>Prefs` implements; library/ui opens no DataStore
98- com/vayunmathur/library/ui/SettingsComponents.kt
99- com/vayunmathur/library/ui/SettingsMenuRow.kt — settings row that opens a menu of actions (no persistent selection; use `SettingsSelectRow` in `SettingsComponents.kt` for picking a value)
100- com/vayunmathur/library/ui/SettingsSliderRow.kt
101- com/vayunmathur/library/ui/SettingsRadioRow.kt
102- com/vayunmathur/library/ui/SettingsFooter.kt
103- com/vayunmathur/library/ui/DailyReminderSettingsSection.kt
104- com/vayunmathur/library/ui/MultiCategoryPicker.kt
105- com/vayunmathur/library/ui/RingtonePicker.kt
106- com/vayunmathur/library/ui/BackupButtons.kt — shared backup destination picker buttons
107- com/vayunmathur/library/ui/ShareVaultDialog.kt — everysync vault share dialog
108### Reorderable grids
109- com/vayunmathur/library/ui/ReorderableGrid.kt
110- com/vayunmathur/library/ui/ReorderableGridGestures.kt
111- com/vayunmathur/library/ui/ReorderableUtil.kt
112### Permissions + system access
113- com/vayunmathur/library/ui/AppPermissionsGate.kt
114- com/vayunmathur/library/ui/PermissionRequest.kt
115- com/vayunmathur/library/ui/PermissionRequirement.kt
116- com/vayunmathur/library/ui/SpecialAccess.kt
117- com/vayunmathur/library/ui/ExternalIntents.kt
118- com/vayunmathur/library/ui/AppPullToRefreshBox.kt
119### Maps + sensors
120- com/vayunmathur/library/ui/MapsPoiVectors.kt
121- com/vayunmathur/library/ui/MapUnavailableMessage.kt
122- com/vayunmathur/library/ui/CompassCalibrationBanner.kt
123- com/vayunmathur/library/ui/CompassCalibrationHint.kt
124### Panorama
125- com/vayunmathur/library/ui/PanoramaCameraState.kt
126- com/vayunmathur/library/ui/PanoramaCrop.kt
127- com/vayunmathur/library/ui/PanoramaSphere.kt
128- com/vayunmathur/library/ui/PanoramaSphereView.kt
129### Editors — Html
130- com/vayunmathur/library/ui/HtmlEditor.kt
131- com/vayunmathur/library/ui/HtmlEditorController.kt
132- com/vayunmathur/library/ui/HtmlEditorControllerCore.kt
133- com/vayunmathur/library/ui/HtmlEditorSpans.kt
134- com/vayunmathur/library/ui/HtmlSerialize.kt
135- com/vayunmathur/library/ui/HtmlText.kt — `scrollInternally`/`fitContentToWidth` for long untrusted mail
136- com/vayunmathur/library/ui/HtmlTextDocument.kt — pure document wrapper (viewport, CSP, fit CSS)
137- com/vayunmathur/library/ui/RichEmailSpans.kt
138- com/vayunmathur/library/ui/EditorFormatter.kt
139- com/vayunmathur/library/ui/EditorLink.kt
140### Editors — Markdown
141- com/vayunmathur/library/ui/MarkdownEditor.kt
142- com/vayunmathur/library/ui/MarkdownEditOps.kt
143- com/vayunmathur/library/ui/MarkdownToHtml.kt
144- com/vayunmathur/library/ui/OdfMarkdownEditor.kt
145### dialog/ — date/time pickers
146- com/vayunmathur/library/ui/dialog/DatePickerDialog.kt
147- com/vayunmathur/library/ui/dialog/TimePickerDialog.kt
148### game/ — shared game chrome
149- com/vayunmathur/library/ui/game/GameModeChooser.kt
150- com/vayunmathur/library/ui/game/GameResultOverlay.kt
151- com/vayunmathur/library/ui/game/GameTopBarActions.kt
152- com/vayunmathur/library/ui/game/GameInfoBox.kt
153- com/vayunmathur/library/ui/game/GameInfoBoxes.kt
154- com/vayunmathur/library/ui/game/DailyChallengeCard.kt
155- com/vayunmathur/library/ui/game/DailyStreakText.kt
156- com/vayunmathur/library/ui/game/HeartsRow.kt
157- com/vayunmathur/library/ui/game/FormatDuration.kt
158### odf/ — document model + exporters
159- com/vayunmathur/library/ui/odf/OdfDocument.kt
160- com/vayunmathur/library/ui/odf/OdfText.kt
161- com/vayunmathur/library/ui/odf/OdfTextEditorState.kt
162- com/vayunmathur/library/ui/odf/OdfTextEditorView.kt
163- com/vayunmathur/library/ui/odf/OdfTextHelpers.kt
164- com/vayunmathur/library/ui/odf/OdfParagraphOps.kt
165- com/vayunmathur/library/ui/odf/OdfRunEdits.kt
166- com/vayunmathur/library/ui/odf/OdfDocTransform.kt
167- com/vayunmathur/library/ui/odf/OdfListPrefixes.kt
168- com/vayunmathur/library/ui/odf/OdfMetadata.kt
169- com/vayunmathur/library/ui/odf/OdfTables.kt
170- com/vayunmathur/library/ui/odf/OdfSlides.kt
171- com/vayunmathur/library/ui/odf/OdfSerializer.kt
172- com/vayunmathur/library/ui/odf/HtmlOdfConverter.kt
173- com/vayunmathur/library/ui/odf/HtmlOdfExport.kt
174- com/vayunmathur/library/ui/odf/MarkdownOdfConverter.kt
175- com/vayunmathur/library/ui/odf/RtfOdfConverter.kt
176- com/vayunmathur/library/ui/odf/EpubExporter.kt
177- com/vayunmathur/library/ui/odf/OoxmlExporter.kt
178- com/vayunmathur/library/ui/odf/PdfExporter.kt
179- com/vayunmathur/library/ui/odf/LatexExporter.kt
180### Connectivity
181- com/vayunmathur/library/util/ConnectivityCompose.kt — offline banner (`OfflineAware`); lives in `:library:network`, not this module
182- com/vayunmathur/library/ui/Haptics.kt
183
184## Verify (this module only)
185```
186./gradlew :library:ui:compileDevKotlin
187./gradlew :library:ui:lint
188python3 scripts/check_icons_parity.py <old Icons.kt> library/ui/src/main/java/com/vayunmathur/library/ui/Icons.kt library/ui/build/generated/kotlin/generateDevIcons/IconsGenerated.kt
189```