@@ -64,35 +64,38 @@ fun CountryInfoDetailedViewSuccess(viewState: CountryDetailsUIState.Success, onY
6464 .verticalScroll(rememberScrollState())
6565 .fillMaxSize()
6666 .padding(16 .dp),
67- horizontalAlignment = Alignment .CenterHorizontally
67+ horizontalAlignment = Alignment .Start
6868 ) {
69-
70- Text (
71- text = viewState.country.name,
72- style = MaterialTheme .typography.titleLarge,
73- textAlign = TextAlign .Center
74- )
69+ // Header card with flag + country label info
70+ CountryHeader (viewState)
7571
7672 Spacer (modifier = Modifier .size(16 .dp))
7773
7874 val year = viewState.year
7975 val countryAssetEmissionsList = viewState.countryAssetEmissionsList
8076 val countryEmissionInfo = viewState.countryEmissionInfo
8177
82- YearSelector (year, viewState.availableYears, onYearSelected)
78+ // Year selector row
79+ Column {
80+ Text (text = " Year" , style = MaterialTheme .typography.labelLarge, color = MaterialTheme .colorScheme.primary)
81+ Spacer (modifier = Modifier .size(6 .dp))
82+ YearSelector (year, viewState.availableYears, onYearSelected)
83+ }
84+
85+ Spacer (modifier = Modifier .size(12 .dp))
86+
8387 countryEmissionInfo?.let {
8488 val co2 = (countryEmissionInfo.emissions.co2 / 1_000_000 ).toInt()
85- val percentage =
86- (countryEmissionInfo.emissions.co2 / countryEmissionInfo.worldEmissions.co2).toPercent(2 )
89+ val percentage = (countryEmissionInfo.emissions.co2 / countryEmissionInfo.worldEmissions.co2).toPercent(2 )
8790
88- Text (text = " co2 = $co2 Million Tonnes ( $year ) " )
89- Text (text = " rank = ${ countryEmissionInfo.rank} ( $ percentage) " )
91+ // Key figures chips
92+ KeyFiguresRow (co2Mt = co2, rank = countryEmissionInfo.rank, share = percentage)
9093
9194 Spacer (modifier = Modifier .size(16 .dp))
9295
93- val filteredCountryAssetEmissionsList =
94- countryAssetEmissionsList.filter { it.sector != null }
96+ val filteredCountryAssetEmissionsList = countryAssetEmissionsList.filter { it.sector != null }
9597 if (filteredCountryAssetEmissionsList.isNotEmpty()) {
98+ // Keep charts unchanged
9699 SectorEmissionsPieChart (countryAssetEmissionsList)
97100 Spacer (modifier = Modifier .size(32 .dp))
98101 CountryAssetEmissionsInfoTreeMapChart (countryAssetEmissionsList)
@@ -110,6 +113,54 @@ fun CountryInfoDetailedViewSuccess(viewState: CountryDetailsUIState.Success, onY
110113 }
111114}
112115
116+ @Composable
117+ private fun CountryHeader (viewState : CountryDetailsUIState .Success ) {
118+ val c = viewState.country
119+ androidx.compose.material3.Surface (
120+ tonalElevation = 2 .dp,
121+ shape = MaterialTheme .shapes.medium,
122+ color = MaterialTheme .colorScheme.surfaceVariant
123+ ) {
124+ Column (modifier = Modifier .padding(16 .dp)) {
125+ Text (
126+ text = " ${c.name} " ,
127+ style = MaterialTheme .typography.headlineSmall
128+ )
129+ Spacer (modifier = Modifier .size(4 .dp))
130+ Text (
131+ text = " ${c.continent} • ${c.alpha2} / ${c.alpha3} " ,
132+ style = MaterialTheme .typography.bodyMedium,
133+ color = MaterialTheme .colorScheme.onSurfaceVariant
134+ )
135+ }
136+ }
137+ }
138+
139+ @Composable
140+ private fun KeyFiguresRow (co2Mt : Int , rank : Int , share : String ) {
141+ androidx.compose.foundation.layout.Row {
142+ KeyFigureChip (label = " CO₂ (Mt)" , value = co2Mt.toString())
143+ Spacer (modifier = Modifier .size(8 .dp))
144+ KeyFigureChip (label = " Rank" , value = rank.toString())
145+ Spacer (modifier = Modifier .size(8 .dp))
146+ KeyFigureChip (label = " World Share" , value = share)
147+ }
148+ }
149+
150+ @Composable
151+ private fun KeyFigureChip (label : String , value : String ) {
152+ androidx.compose.material3.AssistChip (
153+ onClick = {},
154+ label = {
155+ Column {
156+ Text (text = label, style = MaterialTheme .typography.labelSmall, color = MaterialTheme .colorScheme.onSecondaryContainer)
157+ Text (text = value, style = MaterialTheme .typography.titleMedium)
158+ }
159+ }
160+ )
161+ }
162+
163+
113164
114165@Composable
115166fun YearSelector (selectedYear : String , availableYears : List <String >, onYearSelected : (String ) -> Unit ) {
0 commit comments