mirror of
https://github.com/JetBrains/intellij-platform-plugin-template.git
synced 2025-12-05 06:11:52 +00:00
Make WeatherDetailsCard vertically scrollable and add safeContentPadding
This commit is contained in:
parent
11dfe41249
commit
f25ee25399
@ -18,10 +18,7 @@ import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import org.jetbrains.jewel.foundation.theme.JewelTheme
|
||||
import org.jetbrains.jewel.ui.component.ActionButton
|
||||
import org.jetbrains.jewel.ui.component.HorizontallyScrollableContainer
|
||||
import org.jetbrains.jewel.ui.component.Icon
|
||||
import org.jetbrains.jewel.ui.component.Text
|
||||
import org.jetbrains.jewel.ui.component.*
|
||||
import org.jetbrains.jewel.ui.icons.AllIconsKeys
|
||||
import org.jetbrains.plugins.template.ComposeTemplateBundle
|
||||
import org.jetbrains.plugins.template.weatherApp.WeatherAppColors
|
||||
@ -54,8 +51,9 @@ fun WeatherDetailsCard(
|
||||
val cardColor = getCardColorByTemperature(currentWeatherForecast.temperature, isNightTime)
|
||||
val textColor = Color.White
|
||||
|
||||
VerticallyScrollableContainer(modifier = modifier.safeContentPadding()) {
|
||||
Box(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
.background(cardColor)
|
||||
.padding(16.dp)
|
||||
@ -71,21 +69,42 @@ fun WeatherDetailsCard(
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
// Current Time
|
||||
/**
|
||||
* Jewel org.jetbrains.jewel.ui.component.Text
|
||||
* @see https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Text.kt
|
||||
*/
|
||||
Text(
|
||||
text = ComposeTemplateBundle.message("weather.app.time.text", timeToDisplay),
|
||||
text = ComposeTemplateBundle.message(
|
||||
"weather.app.time.text",
|
||||
formatDateTime(currentWeatherForecast.date)
|
||||
),
|
||||
color = textColor,
|
||||
fontSize = JewelTheme.defaultTextStyle.fontSize,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
|
||||
/**
|
||||
* Jewel org.jetbrains.jewel.ui.component.ActionButton
|
||||
* @see https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Button.kt
|
||||
*/
|
||||
ActionButton(
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(8.dp))
|
||||
.background(Color.Transparent)
|
||||
.padding(8.dp),
|
||||
tooltip = { Text("Refresh weather data") },
|
||||
tooltip = {
|
||||
/**
|
||||
* Jewel org.jetbrains.jewel.ui.component.Text
|
||||
* @see https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Text.kt
|
||||
*/
|
||||
Text("Refresh weather data")
|
||||
},
|
||||
onClick = { onReloadWeatherData(weatherForecastData.location) },
|
||||
) {
|
||||
/**
|
||||
* Jewel org.jetbrains.jewel.ui.component.Icon
|
||||
* @see https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Icon.kt
|
||||
*/
|
||||
Icon(
|
||||
key = AllIconsKeys.Actions.Refresh,
|
||||
contentDescription = "Refresh",
|
||||
@ -102,6 +121,10 @@ fun WeatherDetailsCard(
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
|
||||
/**
|
||||
* Jewel org.jetbrains.jewel.ui.component.Icon
|
||||
* @see https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Icon.kt
|
||||
*/
|
||||
Icon(
|
||||
key = when {
|
||||
isNightTime -> currentWeatherForecast.weatherType.nightIconKey
|
||||
@ -114,6 +137,10 @@ fun WeatherDetailsCard(
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
// Temperature (emphasized)
|
||||
/**
|
||||
* Jewel org.jetbrains.jewel.ui.component.Text
|
||||
* @see https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Text.kt
|
||||
*/
|
||||
Text(
|
||||
text = ComposeTemplateBundle.message(
|
||||
"weather.app.temperature.text",
|
||||
@ -127,6 +154,10 @@ fun WeatherDetailsCard(
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
// City name
|
||||
/**
|
||||
* Jewel org.jetbrains.jewel.ui.component.Text
|
||||
* @see https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Text.kt
|
||||
*/
|
||||
Text(
|
||||
text = weatherForecastData.location.label,
|
||||
color = textColor,
|
||||
@ -143,6 +174,10 @@ fun WeatherDetailsCard(
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
// Wind info
|
||||
/**
|
||||
* Jewel org.jetbrains.jewel.ui.component.Text
|
||||
* @see https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Text.kt
|
||||
*/
|
||||
Text(
|
||||
text = ComposeTemplateBundle.message(
|
||||
"weather.app.wind.direction.text",
|
||||
@ -154,6 +189,10 @@ fun WeatherDetailsCard(
|
||||
)
|
||||
|
||||
// Humidity info
|
||||
/**
|
||||
* Jewel org.jetbrains.jewel.ui.component.Text
|
||||
* @see https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Text.kt
|
||||
*/
|
||||
Text(
|
||||
text = ComposeTemplateBundle.message(
|
||||
"weather.app.humidity.text",
|
||||
@ -177,6 +216,7 @@ fun WeatherDetailsCard(
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@ -187,6 +227,10 @@ private fun SevenDaysForecastWidget(
|
||||
) {
|
||||
if (weatherForecastData.dailyForecasts.isNotEmpty()) {
|
||||
Column(modifier) {
|
||||
/**
|
||||
* Jewel org.jetbrains.jewel.ui.component.Text
|
||||
* @see https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Text.kt
|
||||
*/
|
||||
Text(
|
||||
text = ComposeTemplateBundle.message("weather.app.7days.forecast.title.text"),
|
||||
color = textColor,
|
||||
@ -198,8 +242,12 @@ private fun SevenDaysForecastWidget(
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
val scrollState = rememberLazyListState()
|
||||
/**
|
||||
* Jewel org.jetbrains.jewel.ui.component.HorizontallyScrollableContainer
|
||||
* @see https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/ScrollableContainer.kt
|
||||
*/
|
||||
HorizontallyScrollableContainer(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
modifier = Modifier.fillMaxWidth().safeContentPadding(),
|
||||
scrollState = scrollState,
|
||||
) {
|
||||
LazyRow(
|
||||
@ -244,6 +292,10 @@ private fun DayForecastItem(
|
||||
.padding(8.dp)
|
||||
) {
|
||||
// Day name
|
||||
/**
|
||||
* Jewel org.jetbrains.jewel.ui.component.Text
|
||||
* @see https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Text.kt
|
||||
*/
|
||||
Text(
|
||||
text = dayName,
|
||||
color = textColor,
|
||||
@ -252,6 +304,10 @@ private fun DayForecastItem(
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
|
||||
/**
|
||||
* Jewel org.jetbrains.jewel.ui.component.Text
|
||||
* @see https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Text.kt
|
||||
*/
|
||||
Text(
|
||||
text = date,
|
||||
color = textColor,
|
||||
@ -263,6 +319,10 @@ private fun DayForecastItem(
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
// Weather icon
|
||||
/**
|
||||
* Jewel org.jetbrains.jewel.ui.component.Icon
|
||||
* @see https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Icon.kt
|
||||
*/
|
||||
Icon(
|
||||
key = if (isNightTime(forecast.date)) forecast.weatherType.nightIconKey else forecast.weatherType.dayIconKey,
|
||||
contentDescription = forecast.weatherType.label,
|
||||
@ -273,6 +333,10 @@ private fun DayForecastItem(
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
// Temperature
|
||||
/**
|
||||
* Jewel org.jetbrains.jewel.ui.component.Text
|
||||
* @see https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Text.kt
|
||||
*/
|
||||
Text(
|
||||
text = ComposeTemplateBundle.message(
|
||||
"weather.app.temperature.text",
|
||||
@ -286,6 +350,10 @@ private fun DayForecastItem(
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
// Humidity
|
||||
/**
|
||||
* Jewel org.jetbrains.jewel.ui.component.Text
|
||||
* @see https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Text.kt
|
||||
*/
|
||||
Text(
|
||||
text = ComposeTemplateBundle.message(
|
||||
"weather.app.humidity.text",
|
||||
@ -298,6 +366,10 @@ private fun DayForecastItem(
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
// Wind direction
|
||||
/**
|
||||
* Jewel org.jetbrains.jewel.ui.component.Text
|
||||
* @see https://github.com/JetBrains/intellij-community/blob/master/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Text.kt
|
||||
*/
|
||||
Text(
|
||||
text = ComposeTemplateBundle.message(
|
||||
"weather.app.wind.direction.text",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user