Skip to content

Commit

Permalink
Merge pull request #12 from niscy-eudiw/main
Browse files Browse the repository at this point in the history
Show application version in dashboard options menu
  • Loading branch information
stzouvaras authored Feb 6, 2024
2 parents d36b99e + bc9d73e commit b2d364e
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 4 deletions.
5 changes: 5 additions & 0 deletions business-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import eu.europa.ec.euidi.addConfigField
import eu.europa.ec.euidi.getProperty

plugins {
id("eudi.android.library")
Expand All @@ -26,6 +27,10 @@ android {

defaultConfig {
addConfigField("DEEPLINK", "eudi-wallet://")
addConfigField(
"APP_VERSION",
getProperty("VERSION_NAME", "version.properties") ?: ""
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ interface ConfigLogic {
* Server Environment Configuration.
*/
val environmentConfig: EnvironmentConfig

/**
* Application version.
*/
val appVersion: String get() = BuildConfig.APP_VERSION
}

enum class AppBuildType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package eu.europa.ec.dashboardfeature.di

import eu.europa.ec.businesslogic.config.ConfigLogic
import eu.europa.ec.businesslogic.config.WalletCoreConfig
import eu.europa.ec.businesslogic.controller.walletcore.WalletCoreDocumentsController
import eu.europa.ec.dashboardfeature.interactor.DashboardInteractor
Expand All @@ -33,6 +34,12 @@ class FeatureDashboardModule
fun provideDashboardInteractor(
resourceProvider: ResourceProvider,
walletCoreDocumentsController: WalletCoreDocumentsController,
walletCoreConfig: WalletCoreConfig
walletCoreConfig: WalletCoreConfig,
configLogic: ConfigLogic
): DashboardInteractor =
DashboardInteractorImpl(resourceProvider, walletCoreDocumentsController, walletCoreConfig)
DashboardInteractorImpl(
resourceProvider,
walletCoreDocumentsController,
walletCoreConfig,
configLogic
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package eu.europa.ec.dashboardfeature.interactor

import android.bluetooth.BluetoothManager
import android.content.Context
import eu.europa.ec.businesslogic.config.ConfigLogic
import eu.europa.ec.businesslogic.config.WalletCoreConfig
import eu.europa.ec.businesslogic.controller.walletcore.WalletCoreDocumentsController
import eu.europa.ec.businesslogic.extension.safeAsync
Expand Down Expand Up @@ -46,12 +47,14 @@ interface DashboardInteractor {
fun getDocuments(): Flow<DashboardInteractorPartialState>
fun isBleAvailable(): Boolean
fun isBleCentralClientModeEnabled(): Boolean
fun getAppVersion(): String
}

class DashboardInteractorImpl(
private val resourceProvider: ResourceProvider,
private val walletCoreDocumentsController: WalletCoreDocumentsController,
private val walletCoreConfig: WalletCoreConfig
private val walletCoreConfig: WalletCoreConfig,
private val configLogic: ConfigLogic
) : DashboardInteractor {

private val genericErrorMsg
Expand Down Expand Up @@ -117,4 +120,6 @@ class DashboardInteractorImpl(
error = it.localizedMessage ?: genericErrorMsg
)
}

override fun getAppVersion(): String = configLogic.appVersion
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import androidx.lifecycle.Lifecycle
Expand Down Expand Up @@ -153,6 +154,7 @@ fun DashboardScreen(
) {
DashboardSheetContent(
sheetContent = state.sheetContent,
state = state,
onEventSent = {
viewModel.setEvent(it)
}
Expand Down Expand Up @@ -266,6 +268,7 @@ private fun Content(
@Composable
private fun DashboardSheetContent(
sheetContent: DashboardBottomSheetContent,
state: State,
onEventSent: (event: Event) -> Unit
) {
when (sheetContent) {
Expand Down Expand Up @@ -343,6 +346,16 @@ private fun DashboardSheetContent(
color = MaterialTheme.colorScheme.textPrimaryDark
)
}

VSpacer.Medium()

Text(
modifier = Modifier.fillMaxWidth(),
text = state.appVersion,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.textSecondaryDark,
textAlign = TextAlign.Center
)
}
)
}
Expand Down Expand Up @@ -677,6 +690,7 @@ private fun SheetContentPreview() {
PreviewTheme {
DashboardSheetContent(
sheetContent = DashboardBottomSheetContent.OPTIONS,
state = State(),
onEventSent = {}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ data class State(
val documents: List<DocumentUi> = emptyList(),

val deepLinkUri: Uri? = null,
val appVersion: String = ""
) : ViewState

sealed class Event : ViewEvent {
Expand Down Expand Up @@ -123,7 +124,8 @@ class DashboardViewModel(
) : MviViewModel<Event, State, Effect>() {

override fun setInitialState(): State = State(
isBleCentralClientModeEnabled = dashboardInteractor.isBleCentralClientModeEnabled()
isBleCentralClientModeEnabled = dashboardInteractor.isBleCentralClientModeEnabled(),
appVersion = dashboardInteractor.getAppVersion()
)

override fun handleEvents(event: Event) {
Expand Down

0 comments on commit b2d364e

Please sign in to comment.