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

Fix/issue 38 password keyboard behaviour #43

Merged
merged 30 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
437e81e
extended ValidatedOutlinedTextField
Basler182 Jun 14, 2024
ca1ab36
updated RegisterScreen to ValidatedOutlinedTextField
Basler182 Jun 14, 2024
a7fa86e
added visibility icon on/off
Basler182 Jun 14, 2024
445f308
added LoginFormValidator
Basler182 Jun 14, 2024
0e0a64c
update password keyboard Behaviour in LoginScreen
Basler182 Jun 14, 2024
9b14a16
tested CredentialRegisterManagerAuth
Basler182 Jun 14, 2024
d11b89a
update RegisterFormValidatorTest
Basler182 Jun 14, 2024
93c97d9
tested LoginViewModel
Basler182 Jun 14, 2024
18e6dc8
switched to PattersCompat Email Matcher for easier testing
Basler182 Jun 14, 2024
decf4e3
tested LoginFormValidator
Basler182 Jun 14, 2024
c170066
Fix/issue 32 leading aligned icons register (#44)
Basler182 Jun 21, 2024
bab77f2
vertical aligned leading icon to top
Basler182 Jun 21, 2024
475d254
invoked painter resource on iconId
Basler182 Jun 21, 2024
9217d44
added local date format and also moved formatting into view model
Basler182 Jun 21, 2024
d0cee71
Merge branch 'main' into fix/issue-38-password-keyboard-behaviour
Basler182 Jun 21, 2024
40cf3f1
Merge branch 'main' into fix/issue-38-password-keyboard-behaviour
Basler182 Jun 21, 2024
f02427b
used typealias composable block
Basler182 Jun 22, 2024
c4f0444
improved FormValidator
Basler182 Jun 22, 2024
2383523
introduced namespace and extracted button enabled logic
Basler182 Jun 22, 2024
0d8a594
use run catching in password login
Basler182 Jun 22, 2024
bc02edf
extracted date time formatter
Basler182 Jun 22, 2024
2505669
extracted register button enabled logic from screen
Basler182 Jun 22, 2024
4bc3c48
extracted register button enabled logic from screen
Basler182 Jun 22, 2024
1c39df8
added missing spacing
Basler182 Jun 22, 2024
b1e0f2c
Removed enclosing update
Basler182 Jun 22, 2024
90c0a0d
updated tests
Basler182 Jun 22, 2024
4531c13
added password sign in enabled button
Basler182 Jun 22, 2024
f33201e
updated usage of .isValid
Basler182 Jun 22, 2024
175955c
changed property method order
Basler182 Jun 22, 2024
0af5247
refactored register button enabled form validation into view model
Basler182 Jun 22, 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
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<activity
android:name=".MainActivity"
android:exported="true"
android:windowSoftInputMode="adjustResize"
android:theme="@style/Theme.Spezi">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
9 changes: 7 additions & 2 deletions app/src/main/kotlin/edu/stanford/bdh/engagehf/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,17 @@
Routes.InvitationCodeScreen
)

is OnboardingNavigationEvent.OnboardingScreen -> navHostController.navigate(Routes.OnboardingScreen)
is OnboardingNavigationEvent.OnboardingScreen -> navHostController.navigate(
Routes.OnboardingScreen

Check warning on line 134 in app/src/main/kotlin/edu/stanford/bdh/engagehf/MainActivity.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/MainActivity.kt#L134

Added line #L134 was not covered by tests
)

is OnboardingNavigationEvent.SequentialOnboardingScreen -> navHostController.navigate(
Routes.SequentialOnboardingScreen
)

