-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #316 from PermanentOrg/feature/VSP-1473
Biometrics implementation for phone.
- Loading branch information
Showing
8 changed files
with
336 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
app/src/main/java/org/permanent/permanent/ui/login/compose/BiometricsPage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
@file:OptIn(ExperimentalFoundationApi::class) | ||
|
||
package org.permanent.permanent.ui.login.compose | ||
|
||
import androidx.compose.foundation.ExperimentalFoundationApi | ||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.rememberScrollState | ||
import androidx.compose.foundation.verticalScroll | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.collectAsState | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.font.Font | ||
import androidx.compose.ui.text.font.FontFamily | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import org.permanent.permanent.R | ||
import org.permanent.permanent.ui.composeComponents.ButtonColor | ||
import org.permanent.permanent.ui.composeComponents.CenteredTextAndIconButton | ||
import org.permanent.permanent.ui.composeComponents.CustomSnackbar | ||
import org.permanent.permanent.viewmodels.AuthenticationViewModel | ||
|
||
|
||
@Composable | ||
fun BiometricsPage( | ||
viewModel: AuthenticationViewModel | ||
) { | ||
val regularFont = FontFamily(Font(R.font.open_sans_regular_ttf)) | ||
|
||
val snackbarMessage by viewModel.snackbarMessage.collectAsState() | ||
val snackbarType by viewModel.snackbarType.collectAsState() | ||
|
||
val keyboardController = LocalSoftwareKeyboardController.current | ||
val scrollState = rememberScrollState() | ||
|
||
Box( | ||
modifier = Modifier.fillMaxSize() | ||
) { | ||
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.verticalScroll(scrollState), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Image( | ||
painter = painterResource(id = R.drawable.img_logo), | ||
contentDescription = "Logo", | ||
modifier = Modifier.size(64.dp) | ||
) | ||
|
||
Spacer(modifier = Modifier.height(32.dp)) | ||
|
||
Text( | ||
text = stringResource(id = R.string.welcome_back), | ||
fontSize = 32.sp, | ||
lineHeight = 48.sp, | ||
color = Color.White, | ||
fontFamily = regularFont | ||
) | ||
|
||
Spacer(modifier = Modifier.height(64.dp)) | ||
|
||
Column( | ||
modifier = Modifier.fillMaxWidth() | ||
) { | ||
CenteredTextAndIconButton( | ||
buttonColor = ButtonColor.LIGHT, | ||
text = stringResource(id = R.string.unlock_with_fingerprint), | ||
icon = painterResource(id = R.drawable.ic_fingerprint_primary), | ||
) { | ||
keyboardController?.hide() | ||
viewModel.clearSnackbar() | ||
viewModel.authenticateUser() | ||
} | ||
|
||
Spacer(modifier = Modifier.height(16.dp)) | ||
|
||
CenteredTextAndIconButton( | ||
buttonColor = ButtonColor.TRANSPARENT, | ||
text = stringResource(id = R.string.unlock_with_credentials), | ||
icon = null | ||
) { | ||
viewModel.deleteDeviceToken() | ||
} | ||
} | ||
} | ||
|
||
CustomSnackbar(modifier = Modifier.align(Alignment.BottomCenter), | ||
isForError = snackbarType == AuthenticationViewModel.SnackbarType.ERROR, | ||
message = snackbarMessage, | ||
buttonText = stringResource(id = R.string.ok), | ||
onButtonClick = { | ||
viewModel.clearSnackbar() | ||
}) | ||
} | ||
} |
Oops, something went wrong.