Skip to content

Commit 54d65d8

Browse files
authored
Merge pull request #137 from joreilly/dependency_updates
dependency updates + updated year handling
2 parents dd16fd1 + 671111d commit 54d65d8

File tree

8 files changed

+907
-157
lines changed

8 files changed

+907
-157
lines changed

composeApp/ClimateTrace.ipynb

Lines changed: 885 additions & 131 deletions
Large diffs are not rendered by default.

composeApp/src/commonMain/kotlin/dev/johnoreilly/climatetrace/ui/CountryInfoDetailedView.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fun CountryInfoDetailedViewSuccess(viewState: CountryDetailsUIState.Success, onY
7979
val countryAssetEmissionsList = viewState.countryAssetEmissionsList
8080
val countryEmissionInfo = viewState.countryEmissionInfo
8181

82-
YearSelector(year, onYearSelected)
82+
YearSelector(year, viewState.availableYears, onYearSelected)
8383
countryEmissionInfo?.let {
8484
val co2 = (countryEmissionInfo.emissions.co2 / 1_000_000).toInt()
8585
val percentage =
@@ -112,17 +112,16 @@ fun CountryInfoDetailedViewSuccess(viewState: CountryDetailsUIState.Success, onY
112112

113113

114114
@Composable
115-
fun YearSelector(selectedYear: String, onYearSelected: (String) -> Unit) {
115+
fun YearSelector(selectedYear: String, availableYears: List<String>, onYearSelected: (String) -> Unit) {
116116
var expanded by remember { mutableStateOf(false) }
117-
val items = listOf("2021", "2022")
118117

119118
Box(modifier = Modifier.wrapContentSize(Alignment.TopStart)) {
120119
Text(selectedYear, modifier = Modifier.clickable(onClick = { expanded = true }))
121120
DropdownMenu(
122121
expanded = expanded,
123122
onDismissRequest = { expanded = false },
124123
) {
125-
items.forEach { year ->
124+
availableYears.forEach { year ->
126125
DropdownMenuItem(onClick = {
127126
onYearSelected(year)
128127
expanded = false

composeApp/src/commonMain/kotlin/dev/johnoreilly/climatetrace/viewmodel/CountryDetailsViewModel.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ sealed class CountryDetailsUIState {
2828
data class Success(
2929
val country: Country,
3030
val year: String,
31+
val availableYears: List<String>,
3132
val countryEmissionInfo: CountryEmissionsInfo?,
3233
val countryAssetEmissionsList: List<CountryAssetEmissionsInfo>
3334
) : CountryDetailsUIState()
@@ -40,6 +41,7 @@ sealed interface CountryDetailsEvents {
4041

4142
open class CountryDetailsViewModel : ViewModel(), KoinComponent {
4243
private val climateTraceRepository: ClimateTraceRepository by inject()
44+
private val availableYears = listOf("2021", "2022", "2023", "2024")
4345

4446
private val events = MutableSharedFlow<CountryDetailsEvents>(extraBufferCapacity = 20)
4547

@@ -59,7 +61,7 @@ open class CountryDetailsViewModel : ViewModel(), KoinComponent {
5961
fun CountryDetailsPresenter(events: Flow<CountryDetailsEvents>): CountryDetailsUIState {
6062
var uiState by remember { mutableStateOf<CountryDetailsUIState>(CountryDetailsUIState.NoCountrySelected) }
6163
var selectedCountry by remember { mutableStateOf<Country?>(null) }
62-
var selectedYear by remember { mutableStateOf("2022") }
64+
var selectedYear by remember { mutableStateOf("2024") }
6365

6466
LaunchedEffect(Unit) {
6567
events.collect { event ->
@@ -76,9 +78,9 @@ open class CountryDetailsViewModel : ViewModel(), KoinComponent {
7678
try {
7779
val countryEmissionInfo = climateTraceRepository.fetchCountryEmissionsInfo(country.alpha3, selectedYear).firstOrNull()
7880
val countryAssetEmissionsList = climateTraceRepository.fetchCountryAssetEmissionsInfo(country.alpha3)
79-
uiState = CountryDetailsUIState.Success(country, selectedYear, countryEmissionInfo, countryAssetEmissionsList)
81+
uiState = CountryDetailsUIState.Success(country, selectedYear, availableYears, countryEmissionInfo, countryAssetEmissionsList)
8082
} catch (e: Exception) {
81-
uiState = CountryDetailsUIState.Error("Error retrieving data from backend")
83+
uiState = CountryDetailsUIState.Error("Error retrieving data from backend, ${e.message}")
8284
}
8385
}
8486
}

composeApp/src/commonTest/kotlin/dev/johnoreilly/climatetrace/screen/ClimateTraceTestsScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ClimateTraceScreenTest {
3535
@Test
3636
fun testCountryInfoDetailsView() = runComposeUiTest {
3737
val state = CountryDetailsUIState.Success(country,
38-
year, countryEmissionsInfo, emptyList()
38+
year, listOf("2022", "2023"), countryEmissionsInfo, emptyList()
3939
)
4040
setContent {
4141
CountryInfoDetailedView(state, {})

gradle/libs.versions.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
[versions]
2-
kotlin = "2.1.0"
3-
ksp = "2.1.0-1.0.29"
4-
kotlinx-coroutines = "1.9.0"
2+
kotlin = "2.1.20"
3+
ksp = "2.1.20-2.0.0"
4+
kotlinx-coroutines = "1.10.1"
55

66

7-
agp = "8.7.3"
8-
android-compileSdk = "34"
7+
agp = "8.9.2"
8+
android-compileSdk = "35"
99
android-minSdk = "24"
10-
android-targetSdk = "34"
11-
androidx-activityCompose = "1.9.3"
12-
compose = "1.7.6"
10+
android-targetSdk = "35"
11+
androidx-activityCompose = "1.10.1"
12+
compose = "1.8.0"
1313
compose-plugin = "1.7.3"
1414
composeAdaptiveLayout = "1.0.0"
1515
harawata-appdirs = "1.2.2"
1616
koalaplot = "0.5.3"
17-
koin = "4.0.1-Beta1"
18-
koin-compose-multiplatform = "4.0.1-Beta1"
17+
koin = "4.0.4"
18+
koin-compose-multiplatform = "4.0.4"
1919
kmpNativeCoroutines = "1.0.0-ALPHA-38"
2020
kmpObservableViewModel = "1.0.0-BETA-7"
2121
kstore = "0.8.0"
22-
ktor = "3.0.1"
22+
ktor = "3.1.1"
2323
treemapChart = "0.1.1"
2424
voyager= "1.1.0-beta03"
2525
molecule = "2.0.0"

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

kotlin-js-store/yarn.lock

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,12 +2806,7 @@ wrappy@1:
28062806
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
28072807
integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==
28082808

2809-
2810-
version "8.5.0"
2811-
resolved "https://registry.yarnpkg.com/ws/-/ws-8.5.0.tgz#bfb4be96600757fe5382de12c670dab984a1ed4f"
2812-
integrity sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==
2813-
2814-
ws@^8.13.0:
2809+
[email protected], ws@^8.13.0:
28152810
version "8.18.0"
28162811
resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc"
28172812
integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==

0 commit comments

Comments
 (0)