Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/jvmMain/kotlin/app/EventUIState.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package app

interface EventUIState {
fun onClickSearch(text: String)
}
35 changes: 35 additions & 0 deletions src/jvmMain/kotlin/app/WeatherUIState.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package app


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<ForeCaseDayUIState> = 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 = ""
)
44 changes: 44 additions & 0 deletions src/jvmMain/kotlin/app/WeatherUIStateMapper.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package app

import domain.entity.*

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,
condition = this.current?.condition?.toConditionUIStateMapper() ?: ConditionUIState(),
location = this.location?.toLocationUIStateMapper() ?: LocationUIState(),
weeklyForeCase = this.forecast?.toWeeklyForeCaseUIStateMapper() ?: WeeklyForeCaseUIState()
)
}

fun ConditionEntity.toConditionUIStateMapper(): ConditionUIState{
return ConditionUIState(
text = this.text ?: "",
icon = this.icon ?: ""
)
}

fun LocationEntity.toLocationUIStateMapper(): LocationUIState{
return LocationUIState(
name = this.name ?: "",
localTime = this.localtime ?: ""
)
}

fun ForecastEntity.toWeeklyForeCaseUIStateMapper(): WeeklyForeCaseUIState{
return WeeklyForeCaseUIState(
foreCaseDay = this.forecastDay?.map { it.toForeCaseDayUIState() }.orEmpty()
)
}

fun ForecastDayEntity.toForeCaseDayUIState(): ForeCaseDayUIState{
return ForeCaseDayUIState(
date = this.date ?: "",
maxTemp = this.day?.maxtempC ?: 0.0,
minTemp = this.day?.mintempC ?: 0.0,
icon = this.day?.condition?.icon ?: ""
)
}
12 changes: 12 additions & 0 deletions src/jvmMain/kotlin/data/remote/dto/Condition.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package data.remote.dto

import com.google.gson.annotations.SerializedName

data class Condition(
@SerializedName("code")
val code: Int? = null,
@SerializedName("icon")
val icon: String? = null,
@SerializedName("text")
val text: String? = null
)
52 changes: 52 additions & 0 deletions src/jvmMain/kotlin/data/remote/dto/Current.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package data.remote.dto

import com.google.gson.annotations.SerializedName

data class Current(
@SerializedName("cloud")
val cloud: Int? = null,
@SerializedName("condition")
val condition: Condition? = null,
@SerializedName("feelslike_c")
val feelslikeC: Double? = null,
@SerializedName("feelslike_f")
val feelslikeF: Double? = null,
@SerializedName("gust_kph")
val gustKph: Double? = null,
@SerializedName("gust_mph")
val gustMph: Double? = null,
@SerializedName("humidity")
val humidity: Int? = null,
@SerializedName("is_day")
val isDay: Int? = null,
@SerializedName("last_updated")
val lastUpdated: String? = null,
@SerializedName("last_updated_epoch")
val lastUpdatedEpoch: Int? = null,
@SerializedName("precip_in")
val precipIn: Double? = null,
@SerializedName("precip_mm")
val precipMm: Double? = null,
@SerializedName("pressure_in")
val pressureIn: Double? = null,
@SerializedName("pressure_mb")
val pressureMb: Double? = null,
@SerializedName("temp_c")
val tempC: Double? = null,
@SerializedName("temp_f")
val tempF: Double? = null,
@SerializedName("uv")
val uv: Double? = null,
@SerializedName("vis_km")
val visKm: Double? = null,
@SerializedName("vis_miles")
val visMiles: Double? = null,
@SerializedName("wind_degree")
val windDegree: Int? = null,
@SerializedName("wind_dir")
val windDir: String? = null,
@SerializedName("wind_kph")
val windKph: Double? = null,
@SerializedName("wind_mph")
val windMph: Double? = null
)
2 changes: 1 addition & 1 deletion src/jvmMain/kotlin/data/remote/dto/CurrentDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.google.gson.annotations.SerializedName

data class CurrentDto(
val cloud: Int?,
val condition: ConditionDto?,
val condition: Condition?,
@SerializedName("feelslike_c")
val feelslikeC: Double?,
@SerializedName("feelslike_f")
Expand Down
2 changes: 1 addition & 1 deletion src/jvmMain/kotlin/data/remote/dto/DaysWeatherDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ package data.remote.dto
data class DaysWeatherDto(
val current: CurrentDto?,
val forecast: ForecastDto?,
val location: LocationDto?
val location: Location?
)
4 changes: 2 additions & 2 deletions src/jvmMain/kotlin/data/remote/dto/ForecastDayDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ data class DayDto(
val avgvisKm: Double?,
@SerializedName("avgvis_miles")
val avgvisMiles: Double?,
val condition: ConditionDto?,
val condition: Condition?,
@SerializedName("daily_chance_of_rain")
val dailyChanceOfRain: Int?,
@SerializedName("daily_chance_of_snow")
Expand Down Expand Up @@ -81,7 +81,7 @@ data class HourDto(
@SerializedName("chance_of_snow")
val chanceOfSnow: Int?,
val cloud: Int?,
val condition: ConditionDto?,
val condition: Condition?,
@SerializedName("dewpoint_c")
val dewpointC: Double?,
@SerializedName("dewpoint_f")
Expand Down
22 changes: 22 additions & 0 deletions src/jvmMain/kotlin/data/remote/dto/Location.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package data.remote.dto

import com.google.gson.annotations.SerializedName

data class Location(
@SerializedName("country")
val country: String? = null,
@SerializedName("lat")
val lat: Double? = null,
@SerializedName("localtime")
val localtime: String? = null,
@SerializedName("localtime_epoch")
val localtimeEpoch: Int? = null,
@SerializedName("lon")
val lon: Double? = null,
@SerializedName("name")
val name: String? = null,
@SerializedName("region")
val region: String? = null,
@SerializedName("tz_id")
val tzId: String? = null
)
101 changes: 0 additions & 101 deletions src/jvmMain/kotlin/data/remote/dto/WeatherDTO.kt

This file was deleted.

29 changes: 4 additions & 25 deletions src/jvmMain/kotlin/data/remote/dto/WeatherDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,9 @@ package data.remote.dto

import com.google.gson.annotations.SerializedName



data class WeatherDto(
val current: CurrentDto?,
val location: LocationDto?
)


data class ConditionDto(
val code: Int?,
val icon: String?,
val text: String?
)


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?
@SerializedName("current")
val current: Current? = null,
@SerializedName("location")
val location: Location? = null
)
Loading