Skip to content

Commit

Permalink
[MOD/#4] extract strings for stop watch screen
Browse files Browse the repository at this point in the history
  • Loading branch information
b1urrrr committed Jan 4, 2024
1 parent 0c35886 commit 1679974
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.viewmodel.compose.viewModel
Expand All @@ -53,8 +54,8 @@ class StopWatchScreen : ComponentActivity() {
stopWatchState = stopWatchState,
lapTimes = lapTimes,
onReset = { viewModel.reset() },
onToggle = { stopWatchState ->
when (stopWatchState) {
onToggle = { state ->
when (state) {
Pause -> {
viewModel.start()
}
Expand Down Expand Up @@ -82,7 +83,7 @@ fun MainScreen(
) {
Scaffold(
topBar = {
TopAppBar(title = { Text("StopWatch") })
TopAppBar(title = { Text(stringResource(R.string.section3_stop_watch)) })
},
) { padding ->
Column(
Expand Down Expand Up @@ -130,7 +131,7 @@ fun MainScreen(
) {
Image(
painter = painterResource(id = R.drawable.baseline_refresh_24),
contentDescription = "stop watch refresh button icon",
contentDescription = stringResource(R.string.section3_refresh_button),
)
}

Expand All @@ -145,14 +146,14 @@ fun MainScreen(
Running -> R.drawable.baseline_pause_24
},
),
contentDescription = "stop watch toggle button icon",
contentDescription = stringResource(R.string.section3_toggle_button),
)
}

Button(
onClick = { onLapTime() },
) {
Text("LAP TIME")
Text(stringResource(R.string.section3_lap_time))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<resources>
<string name="app_name">section3</string>
<string name="section3_stop_watch">StopWatch</string>
<string name="section3_refresh_button">stop watch refresh button icon</string>
<string name="section3_toggle_button">stop watch toggle button icon</string>
<string name="section3_lap_time">LAP TIME</string>
</resources>

0 comments on commit 1679974

Please sign in to comment.