is OnboardingNavigationEvent.ConsentScreen -> navHostController.navigate(Routes.ConsentScreen)
is OnboardingNavigationEvent.ConsentScreen -> navHostController.navigate(
Routes.ConsentScreen

Check warning on line 142 in app/src/main/kotlin/edu/stanford/bdh/engagehf/MainActivity.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/MainActivity.kt#L142

Added line #L142 was not covered by tests
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import edu.stanford.spezi.core.design.theme.Colors
import edu.stanford.spezi.core.design.theme.TextStyles.labelSmall

@Composable
fun ValidatedOutlinedTextField(
Expand All @@ -22,6 +22,12 @@
onValueChange: (String) -> Unit,
labelText: String = "",
errorText: String? = null,
singleLine: Boolean = true,
keyboardOptions: KeyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next),
visualTransformation: VisualTransformation = VisualTransformation.None,
readOnly: Boolean = false,
trailingIcon: @Composable (() -> Unit)? = null,
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
keyboardActions: KeyboardActions = KeyboardActions.Default,
) {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
OutlinedTextField(
Expand All @@ -31,17 +37,23 @@
onValueChange(it)
},
label = { Text(labelText) },
singleLine = true,
keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next),
singleLine = singleLine,
keyboardOptions = keyboardOptions,

Check warning on line 41 in core/design/src/main/kotlin/edu/stanford/spezi/core/design/component/validated/outlinedtextfield/ValidatedOutlinedTextField.kt

View check run for this annotation

Codecov / codecov/patch

core/design/src/main/kotlin/edu/stanford/spezi/core/design/component/validated/outlinedtextfield/ValidatedOutlinedTextField.kt#L40-L41

Added lines #L40 - L41 were not covered by tests
isError = errorText != null,
readOnly = readOnly,
trailingIcon = trailingIcon,
keyboardActions = keyboardActions,
visualTransformation = visualTransformation,

Check warning on line 46 in core/design/src/main/kotlin/edu/stanford/spezi/core/design/component/validated/outlinedtextfield/ValidatedOutlinedTextField.kt

View check run for this annotation

Codecov / codecov/patch

core/design/src/main/kotlin/edu/stanford/spezi/core/design/component/validated/outlinedtextfield/ValidatedOutlinedTextField.kt#L43-L46

