Skip to content

Commit

Permalink
TIQR-477: Verification failed screen
Browse files Browse the repository at this point in the history
  • Loading branch information
dzolnai committed Nov 6, 2024
1 parent bdd4d48 commit 97e9c71
Show file tree
Hide file tree
Showing 7 changed files with 266 additions and 21 deletions.
15 changes: 15 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
android:scheme="https" />
</intent-filter>

<!-- EPPN already linked -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />

Expand All @@ -238,6 +239,7 @@
android:scheme="https" />
</intent-filter>

<!-- Session expired -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />

Expand All @@ -262,6 +264,19 @@
android:scheme="eduid" />

</intent-filter>

<!-- External account linking error -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="*.eduid.nl"
android:path="/client/mobile/external-account-linked-error"
android:scheme="https" />
</intent-filter>
</activity>

<activity
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/kotlin/nl/eduid/di/model/EduIdModels.kt
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ enum class IdpScoping {
STUDIELINK;

/**
* @Json doesn't work, so we override toString instead
* @Json doesn't work on enum values for serialization, so we override toString instead
*/
override fun toString(): String {
return when (this) {
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/kotlin/nl/eduid/graphs/MainGraph.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import nl.eduid.screens.editemail.EditEmailScreen
import nl.eduid.screens.editemail.EditEmailViewModel
import nl.eduid.screens.editname.EditNameFormScreen
import nl.eduid.screens.editname.EditNameFormViewModel
import nl.eduid.screens.externalaccountlinkederror.ExternalAccountLinkedErrorScreen
import nl.eduid.screens.firsttimedialog.FirstTimeDialogRoute
import nl.eduid.screens.firsttimedialog.LinkAccountViewModel
import nl.eduid.screens.homepage.HomePageScreen
Expand Down Expand Up @@ -523,6 +524,21 @@ fun MainGraph(
goBack = { navController.popBackStack() }
)
}

composable(ExternalAccountLinkedError.route, deepLinks = listOf(navDeepLink {
uriPattern = ExternalAccountLinkedError.getUriPattern(baseUrl)
})) {
ExternalAccountLinkedErrorScreen(
goBack = {
// We don't have a back stack anymore since this screen is always opened from a deeplink,
// so we recreate the stack manually
navController.popBackStack()
navController.navigate(Graph.HOME_PAGE)
navController.navigate(Graph.PERSONAL_INFO)
navController.navigate(VerifyIdentityRoute.route)
}
)
}
//endregion
}

Expand Down
7 changes: 6 additions & 1 deletion app/src/main/kotlin/nl/eduid/graphs/Routes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,9 @@ object VerifyIdentityRoute {

object SelectYourBankRoute {
const val route = "select_your_bank"
}
}

object ExternalAccountLinkedError {
const val route = "external_account_linked_error"
fun getUriPattern(baseUrl: String) = "$baseUrl/client/mobile/external-account-linked-error"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package nl.eduid.screens.externalaccountlinkederror

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.systemBarsPadding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role.Companion.Image
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import nl.eduid.R
import nl.eduid.ui.EduIdTopAppBar
import nl.eduid.ui.PrimaryButton
import nl.eduid.ui.theme.EduidAppAndroidTheme

@Composable
fun ExternalAccountLinkedErrorScreen(
goBack: () -> Unit,
) = EduIdTopAppBar(onBackClicked = goBack) { padding ->
ExternalAccountLinkedErrorScreenContent(
padding = padding,
goBack = goBack
)
}

@Composable
fun ExternalAccountLinkedErrorScreenContent(
padding: PaddingValues = PaddingValues(),
goBack: () -> Unit
) = Column(
modifier = Modifier
.fillMaxSize()
.padding(padding)
.systemBarsPadding()
.padding(start = 24.dp, end = 24.dp, bottom = 24.dp)
.verticalScroll(rememberScrollState()),
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
text = stringResource(R.string.ExternalAccountLinkingError_Title_COPY),
style = MaterialTheme.typography.titleLarge.copy(
textAlign = TextAlign.Start, color = MaterialTheme.colorScheme.onSecondary
),
modifier = Modifier
.fillMaxWidth()
.padding(top = 16.dp)
)
Spacer(Modifier.height(88.dp))
Image(
painter = painterResource(id = R.drawable.ic_access_denied),
contentDescription = null,
modifier = Modifier
.align(Alignment.CenterHorizontally)
.width(185.dp)
)
Spacer(Modifier.height(44.dp))
Text(
text = stringResource(R.string.ExternalAccountLinkingError_Subtitle_COPY),
style = MaterialTheme.typography.bodyLarge,
modifier = Modifier.fillMaxWidth()
)
Spacer(Modifier.weight(1f))
PrimaryButton(
modifier = Modifier.fillMaxWidth(),
text = stringResource(R.string.ExternalAccountLinkingError_TryAnotherOption_COPY),
onClick = {
goBack()
}
)
Spacer(Modifier.height(16.dp))

}

@Composable
@Preview
fun ExternalAccountLinkedErrorScreenPreview() {
EduidAppAndroidTheme {
ExternalAccountLinkedErrorScreenContent(goBack = {})
}
}
19 changes: 0 additions & 19 deletions app/src/main/kotlin/nl/eduid/ui/SvgImage.kt
Original file line number Diff line number Diff line change
@@ -1,35 +1,16 @@
package nl.eduid.ui

import android.content.Context
import android.graphics.drawable.PictureDrawable
import androidx.compose.foundation.Image
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import coil.ImageLoader
import coil.compose.AsyncImage
import coil.compose.rememberAsyncImagePainter
import coil.decode.SvgDecoder
import coil.imageLoader
import coil.request.ImageRequest
import coil.request.SuccessResult
import coil.util.DebugLogger
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.nio.ByteBuffer


suspend fun svgStringToDrawable(context: Context, svgString: String, imageLoader: ImageLoader): PictureDrawable? {
return withContext(Dispatchers.IO) {
val request = ImageRequest.Builder(context)
.data(svgString.toByteArray())
.decoderFactory(SvgDecoder.Factory())
.build()
val result = (imageLoader.execute(request) as? SuccessResult)?.drawable
result as? PictureDrawable
}
}

@Composable
fun SvgImage(svgString: String, modifier: Modifier = Modifier) {
val model: ImageRequest = ImageRequest.Builder(context = LocalContext.current)
Expand Down
Loading

0 comments on commit 97e9c71

Please sign in to comment.