Skip to content

Commit

Permalink
Merge pull request #302 from PermanentOrg/feature/VSP-1443
Browse files Browse the repository at this point in the history
Sign in implementation
  • Loading branch information
flaviahandrea-vsp authored Sep 27, 2024
2 parents 86ef4da + fe09206 commit 5d840fa
Show file tree
Hide file tree
Showing 38 changed files with 939 additions and 607 deletions.
8 changes: 4 additions & 4 deletions app/src/main/java/org/permanent/permanent/Validator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ class Validator {
}
}

fun isValidPassword(password: String?, passwordError: MutableLiveData<Int>): Boolean {
fun isValidPassword(password: String?, passwordError: MutableLiveData<Int>?): Boolean {
return when {
password.isNullOrEmpty() -> {
passwordError.value = R.string.password_empty_error
passwordError?.value = R.string.password_empty_error
false
}
password.length < MIN_PASSWORD_LENGTH -> {
passwordError.value = R.string.password_too_short_error
passwordError?.value = R.string.password_too_short_error
false
}
else -> {
passwordError.value = null
passwordError?.value = null
true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import kotlinx.coroutines.launch
import org.permanent.permanent.R
import org.permanent.permanent.ui.composeComponents.ButtonColor
import org.permanent.permanent.ui.composeComponents.ButtonIconAlignment
import org.permanent.permanent.ui.composeComponents.SmallTextAndIconButton
import org.permanent.permanent.ui.composeComponents.CenteredTextAndIconButton


@Composable
Expand Down Expand Up @@ -200,7 +200,7 @@ private fun TabletBody(
Box(
modifier = Modifier.weight(1f)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.TRANSPARENT,
text = stringResource(id = R.string.back),
icon = painterResource(id = R.drawable.ic_arrow_back_rounded_white),
Expand All @@ -215,7 +215,7 @@ private fun TabletBody(
Box(
modifier = Modifier.weight(1f)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.LIGHT,
text = stringResource(id = R.string.next),
showButtonEnabled = textFieldValueState.text.isNotEmpty()
Expand Down Expand Up @@ -353,7 +353,7 @@ private fun PhoneBody(
.fillMaxWidth()
.weight(1f)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.TRANSPARENT,
text = stringResource(id = R.string.back),
icon = painterResource(id = R.drawable.ic_arrow_back_rounded_white),
Expand All @@ -370,7 +370,7 @@ private fun PhoneBody(
.fillMaxWidth()
.weight(1f)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.LIGHT,
text = stringResource(id = R.string.next),
showButtonEnabled = textFieldValueState.text.isNotEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,9 @@

package org.permanent.permanent.ui.archiveOnboarding.compose

import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -37,12 +30,10 @@ import androidx.compose.runtime.saveable.listSaver
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.runtime.toMutableStateList
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
Expand All @@ -53,7 +44,8 @@ import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.launch
import org.permanent.permanent.R
import org.permanent.permanent.models.ArchiveType
import org.permanent.permanent.ui.composeComponents.CustomProgressIndicator
import org.permanent.permanent.ui.composeComponents.CircularProgressIndicator
import org.permanent.permanent.ui.composeComponents.CustomLinearProgressIndicator
import org.permanent.permanent.viewmodels.ArchiveOnboardingViewModel

@Composable
Expand Down Expand Up @@ -282,29 +274,7 @@ fun ArchiveOnboardingScreen(

// Overlay with spinning images
if (isBusyState) {
Box(
modifier = Modifier
.fillMaxSize()
.background(Color.Black.copy(alpha = 0.5f))
.clickable(enabled = false) {}, contentAlignment = Alignment.Center
) {
val infiniteTransition = rememberInfiniteTransition(label = "")

val rotation by infiniteTransition.animateFloat(
initialValue = 0f, targetValue = 360f, animationSpec = infiniteRepeatable(
animation = tween(1000, easing = LinearEasing),
repeatMode = RepeatMode.Restart
), label = ""
)

Image(painter = painterResource(id = R.drawable.ellipse_exterior),
contentDescription = null,
modifier = Modifier.graphicsLayer { rotationZ = -rotation })

Image(painter = painterResource(id = R.drawable.ellipse_interior),
contentDescription = null,
modifier = Modifier.graphicsLayer { rotationZ = rotation })
}
CircularProgressIndicator()
}
}

Expand Down Expand Up @@ -337,7 +307,7 @@ fun OnboardingProgressIndicator(
val configuration = LocalConfiguration.current
val screenWidthDp = configuration.screenWidthDp.dp

CustomProgressIndicator(
CustomLinearProgressIndicator(
Modifier
.clip(shape = RoundedCornerShape(3.dp))
.height(height),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import org.permanent.permanent.R
import org.permanent.permanent.models.ArchiveType
import org.permanent.permanent.ui.composeComponents.ButtonColor
import org.permanent.permanent.ui.composeComponents.ButtonIconAlignment
import org.permanent.permanent.ui.composeComponents.SmallTextAndIconButton
import org.permanent.permanent.ui.composeComponents.CenteredTextAndIconButton

@Composable
fun ArchiveTypePage(
Expand Down Expand Up @@ -131,7 +131,7 @@ private fun TabletBody(
Box(
modifier = Modifier.weight(1f)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.TRANSPARENT,
text = stringResource(id = R.string.back),
icon = painterResource(id = R.drawable.ic_arrow_back_rounded_white),
Expand All @@ -146,7 +146,7 @@ private fun TabletBody(
Box(
modifier = Modifier.weight(1f)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.LIGHT,
text = stringResource(id = R.string.next)
) {
Expand Down Expand Up @@ -218,7 +218,7 @@ private fun PhoneBody(
.fillMaxWidth()
.weight(1f)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.TRANSPARENT,
text = stringResource(id = R.string.back),
icon = painterResource(id = R.drawable.ic_arrow_back_rounded_white),
Expand All @@ -235,7 +235,7 @@ private fun PhoneBody(
.fillMaxWidth()
.weight(1f)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
ButtonColor.LIGHT, text = stringResource(id = R.string.next)
) {
coroutineScope.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import org.permanent.permanent.models.Archive
import org.permanent.permanent.models.ThumbStatus
import org.permanent.permanent.ui.composeComponents.ArchiveItem
import org.permanent.permanent.ui.composeComponents.ButtonColor
import org.permanent.permanent.ui.composeComponents.SmallTextAndIconButton
import org.permanent.permanent.ui.composeComponents.CenteredTextAndIconButton
import org.permanent.permanent.viewmodels.ArchiveOnboardingViewModel

@Composable
Expand Down Expand Up @@ -176,7 +176,7 @@ private fun PhoneBody(
.fillMaxWidth()
.weight(1f)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.LIGHT,
text = stringResource(id = R.string.done),
icon = painterResource(id = R.drawable.ic_done_white),
Expand Down Expand Up @@ -287,7 +287,7 @@ private fun TabletBody(
.fillMaxWidth()
.weight(1f)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.LIGHT,
text = stringResource(id = R.string.done),
icon = painterResource(id = R.drawable.ic_done_white),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ import kotlinx.coroutines.launch
import org.permanent.permanent.R
import org.permanent.permanent.ui.composeComponents.ButtonColor
import org.permanent.permanent.ui.composeComponents.ButtonIconAlignment
import org.permanent.permanent.ui.composeComponents.CenteredTextAndIconButton
import org.permanent.permanent.ui.composeComponents.CustomCheckbox
import org.permanent.permanent.ui.composeComponents.SmallTextAndIconButton
import org.permanent.permanent.viewmodels.ArchiveOnboardingViewModel


Expand Down Expand Up @@ -181,7 +181,7 @@ private fun PhoneBody(
.fillMaxWidth()
.weight(1f)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.TRANSPARENT,
text = stringResource(id = R.string.back),
icon = painterResource(id = R.drawable.ic_arrow_back_rounded_white),
Expand All @@ -200,7 +200,7 @@ private fun PhoneBody(
.fillMaxWidth()
.weight(1f)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.LIGHT, text = stringResource(id = R.string.next)
) {
newArchive.goals = goals
Expand Down Expand Up @@ -317,7 +317,7 @@ private fun TabletBody(
Box(
modifier = Modifier.weight(1f)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.TRANSPARENT,
text = stringResource(id = R.string.back),
icon = painterResource(id = R.drawable.ic_arrow_back_rounded_white),
Expand All @@ -334,7 +334,7 @@ private fun TabletBody(
Box(
modifier = Modifier.weight(1f)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.LIGHT,
text = stringResource(id = R.string.next)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ import kotlinx.coroutines.launch
import org.permanent.permanent.R
import org.permanent.permanent.ui.composeComponents.ButtonColor
import org.permanent.permanent.ui.composeComponents.ButtonIconAlignment
import org.permanent.permanent.ui.composeComponents.CenteredTextAndIconButton
import org.permanent.permanent.ui.composeComponents.CustomCheckbox
import org.permanent.permanent.ui.composeComponents.SmallTextAndIconButton
import org.permanent.permanent.viewmodels.ArchiveOnboardingViewModel

@Composable
Expand Down Expand Up @@ -199,7 +199,7 @@ private fun PhoneBody(
.fillMaxWidth()
.weight(1f)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.TRANSPARENT,
text = stringResource(id = R.string.back),
icon = painterResource(id = R.drawable.ic_arrow_back_rounded_white),
Expand All @@ -216,7 +216,7 @@ private fun PhoneBody(
.fillMaxWidth()
.weight(1f)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.LIGHT, text = stringResource(id = R.string.next)
) {
newArchive.priorities = priorities
Expand Down Expand Up @@ -334,7 +334,7 @@ private fun TabletBody(
Box(
modifier = Modifier.weight(1f)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.TRANSPARENT,
text = stringResource(id = R.string.back),
icon = painterResource(id = R.drawable.ic_arrow_back_rounded_white),
Expand All @@ -349,7 +349,7 @@ private fun TabletBody(
Box(
modifier = Modifier.weight(1f)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.LIGHT,
text = stringResource(id = R.string.next)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import org.permanent.permanent.models.Status
import org.permanent.permanent.models.ThumbStatus
import org.permanent.permanent.ui.composeComponents.ArchiveItem
import org.permanent.permanent.ui.composeComponents.ButtonColor
import org.permanent.permanent.ui.composeComponents.SmallTextAndIconButton
import org.permanent.permanent.ui.composeComponents.CenteredTextAndIconButton
import org.permanent.permanent.viewmodels.ArchiveOnboardingViewModel

@Composable
Expand Down Expand Up @@ -169,7 +169,7 @@ private fun TabletBody(
modifier = Modifier.weight(1f)
) {
if (archives.isNotEmpty()) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.TRANSPARENT,
text = stringResource(id = R.string.create_new_archive),
icon = painterResource(id = R.drawable.ic_plus_white)
Expand All @@ -184,7 +184,7 @@ private fun TabletBody(
Box(
modifier = Modifier.weight(1f)
) {
SmallTextAndIconButton(buttonColor = ButtonColor.LIGHT,
CenteredTextAndIconButton(buttonColor = ButtonColor.LIGHT,
text = stringResource(id = if (archives.isEmpty()) R.string.get_started else R.string.next),
showButtonEnabled = archives.isEmpty() || archives.any { it.status == Status.OK }) {
val nextPage =
Expand Down Expand Up @@ -300,7 +300,7 @@ private fun PhoneBody(
}
.padding(horizontal = 32.dp), verticalArrangement = Arrangement.spacedBy(24.dp)) {

SmallTextAndIconButton(buttonColor = ButtonColor.LIGHT,
CenteredTextAndIconButton(buttonColor = ButtonColor.LIGHT,
text = stringResource(id = if (archives.isEmpty()) R.string.get_started else R.string.next),
showButtonEnabled = archives.isEmpty() || archives.any { it.status == Status.OK }
) {
Expand All @@ -316,7 +316,7 @@ private fun PhoneBody(
}

if (archives.isNotEmpty()) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.TRANSPARENT,
text = stringResource(id = R.string.new_archive),
icon = painterResource(id = R.drawable.ic_plus_white)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fun ArchiveItem(
.width(90.dp)
.height(40.dp)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.TRANSPARENT,
text = stringResource(id = R.string.accept),
fontSize = 12.sp,
Expand Down Expand Up @@ -183,7 +183,7 @@ private fun TabletBodyForWelcomePage(
.width(96.dp)
.height(48.dp)
) {
SmallTextAndIconButton(
CenteredTextAndIconButton(
buttonColor = ButtonColor.TRANSPARENT,
text = stringResource(id = R.string.accept),
fontSize = 12.sp,
Expand Down
Loading

0 comments on commit 5d840fa

Please sign in to comment.