Added lines #L43 - L46 were not covered by tests
supportingText = if (errorText != null) {
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
{
Text(
text = errorText,

Check warning on line 50 in core/design/src/main/kotlin/edu/stanford/spezi/core/design/component/validated/outlinedtextfield/ValidatedOutlinedTextField.kt

View check run for this annotation

Codecov / codecov/patch

core/design/src/main/kotlin/edu/stanford/spezi/core/design/component/validated/outlinedtextfield/ValidatedOutlinedTextField.kt#L50

Added line #L50 was not covered by tests
)
}
} else {
null

Check warning on line 54 in core/design/src/main/kotlin/edu/stanford/spezi/core/design/component/validated/outlinedtextfield/ValidatedOutlinedTextField.kt

View check run for this annotation

Codecov / codecov/patch

core/design/src/main/kotlin/edu/stanford/spezi/core/design/component/validated/outlinedtextfield/ValidatedOutlinedTextField.kt#L54

Added line #L54 was not covered by tests
},
)
if (errorText != null) {
Text(
text = errorText,
style = labelSmall,
color = Colors.error
)
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions core/design/src/main/res/drawable/ic_visibility.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/black"
android:pathData="M480,640Q555,640 607.5,587.5Q660,535 660,460Q660,385 607.5,332.5Q555,280 480,280Q405,280 352.5,332.5Q300,385 300,460Q300,535 352.5,587.5Q405,640 480,640ZM480,568Q435,568 403.5,536.5Q372,505 372,460Q372,415 403.5,383.5Q435,352 480,352Q525,352 556.5,383.5Q588,415 588,460Q588,505 556.5,536.5Q525,568 480,568ZM480,760Q334,760 214,678.5Q94,597 40,460Q94,323 214,241.5Q334,160 480,160Q626,160 746,241.5Q866,323 920,460Q866,597 746,678.5Q626,760 480,760ZM480,460Q480,460 480,460Q480,460 480,460Q480,460 480,460Q480,460 480,460Q480,460 480,460Q480,460 480,460Q480,460 480,460Q480,460 480,460ZM480,680Q593,680 687.5,620.5Q782,561 832,460Q782,359 687.5,299.5Q593,240 480,240Q367,240 272.5,299.5Q178,359 128,460Q178,561 272.5,620.5Q367,680 480,680Z" />
</vector>
10 changes: 10 additions & 0 deletions core/design/src/main/res/drawable/ic_visibility_off.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/black"
android:pathData="M644,532L586,474Q595,427 559,386Q523,345 466,354L408,296Q425,288 442.5,284Q460,280 480,280Q555,280 607.5,332.5Q660,385 660,460Q660,480 656,497.5Q652,515 644,532ZM772,658L714,602Q752,573 781.5,538.5Q811,504 832,460Q782,359 688.5,299.5Q595,240 480,240Q451,240 423,244Q395,248 368,256L306,194Q347,177 390,168.5Q433,160 480,160Q631,160 749,243.5Q867,327 920,460Q897,519 859.5,569.5Q822,620 772,658ZM792,904L624,738Q589,749 553.5,754.5Q518,760 480,760Q329,760 211,676.5Q93,593 40,460Q61,407 93,361.5Q125,316 166,280L56,168L112,112L848,848L792,904ZM222,336Q193,362 169,393Q145,424 128,460Q178,561 271.5,620.5Q365,680 480,680Q500,680 519,677.5Q538,675 558,672L522,634Q511,637 501,638.5Q491,640 480,640Q405,640 352.5,587.5Q300,535 300,460Q300,449 301.5,439Q303,429 306,418L222,336ZM541,429L541,429Q541,429 541,429Q541,429 541,429Q541,429 541,429Q541,429 541,429Q541,429 541,429Q541,429 541,429ZM390,504Q390,504 390,504Q390,504 390,504L390,504Q390,504 390,504Q390,504 390,504Q390,504 390,504Q390,504 390,504Z" />
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package edu.stanford.spezi.module.account.login

import edu.stanford.spezi.module.account.register.FormValidator
import javax.inject.Inject

internal class LoginFormValidator @Inject internal constructor() : FormValidator() {

fun emailResult(email: String): Result = if (isValidEmail(email)) {
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
Result.Valid
} else {
Result.Invalid("Invalid email")
}

fun passwordResult(password: String): Result = if (isValidPassword(password)) {
Result.Valid
} else {
Result.Invalid("Password must be at least $MIN_PASSWORD_LENGTH characters")
}

fun isFormValid(uiState: UiState): Boolean {
return emailResult(uiState.email.value) is Result.Valid &&
passwordResult(uiState.password.value) is Result.Valid
}

fun isEmailValid(email: String): Boolean = emailResult(email) is Result.Valid
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,54 @@

package edu.stanford.spezi.module.account.login

import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
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.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Email
import androidx.compose.material.icons.outlined.Lock
import androidx.compose.material3.Button
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
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.painter.Painter
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import androidx.hilt.navigation.compose.hiltViewModel
import edu.stanford.spezi.core.design.component.validated.outlinedtextfield.ValidatedOutlinedTextField
import edu.stanford.spezi.core.design.theme.Spacings
import edu.stanford.spezi.core.design.theme.SpeziTheme
import edu.stanford.spezi.core.design.theme.TextStyles.bodyLarge
import edu.stanford.spezi.core.design.theme.TextStyles.titleLarge
import edu.stanford.spezi.core.utils.extensions.testIdentifier
import edu.stanford.spezi.module.account.login.components.SignInWithGoogleButton
import edu.stanford.spezi.module.account.login.components.TextDivider
import edu.stanford.spezi.module.account.register.FieldState
import edu.stanford.spezi.module.account.register.IconLeadingContent

@Composable
fun LoginScreen(
Expand All @@ -54,11 +69,23 @@
uiState: UiState,
onAction: (Action) -> Unit,
) {
val keyboardController = LocalSoftwareKeyboardController.current

Check warning on line 72 in modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt

View check run for this annotation

Codecov / codecov/patch

modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt#L72

Added line #L72 was not covered by tests

Column(
modifier = Modifier
.testIdentifier(LoginScreenTestIdentifier.ROOT)
.fillMaxSize()
.padding(Spacings.medium),
.imePadding()
.verticalScroll(rememberScrollState())
.padding(Spacings.medium)
.pointerInput(Unit) {
detectTapGestures(

Check warning on line 82 in modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt

View check run for this annotation

Codecov / codecov/patch

modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt#L78-L82

Added lines #L78 - L82 were not covered by tests
onTap = {
println("Hide Keyboard")

Check warning on line 84 in modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt

View check run for this annotation

Codecov / codecov/patch

modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt#L84

Added line #L84 was not covered by tests
keyboardController?.hide()
}
)
},

Check warning on line 88 in modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt

View check run for this annotation

Codecov / codecov/patch

modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt#L88

Added line #L88 was not covered by tests
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Expand All @@ -74,33 +101,57 @@
style = bodyLarge,
)
Spacer(modifier = Modifier.height(Spacings.large))
OutlinedTextField(
modifier = Modifier.fillMaxWidth(),
value = uiState.email,
onValueChange = { email ->
onAction(Action.TextFieldUpdate(email, TextFieldType.EMAIL))
},
label = { Text("E-Mail Address") },
singleLine = true,
keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next)
)
IconLeadingContent(
icon = Icons.Outlined.Email,
content = {

Check warning on line 106 in modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt

View check run for this annotation

Codecov / codecov/patch

modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt#L104-L106

Added lines #L104 - L106 were not covered by tests
ValidatedOutlinedTextField(
modifier = Modifier.fillMaxWidth(),
value = uiState.email.value,
errorText = uiState.email.error,
onValueChange = { email ->
onAction(Action.TextFieldUpdate(email, TextFieldType.EMAIL))
},
labelText = "E-Mail Address",
singleLine = true,
keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next)

Check warning on line 116 in modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt

View check run for this annotation

Codecov / codecov/patch

modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt#L108-L116

Added lines #L108 - L116 were not covered by tests
)
})

Check warning on line 118 in modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt

View check run for this annotation

Codecov / codecov/patch

modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt#L118

Added line #L118 was not covered by tests
Spacer(modifier = Modifier.height(Spacings.small))
OutlinedTextField(
modifier = Modifier.fillMaxWidth(),
value = uiState.password,
onValueChange = {
onAction(Action.TextFieldUpdate(it, TextFieldType.PASSWORD))
},
label = { Text("Password") },
singleLine = true,
visualTransformation = if (uiState.passwordVisibility) {
VisualTransformation.None
} else {
PasswordVisualTransformation()
},
keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = { onAction(Action.TogglePasswordVisibility) })
)
IconLeadingContent(
icon = Icons.Outlined.Lock,
content = {

Check warning on line 122 in modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt

View check run for this annotation

Codecov / codecov/patch

modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt#L121-L122

Added lines #L121 - L122 were not covered by tests
ValidatedOutlinedTextField(
modifier = Modifier.fillMaxWidth(),
value = uiState.password.value,
errorText = uiState.password.error,
onValueChange = {
onAction(Action.TextFieldUpdate(it, TextFieldType.PASSWORD))
},
labelText = "Password",

Check warning on line 130 in modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt

View check run for this annotation

Codecov / codecov/patch

modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt#L124-L130

Added lines #L124 - L130 were not covered by tests
visualTransformation = if (uiState.passwordVisibility) {
VisualTransformation.None

Check warning on line 132 in modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt

View check run for this annotation

Codecov / codecov/patch

modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt#L132

Added line #L132 was not covered by tests
} else {
PasswordVisualTransformation()

Check warning on line 134 in modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt

View check run for this annotation

Codecov / codecov/patch

modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt#L134

Added line #L134 was not covered by tests
},
keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = {
onAction(Action.PasswordSignInOrSignUp)
}),
trailingIcon = {

Check warning on line 140 in modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt

View check run for this annotation

Codecov / codecov/patch

modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt#L136-L140

Added lines #L136 - L140 were not covered by tests
IconButton(onClick = { onAction(Action.TogglePasswordVisibility) }) {
val icon: Painter = if (uiState.passwordVisibility) {
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
painterResource(id = edu.stanford.spezi.core.design.R.drawable.ic_visibility)
} else {
painterResource(id = edu.stanford.spezi.core.design.R.drawable.ic_visibility_off)

Check warning on line 145 in modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt

View check run for this annotation

Codecov / codecov/patch

modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt#L143-L145

Added lines #L143 - L145 were not covered by tests
}
Icon(
painter = icon,

Check warning on line 148 in modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt

View check run for this annotation

Codecov / codecov/patch

modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt#L147-L148

Added lines #L147 - L148 were not covered by tests
contentDescription = if (uiState.passwordVisibility) "Hide password" else "Show password"
)
}
}
)
})

