Modern Apps git

← Modern-Apps.git

weather: shared scaffolds + block text fits at large font size

Commit
506eb3b8752d9db4db39013360967fcbac6dd47b
Author
vayun-mathur <[email protected]>
When
2026-08-16 03:11 UTC (3 months ago)
Parents
36c4efe

Diff

weather/src/main/java/com/vayunmathur/weather/ui/HomePage.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/HomePage.kt b/weather/src/main/java/com/vayunmathur/weather/ui/HomePage.ktindex 08f6f56554..b6563811f6 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/HomePage.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/HomePage.kt@@ -1,420 +1,426 @@-package com.vayunmathur.weather.ui--import androidx.activity.compose.BackHandler-import androidx.compose.animation.AnimatedVisibility-import androidx.compose.animation.expandVertically-import androidx.compose.animation.fadeIn-import androidx.compose.animation.fadeOut-import androidx.compose.animation.shrinkVertically-import androidx.compose.foundation.layout.Arrangement-import androidx.compose.foundation.layout.Box-import androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.PaddingValues-import androidx.compose.foundation.layout.Spacer-import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.height-import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.rememberScrollState-import androidx.compose.foundation.verticalScroll-import com.vayunmathur.library.ui.Button-import com.vayunmathur.library.ui.CircularProgressIndicator-import com.vayunmathur.library.ui.DrawerState-import com.vayunmathur.library.ui.DrawerValue-import com.vayunmathur.library.ui.ExperimentalMaterial3Api-import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.ModalDrawerSheet-import com.vayunmathur.library.ui.ModalNavigationDrawer-import com.vayunmathur.library.ui.OutlinedButton-import com.vayunmathur.library.ui.PullToRefreshBox-import com.vayunmathur.library.ui.Scaffold-import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TopAppBar-import com.vayunmathur.library.ui.rememberDrawerState-import androidx.compose.runtime.Composable-import androidx.compose.runtime.LaunchedEffect-import androidx.compose.runtime.collectAsState-import androidx.compose.runtime.getValue-import androidx.compose.runtime.rememberCoroutineScope-import androidx.compose.runtime.mutableStateOf-import androidx.compose.runtime.remember-import androidx.compose.runtime.setValue-import androidx.compose.ui.Alignment-import androidx.compose.ui.Modifier-import androidx.compose.ui.platform.LocalContext-import androidx.compose.ui.res.stringResource-import androidx.compose.ui.unit.dp-import androidx.lifecycle.Lifecycle-import androidx.lifecycle.compose.LocalLifecycleOwner-import androidx.lifecycle.repeatOnLifecycle-import com.vayunmathur.library.util.NavBackStack-import com.vayunmathur.weather.R-import com.vayunmathur.weather.Route-import com.vayunmathur.weather.ui.components.CurrentWeatherCard-import com.vayunmathur.weather.ui.components.DailyCard-import com.vayunmathur.weather.ui.components.HourlyCard-import com.vayunmathur.weather.ui.components.MainSearchBar-import com.vayunmathur.weather.ui.components.MetricGraphSheet-import com.vayunmathur.weather.ui.components.SelectedDateTimeHeader-import com.vayunmathur.weather.ui.components.SummaryCard-import com.vayunmathur.weather.ui.components.WeatherBlocks-import com.vayunmathur.weather.platform.DisplayUnits-import com.vayunmathur.weather.platform.LocationUiState-import com.vayunmathur.weather.domain.SelectedDateOrTime-import com.vayunmathur.weather.domain.WeatherMetric-import com.vayunmathur.weather.domain.formatHourAxisLabel-import com.vayunmathur.weather.domain.metricSeries-import com.vayunmathur.weather.domain.metricValueFormatter-import com.vayunmathur.weather.domain.parseLocalIsoToEpochSec-import com.vayunmathur.weather.domain.resolveConditions-import com.vayunmathur.weather.platform.WeatherActions-import com.vayunmathur.weather.platform.WeatherViewModel-import com.vayunmathur.weather.platform.precipitationNowcast-import com.vayunmathur.weather.platform.rememberDisplayUnits-import kotlinx.coroutines.delay-import kotlinx.coroutines.launch--/** Binds [WeatherViewModel] and the back stack to the stateless [HomeScreen]. */-@OptIn(ExperimentalMaterial3Api::class)-@Composable-fun HomePage(backStack: NavBackStack<Route>, viewModel: WeatherViewModel) {-    val locations = viewModel.savedLocations.collectAsState().value--    if (locations == null) {-        // Room hasn't answered yet. Hold a plain surface rather than falling-        // through to EmptyHome, which would flash the location chooser on-        // every cold start before the saved rows arrive.-        Scaffold(containerColor = MaterialTheme.colorScheme.surfaceContainerHigh) {}-        return-    }--    if (locations.isEmpty()) {-        EmptyHome(-            viewModel = viewModel,-            onAddLocation = { backStack.add(Route.SearchLocation) },-        )-        return-    }--    var activeLocationId by remember { mutableStateOf(locations.first().id) }-    val activeLocation = locations.firstOrNull { it.id == activeLocationId } ?: locations.first()--    val forecasts by viewModel.forecasts.collectAsState()-    val selected by viewModel.selectedDateOrTime.collectAsState()-    val forecastState = forecasts[activeLocation.id]-    val forecast = forecastState?.forecast--    val lifecycleOwner = LocalLifecycleOwner.current-    LaunchedEffect(activeLocation.id, lifecycleOwner) {-        // Only poll while the app is actually in the foreground; repeatOnLifecycle-        // cancels the loop when the app is backgrounded and restarts it on resume,-        // so we don't hit the network every 60s behind the user's back (the hourly-        // WorkManager job covers background refreshes).-        lifecycleOwner.repeatOnLifecycle(Lifecycle.State.RESUMED) {-            while (true) {-                viewModel.refreshAll()-                delay(60_000)-            }-        }-    }--    // "Rain in ~30 min" needs both the wall clock and the string table, so it is-    // resolved here rather than inside the screen — see WeatherUiContract.-    val context = LocalContext.current-    val nowcast = if (selected == null && forecast != null) {-        precipitationNowcast(context, forecast.minutely15, forecast.utcOffsetSeconds)-    } else {-        null-    }--    val drawerState = rememberDrawerState(DrawerValue.Closed)-    val scope = rememberCoroutineScope()-    val closeDrawer = { scope.launch { drawerState.close() } }--    HomeScreen(-        state = LocationUiState(-            location = activeLocation,-            forecast = forecast,-            airQuality = forecastState?.airQuality?.current,-            refreshing = forecastState?.refreshing == true,-            error = forecastState?.error,-            selected = selected,-        ),-        units = rememberDisplayUnits(),-        actions = viewModel,-        drawerState = drawerState,-        precipitationNowcast = nowcast,-        onOpenMap = { metric, isoTime ->-            backStack.add(-                Route.WeatherMap(-                    latitude = activeLocation.latitude,-                    longitude = activeLocation.longitude,-                    name = activeLocation.name,-                    isoTime = isoTime,-                    metric = metric.name,-                )-            )-        },-        drawerContent = {-            LocationsPage(-                backStack = backStack,-                viewModel = viewModel,-                activeLocation = activeLocation,-                onLocationSelect = { picked ->-                    activeLocationId = picked.id-                    viewModel.clearSelection()-                    closeDrawer()-                },-                onClose = { closeDrawer() },-            )-        },-    )-}--/**- * The forecast page, with no dependency on the ViewModel, the back stack or the clock so it- * can be rendered from a `@Preview` — see `src/screenshotTest`, which is where the store- * listing images come from.- */-@OptIn(ExperimentalMaterial3Api::class)-@Composable-fun HomeScreen(-    state: LocationUiState,-    units: DisplayUnits,-    actions: WeatherActions,-    drawerState: DrawerState = rememberDrawerState(DrawerValue.Closed),-    /** Short-range rain outlook; reads a clock, so the binder resolves it. */-    precipitationNowcast: String? = null,-    /**-     * "Now" for the hourly strip and the sun arc. A parameter rather than a clock read so a-     * preview's fixed sample data can't age out from under it.-     */-    nowEpochSec: Long = System.currentTimeMillis() / 1000,-    onOpenMap: (WeatherMetric, String?) -> Unit = { _, _ -> },-    /** The locations drawer. Empty in a preview, which has no saved-location list. */-    drawerContent: @Composable () -> Unit = {},-) {-    val scope = rememberCoroutineScope()-    BackHandler(enabled = drawerState.isOpen) { scope.launch { drawerState.close() } }--    ModalNavigationDrawer(-        drawerState = drawerState,-        drawerContent = {-            ModalDrawerSheet(-                drawerContainerColor = MaterialTheme.colorScheme.surfaceContainer,-            ) {-                drawerContent()-            }-        },-    ) {-        Scaffold(-            containerColor = MaterialTheme.colorScheme.surfaceContainerHigh,-        ) { paddingValues ->-            ForecastColumn(-                state = state,-                units = units,-                actions = actions,-                drawerState = drawerState,-                paddingValues = paddingValues,-                precipitationNowcast = precipitationNowcast,-                nowEpochSec = nowEpochSec,-                onOpenMap = onOpenMap,-            )-        }-    }-}--@OptIn(ExperimentalMaterial3Api::class)-@Composable-private fun ForecastColumn(-    state: LocationUiState,-    units: DisplayUnits,-    actions: WeatherActions,-    drawerState: DrawerState,-    paddingValues: PaddingValues,-    precipitationNowcast: String?,-    nowEpochSec: Long,-    onOpenMap: (WeatherMetric, String?) -> Unit,-) {-    var graphMetric by remember { mutableStateOf<WeatherMetric?>(null) }--    val forecast = state.forecast-    val selected = state.selected-    val scrollState = rememberScrollState()--    PullToRefreshBox(-        isRefreshing = state.refreshing,-        onRefresh = { actions.refreshAll(force = true) },-        modifier = Modifier.fillMaxSize(),-    ) {-        Column(modifier = Modifier.fillMaxSize().verticalScroll(scrollState)) {-            MainSearchBar(-                paddingValues = paddingValues,-                drawerState = drawerState,-                activeLocation = state.location,-            )--            if (forecast == null) {-                Box(modifier = Modifier.fillMaxSize().padding(top = 64.dp), contentAlignment = Alignment.TopCenter) {-                    val error = state.error-                    if (error != null) {-                        Text(error, color = MaterialTheme.colorScheme.error)-                    } else {-                        CircularProgressIndicator()-                    }-                }-                return@Column-            }--            val current = forecast.current-            val daily = forecast.daily-            val resolved = resolveConditions(forecast, selected)--            var lastSelection by remember { mutableStateOf(selected) }-            LaunchedEffect(selected) { if (selected != null) lastSelection = selected }-            AnimatedVisibility(-                visible = selected != null,-                enter = expandVertically() + fadeIn(),-                exit = shrinkVertically() + fadeOut(),-            ) {-                (selected ?: lastSelection)?.let { sel ->-                    SelectedDateTimeHeader(-                        selection = sel,-                        forecast = forecast,-                        use24Hour = units.use24Hour,-                        onClear = { actions.clearSelection() },-                    )-                }-            }--            if (current != null && resolved != null) {-                CurrentWeatherCard(-                    weatherCode = resolved.weatherCode,-                    isDay = resolved.isDay,-                    temperature = resolved.temperature,-                    apparentTemperature = resolved.apparentTemperature,-                    high = resolved.high,-                    low = resolved.low,-                    tempUnit = units.temperature,-                )-            }-            Column(-                // Include the navigation-bar inset so the last cards (Air quality /-                // Pollen) clear the system nav bar and can scroll fully into view.-                modifier = Modifier.padding(-                    start = 16.dp,-                    end = 16.dp,-                    top = 24.dp,-                    bottom = paddingValues.calculateBottomPadding(),-                ),-                verticalArrangement = Arrangement.spacedBy(14.dp),-            ) {-                if (selected == null) {-                    SummaryCard(forecast = forecast, tempUnit = units.temperature)-                }-                if (forecast.hourly != null) {-                    HourlyCard(-                        hourly = forecast.hourly,-                        tempUnit = units.temperature,-                        utcOffsetSeconds = forecast.utcOffsetSeconds,-                        use24Hour = units.use24Hour,-                        selectedIsoTime = (selected as? SelectedDateOrTime.Time)?.isoTime,-                        onHourSelected = { actions.toggleTime(it) },-                        scrollToIsoDate = (selected as? SelectedDateOrTime.Day)?.isoDate,-                        nowEpochSec = nowEpochSec,-                    )-                }-                if (daily != null) {-                    DailyCard(-                        daily = daily,-                        tempUnit = units.temperature,-                        selectedIsoDate = (selected as? SelectedDateOrTime.Day)?.isoDate,-                        onDaySelected = { actions.toggleDay(it) },-                    )-                }-                if (current != null && resolved != null) {-                    val sunriseEpoch = resolved.sunriseIso?.let { parseLocalIsoToEpochSec(it, forecast.utcOffsetSeconds) }-                    val sunsetEpoch = resolved.sunsetIso?.let { parseLocalIsoToEpochSec(it, forecast.utcOffsetSeconds) }-                    val moonriseEpoch = resolved.moonriseIso?.let { parseLocalIsoToEpochSec(it, forecast.utcOffsetSeconds) }-                    val moonsetEpoch = resolved.moonsetIso?.let { parseLocalIsoToEpochSec(it, forecast.utcOffsetSeconds) }-                    WeatherBlocks(-                        current = resolved.blockCurrent,-                        uvIndex = resolved.uvIndexMax,-                        air = state.airQuality,-                        sunriseEpochSec = sunriseEpoch,-                        sunsetEpochSec = sunsetEpoch,-                        precipitationMm = resolved.precipitationSum,-                        precipitationNowcast = precipitationNowcast,-                        daylightDurationSec = resolved.daylightDurationSec,-                        moonPhase = resolved.moonPhase,-                        moonriseEpochSec = moonriseEpoch,-                        moonsetEpochSec = moonsetEpoch,-                        onMetricSelected = { graphMetric = it },-                        tempUnit = units.temperature,-                        windUnit = units.wind,-                        pressureUnit = units.pressure,-                        use24Hour = units.use24Hour,-                        nowEpochSec = nowEpochSec,-                    )-                }-            }-        }--        val gm = graphMetric-        if (gm != null && forecast != null) {-            MetricGraphSheet(-                title = stringResource(gm.title),-                points = metricSeries(forecast, gm, selected),-                valueLabel = metricValueFormatter(gm, units.temperature, units.wind, units.pressure),-                timeLabel = { epoch -> formatHourAxisLabel(epoch, units.use24Hour) },-                onOpenMap = {-                    val iso = when (val s = selected) {-                        is SelectedDateOrTime.Time -> s.isoTime-                        is SelectedDateOrTime.Day -> "${s.isoDate}T00:00"-                        null -> null-                    }-                    onOpenMap(gm, iso)-                    graphMetric = null-                },-                onDismiss = { graphMetric = null },-            )-        }-    }-}--/**- * Shown in place of the forecast when nothing is pinned yet. Stays on the ViewModel: it is- * an empty state, not a listing shot.- */-@OptIn(ExperimentalMaterial3Api::class)-@Composable-private fun EmptyHome(viewModel: WeatherViewModel, onAddLocation: () -> Unit) {-    val (onUseCurrent, requesting) = rememberRequestDeviceLocation(viewModel)--    Scaffold(topBar = { TopAppBar(title = { Text(stringResource(R.string.weather_title)) }) }) { padding ->-        Box(modifier = Modifier.fillMaxSize().padding(padding), contentAlignment = Alignment.Center) {-            Column(horizontalAlignment = Alignment.CenterHorizontally) {-                Text(stringResource(R.string.no_locations_yet), style = MaterialTheme.typography.titleMedium)-                Text(-                    stringResource(R.string.add_a_city_or_use_your_current_location),-                    style = MaterialTheme.typography.bodyMedium,-                    color = MaterialTheme.colorScheme.onSurfaceVariant,-                    modifier = Modifier.padding(horizontal = 32.dp, vertical = 8.dp),-                )-                Button(onClick = onAddLocation) { Text(stringResource(R.string.add_location)) }-                Spacer(Modifier.height(8.dp))-                OutlinedButton(-                    onClick = { onUseCurrent() },-                    enabled = !requesting,-                ) {-                    if (requesting) {-                        CircularProgressIndicator(-                            modifier = Modifier.padding(end = 8.dp),-                            strokeWidth = 2.dp,-                        )-                    }-                    Text(if (requesting) stringResource(R.string.locating) else stringResource(R.string.use_current_location))-                }-            }-        }-    }-}+package com.vayunmathur.weather.ui++import androidx.activity.compose.BackHandler+import androidx.compose.animation.AnimatedVisibility+import androidx.compose.animation.expandVertically+import androidx.compose.animation.fadeIn+import androidx.compose.animation.fadeOut+import androidx.compose.animation.shrinkVertically+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.PaddingValues+import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.verticalScroll+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.Button+import com.vayunmathur.library.ui.CircularProgressIndicator+import com.vayunmathur.library.ui.DrawerState+import com.vayunmathur.library.ui.DrawerValue+import com.vayunmathur.library.ui.ExperimentalMaterial3Api+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.ModalDrawerSheet+import com.vayunmathur.library.ui.ModalNavigationDrawer+import com.vayunmathur.library.ui.OutlinedButton+import com.vayunmathur.library.ui.PullToRefreshBox+import com.vayunmathur.library.ui.Scaffold+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.rememberDrawerState+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.collectAsState+import androidx.compose.runtime.getValue+import androidx.compose.runtime.rememberCoroutineScope+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.platform.LocalContext+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.unit.dp+import androidx.lifecycle.Lifecycle+import androidx.lifecycle.compose.LocalLifecycleOwner+import androidx.lifecycle.repeatOnLifecycle+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.weather.R+import com.vayunmathur.weather.Route+import com.vayunmathur.weather.ui.components.CurrentWeatherCard+import com.vayunmathur.weather.ui.components.DailyCard+import com.vayunmathur.weather.ui.components.HourlyCard+import com.vayunmathur.weather.ui.components.MainSearchBar+import com.vayunmathur.weather.ui.components.MetricGraphSheet+import com.vayunmathur.weather.ui.components.SelectedDateTimeHeader+import com.vayunmathur.weather.ui.components.SummaryCard+import com.vayunmathur.weather.ui.components.WeatherBlocks+import com.vayunmathur.weather.platform.DisplayUnits+import com.vayunmathur.weather.platform.LocationUiState+import com.vayunmathur.weather.domain.SelectedDateOrTime+import com.vayunmathur.weather.domain.WeatherMetric+import com.vayunmathur.weather.domain.formatHourAxisLabel+import com.vayunmathur.weather.domain.metricSeries+import com.vayunmathur.weather.domain.metricValueFormatter+import com.vayunmathur.weather.domain.parseLocalIsoToEpochSec+import com.vayunmathur.weather.domain.resolveConditions+import com.vayunmathur.weather.platform.WeatherActions+import com.vayunmathur.weather.platform.WeatherViewModel+import com.vayunmathur.weather.platform.precipitationNowcast+import com.vayunmathur.weather.platform.rememberDisplayUnits+import kotlinx.coroutines.delay+import kotlinx.coroutines.launch++/** Binds [WeatherViewModel] and the back stack to the stateless [HomeScreen]. */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun HomePage(backStack: NavBackStack<Route>, viewModel: WeatherViewModel) {+    val locations = viewModel.savedLocations.collectAsState().value++    if (locations == null) {+        // Room hasn't answered yet. Hold a plain surface rather than falling+        // through to EmptyHome, which would flash the location chooser on+        // every cold start before the saved rows arrive.+        // RAW SCAFFOLD EXCEPTION: cold-start placeholder — a bare, bar-less,+        // content-less surface. No shared scaffold applies (they all draw chrome).+        Scaffold(containerColor = MaterialTheme.colorScheme.surfaceContainerHigh) {}+        return+    }++    if (locations.isEmpty()) {+        EmptyHome(+            viewModel = viewModel,+            onAddLocation = { backStack.add(Route.SearchLocation) },+        )+        return+    }++    var activeLocationId by remember { mutableStateOf(locations.first().id) }+    val activeLocation = locations.firstOrNull { it.id == activeLocationId } ?: locations.first()++    val forecasts by viewModel.forecasts.collectAsState()+    val selected by viewModel.selectedDateOrTime.collectAsState()+    val forecastState = forecasts[activeLocation.id]+    val forecast = forecastState?.forecast++    val lifecycleOwner = LocalLifecycleOwner.current+    LaunchedEffect(activeLocation.id, lifecycleOwner) {+        // Only poll while the app is actually in the foreground; repeatOnLifecycle+        // cancels the loop when the app is backgrounded and restarts it on resume,+        // so we don't hit the network every 60s behind the user's back (the hourly+        // WorkManager job covers background refreshes).+        lifecycleOwner.repeatOnLifecycle(Lifecycle.State.RESUMED) {+            while (true) {+                viewModel.refreshAll()+                delay(60_000)+            }+        }+    }++    // "Rain in ~30 min" needs both the wall clock and the string table, so it is+    // resolved here rather than inside the screen — see WeatherUiContract.+    val context = LocalContext.current+    val nowcast = if (selected == null && forecast != null) {+        precipitationNowcast(context, forecast.minutely15, forecast.utcOffsetSeconds)+    } else {+        null+    }++    val drawerState = rememberDrawerState(DrawerValue.Closed)+    val scope = rememberCoroutineScope()+    val closeDrawer = { scope.launch { drawerState.close() } }++    HomeScreen(+        state = LocationUiState(+            location = activeLocation,+            forecast = forecast,+            airQuality = forecastState?.airQuality?.current,+            refreshing = forecastState?.refreshing == true,+            error = forecastState?.error,+            selected = selected,+        ),+        units = rememberDisplayUnits(),+        actions = viewModel,+        drawerState = drawerState,+        precipitationNowcast = nowcast,+        onOpenMap = { metric, isoTime ->+            backStack.add(+                Route.WeatherMap(+                    latitude = activeLocation.latitude,+                    longitude = activeLocation.longitude,+                    name = activeLocation.name,+                    isoTime = isoTime,+                    metric = metric.name,+                )+            )+        },+        drawerContent = {+            LocationsPage(+                backStack = backStack,+                viewModel = viewModel,+                activeLocation = activeLocation,+                onLocationSelect = { picked ->+                    activeLocationId = picked.id+                    viewModel.clearSelection()+                    closeDrawer()+                },+                onClose = { closeDrawer() },+            )+        },+    )+}++/**+ * The forecast page, with no dependency on the ViewModel, the back stack or the clock so it+ * can be rendered from a `@Preview` — see `src/screenshotTest`, which is where the store+ * listing images come from.+ */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun HomeScreen(+    state: LocationUiState,+    units: DisplayUnits,+    actions: WeatherActions,+    drawerState: DrawerState = rememberDrawerState(DrawerValue.Closed),+    /** Short-range rain outlook; reads a clock, so the binder resolves it. */+    precipitationNowcast: String? = null,+    /**+     * "Now" for the hourly strip and the sun arc. A parameter rather than a clock read so a+     * preview's fixed sample data can't age out from under it.+     */+    nowEpochSec: Long = System.currentTimeMillis() / 1000,+    onOpenMap: (WeatherMetric, String?) -> Unit = { _, _ -> },+    /** The locations drawer. Empty in a preview, which has no saved-location list. */+    drawerContent: @Composable () -> Unit = {},+) {+    val scope = rememberCoroutineScope()+    BackHandler(enabled = drawerState.isOpen) { scope.launch { drawerState.close() } }++    ModalNavigationDrawer(+        drawerState = drawerState,+        drawerContent = {+            ModalDrawerSheet(+                drawerContainerColor = MaterialTheme.colorScheme.surfaceContainer,+            ) {+                drawerContent()+            }+        },+    ) {+        Scaffold(+            // RAW SCAFFOLD EXCEPTION: bespoke full-bleed home. The forecast+            // scrolls under a floating in-content MainSearchBar (there is no top+            // app bar), inside a ModalNavigationDrawer + PullToRefreshBox, and the+            // body consumes the scaffold insets itself. No shared scaffold fits.+            containerColor = MaterialTheme.colorScheme.surfaceContainerHigh,+        ) { paddingValues ->+            ForecastColumn(+                state = state,+                units = units,+                actions = actions,+                drawerState = drawerState,+                paddingValues = paddingValues,+                precipitationNowcast = precipitationNowcast,+                nowEpochSec = nowEpochSec,+                onOpenMap = onOpenMap,+            )+        }+    }+}++@OptIn(ExperimentalMaterial3Api::class)+@Composable+private fun ForecastColumn(+    state: LocationUiState,+    units: DisplayUnits,+    actions: WeatherActions,+    drawerState: DrawerState,+    paddingValues: PaddingValues,+    precipitationNowcast: String?,+    nowEpochSec: Long,+    onOpenMap: (WeatherMetric, String?) -> Unit,+) {+    var graphMetric by remember { mutableStateOf<WeatherMetric?>(null) }++    val forecast = state.forecast+    val selected = state.selected+    val scrollState = rememberScrollState()++    PullToRefreshBox(+        isRefreshing = state.refreshing,+        onRefresh = { actions.refreshAll(force = true) },+        modifier = Modifier.fillMaxSize(),+    ) {+        Column(modifier = Modifier.fillMaxSize().verticalScroll(scrollState)) {+            MainSearchBar(+                paddingValues = paddingValues,+                drawerState = drawerState,+                activeLocation = state.location,+            )++            if (forecast == null) {+                Box(modifier = Modifier.fillMaxSize().padding(top = 64.dp), contentAlignment = Alignment.TopCenter) {+                    val error = state.error+                    if (error != null) {+                        Text(error, color = MaterialTheme.colorScheme.error)+                    } else {+                        CircularProgressIndicator()+                    }+                }+                return@Column+            }++            val current = forecast.current+            val daily = forecast.daily+            val resolved = resolveConditions(forecast, selected)++            var lastSelection by remember { mutableStateOf(selected) }+            LaunchedEffect(selected) { if (selected != null) lastSelection = selected }+            AnimatedVisibility(+                visible = selected != null,+                enter = expandVertically() + fadeIn(),+                exit = shrinkVertically() + fadeOut(),+            ) {+                (selected ?: lastSelection)?.let { sel ->+                    SelectedDateTimeHeader(+                        selection = sel,+                        forecast = forecast,+                        use24Hour = units.use24Hour,+                        onClear = { actions.clearSelection() },+                    )+                }+            }++            if (current != null && resolved != null) {+                CurrentWeatherCard(+                    weatherCode = resolved.weatherCode,+                    isDay = resolved.isDay,+                    temperature = resolved.temperature,+                    apparentTemperature = resolved.apparentTemperature,+                    high = resolved.high,+                    low = resolved.low,+                    tempUnit = units.temperature,+                )+            }+            Column(+                // Include the navigation-bar inset so the last cards (Air quality /+                // Pollen) clear the system nav bar and can scroll fully into view.+                modifier = Modifier.padding(+                    start = 16.dp,+                    end = 16.dp,+                    top = 24.dp,+                    bottom = paddingValues.calculateBottomPadding(),+                ),+                verticalArrangement = Arrangement.spacedBy(14.dp),+            ) {+                if (selected == null) {+                    SummaryCard(forecast = forecast, tempUnit = units.temperature)+                }+                if (forecast.hourly != null) {+                    HourlyCard(+                        hourly = forecast.hourly,+                        tempUnit = units.temperature,+                        utcOffsetSeconds = forecast.utcOffsetSeconds,+                        use24Hour = units.use24Hour,+                        selectedIsoTime = (selected as? SelectedDateOrTime.Time)?.isoTime,+                        onHourSelected = { actions.toggleTime(it) },+                        scrollToIsoDate = (selected as? SelectedDateOrTime.Day)?.isoDate,+                        nowEpochSec = nowEpochSec,+                    )+                }+                if (daily != null) {+                    DailyCard(+                        daily = daily,+                        tempUnit = units.temperature,+                        selectedIsoDate = (selected as? SelectedDateOrTime.Day)?.isoDate,+                        onDaySelected = { actions.toggleDay(it) },+                    )+                }+                if (current != null && resolved != null) {+                    val sunriseEpoch = resolved.sunriseIso?.let { parseLocalIsoToEpochSec(it, forecast.utcOffsetSeconds) }+                    val sunsetEpoch = resolved.sunsetIso?.let { parseLocalIsoToEpochSec(it, forecast.utcOffsetSeconds) }+                    val moonriseEpoch = resolved.moonriseIso?.let { parseLocalIsoToEpochSec(it, forecast.utcOffsetSeconds) }+                    val moonsetEpoch = resolved.moonsetIso?.let { parseLocalIsoToEpochSec(it, forecast.utcOffsetSeconds) }+                    WeatherBlocks(+                        current = resolved.blockCurrent,+                        uvIndex = resolved.uvIndexMax,+                        air = state.airQuality,+                        sunriseEpochSec = sunriseEpoch,+                        sunsetEpochSec = sunsetEpoch,+                        precipitationMm = resolved.precipitationSum,+                        precipitationNowcast = precipitationNowcast,+                        daylightDurationSec = resolved.daylightDurationSec,+                        moonPhase = resolved.moonPhase,+                        moonriseEpochSec = moonriseEpoch,+                        moonsetEpochSec = moonsetEpoch,+                        onMetricSelected = { graphMetric = it },+                        tempUnit = units.temperature,+                        windUnit = units.wind,+                        pressureUnit = units.pressure,+                        use24Hour = units.use24Hour,+                        nowEpochSec = nowEpochSec,+                    )+                }+            }+        }++        val gm = graphMetric+        if (gm != null && forecast != null) {+            MetricGraphSheet(+                title = stringResource(gm.title),+                points = metricSeries(forecast, gm, selected),+                valueLabel = metricValueFormatter(gm, units.temperature, units.wind, units.pressure),+                timeLabel = { epoch -> formatHourAxisLabel(epoch, units.use24Hour) },+                onOpenMap = {+                    val iso = when (val s = selected) {+                        is SelectedDateOrTime.Time -> s.isoTime+                        is SelectedDateOrTime.Day -> "${s.isoDate}T00:00"+                        null -> null+                    }+                    onOpenMap(gm, iso)+                    graphMetric = null+                },+                onDismiss = { graphMetric = null },+            )+        }+    }+}++/**+ * Shown in place of the forecast when nothing is pinned yet. Stays on the ViewModel: it is+ * an empty state, not a listing shot.+ */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+private fun EmptyHome(viewModel: WeatherViewModel, onAddLocation: () -> Unit) {+    val (onUseCurrent, requesting) = rememberRequestDeviceLocation(viewModel)++    AppScaffold(title = stringResource(R.string.weather_title)) { padding ->+        Box(modifier = Modifier.fillMaxSize().padding(padding), contentAlignment = Alignment.Center) {+            Column(horizontalAlignment = Alignment.CenterHorizontally) {+                Text(stringResource(R.string.no_locations_yet), style = MaterialTheme.typography.titleMedium)+                Text(+                    stringResource(R.string.add_a_city_or_use_your_current_location),+                    style = MaterialTheme.typography.bodyMedium,+                    color = MaterialTheme.colorScheme.onSurfaceVariant,+                    modifier = Modifier.padding(horizontal = 32.dp, vertical = 8.dp),+                )+                Button(onClick = onAddLocation) { Text(stringResource(R.string.add_location)) }+                Spacer(Modifier.height(8.dp))+                OutlinedButton(+                    onClick = { onUseCurrent() },+                    enabled = !requesting,+                ) {+                    if (requesting) {+                        CircularProgressIndicator(+                            modifier = Modifier.padding(end = 8.dp),+                            strokeWidth = 2.dp,+                        )+                    }+                    Text(if (requesting) stringResource(R.string.locating) else stringResource(R.string.use_current_location))+                }+            }+        }+    }+}
weather/src/main/java/com/vayunmathur/weather/ui/LocationsScreen.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/LocationsScreen.kt b/weather/src/main/java/com/vayunmathur/weather/ui/LocationsScreen.ktindex b375244713..6b8edd42c6 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/LocationsScreen.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/LocationsScreen.kt@@ -13,7 +13,6 @@ import androidx.compose.animation.core.animateDpAsState import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize@@ -39,9 +38,9 @@ import com.vayunmathur.library.ui.IconSearch import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.ListItem import com.vayunmathur.library.ui.ListItemDefaults+import com.vayunmathur.library.ui.LazyListScaffold import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.ModalBottomSheet-import com.vayunmathur.library.ui.Scaffold import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.TopAppBar import com.vayunmathur.library.ui.TopAppBarDefaults@@ -241,8 +240,11 @@ fun LocationsScreen(         }     } -    Scaffold(+    LazyListScaffold(         containerColor = MaterialTheme.colorScheme.surfaceContainer,+        state = listState,+        horizontalPadding = 16.dp,+        verticalArrangement = Arrangement.spacedBy(8.dp),         topBar = {             TopAppBar(                 colors = TopAppBarDefaults.topAppBarColors(@@ -286,66 +288,53 @@ fun LocationsScreen(                 }             }         },-    ) { paddingValues ->-        Box(-            modifier = Modifier-                .fillMaxSize()-                .padding(top = paddingValues.calculateTopPadding(), bottom = paddingValues.calculateBottomPadding()),-        ) {-            LazyColumn(-                state = listState,-                modifier = Modifier.padding(horizontal = 16.dp),-                verticalArrangement = Arrangement.spacedBy(8.dp),-                contentPadding = PaddingValues(top = 8.dp, bottom = 16.dp),-            ) {-                val showDeviceLocationCard = localData.none { it.location.isCurrent }-                if (showDeviceLocationCard) {-                    item {-                        UseDeviceLocationCard(-                            onClick = { if (!state.deviceLocationLoading) onUseDeviceLocation() },-                            isLoading = state.deviceLocationLoading,-                        )-                        Spacer(Modifier.height(8.dp))-                    }-                }-                itemsIndexed(localData, key = { _, item -> item.location.id }) { idx, row ->-                    val loc = row.location-                    ReorderableItem(reorderState, key = loc.id) { isDragging ->-                        val elevation by animateDpAsState(if (isDragging) 6.dp else 0.dp)-                        LocationItem(-                            location = loc,-                            description = row.description,-                            currentWeatherCode = row.weatherCode,-                            isDay = row.isDay,-                            isSelected = loc.id == state.activeLocationId,-                            onClick = { onLocationSelect(loc) },-                            onLongClick = { longPressedLocation = loc },-                            modifier = Modifier.shadow(elevation, MaterialTheme.shapes.extraLarge),-                            dragHandle = if (localData.size > 1) {-                                {-                                    IconButton(-                                        onClick = {},-                                        modifier = Modifier.draggableHandle(-                                            reorderState,-                                            key = loc.id,-                                            index = idx,-                                            onDragStarted = {-                                                haptics.performHapticFeedback(HapticFeedbackType.GestureThresholdActivate)-                                            },-                                            onDragStopped = {-                                                haptics.performHapticFeedback(HapticFeedbackType.GestureEnd)-                                            },-                                        ),-                                    ) {-                                        IconDragHandle(tint = MaterialTheme.colorScheme.onSurfaceVariant)-                                    }-                                }-                            } else {-                                null-                            },-                        )-                    }-                }+    ) {+        val showDeviceLocationCard = localData.none { it.location.isCurrent }+        if (showDeviceLocationCard) {+            item {+                UseDeviceLocationCard(+                    onClick = { if (!state.deviceLocationLoading) onUseDeviceLocation() },+                    isLoading = state.deviceLocationLoading,+                )+                Spacer(Modifier.height(8.dp))+            }+        }+        itemsIndexed(localData, key = { _, item -> item.location.id }) { idx, row ->+            val loc = row.location+            ReorderableItem(reorderState, key = loc.id) { isDragging ->+                val elevation by animateDpAsState(if (isDragging) 6.dp else 0.dp)+                LocationItem(+                    location = loc,+                    description = row.description,+                    currentWeatherCode = row.weatherCode,+                    isDay = row.isDay,+                    isSelected = loc.id == state.activeLocationId,+                    onClick = { onLocationSelect(loc) },+                    onLongClick = { longPressedLocation = loc },+                    modifier = Modifier.shadow(elevation, MaterialTheme.shapes.extraLarge),+                    dragHandle = if (localData.size > 1) {+                        {+                            IconButton(+                                onClick = {},+                                modifier = Modifier.draggableHandle(+                                    reorderState,+                                    key = loc.id,+                                    index = idx,+                                    onDragStarted = {+                                        haptics.performHapticFeedback(HapticFeedbackType.GestureThresholdActivate)+                                    },+                                    onDragStopped = {+                                        haptics.performHapticFeedback(HapticFeedbackType.GestureEnd)+                                    },+                                ),+                            ) {+                                IconDragHandle(tint = MaterialTheme.colorScheme.onSurfaceVariant)+                            }+                        }+                    } else {+                        null+                    },+                )             }         }     }
weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/AirQualityBlock.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/AirQualityBlock.kt b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/AirQualityBlock.ktindex feabb5cefa..710cd3cd1d 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/AirQualityBlock.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/AirQualityBlock.kt@@ -58,8 +58,10 @@ fun AirQualityBlock(air: AirQualityCurrent?) {                 text = levelRes?.let { stringResource(it) } ?: "—",                 modifier = Modifier.fillMaxWidth(),                 textAlign = TextAlign.End,+                maxLines = 2,+                softWrap = true,                 color = MaterialTheme.colorScheme.onSurfaceVariant,-                style = MaterialTheme.typography.bodyLarge,+                style = MaterialTheme.typography.bodyMedium,             )         }     }
weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/BlockHeader.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/BlockHeader.kt b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/BlockHeader.ktindex 670747ff14..ee58fbaf5b 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/BlockHeader.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/BlockHeader.kt@@ -43,6 +43,8 @@ fun BlockHeader(             text = title,             style = MaterialTheme.typography.titleMedium,             fontWeight = FontWeight.Bold,+            maxLines = 2,+            softWrap = true,             color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.9f),         )     }@@ -68,6 +70,7 @@ fun RiseSetTimeRow(             color = MaterialTheme.colorScheme.onSurface,             style = style,             maxLines = 1,+            softWrap = true,         )     } }
weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/CloudCoverBlock.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/CloudCoverBlock.kt b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/CloudCoverBlock.ktindex b335ba5136..ff13c3aad7 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/CloudCoverBlock.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/CloudCoverBlock.kt@@ -1,13 +1,16 @@ package com.vayunmathur.weather.ui.components.blocks  import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.offset+import androidx.compose.foundation.layout.padding import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.IconCloudy import com.vayunmathur.library.ui.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier+import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.res.stringResource import com.vayunmathur.weather.R@@ -44,8 +47,15 @@ fun CloudCoverBlock(current: Current) {         )         Text(             text = stringResource(labelRes),-            modifier = Modifier.align(Alignment.BottomCenter).offset(y = (-26).dp),-            style = MaterialTheme.typography.bodyMedium,+            modifier = Modifier+                .align(Alignment.BottomCenter)+                .offset(y = (-26).dp)+                .fillMaxWidth()+                .padding(horizontal = 12.dp),+            style = MaterialTheme.typography.bodySmall,+            textAlign = TextAlign.Center,+            maxLines = 2,+            softWrap = true,             color = MaterialTheme.colorScheme.onSurfaceVariant,         )     }
weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/HumidityBlock.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/HumidityBlock.kt b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/HumidityBlock.ktindex 6ceb9da17a..6d0eed05b9 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/HumidityBlock.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/HumidityBlock.kt@@ -78,6 +78,8 @@ private fun DewPointRow(dewPointCelsius: Double, tempUnit: TemperatureUnit) {                 Text(                     formatTemperatureCompact(dewPointCelsius, tempUnit),                     style = MaterialTheme.typography.titleMedium,+                    maxLines = 1,+                    softWrap = true,                     color = MaterialTheme.colorScheme.onPrimary,                 )             }@@ -86,6 +88,8 @@ private fun DewPointRow(dewPointCelsius: Double, tempUnit: TemperatureUnit) {         Text(             stringResource(R.string.dew_point),             style = MaterialTheme.typography.labelLarge,+            maxLines = 2,+            softWrap = true,             color = MaterialTheme.colorScheme.onSurface,         )     }
weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/PollenBlock.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/PollenBlock.kt b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/PollenBlock.ktindex 5aad3419ae..d0c1c3341f 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/PollenBlock.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/PollenBlock.kt@@ -57,6 +57,8 @@ fun PollenBlock(air: AirQualityCurrent?) {             text = label,             modifier = Modifier.align(Alignment.BottomCenter).offset(y = (-20).dp),             style = MaterialTheme.typography.bodyMedium,+            maxLines = 1,+            softWrap = true,             color = MaterialTheme.colorScheme.onSurfaceVariant,         )     }
weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/PrecipitationBlock.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/PrecipitationBlock.kt b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/PrecipitationBlock.ktindex 7ad96e8654..da8d80f88e 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/PrecipitationBlock.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/PrecipitationBlock.kt@@ -58,6 +58,8 @@ fun PrecipitationBlock(                 Text(                     text = unit,                     style = MaterialTheme.typography.bodyMedium,+                    maxLines = 1,+                    softWrap = true,                     color = MaterialTheme.colorScheme.onSurfaceVariant,                 )             }@@ -68,6 +70,8 @@ fun PrecipitationBlock(                         modifier = Modifier.align(Alignment.Center),                         style = MaterialTheme.typography.labelLarge,                         textAlign = TextAlign.Center,+                        maxLines = 2,+                        softWrap = true,                         color = MaterialTheme.colorScheme.primary,                     )                 }
weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/PressureBlock.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/PressureBlock.kt b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/PressureBlock.ktindex 4d66fbacc2..883d4f09f1 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/PressureBlock.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/PressureBlock.kt@@ -80,6 +80,8 @@ fun PressureBlock(current: Current, pressureUnit: PressureUnit) {             text = unitText,             modifier = Modifier.align(Alignment.BottomCenter).offset(y = (-24).dp),             style = MaterialTheme.typography.bodyMedium,+            maxLines = 1,+            softWrap = true,             color = MaterialTheme.colorScheme.onSurfaceVariant,         )     }
weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/StatBlock.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/StatBlock.kt b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/StatBlock.ktindex aef038ff48..631e8dc9d3 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/StatBlock.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/StatBlock.kt@@ -8,8 +8,11 @@ import androidx.compose.foundation.shape.CircleShape import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Surface import androidx.compose.runtime.Composable+import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Shape+import androidx.compose.ui.platform.LocalDensity+import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.dp  /**@@ -17,6 +20,11 @@ import androidx.compose.ui.unit.dp  * with a 2.dp shadow and the given [shape], wrapping a square  * (`aspectRatio(1f)`) [Box] that fills it. Blocks lay out their content with  * the usual [BoxScope] alignment modifiers.+ *+ * Block content runs with the font scale capped at 1.3×: the tile is a fixed+ * square/circle, so at large system font sizes the big value would otherwise+ * overflow the shape. Capping lets text still grow with accessibility settings+ * but bounds it so it always fits.  */ @Composable fun StatBlock(@@ -28,7 +36,16 @@ fun StatBlock(         shape = shape,         shadowElevation = 2.dp,     ) {-        Box(modifier = Modifier.fillMaxSize().aspectRatio(1f), content = content)+        Box(modifier = Modifier.fillMaxSize().aspectRatio(1f)) {+            CompositionLocalProvider(+                LocalDensity provides Density(+                    density = LocalDensity.current.density,+                    fontScale = LocalDensity.current.fontScale.coerceAtMost(1.3f),+                ),+            ) {+                [email protected]()+            }+        }     } } 
weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/UvIndexBlock.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/UvIndexBlock.kt b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/UvIndexBlock.ktindex 396a0f8a71..4c9a571cb3 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/UvIndexBlock.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/UvIndexBlock.kt@@ -2,7 +2,9 @@ package com.vayunmathur.weather.ui.components.blocks  import androidx.compose.foundation.Canvas import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.offset+import androidx.compose.foundation.layout.padding import com.vayunmathur.library.ui.ExperimentalMaterial3ExpressiveApi import com.vayunmathur.library.ui.IconSunny import com.vayunmathur.library.ui.MaterialShapes@@ -14,6 +16,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Color+import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.res.stringResource import com.vayunmathur.weather.R@@ -95,8 +98,15 @@ fun UvIndexBlock(uvIndex: Double?) {         )         Text(             text = labelRes?.let { stringResource(it) } ?: "—",-            modifier = Modifier.align(Alignment.BottomCenter).offset(y = (-35).dp),-            style = MaterialTheme.typography.bodyMedium,+            modifier = Modifier+                .align(Alignment.BottomCenter)+                .offset(y = (-35).dp)+                .fillMaxWidth()+                .padding(horizontal = 12.dp),+            style = MaterialTheme.typography.bodySmall,+            textAlign = TextAlign.Center,+            maxLines = 2,+            softWrap = true,             color = MaterialTheme.colorScheme.onSurfaceVariant,         )     }
weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/VisibilityBlock.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/VisibilityBlock.kt b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/VisibilityBlock.ktindex 672a859355..1d2e01b273 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/VisibilityBlock.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/VisibilityBlock.kt@@ -55,6 +55,8 @@ fun VisibilityBlock(current: Current, useMiles: Boolean = false) {             text = unit,             modifier = Modifier.align(Alignment.BottomCenter).offset(y = (-30).dp),             style = MaterialTheme.typography.bodyMedium,+            maxLines = 1,+            softWrap = true,             color = MaterialTheme.colorScheme.onSurfaceVariant,         )     }
weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/WindBlock.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/WindBlock.kt b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/WindBlock.ktindex b177689883..5c5d8acbd3 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/WindBlock.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/components/blocks/WindBlock.kt@@ -71,12 +71,14 @@ fun WindBlock(current: Current, unit: WindUnit) {             }             Text(                 text = stringResource(R.string.from_gusts, compassDirection(current.windDirection), formatWind(current.windGusts, unit)),-                style = MaterialTheme.typography.bodyLarge,+                style = MaterialTheme.typography.bodyMedium,                 modifier = Modifier                     .fillMaxWidth()                     .padding(bottom = 20.dp)                     .padding(horizontal = 16.dp),                 textAlign = TextAlign.Center,+                maxLines = 2,+                softWrap = true,                 color = MaterialTheme.colorScheme.onSurfaceVariant,             )         }