mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-09-21 11:15:18 -04:00
core:ui is the first UI-layer module in this effort -- 204 Kotlin files, the substrate every feature module depends on. Every one of its own dependencies (core/*, coil3, jetbrains:markdown, qrcode-kotlin, every compose-multiplatform-*/jetbrains-* artifact) already publishes a wasmJs variant, so this was mostly a platform-seam problem, not a dependency problem: 6 commonMain files carry expect/actual declarations (an initial survey found 3; a second sweep before writing any code found 3 more), and the other 198 files needed zero changes. PlatformUtils.kt's ~23 members are mostly Android-system-settings concepts (NFC/Bluetooth/Wi-Fi/location/app settings deep-links, ahead-of-time permission-state checks, native file/document pickers) with no browser equivalent -- these mirror iOS's own NoopStubs.kt exactly, the established precedent in this codebase for "the platform doesn't have this concept, don't block the UI on it." Two exceptions get real implementations instead: rememberOpenUrl opens the URL via window.open, and KeepScreenOn is backed by the real Screen Wake Lock API (hand-declared external binding, kotlinx-browser has none) with its acquire/release lifecycle kept in one coroutine via awaitCancellation()/finally so a fast dispose can never race ahead of an in-flight request and leak the lock. createClipEntry (ClipboardUtils.kt) upgrades to ClipEntry.withPlainText -- verified against Compose Multiplatform's own wasmJs klib metadata that this is the only factory available on this target, with the actual Clipboard API access handled inside Compose Multiplatform's own setClipEntry() implementation, not something this module needs to wire itself. annotatedStringFromHtml (HtmlUtils.kt) keeps the plain-text fallback that the JVM/desktop actual already uses -- matching this codebase's own established fidelity bar for HTML rendering off Android, not a regression introduced here. dynamicColorScheme, SetScreenBrightness, and DropDownPreference's enum-reflection helpers (found in the second sweep) all get honest no-ops matching the JVM/iOS actuals already in place, each documented with why no better browser answer exists. 3 of 27 commonTest files (the ones depending on core:testing, which has no wasmJs target -- the same gap every prior module's test suite has hit) move to a new nonWebTest source set; a vestigial, actually-unused libs.junit dependency moves with them. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
:core:ui
Overview
The :core:ui module contains Compose Multiplatform components, themes, and utility functions shared across the Android and Desktop apps (and the iOS compile target). It ensures a consistent look and feel following Material 3 guidelines.
Key Components
1. Alert Dialogs (org.meshtastic.core.ui.component.AlertDialogs.kt)
MeshtasticDialog: The base dialog component for all alerts.MeshtasticResourceDialog: Optimized for dialogs with resource-only content.MeshtasticTextDialog: Optimized for dialogs with mixed resource and raw text content.
2. Common UI Elements
LastHeardInfo: Displays when a node was last seen.TelemetryInfo: Displays battery, voltage, and other telemetry data.TransportIcon: Shows the connection type (BLE, USB, TCP).MainAppBar: The standard top app bar used in the app.
3. Preferences
Standardized Material 3 preference components for settings screens:
RegularPreferenceSwitchPreferenceDropDownPreferenceSliderPreferenceEditTextPreference
4. Utilities
ModifierExtensions.kt: Useful Compose Modifiers (e.g., conditional modifiers).ProtoExtensions.kt: Extensions for mapping Protobuf models to UI-friendly strings or icons.
Usage
Most components are designed to be used with the Compose Multiplatform Resource library for strings.
import org.meshtastic.core.ui.component.MeshtasticResourceDialog
import org.meshtastic.core.resources.Res
import org.meshtastic.core.resources.ok
MeshtasticResourceDialog(
title = Res.string.your_title,
message = Res.string.your_message,
onDismissRequest = { /* ... */ },
confirmButtonText = Res.string.ok
)
Dependency Graph
graph TB
:core:ui[ui]:::kmp-library-compose
:core:ui -.-> :core:common
:core:ui -.-> :core:data
:core:ui -.-> :core:database
:core:ui -.-> :core:datastore
:core:ui -.-> :core:model
:core:ui -.-> :core:navigation
:core:ui -.-> :core:prefs
:core:ui -.-> :core:repository
:core:ui -.-> :core:resources
:core:ui -.-> :core:service
:core:ui -.-> :core:testing
classDef android-application fill:#CAFFBF,stroke:#000,stroke-width:2px,color:#000;
classDef android-application-compose fill:#CAFFBF,stroke:#000,stroke-width:2px,color:#000;
classDef compose-desktop-application fill:#CAFFBF,stroke:#000,stroke-width:2px,color:#000;
classDef android-feature fill:#FFD6A5,stroke:#000,stroke-width:2px,color:#000;
classDef android-library fill:#9BF6FF,stroke:#000,stroke-width:2px,color:#000;
classDef android-library-compose fill:#9BF6FF,stroke:#000,stroke-width:2px,color:#000;
classDef android-test fill:#A0C4FF,stroke:#000,stroke-width:2px,color:#000;
classDef jvm-library fill:#BDB2FF,stroke:#000,stroke-width:2px,color:#000;
classDef kmp-feature fill:#FFD6A5,stroke:#000,stroke-width:2px,color:#000;
classDef kmp-library-compose fill:#FFC1CC,stroke:#000,stroke-width:2px,color:#000;
classDef kmp-library fill:#FFC1CC,stroke:#000,stroke-width:2px,color:#000;
classDef unknown fill:#FFADAD,stroke:#000,stroke-width:2px,color:#000;