@@ -5,26 +5,12 @@ package dev.johnoreilly.climatetrace
55import android.os.Bundle
66import androidx.activity.ComponentActivity
77import androidx.activity.compose.setContent
8- import androidx.compose.foundation.layout.Column
9- import androidx.compose.foundation.layout.padding
10- import androidx.compose.material3.CenterAlignedTopAppBar
118import androidx.compose.material3.ExperimentalMaterial3Api
129import androidx.compose.material3.MaterialTheme
13- import androidx.compose.material3.Scaffold
14- import androidx.compose.material3.Text
1510import androidx.compose.runtime.Composable
16- import androidx.compose.runtime.collectAsState
17- import androidx.compose.runtime.getValue
18- import androidx.compose.ui.Modifier
19- import cafe.adriel.voyager.core.screen.Screen
20- import cafe.adriel.voyager.navigator.LocalNavigator
2111import cafe.adriel.voyager.navigator.Navigator
22- import cafe.adriel.voyager.navigator.currentOrThrow
2312import dev.johnoreilly.climatetrace.di.initKoin
24- import dev.johnoreilly.climatetrace.ui.CountryEmissionsScreen
25- import dev.johnoreilly.climatetrace.ui.CountryListView
26- import dev.johnoreilly.climatetrace.viewmodel.ClimateTraceViewModel
27- import org.koin.compose.koinInject
13+ import dev.johnoreilly.climatetrace.ui.CountryListScreen
2814
2915class MainActivity : ComponentActivity () {
3016
@@ -45,35 +31,3 @@ class MainActivity : ComponentActivity() {
4531fun AndroidApp () {
4632 Navigator (screen = CountryListScreen ())
4733}
48-
49-
50- class CountryListScreen : Screen {
51- @Composable
52- override fun Content () {
53- val navigator = LocalNavigator .currentOrThrow
54-
55- val viewModel = koinInject<ClimateTraceViewModel >()
56- val countryList = viewModel.countryList.collectAsState()
57- val selectedCountry = viewModel.selectedCountry.collectAsState()
58- val isLoadingCountries by viewModel.isLoadingCountries.collectAsState()
59-
60- Scaffold (
61- topBar = {
62- CenterAlignedTopAppBar (title = {
63- Text (" ClimateTraceKMP" )
64- })
65- }
66- ) {
67- Column (Modifier .padding(it)) {
68- CountryListView (
69- countryList.value,
70- selectedCountry.value,
71- isLoadingCountries
72- ) { country ->
73- navigator.push(CountryEmissionsScreen (country))
74- }
75- }
76- }
77- }
78- }
79-
0 commit comments