Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Mail validation screen #254

Draft
wants to merge 42 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
980ed6a
feat: First try at OtpTextField
LunarX Dec 5, 2024
e5c16b6
feat: Basic structure of the user email validation screen
LunarX Dec 6, 2024
568f676
feat: Import strings
LunarX Dec 6, 2024
ebf0b13
feat: Control spacing between each character
LunarX Dec 10, 2024
b6c3053
refactor: Make it so otp text field always has a "focused" visual cue…
LunarX Dec 10, 2024
c2f0e7a
feat: Add isEnabled to OtpTextField
LunarX Dec 10, 2024
db1c674
feat: Make otp load when a code is entered
LunarX Dec 10, 2024
2225e9c
fix: Correctly filter out forbidden characters
LunarX Dec 10, 2024
95fa100
fix: System contextual menu not displaying at the correct coordinates
LunarX Dec 10, 2024
b2b0b5c
feat: Adapt layout for large screens
LunarX Dec 10, 2024
cbd70db
feat: Make email validation screen scrollable
LunarX Dec 11, 2024
d349dd4
refactor: Regroup layout style choice with its enum
LunarX Dec 11, 2024
682200b
refactor: Extract OtpTextField to its own file
LunarX Dec 11, 2024
04a427f
refactor: Clean the OtpTextField file and add missing doc/preview
LunarX Dec 11, 2024
15b7fa5
feat: Add actions when the topappbar buttons are clicked
LunarX Dec 11, 2024
033861c
refactor: Reorder enum at the end of the file
LunarX Dec 11, 2024
afcce96
refactor: Remove hardcoded values
LunarX Dec 11, 2024
8f531ab
refactor: Move validate user email files to their own package
LunarX Dec 11, 2024
2670b36
feat: Validate email otp code using the correct api route
LunarX Dec 11, 2024
9513e6b
Merge remote-tracking branch 'origin/main' into t3
LunarX Dec 12, 2024
76051d8
fix: Adapt to the new button argument signature
LunarX Dec 12, 2024
8cf9cfa
feat: Add resend email code button timer
LunarX Dec 12, 2024
09b8865
feat: Disable buttons while the code is being verified
LunarX Dec 12, 2024
642f23d
feat: Remove "select all" from the current text toolbar
LunarX Dec 16, 2024
d1ae597
feat: Show snackbar when unknown validation api error occurs
LunarX Dec 16, 2024
0bcbc2d
refactor: Keep logic contained inside the inner ValidateUserEmailScreen
LunarX Dec 16, 2024
b9cff14
Merge remote-tracking branch 'origin/main' into t2
LunarX Dec 16, 2024
838ec11
feat: Take user email as nav arg
LunarX Dec 16, 2024
c6954b0
refactor: Use a data class to pass named parameters to method's lambd…
LunarX Dec 16, 2024
d153401
feat: Extract CodeVerification to its own file
LunarX Dec 16, 2024
c09d04c
refactor: Extract ResendCodeCountDownButton to its own file
LunarX Dec 16, 2024
3c90939
Merge remote-tracking branch 'origin/main' into mail-validation-ui
LunarX Dec 16, 2024
e731a5a
feat: Automatically open email validation screen when catching the as…
LunarX Dec 16, 2024
c627352
feat: Open mail apps when clicking on the associated button
LunarX Dec 17, 2024
0a5806a
refactor: Use a UiState to define the ValidateUserEmailScreen state
LunarX Dec 17, 2024
69f9fdd
refactor: Shorten long lines
LunarX Dec 17, 2024
07fef3a
Merge remote-tracking branch 'origin/main' into mail-validation-ui
LunarX Dec 17, 2024
ec33f4e
feat: Add resend email code api call to the button
LunarX Dec 17, 2024
4a13692
Merge remote-tracking branch 'origin/main' into mail-validation-ui
LunarX Dec 18, 2024
e776e53
feat: Update verifyEmailCode call to new kmp version
LunarX Dec 18, 2024
3084096
Merge remote-tracking branch 'origin/main' into mail-validation-ui
LunarX Dec 18, 2024
40e505e
wip
LunarX Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: Correctly filter out forbidden characters
LunarX committed Dec 12, 2024

Verified

This commit was signed with the committer’s verified signature.
LunarX Gibran Chevalley
commit 2225e9cce8a49f0ee08cc2d094f5abd2eb2c46d9
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@
*/
package com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles

import android.util.Log
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.*
@@ -113,13 +112,12 @@ private fun CodeVerification() {
OtpTextField(
modifier = Modifier.fillMaxWidth(),
otpText = otp,
otpCount = OPT_LENGTH,
otpLength = OPT_LENGTH,
horizontalArrangement = Arrangement.SpaceBetween,
onOtpTextChange = { text, _ ->
Log.e("gibran", "ValidateUserEmailScreen - text: ${text}")
otp = text.filter { it in VALID_CHARACTERS }
onOtpTextChange = { text, isFilled ->
otp = text

if (otp.length == OPT_LENGTH) {
if (isFilled) {
scope.launch {
isLoading = true
delay(2000)
@@ -131,6 +129,7 @@ private fun CodeVerification() {
isError = false
}
},
isCharacterValid = { it in VALID_CHARACTERS },
isError = { isError },
otpTextFieldStyle = OtpTextFieldStyle.default(
textStyle = SwissTransferTheme.typography.bodyMedium.copy(color = SwissTransferTheme.colors.secondaryTextColor),
@@ -192,7 +191,7 @@ data class OtpTextFieldStyle(
fun OtpTextField(
modifier: Modifier = Modifier,
otpText: String,
otpCount: Int,
otpLength: Int,
horizontalArrangement: Arrangement.Horizontal,
onOtpTextChange: (String, Boolean) -> Unit,
isCharacterValid: ((Char) -> Boolean)? = null,
@@ -201,8 +200,8 @@ fun OtpTextField(
isEnabled: () -> Boolean = { true },
) {
LaunchedEffect(Unit) {
if (otpText.length > otpCount) {
error("Otp text value must not have more than otpCount: $otpCount characters")
if (otpText.length > otpLength) {
error("Otp text value must not have more than otpCount: $otpLength characters")
}
}

@@ -213,11 +212,15 @@ fun OtpTextField(
modifier = modifier.onFocusChanged { isTextFieldFocused = it.isFocused },
value = TextFieldValue(otpText, selection = TextRange(otpText.length)),
onValueChange = { textFieldValue ->
Log.v("gibran", "OtpTextField - textFieldValue.text: ${textFieldValue.text}")
val text = isCharacterValid?.let { textFieldValue.text.filter { char -> it(char) } } ?: textFieldValue.text

if (text.length <= otpCount) {
onOtpTextChange.invoke(text, text.length == otpCount)
if (text.length <= otpLength) {
onOtpTextChange.invoke(text, text.length == otpLength)
} else {
val truncatedText = text.take(otpLength)
if (truncatedText != otpText) {
onOtpTextChange.invoke(truncatedText, true)
}
}
},
keyboardOptions = KeyboardOptions(
@@ -226,11 +229,11 @@ fun OtpTextField(
),
decorationBox = {
Row(horizontalArrangement = horizontalArrangement) {
repeat(otpCount) { index ->
repeat(otpLength) { index ->
CharView(
index = index,
text = otpText,
otpCount = otpCount,
otpCount = otpLength,
isTextFieldFocused = { isTextFieldFocused },
isError = isError,
otpTextFieldStyle = otpTextFieldStyle,