diff --git a/src/jvmMain/kotlin/app/EventUIState.kt b/src/jvmMain/kotlin/app/EventUIState.kt new file mode 100644 index 0000000..ca9e0ed --- /dev/null +++ b/src/jvmMain/kotlin/app/EventUIState.kt @@ -0,0 +1,5 @@ +package app + +interface EventUIState { + fun onClickSearch(text: String) +} \ No newline at end of file diff --git a/src/jvmMain/kotlin/app/WeatherUIState.kt b/src/jvmMain/kotlin/app/WeatherUIState.kt new file mode 100644 index 0000000..227e404 --- /dev/null +++ b/src/jvmMain/kotlin/app/WeatherUIState.kt @@ -0,0 +1,36 @@ +package app + +import javax.swing.Icon + +data class WeatherUIState( + val search: String = "", + val cloud: Int = 0, + val humidity: Int = 0, + val wind: Double = 0.0, + val chanceOfRain: Int = 0, + val weeklyForeCase: WeeklyForeCaseUIState = WeeklyForeCaseUIState(), + val temp: Double = 0.0, + val condition: ConditionUIState = ConditionUIState(), + val location: LocationUIState = LocationUIState() +) + +data class WeeklyForeCaseUIState( + val foreCaseDay: List = emptyList() +) + +data class ForeCaseDayUIState( + val date: String = "", + val maxTemp: Double = 0.0, + val minTemp: Double = 0.0, + val icon: String = "" +) + +data class ConditionUIState( + val text: String = "", + val icon: String = "" +) + +data class LocationUIState( + val name: String = "", + val localTime: String = "" +) \ No newline at end of file diff --git a/src/jvmMain/kotlin/app/WeatherUIStateMapper.kt b/src/jvmMain/kotlin/app/WeatherUIStateMapper.kt new file mode 100644 index 0000000..1c805f7 --- /dev/null +++ b/src/jvmMain/kotlin/app/WeatherUIStateMapper.kt @@ -0,0 +1,23 @@ +package app + +import domain.entity.ConditionEntity +import domain.entity.WeatherEntity + +fun WeatherEntity.toWeatherUIState(): WeatherUIState{ + + return WeatherUIState( + cloud = this.current?.cloud ?: 0, + humidity = this.current?.humidity ?: 0, + wind = this.current?.windKph ?: 0.0, + temp = this.current?.tempC ?:0.0, + + ) + +} + +fun ConditionEntity.toConditionUIStateMapper(): ConditionUIState{ + return ConditionUIState( + text = this.text ?: "", + icon = this.icon ?: "" + ) +} \ No newline at end of file diff --git a/src/jvmMain/kotlin/data/remote/dto/WeatherDto.kt b/src/jvmMain/kotlin/data/remote/dto/WeatherDto.kt index 63fe598..c480823 100644 --- a/src/jvmMain/kotlin/data/remote/dto/WeatherDto.kt +++ b/src/jvmMain/kotlin/data/remote/dto/WeatherDto.kt @@ -1,31 +1,101 @@ package data.remote.dto -import com.google.gson.annotations.SerializedName +import kotlinx.serialization.SerialName -data class WeatherDto( - val current: CurrentDto?, - val location: LocationDto? -) +data class WeatherDTO( + @SerialName("query") + val query: Query +) { + data class Query( + @SerialName("custom_id") + val customId: String, + @SerialName("q") + val q: String, + @SerialName("location") + val location: Location, + @SerialName("current") + val current: Current + ) { -data class ConditionDto( - val code: Int?, - val icon: String?, - val text: String? -) + data class Location( + @SerialName("name") + val name: String, + @SerialName("region") + val region: String, + @SerialName("country") + val country: String, + @SerialName("lat") + val lat: Double, + @SerialName("lon") + val lon: Double, + @SerialName("tz_id") + val tzId: String, + @SerialName("localtime_epoch") + val localtimeEpoch: Int, + @SerialName("localtime") + val localtime: String + ) + data class Current( + @SerialName("last_updated_epoch") + val lastUpdatedEpoch: Int, + @SerialName("last_updated") + val lastUpdated: String, + @SerialName("temp_c") + val tempC: Double, + @SerialName("temp_f") + val tempF: Double, + @SerialName("is_day") + val isDay: Int, + @SerialName("condition") + val condition: Condition, + @SerialName("wind_mph") + val windMph: Double, + @SerialName("wind_kph") + val windKph: Double, + @SerialName("wind_degree") + val windDegree: Int, + @SerialName("wind_dir") + val windDir: String, + @SerialName("pressure_mb") + val pressureMb: Double, + @SerialName("pressure_in") + val pressureIn: Double, + @SerialName("precip_mm") + val precipMm: Double, + @SerialName("precip_in") + val precipIn: Double, + @SerialName("humidity") + val humidity: Int, + @SerialName("cloud") + val cloud: Int, + @SerialName("feelslike_c") + val feelslikeC: Double, + @SerialName("feelslike_f") + val feelslikeF: Double, + @SerialName("vis_km") + val visKm: Double, + @SerialName("vis_miles") + val visMiles: Double, + @SerialName("uv") + val uv: Double, + @SerialName("gust_mph") + val gustMph: Double, + @SerialName("gust_kph") + val gustKph: Double + ) { -data class LocationDto( - val country: String?, - val lat: Double?, - val localtime: String?, - @SerializedName("localtime_epoch") - val localtimeEpoch: Int?, - val lon: Double?, - val name: String?, - val region: String?, - @SerializedName("tz_id") - val tzId: String? -) \ No newline at end of file + data class Condition( + @SerialName("text") + val text: String, + @SerialName("icon") + val icon: String, + @SerialName("code") + val code: Int + ) + } + } +} \ No newline at end of file