Introducing a new way to review your PRs.

Read the announcement

junkfood02 / seal

🦭 Video/Audio Downloader for Android, based on yt-dlp

View on GitHub

13 documents · Updated Nov 16, 2026

docs / shared-compose-ui-components-and-theme

Shared Compose UI Components and Theme

Overview

This area is the app-wide Jetpack Compose UI foundation: common route constants, composition locals, motion helpers, themed vector artwork, reusable Material components, and Android resources used by those components.

Routing is centralized in app/…/Route.kt. Route defines the string routes for primary destinations (HOME, DOWNLOADS, PLAYLIST, SETTINGS, FORMAT_SELECTION, TASK_LIST, TASK_LOG) and settings subpages (APPEARANCE, INTERACTION, DOWNLOAD_FORMAT, COOKIE_PROFILE, AUTO_UPDATE, etc.). The infix helpers String.arg() and String.id() append navigation arguments (route/{arg}) and integer IDs (route/id), so route definitions and call sites should use the same constants rather than duplicating path text.

Theme state is bridged from app preferences into Compose by app/…/CompositionLocals.kt. SettingsProvider() collects PreferenceUtil.AppSettingsStateFlow, computes tonal palettes from either Android 12+ dynamic color or the stored seed color/palette style, then provides locals for dark theme preference, seed color, palette style, dynamic-color switch, fixed color roles, and window width size class. app/…/Theme.kt consumes those locals in SealTheme(): it applies Monet dynamicColorScheme, optionally forces black surface/background roles in high-contrast dark mode, updates light status-bar appearance on Android R+, installs app typography and shapes, and provides LocalFixedColorRoles derived from the current tonal palettes. app/…/ColorScheme.kt supplies fixed-role colors, the default seed color, auto-dark tone mapping, HCT label-color generation, and color harmonization helpers. app/…/Type.kt modifies Material typography so body text uses paragraph line breaking and all text styles use content-direction text; app/…/Shape.kt currently keeps default Material shapes. The platform XML themes in app/…/themes.xml use Material3 DayNight no-action-bar parents, transparent system bars for the main app theme, and a translucent transparent-background dialog theme.

The shared common helpers in app/src/main/java/com/junkfood/seal/ui/common/** provide small cross-cutting behavior. AsyncImageImpl.kt wraps Coil's AsyncImage with crossfade and the app image loader, but swaps in R.drawable.sample3 while running in Compose preview. AnimatedComposable.kt defines navigation builders that wrap NavGraphBuilder.composable() with shared-axis transitions; it chooses a predictive-back variant on Android 14+ by default and falls back to the legacy shared-axis variant on older Android versions. motion/MaterialSharedAxis.kt, motion/MotionConstants.kt, and motion/AnimationSpecs.kt hold the reusable easing curves and Material shared-axis enter/exit transitions. HapticFeedback.kt adds View extension helpers for clock-tick and long-press feedback, and Ext.kt creates remembered Compose state from stored preference keys.

Reusable components live in app/src/main/java/com/junkfood/seal/ui/component/**. The component set is not a single widget family; it standardizes app interaction patterns:

  • Buttons and icon buttons in Buttons.kt and IconButtons.kt wrap Material buttons with icon/text spacing, app strings, clipboard paste, back-button haptics, link opening, and long-tap behavior.
  • Dialog and sheet primitives in Dialogs.kt, DialogItems.kt, ModalBottomSheetM2.kt, and ModalBottomSheetM3.kt implement app-specific alert dialog padding, stacked dialog buttons, selectable dialog rows, switch/checkbox rows, M2 bottom sheets with navigation-bar spacer support, and M3 modal bottom sheets with expanded-by-default state.
  • Preference/settings rows in PreferenceItems.kt and SettingItem.kt define the app's preference list language: title/description rows, switch rows, switch-with-divider rows, caution/hint cards, template rows with multi-select behavior, credit rows, subtitles, and information blocks. Disabled state is expressed through applyOpacity() from Theme.kt, and selected/accent states often use FixedAccentColors/LocalFixedColorRoles from ColorScheme.kt.
  • Selection controls in SelectionGroup.kt, SegementedButton.kt, and Chips.kt wrap selectable surfaces, segmented buttons, assist chips, filter chips, shortcut chips, and fixed-role selected chip colors.
  • Input/search components in TextField.kt and SearchBar.kt provide transparent-container text fields, optional accessibility content descriptions, a delayed autofocus field that clears focus on IME Done, and a search bar with clear-button haptics.
  • Media/download display components in VideoCard.kt, VideoListItem.kt, FormatItem.kt, and DownloadQueueItem.kt provide shared visual treatments for thumbnails, media rows, format cards, playlist rows, and custom-command task cards. They delegate image loading to AsyncImageImpl.kt, use formatting helpers from the util layer for durations/file sizes/bitrates, and expose callbacks for feature-specific actions rather than owning feature state.
  • ActionSheetItems.kt defines action-sheet rows and primary circular action buttons, while SponsorItem.kt renders GitHub sponsor avatars/profiles through AsyncImageImpl.kt.
  • CommonComponents.kt contains NavigationBarSpacer(), which only adds height when the navigation-bar bottom inset exceeds 30dp, allowing sheets to avoid extra padding on gesture navigation.

Dynamic vector artwork is generated as composable ImageVector factories under app/src/main/java/com/junkfood/seal/ui/svg/**. __DrawableVectors.kt exposes the DynamicColorImageVectors receiver object, and files such as drawablevectors/Download.kt, VideoFiles.kt, VideoSteaming.kt, and Coder.kt build large vector illustrations whose fills reference MaterialTheme.colorScheme, LocalFixedColorRoles, or deprecated FixedAccentColors; VectorPreviews.kt previews the set under SealTheme. Because these vectors are composable and theme-aware, they should be called from within the theme/provider stack rather than treated as static assets.

Drawable and launcher resources under app/src/main/res/drawable/** and app/src/main/res/mipmap*/** are the non-Compose asset layer. drawable/seal.xml and drawable/ic_launcher_foreground.xml share the seal vector path, drawable/ic_launcher_monochrome.xml backs themed app icons, and mipmap-anydpi-v26/ic_launcher.xml / ic_launcher_round.xml define adaptive icons using @color/ic_launcher_background, the foreground vector, and the monochrome vector. drawable/sample*.webp are used as preview/sample thumbnails, including the preview fallback in AsyncImageImpl.kt; small vector drawables like outline_content_copy_24.xml, outline_cancel_24.xml, icons8_telegram_app.xml, and icons8_matrix.xml are XML resources for places that need Android drawable assets rather than Compose ImageVectors.

Coupling

Risks

  • app/…/FormatItem.kt computes containsAudio in SuggestedFormatItem() with requestedFormats.any { it.containsVideo() }, the same predicate used for containsVideo. If suggested formats include audio-only or mixed requested downloads, the format card can show the wrong audio/video icon state.
  • app/…/Ext.kt initializes preference-backed Compose state with remember { mutableStateOf(key.getBoolean()/getString()/getInt()) } and does not collect preference changes. If another screen or background preference update changes the same key while the composable stays in composition, UI built with these extensions can remain stale until recomposition with a new remembered scope.
  • app/…/TextField.kt always requests focus 200 ms after SealAutoFocusTextField() enters composition. If this field is used in a screen or sheet that should not immediately open the keyboard, it can steal focus from other input controls or reopen the IME after navigation animations.