@@ -20,6 +20,7 @@ import androidx.compose.runtime.Immutable
2020import androidx.compose.runtime.getValue
2121import androidx.compose.ui.Alignment
2222import androidx.compose.ui.Modifier
23+ import androidx.compose.ui.res.stringResource
2324import androidx.compose.ui.unit.dp
2425import androidx.lifecycle.ViewModel
2526import androidx.lifecycle.compose.collectAsStateWithLifecycle
@@ -88,15 +89,19 @@ internal fun DemoAcceptLanguageHeader(
8889 ) {
8990
9091 Row (horizontalArrangement = Arrangement .spacedBy(8 .dp)) {
91- Button (onClick = viewModel::get) { Text (" GET" ) }
92- OutlinedButton (onClick = viewModel::reset) { Text (" Reset" ) }
92+ Button (onClick = viewModel::get) {
93+ Text (text = stringResource(id = R .string.demo_accept_language_get_button))
94+ }
95+ OutlinedButton (onClick = viewModel::reset) {
96+ Text (text = stringResource(id = R .string.demo_accept_language_reset_button))
97+ }
9398 }
9499
95100 Spacer (modifier = Modifier .height(8 .dp))
96101
97102 when (val currentState = state) {
98103 DemoAcceptLanguageUiState .Idle ->
99- Text (text = " Press GET to call httpbin.org/get " )
104+ Text (text = stringResource(id = R .string.demo_accept_language_prompt) )
100105
101106 DemoAcceptLanguageUiState .Loading ->
102107 Row (
@@ -106,7 +111,7 @@ internal fun DemoAcceptLanguageHeader(
106111 ) {
107112 CircularProgressIndicator ()
108113 Spacer (modifier = Modifier .width(8 .dp))
109- Text (text = " Loading… " )
114+ Text (text = stringResource(id = R .string.demo_accept_language_loading) )
110115 }
111116
112117 is DemoAcceptLanguageUiState .Success -> {
@@ -115,16 +120,28 @@ internal fun DemoAcceptLanguageHeader(
115120 horizontalAlignment = Alignment .CenterHorizontally ,
116121 verticalArrangement = Arrangement .spacedBy(4 .dp)
117122 ) {
118- Text (text = " Response success" , style = MaterialTheme .typography.titleSmall)
119- Text (text = " Response: ${currentState.data} " )
123+ Text (
124+ text = stringResource(id = R .string.demo_accept_language_response_title),
125+ style = MaterialTheme .typography.titleSmall,
126+ )
127+ Text (
128+ text = stringResource(
129+ id = R .string.demo_accept_language_response,
130+ currentState.data.toString(),
131+ ),
132+ )
120133 }
121134 }
122135
123- is DemoAcceptLanguageUiState .Error ->
136+ is DemoAcceptLanguageUiState .Error -> {
137+ val message = currentState.message
138+ ? : stringResource(id = R .string.demo_accept_language_error_unknown)
139+
124140 Text (
125- text = " Error: ${currentState.message ? : " unknown " } " ,
141+ text = stringResource(id = R .string.demo_accept_language_error, message) ,
126142 color = MaterialTheme .colorScheme.error,
127143 )
144+ }
128145 }
129146 }
130147}
0 commit comments