fun WeatherDetailsCard()

in src/main/kotlin/org/jetbrains/plugins/template/weatherApp/ui/components/WeatherDetailsCard.kt [50:149]


fun WeatherDetailsCard(
    modifier: Modifier = Modifier,
    weatherForecastState: WeatherForecastUIState,
    onReloadWeatherData: (Location) -> Unit
) {

    val (cardColor, textColor) = when (weatherForecastState) {
        is WeatherForecastUIState.Success -> {
            val isNightTime = isNightTime(weatherForecastState.weatherForecastData.currentWeatherForecast.date)
            val color =
                getCardColorByTemperature(
                    weatherForecastState.weatherForecastData.currentWeatherForecast.temperature,
                    isNightTime
                )
            color to Color.White
        }

        is WeatherForecastUIState.Loading -> WeatherAppColors.mildWeatherColor to Color.White
        is WeatherForecastUIState.Error -> WeatherAppColors.hotWeatherColor to Color.White
        is WeatherForecastUIState.Empty -> WeatherAppColors.coolWeatherColor to Color.White
    }

    VerticallyScrollableContainer(modifier = modifier.safeContentPadding()) {
        Box(
            modifier = Modifier
                .clip(RoundedCornerShape(16.dp))
                .background(cardColor)
                .padding(16.dp)
        ) {

            // Card content
            Column(
                modifier = Modifier
                    .fillMaxWidth()
            ) {
                Row(
                    modifier = Modifier.fillMaxWidth(),
                    horizontalArrangement = Arrangement.SpaceBetween
                ) {
                    // Current Time
                    TimeDisplay(weatherForecastState, textColor)

                    ActionButton(
                        modifier = Modifier
                            .clip(RoundedCornerShape(8.dp))
                            .background(Color.Transparent)
                            .padding(8.dp),
                        tooltip = { Text("Refresh weather data") },
                        onClick = {
                            weatherForecastState.getLocationOrNull()?.let { onReloadWeatherData(it) }
                        },
                    ) {
                        Icon(
                            key = AllIconsKeys.Actions.Refresh,
                            contentDescription = "Refresh",
                            tint = Color.White
                        )
                    }
                }

                Spacer(modifier = Modifier.height(16.dp))

                // Temperature and weather type column (vertically aligned)
                Column(
                    modifier = Modifier.fillMaxWidth(),
                    horizontalAlignment = Alignment.CenterHorizontally
                ) {

                    WeatherIconDisplay(weatherForecastState)

                    Spacer(modifier = Modifier.height(8.dp))

                    TemperatureDisplay(weatherForecastState, textColor)

                    Spacer(modifier = Modifier.height(8.dp))

                    // City name
                    CityNameDisplay(weatherForecastState, textColor)
                }

                Spacer(modifier = Modifier.height(16.dp))

                // Wind and humidity info
                WeatherDetailsRow(Modifier.fillMaxWidth(), weatherForecastState, textColor)

                Spacer(modifier = Modifier.height(24.dp))

                // 7-day forecast section
                SevenDaysForecastWidget(
                    weatherForecastState,
                    textColor,
                    Modifier
                        .fillMaxWidth()
                        .wrapContentHeight()
                        .align(Alignment.CenterHorizontally)
                )
            }
        }
    }
}