From 7684e2ec13eb435943032758702373ba2d1ab7f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=C2=A0Koby=C5=82ko?= Date: Mon, 7 Oct 2024 18:54:07 +0200 Subject: [PATCH] Fix about version --- .../feature/about/ui/about/AboutScreen.kt | 4 +--- .../feature/about/ui/about/AboutUiState.kt | 1 + .../feature/about/ui/about/AboutViewModel.kt | 15 +++++++++------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/feature/about/src/main/java/com/twofasapp/feature/about/ui/about/AboutScreen.kt b/feature/about/src/main/java/com/twofasapp/feature/about/ui/about/AboutScreen.kt index 835c4591..54922446 100644 --- a/feature/about/src/main/java/com/twofasapp/feature/about/ui/about/AboutScreen.kt +++ b/feature/about/src/main/java/com/twofasapp/feature/about/ui/about/AboutScreen.kt @@ -43,7 +43,6 @@ internal fun AboutScreen( ScreenContent( uiState = uiState, - versionName = viewModel.versionName, onLicensesClick = openLicenses, onReviewClick = { viewModel.reviewDone() }, onSendCrashLogsToggle = { viewModel.toggleSendCrashLogs() } @@ -53,7 +52,6 @@ internal fun AboutScreen( @Composable private fun ScreenContent( uiState: AboutUiState, - versionName: String, onLicensesClick: () -> Unit, onReviewClick: () -> Unit, onSendCrashLogsToggle: () -> Unit, @@ -207,7 +205,7 @@ private fun ScreenContent( .padding(start = 24.dp, end = 16.dp) ) { Text( - text = stringResource(id = R.string.settings__version, versionName), + text = stringResource(id = R.string.settings__version, uiState.versionName), color = TwTheme.color.onSurfaceSecondary, style = TwTheme.typo.body3 ) diff --git a/feature/about/src/main/java/com/twofasapp/feature/about/ui/about/AboutUiState.kt b/feature/about/src/main/java/com/twofasapp/feature/about/ui/about/AboutUiState.kt index 2ef49f51..048473da 100644 --- a/feature/about/src/main/java/com/twofasapp/feature/about/ui/about/AboutUiState.kt +++ b/feature/about/src/main/java/com/twofasapp/feature/about/ui/about/AboutUiState.kt @@ -4,4 +4,5 @@ import com.twofasapp.data.session.domain.AppSettings data class AboutUiState( val appSettings: AppSettings = AppSettings(), + val versionName: String = "" ) diff --git a/feature/about/src/main/java/com/twofasapp/feature/about/ui/about/AboutViewModel.kt b/feature/about/src/main/java/com/twofasapp/feature/about/ui/about/AboutViewModel.kt index 41bc69f7..539e8983 100644 --- a/feature/about/src/main/java/com/twofasapp/feature/about/ui/about/AboutViewModel.kt +++ b/feature/about/src/main/java/com/twofasapp/feature/about/ui/about/AboutViewModel.kt @@ -29,14 +29,17 @@ internal class AboutViewModel( uiState.update { it.copy(appSettings = appSettings) } } } - } - val versionName = - if (appBuild.buildVariant != BuildVariant.Release) { - "${appBuild.versionName} (${appBuild.buildVariant.name.camelCaseBeginLower()})" - } else { - appBuild.versionName + uiState.update { + it.copy( + versionName = if (appBuild.buildVariant != BuildVariant.Release) { + "${appBuild.versionName} (${appBuild.buildVariant.name.camelCaseBeginLower()})" + } else { + appBuild.versionName + } + ) } + } fun reviewDone() { viewModelScope.launch(dispatchers.io) {