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
|
myLocations.value += locationToAdd
|
||||||
selectedLocationIndex.value = myLocations.value.lastIndex
|
selectedLocationIndex.value = myLocations.value.lastIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onReloadWeatherForecast()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDeleteLocation(locationToDelete: Location) {
|
override fun onDeleteLocation(locationToDelete: Location) {
|
||||||
@ -77,6 +79,8 @@ internal class MyLocationsViewModel(cs: CoroutineScope) : MyLocationsViewModelAp
|
|||||||
if (itemIndex in 0..currentSelectedIndex) {
|
if (itemIndex in 0..currentSelectedIndex) {
|
||||||
selectedLocationIndex.value = (currentSelectedIndex - 1).coerceAtLeast(0)
|
selectedLocationIndex.value = (currentSelectedIndex - 1).coerceAtLeast(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onReloadWeatherForecast()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLocationSelected(selectedLocationIndex: Int) {
|
override fun onLocationSelected(selectedLocationIndex: Int) {
|
||||||
|
|||||||
@ -68,8 +68,6 @@ private fun LeftColumn(
|
|||||||
) {
|
) {
|
||||||
val myLocations = myLocationsViewModelApi.myLocationsFlow.collectAsState(emptyList()).value
|
val myLocations = myLocationsViewModelApi.myLocationsFlow.collectAsState(emptyList()).value
|
||||||
|
|
||||||
// TODO Set selected item on initial showing
|
|
||||||
|
|
||||||
Column(modifier) {
|
Column(modifier) {
|
||||||
GroupHeader(
|
GroupHeader(
|
||||||
ComposeTemplateBundle.message("weather.app.my.locations.header.text"),
|
ComposeTemplateBundle.message("weather.app.my.locations.header.text"),
|
||||||
@ -158,8 +156,8 @@ private fun RightColumn(
|
|||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.align(Alignment.CenterHorizontally),
|
.align(Alignment.CenterHorizontally),
|
||||||
weatherForecastData
|
weatherForecastData
|
||||||
) {
|
) { location ->
|
||||||
weatherViewModelApi.onReloadWeatherForecast()
|
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.ComposeTemplateBundle
|
||||||
import org.jetbrains.plugins.template.weatherApp.WeatherAppColors
|
import org.jetbrains.plugins.template.weatherApp.WeatherAppColors
|
||||||
import org.jetbrains.plugins.template.weatherApp.model.DailyForecast
|
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 org.jetbrains.plugins.template.weatherApp.model.WeatherForecastData
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
@ -46,7 +47,7 @@ import java.util.*
|
|||||||
internal fun WeatherDetailsCard(
|
internal fun WeatherDetailsCard(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
weatherForecastData: WeatherForecastData,
|
weatherForecastData: WeatherForecastData,
|
||||||
onReloadWeatherData: () -> Unit
|
onReloadWeatherData: (Location) -> Unit
|
||||||
) {
|
) {
|
||||||
val currentWeatherForecast = weatherForecastData.currentWeatherForecast
|
val currentWeatherForecast = weatherForecastData.currentWeatherForecast
|
||||||
val isNightTime = isNightTime(currentWeatherForecast.date)
|
val isNightTime = isNightTime(currentWeatherForecast.date)
|
||||||
@ -83,7 +84,7 @@ internal fun WeatherDetailsCard(
|
|||||||
.background(Color.Transparent)
|
.background(Color.Transparent)
|
||||||
.padding(8.dp),
|
.padding(8.dp),
|
||||||
tooltip = { Text("Refresh weather data") },
|
tooltip = { Text("Refresh weather data") },
|
||||||
onClick = { onReloadWeatherData() },
|
onClick = { onReloadWeatherData(weatherForecastData.location) },
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
key = AllIconsKeys.Actions.Refresh,
|
key = AllIconsKeys.Actions.Refresh,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user