Skip to content

Commit

Permalink
Merge pull request #157 from niscy-eudiw/main
Browse files Browse the repository at this point in the history
Deferred issuing implementation
  • Loading branch information
stzouvaras authored Jul 25, 2024
2 parents 97f4a09 + 201b035 commit 653c757
Show file tree
Hide file tree
Showing 47 changed files with 1,766 additions and 350 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@
package eu.europa.ec.commonfeature.config

import androidx.annotation.DrawableRes
import androidx.compose.ui.graphics.Color
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import eu.europa.ec.resourceslogic.theme.values.ThemeColors
import eu.europa.ec.uilogic.config.ConfigNavigation
import eu.europa.ec.uilogic.config.NavigationType
import eu.europa.ec.uilogic.serializer.UiSerializable
import eu.europa.ec.uilogic.serializer.UiSerializableParser
import eu.europa.ec.uilogic.serializer.adapter.SerializableTypeAdapter

data class SuccessUIConfig(
val header: String?,
val headerConfig: HeaderConfig?,
val content: String,
val imageConfig: ImageConfig,
val buttonConfig: List<ButtonConfig>,
Expand All @@ -36,6 +38,7 @@ data class SuccessUIConfig(
data class ImageConfig(
val type: Type,
@DrawableRes val drawableRes: Int? = null,
val tint: Color = ThemeColors.success,
val contentDescription: String? = null
) {
enum class Type {
Expand All @@ -53,6 +56,11 @@ data class SuccessUIConfig(
}
}

data class HeaderConfig(
val title: String,
val color: Color = ThemeColors.success
)

companion object Parser : UiSerializableParser {
override val serializedKeyName = "successConfig"
override fun provideParser(): Gson {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,25 @@ import eu.europa.ec.corelogic.model.DocumentIdentifier
import eu.europa.ec.corelogic.model.isSupported
import eu.europa.ec.corelogic.model.toDocumentIdentifier
import eu.europa.ec.eudi.iso18013.transfer.RequestDocument
import eu.europa.ec.eudi.wallet.document.IssuedDocument
import eu.europa.ec.eudi.wallet.document.Document
import eu.europa.ec.eudi.wallet.document.DocumentId
import eu.europa.ec.resourceslogic.R
import eu.europa.ec.resourceslogic.provider.ResourceProvider

enum class DocumentUiIssuanceState {
Issued, Pending, Failed
}

data class DocumentUi(
val documentId: String,
val documentIssuanceState: DocumentUiIssuanceState,
val documentName: String,
val documentIdentifier: DocumentIdentifier,
val documentExpirationDateFormatted: String,
val documentHasExpired: Boolean,
val documentImage: String,
val documentDetails: List<DocumentDetailsUi>,
val userFullName: String? = null,
val documentId: DocumentId,
)

fun DocumentIdentifier.toUiName(resourceProvider: ResourceProvider): String {
Expand All @@ -46,7 +52,7 @@ fun DocumentIdentifier.toUiName(resourceProvider: ResourceProvider): String {
}
}

fun IssuedDocument.toUiName(resourceProvider: ResourceProvider): String {
fun Document.toUiName(resourceProvider: ResourceProvider): String {
val docIdentifier = this.toDocumentIdentifier()
return docIdentifier.toUiName(
fallbackDocName = this.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package eu.europa.ec.commonfeature.ui.document_details.transformer
import eu.europa.ec.businesslogic.util.toDateFormatted
import eu.europa.ec.businesslogic.util.toList
import eu.europa.ec.commonfeature.model.DocumentUi
import eu.europa.ec.commonfeature.model.DocumentUiIssuanceState
import eu.europa.ec.commonfeature.model.toUiName
import eu.europa.ec.commonfeature.ui.document_details.model.DocumentDetailsUi
import eu.europa.ec.commonfeature.ui.document_details.model.DocumentJsonKeys
Expand Down Expand Up @@ -92,7 +93,8 @@ object DocumentDetailsTransformer {
documentHasExpired = docHasExpired,
documentImage = documentImage,
documentDetails = detailsItems,
userFullName = extractFullNameFromDocumentOrEmpty(document)
userFullName = extractFullNameFromDocumentOrEmpty(document),
documentIssuanceState = DocumentUiIssuanceState.Issued,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,9 @@ class PinViewModel(
mapOf(
SuccessUIConfig.serializedKeyName to uiSerializer.toBase64(
SuccessUIConfig(
header = resourceProvider.getString(R.string.quick_pin_success_title),
headerConfig = SuccessUIConfig.HeaderConfig(
title = resourceProvider.getString(R.string.quick_pin_success_title),
),
content = when (pinFlow) {
PinFlow.CREATE -> resourceProvider.getString(R.string.quick_pin_create_success_subtitle)
PinFlow.UPDATE -> resourceProvider.getString(R.string.quick_pin_change_success_subtitle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
Expand All @@ -41,7 +42,9 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import eu.europa.ec.commonfeature.config.SuccessUIConfig
import eu.europa.ec.resourceslogic.theme.values.ThemeColors
import eu.europa.ec.resourceslogic.theme.values.success
import eu.europa.ec.uilogic.component.AppIcons
import eu.europa.ec.uilogic.component.content.ContentScreen
import eu.europa.ec.uilogic.component.content.ContentTitle
import eu.europa.ec.uilogic.component.content.ScreenNavigateAction
Expand Down Expand Up @@ -127,9 +130,9 @@ private fun SuccessScreenView(
) {
Column(modifier = Modifier.fillMaxWidth()) {
ContentTitle(
title = state.successConfig.header,
title = state.successConfig.headerConfig?.title,
titleStyle = MaterialTheme.typography.headlineSmall.copy(
color = MaterialTheme.colorScheme.success
color = state.successConfig.headerConfig?.color ?: Color.Unspecified
),
subtitle = state.successConfig.content,
)
Expand All @@ -156,8 +159,11 @@ private fun SuccessScreenView(
// Image
imageConfig.type == SuccessUIConfig.ImageConfig.Type.DRAWABLE && imageConfig.drawableRes != null -> {
Image(
modifier = Modifier.fillMaxWidth(0.25f),
painter = painterResource(id = imageConfig.drawableRes),
contentDescription = imageConfig.contentDescription
contentDescription = imageConfig.contentDescription,
colorFilter = ColorFilter.tint(imageConfig.tint),
contentScale = ContentScale.FillWidth
)
}
}
Expand Down Expand Up @@ -225,13 +231,15 @@ private fun ButtonRow(text: String) {

@ThemeModePreviews
@Composable
private fun SuccessPreview() {
private fun SuccessDefaultPreview() {
PreviewTheme {
SuccessScreenView(
state = State(
successConfig = SuccessUIConfig(
header = "Success",
content = "",
headerConfig = SuccessUIConfig.HeaderConfig(
title = "Success",
),
content = "Subtitle",
imageConfig = SuccessUIConfig.ImageConfig(
type = SuccessUIConfig.ImageConfig.Type.DEFAULT
),
Expand All @@ -255,4 +263,44 @@ private fun SuccessPreview() {
paddingValues = PaddingValues(16.dp)
)
}
}

@ThemeModePreviews
@Composable
private fun SuccessDrawablePreview() {
PreviewTheme {
SuccessScreenView(
state = State(
successConfig = SuccessUIConfig(
headerConfig = SuccessUIConfig.HeaderConfig(
title = "In Progress",
color = ThemeColors.warning
),
content = "Subtitle",
imageConfig = SuccessUIConfig.ImageConfig(
type = SuccessUIConfig.ImageConfig.Type.DRAWABLE,
drawableRes = AppIcons.ClockTimer.resourceId,
tint = ThemeColors.warning,
contentDescription = "contentDescription"
),
buttonConfig = listOf(
SuccessUIConfig.ButtonConfig(
text = "back",
style = SuccessUIConfig.ButtonConfig.Style.PRIMARY,
navigation = ConfigNavigation(
navigationType = NavigationType.PopTo(StartupScreens.Splash),
)
)
),
onBackScreenToNavigate = ConfigNavigation(
navigationType = NavigationType.PopTo(StartupScreens.Splash),
),
)
),
effectFlow = Channel<Effect>().receiveAsFlow(),
onEventSent = {},
onNavigationRequested = {},
paddingValues = PaddingValues(16.dp)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package eu.europa.ec.commonfeature.util
import androidx.annotation.VisibleForTesting
import eu.europa.ec.commonfeature.model.DocumentOptionItemUi
import eu.europa.ec.commonfeature.model.DocumentUi
import eu.europa.ec.commonfeature.model.DocumentUiIssuanceState
import eu.europa.ec.commonfeature.ui.document_details.model.DocumentDetailsUi
import eu.europa.ec.commonfeature.ui.request.Event
import eu.europa.ec.commonfeature.ui.request.model.DocumentItemDomainPayload
Expand Down Expand Up @@ -222,6 +223,7 @@ object TestsData {
documentHasExpired = mockedDocumentHasExpired,
documentImage = "",
documentDetails = emptyList(),
documentIssuanceState = DocumentUiIssuanceState.Issued,
)

val mockedBasicPidUi = mockedFullPidUi.copy(
Expand Down Expand Up @@ -294,6 +296,7 @@ object TestsData {
documentHasExpired = mockedDocumentHasExpired,
documentImage = "",
documentDetails = emptyList(),
documentIssuanceState = DocumentUiIssuanceState.Issued,
)

val mockedBasicMdlUi = mockedFullMdlUi.copy(
Expand Down
Loading

0 comments on commit 653c757

Please sign in to comment.