mirror of
https://github.com/JetBrains/intellij-platform-plugin-template.git
synced 2025-12-05 06:11:52 +00:00
Fix UI bugs with reloading weather data
This commit is contained in:
parent
da436500bf
commit
e9188b61cb
@ -67,6 +67,8 @@ internal class MyLocationsViewModel(cs: CoroutineScope) : MyLocationsViewModelAp
|
||||
myLocations.value += locationToAdd
|
||||
selectedLocationIndex.value = myLocations.value.lastIndex
|
||||
}
|
||||
|
||||
onReloadWeatherForecast()
|
||||
}
|
||||
|
||||
override fun onDeleteLocation(locationToDelete: Location) {
|
||||
@ -77,6 +79,8 @@ internal class MyLocationsViewModel(cs: CoroutineScope) : MyLocationsViewModelAp
|
||||
if (itemIndex in 0..currentSelectedIndex) {
|
||||
selectedLocationIndex.value = (currentSelectedIndex - 1).coerceAtLeast(0)
|
||||
}
|
||||
|
||||
onReloadWeatherForecast()
|
||||
}
|
||||
|
||||
override fun onLocationSelected(selectedLocationIndex: Int) {
|
||||
|
||||
@ -68,8 +68,6 @@ private fun LeftColumn(
|
||||
) {
|
||||
val myLocations = myLocationsViewModelApi.myLocationsFlow.collectAsState(emptyList()).value
|
||||
|
||||
// TODO Set selected item on initial showing
|
||||
|
||||
Column(modifier) {
|
||||
GroupHeader(
|
||||
ComposeTemplateBundle.message("weather.app.my.locations.header.text"),
|
||||
@ -158,8 +156,8 @@ private fun RightColumn(
|
||||
.fillMaxWidth()
|
||||
.align(Alignment.CenterHorizontally),
|
||||
weatherForecastData
|
||||
) {
|
||||
weatherViewModelApi.onReloadWeatherForecast()
|
||||
) { location ->
|
||||
weatherViewModelApi.onLoadWeatherForecast(location)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ import org.jetbrains.jewel.ui.icons.AllIconsKeys
|
||||
import org.jetbrains.plugins.template.ComposeTemplateBundle
|
||||
import org.jetbrains.plugins.template.weatherApp.WeatherAppColors
|
||||
import org.jetbrains.plugins.template.weatherApp.model.DailyForecast
|
||||
import org.jetbrains.plugins.template.weatherApp.model.Location
|
||||
import org.jetbrains.plugins.template.weatherApp.model.WeatherForecastData
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
@ -46,7 +47,7 @@ import java.util.*
|
||||
internal fun WeatherDetailsCard(
|
||||
modifier: Modifier = Modifier,
|
||||
weatherForecastData: WeatherForecastData,
|
||||
onReloadWeatherData: () -> Unit
|
||||
onReloadWeatherData: (Location) -> Unit
|
||||
) {
|
||||
val currentWeatherForecast = weatherForecastData.currentWeatherForecast
|
||||
val isNightTime = isNightTime(currentWeatherForecast.date)
|
||||
@ -83,7 +84,7 @@ internal fun WeatherDetailsCard(
|
||||
.background(Color.Transparent)
|
||||
.padding(8.dp),
|
||||
tooltip = { Text("Refresh weather data") },
|
||||
onClick = { onReloadWeatherData() },
|
||||
onClick = { onReloadWeatherData(weatherForecastData.location) },
|
||||
) {
|
||||
Icon(
|
||||
key = AllIconsKeys.Actions.Refresh,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user