Skip to content

Commit

Permalink
Move verticalScroll modifier to ForecastScreen
Browse files Browse the repository at this point in the history
This gives ForecastScreenContent more screen real state for phones in
landscape.
  • Loading branch information
tobyhs committed Sep 17, 2024
1 parent d2eafd9 commit f6aada5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Search
import androidx.compose.material3.CircularProgressIndicator
Expand Down Expand Up @@ -65,7 +67,11 @@ private fun ForecastScreen(
onLocationInputChange: (String) -> Unit = {},
onSubmit: () -> Unit = {},
) {
Column(Modifier.padding(all = dimensionResource(R.dimen.forecast_screen_padding))) {
Column(
Modifier
.padding(all = dimensionResource(R.dimen.forecast_screen_padding))
.verticalScroll(rememberScrollState())
) {
val inputContentDescription = stringResource(R.string.locationSearchHint)
OutlinedTextField(
value = locationInput,
Expand All @@ -86,7 +92,7 @@ private fun ForecastScreen(
)
Spacer(Modifier.height(8.dp))

Box(Modifier.fillMaxWidth().weight(1f)) {
Box(Modifier.fillMaxWidth()) {
when (forecastState) {
is LoadState.Loading -> {
CircularProgressIndicator(
Expand All @@ -102,6 +108,7 @@ private fun ForecastScreen(
}
}

Spacer(Modifier.height(8.dp))
Text(stringResource(R.string.powered_by))
val context = LocalContext.current
Image(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package io.github.tobyhs.weatherweight.forecast

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.ScrollableTabRow
import androidx.compose.material3.Tab
import androidx.compose.material3.Text
Expand Down Expand Up @@ -52,17 +50,15 @@ fun ForecastScreenContent(forecastResultSet: ForecastResultSet) {
}
}

Column(Modifier.verticalScroll(rememberScrollState())) {
when (tabTitleResources[tabIndex]) {
R.string.daily -> {
for (forecast in forecastResultSet.dailyForecasts) {
DailyForecastCard(forecast)
}
when (tabTitleResources[tabIndex]) {
R.string.daily -> {
for (forecast in forecastResultSet.dailyForecasts) {
DailyForecastCard(forecast)
}
R.string.hourly -> {
for (forecast in forecastResultSet.hourlyForecasts) {
HourlyForecastCard(forecast)
}
}
R.string.hourly -> {
for (forecast in forecastResultSet.hourlyForecasts) {
HourlyForecastCard(forecast)
}
}
}
Expand Down

0 comments on commit f6aada5

Please sign in to comment.