Skip to content

Commit

Permalink
feat(about-ui): indicate pre-release status
Browse files Browse the repository at this point in the history
  • Loading branch information
rhenwinch committed Jun 13, 2024
1 parent 7199fc9 commit 5caad98
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/util/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
<string name="play">Play</string>
<string name="playback_speed">Playback speed</string>
<string name="popular">Popular</string>
<string name="pre_release">PRE-RELEASE</string>
<string name="preferred_quality">Preferred quality</string>
<string name="preferred_resize_mode">Preferred resize mode</string>
<string name="privacy_notice">Privacy notice</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.flixclusive.core.ui.common.CommonTopBar
import com.flixclusive.core.ui.common.navigation.GoBackAction
import com.flixclusive.feature.mobile.about.component.BodyContent
Expand All @@ -21,6 +23,7 @@ fun AboutScreen(
navigator: GoBackAction,
) {
val viewModel = hiltViewModel<AboutScreenViewModel>()
val isOnPreRelease by viewModel.isOnPreRelease.collectAsStateWithLifecycle()

Column(
horizontalAlignment = Alignment.CenterHorizontally,
Expand All @@ -36,7 +39,9 @@ fun AboutScreen(
Header(
appName = applicationName,
versionName = versionName,
isInDebugMode = debug
commitVersion = commitVersion,
isInDebugMode = debug,
isOnPreRelease = isOnPreRelease
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
package com.flixclusive.feature.mobile.about

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.flixclusive.core.datastore.AppSettingsManager
import com.flixclusive.data.configuration.AppConfigurationManager
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import javax.inject.Inject

@HiltViewModel
class AboutScreenViewModel @Inject constructor(
appConfigurationManager: AppConfigurationManager
appConfigurationManager: AppConfigurationManager,
appSettingsManager: AppSettingsManager
) : ViewModel() {
val currentAppBuild = appConfigurationManager.currentAppBuild
val isOnPreRelease = appSettingsManager.appSettings
.data.map { it.isUsingPrereleaseUpdates }
.stateIn(
scope = viewModelScope,
started = SharingStarted.WhileSubscribed(5000),
initialValue = false
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ import com.flixclusive.core.util.R as UtilR
internal fun Header(
appName: String,
versionName: String,
commitVersion: String,
isInDebugMode: Boolean,
isOnPreRelease: Boolean,
) {
val appNameUppercase = remember { appName.uppercase() }
val version = versionName + (if (isOnPreRelease) "-[$commitVersion]" else "")
val mode = when {
isInDebugMode -> stringResource(id = UtilR.string.debug)
isOnPreRelease -> stringResource(id = UtilR.string.pre_release)
else -> stringResource(id = UtilR.string.release)
}

Column(
verticalArrangement = Arrangement.spacedBy(
Expand Down Expand Up @@ -75,7 +83,7 @@ internal fun Header(
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = versionName,
text = version,
style = MaterialTheme.typography.headlineSmall.copy(
fontSize = 13.sp
),
Expand All @@ -92,7 +100,7 @@ internal fun Header(
)

Text(
text = if (isInDebugMode) stringResource(id = UtilR.string.debug) else stringResource(id = UtilR.string.release),
text = mode,
style = MaterialTheme.typography.headlineSmall.copy(
fontSize = 13.sp
),
Expand Down

0 comments on commit 5caad98

Please sign in to comment.