Check warning on line 154 in modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt

View check run for this annotation

Codecov / codecov/patch

modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt#L154

Added line #L154 was not covered by tests
TextButton(
onClick = {
onAction(Action.ForgotPassword)
Expand All @@ -111,14 +162,10 @@
Spacer(modifier = Modifier.height(Spacings.medium))
Button(
onClick = {
if (uiState.isAlreadyRegistered) {
onAction(Action.PasswordCredentialSignIn)
} else {
onAction(Action.NavigateToRegister)
}
onAction(Action.PasswordSignInOrSignUp)

Check warning on line 165 in modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt

View check run for this annotation

Codecov / codecov/patch

modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt#L165

Added line #L165 was not covered by tests
},
modifier = Modifier.fillMaxWidth(),
enabled = uiState.email.isNotEmpty() && uiState.password.isNotEmpty()
enabled = uiState.email.value.isNotEmpty() && uiState.password.value.isNotEmpty()
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
) {
Text(
text = if (uiState.isAlreadyRegistered) "Login" else "Register"
Expand All @@ -145,11 +192,7 @@
Spacer(modifier = Modifier.height(Spacings.medium))
SignInWithGoogleButton(
onButtonClick = {
if (uiState.isAlreadyRegistered) {
onAction(Action.GoogleSignIn)
} else {
onAction(Action.GoogleSignUp)
}
onAction(Action.GoogleSignInOrSignUp)

Check warning on line 195 in modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt

View check run for this annotation

Codecov / codecov/patch

modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt#L195

Added line #L195 was not covered by tests
},
isAlreadyRegistered = uiState.isAlreadyRegistered,
)
Expand All @@ -169,12 +212,12 @@
private class LoginScreenPreviewProvider : PreviewParameterProvider<UiState> {
override val values: Sequence<UiState> = sequenceOf(
UiState(
email = "",
password = "",
email = FieldState(""),
password = FieldState(""),

Check warning on line 216 in modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt

View check run for this annotation

Codecov / codecov/patch

modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt#L215-L216

Added lines #L215 - L216 were not covered by tests
passwordVisibility = false,
), UiState(
email = "[email protected]",
password = "password",
email = FieldState("[email protected]"),
password = FieldState("password"),

Check warning on line 220 in modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt

View check run for this annotation

Codecov / codecov/patch

modules/account/src/main/kotlin/edu/stanford/spezi/module/account/login/LoginScreen.kt#L219-L220

Added lines #L219 - L220 were not covered by tests
passwordVisibility = true,
isAlreadyRegistered = true
)
Expand Down
Loading
Loading