refactor: extract PlayerTopBar into a standalone composable

This commit is contained in:
2026-07-08 15:15:27 +02:00
parent 33c464f1ed
commit 7d8ba628e0
@@ -104,53 +104,10 @@ fun PlayerScreen(
Scaffold( Scaffold(
topBar = { topBar = {
TopAppBar( PlayerTopBar(
modifier = Modifier.shadow(elevation = 2.dp), uiState = uiState,
title = { onBackClicked = onBackClicked,
Row( showPreferences = { showPreferences = true },
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
Text(
text = uiState.recordEmoji,
style = MaterialTheme.typography.headlineSmall,
)
Column {
Text(
text = uiState.recordTitle.transcription,
style = MaterialTheme.typography.headlineSmall,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
uiState.recordTitle.translation?.let { translation ->
Text(
text = translation,
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
}
}
},
navigationIcon = {
IconButton(onClick = onBackClicked) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(Res.string.player_back),
)
}
},
actions = {
IconButton(onClick = { showPreferences = true }) {
Icon(
imageVector = Icons.Filled.Subtitles,
contentDescription = stringResource(Res.string.subtitle_preferences_action),
)
}
},
) )
}, },
) { innerPadding -> ) { innerPadding ->
@@ -212,6 +169,62 @@ fun PlayerScreen(
} }
} }
@Composable
private fun PlayerTopBar(
uiState: PlayerUiState,
onBackClicked: () -> Unit,
showPreferences: () -> Unit,
) {
TopAppBar(
modifier = Modifier.shadow(elevation = 2.dp),
title = {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
Text(
text = uiState.recordEmoji,
style = MaterialTheme.typography.headlineSmall,
)
Column {
Text(
text = uiState.recordTitle.transcription,
style = MaterialTheme.typography.headlineSmall,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
uiState.recordTitle.translation?.let { translation ->
Text(
text = translation,
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
}
}
},
navigationIcon = {
IconButton(onClick = onBackClicked) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(Res.string.player_back),
)
}
},
actions = {
IconButton(onClick = showPreferences) {
Icon(
imageVector = Icons.Filled.Subtitles,
contentDescription = stringResource(Res.string.subtitle_preferences_action),
)
}
},
)
}
private val previewSubtitleLines = private val previewSubtitleLines =
listOf( listOf(
SubtitleLine( SubtitleLine(