parent
b40788676f
commit
b6c6f2c005
@ -0,0 +1,150 @@
|
||||
package fr.iut.alldev.allin.ui.betCreation.components
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.safeContentPadding
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalFocusManager
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import fr.iut.alldev.allin.R
|
||||
import fr.iut.alldev.allin.data.model.bet.BetType
|
||||
import fr.iut.alldev.allin.theme.AllInTheme
|
||||
import fr.iut.alldev.allin.ui.betCreation.tabs.BetCreationScreenAnswerTab
|
||||
import fr.iut.alldev.allin.ui.betCreation.tabs.BetCreationScreenQuestionTab
|
||||
import fr.iut.alldev.allin.ui.core.AllInSections
|
||||
import fr.iut.alldev.allin.ui.core.RainbowButton
|
||||
import fr.iut.alldev.allin.ui.core.SectionElement
|
||||
import fr.iut.alldev.allin.ui.core.SelectionElement
|
||||
import java.time.ZonedDateTime
|
||||
|
||||
@Composable
|
||||
fun BetCreationScreenContent(
|
||||
nbFriends: Int,
|
||||
betTheme: String,
|
||||
betThemeError: String?,
|
||||
setBetTheme: (String) -> Unit,
|
||||
betPhrase: String,
|
||||
betPhraseError: String?,
|
||||
setBetPhrase: (String) -> Unit,
|
||||
isPublic: Boolean,
|
||||
setIsPublic: (Boolean) -> Unit,
|
||||
registerDate: ZonedDateTime,
|
||||
registerDateError: String?,
|
||||
betDate: ZonedDateTime,
|
||||
betDateError: String?,
|
||||
selectedFriends: MutableList<Int>,
|
||||
setRegisterDateDialog: (Boolean) -> Unit,
|
||||
setEndDateDialog: (Boolean) -> Unit,
|
||||
setRegisterTimeDialog: (Boolean) -> Unit,
|
||||
setEndTimeDialog: (Boolean) -> Unit,
|
||||
selectedBetTypeElement: SelectionElement?,
|
||||
selectedBetType: BetType,
|
||||
setSelectedBetTypeElement: (SelectionElement) -> Unit,
|
||||
selectionBetType: List<SelectionElement>,
|
||||
onCreateBet: () -> Unit
|
||||
) {
|
||||
val interactionSource = remember { MutableInteractionSource() }
|
||||
val focus = LocalFocusManager.current
|
||||
|
||||
Box(Modifier.fillMaxSize()) {
|
||||
AllInSections(
|
||||
onLoadSection = { focus.clearFocus() },
|
||||
modifier = Modifier.align(Alignment.TopCenter),
|
||||
sections = listOf(
|
||||
SectionElement(stringResource(id = R.string.Question)) {
|
||||
BetCreationScreenQuestionTab(
|
||||
isPublic = isPublic,
|
||||
setIsPublic = setIsPublic,
|
||||
betPhrase = betPhrase,
|
||||
setBetPhrase = setBetPhrase,
|
||||
betTheme = betTheme,
|
||||
setBetTheme = setBetTheme,
|
||||
nbFriends = nbFriends,
|
||||
selectedFriends = selectedFriends,
|
||||
registerDate = registerDate,
|
||||
betDate = betDate,
|
||||
setRegisterDateDialog = setRegisterDateDialog,
|
||||
setEndDateDialog = setEndDateDialog,
|
||||
setRegisterTimeDialog = setRegisterTimeDialog,
|
||||
setEndTimeDialog = setEndTimeDialog,
|
||||
interactionSource = interactionSource,
|
||||
betThemeError = betThemeError,
|
||||
betPhraseError = betPhraseError,
|
||||
registerDateError = registerDateError,
|
||||
betDateError = betDateError
|
||||
)
|
||||
},
|
||||
SectionElement(stringResource(id = R.string.Answer)) {
|
||||
BetCreationScreenAnswerTab(
|
||||
selectedBetType = selectedBetType,
|
||||
selected = selectedBetTypeElement,
|
||||
setSelected = setSelectedBetTypeElement,
|
||||
elements = selectionBetType
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.align(Alignment.BottomCenter)
|
||||
.background(
|
||||
Brush.verticalGradient(
|
||||
0f to Color.Transparent,
|
||||
0.50f to AllInTheme.themeColors.mainSurface
|
||||
)
|
||||
),
|
||||
) {
|
||||
RainbowButton(
|
||||
text = stringResource(id = R.string.Publish),
|
||||
modifier = Modifier
|
||||
.padding(bottom = 14.dp)
|
||||
.padding(horizontal = 20.dp)
|
||||
.safeContentPadding(),
|
||||
onClick = onCreateBet
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun BetCreationScreenContentPreview() {
|
||||
AllInTheme {
|
||||
BetCreationScreenContent(
|
||||
nbFriends = 8900,
|
||||
betTheme = "Ina",
|
||||
betThemeError = null,
|
||||
setBetTheme = { },
|
||||
betPhrase = "Bryon",
|
||||
betPhraseError = null,
|
||||
setBetPhrase = { },
|
||||
isPublic = false,
|
||||
setIsPublic = { },
|
||||
registerDate = ZonedDateTime.now(),
|
||||
registerDateError = null,
|
||||
betDate = ZonedDateTime.now(),
|
||||
betDateError = null,
|
||||
selectedFriends = mutableListOf(),
|
||||
setRegisterDateDialog = { },
|
||||
setEndDateDialog = { },
|
||||
setRegisterTimeDialog = { },
|
||||
setEndTimeDialog = { },
|
||||
selectedBetTypeElement = null,
|
||||
selectedBetType = BetType.BINARY,
|
||||
setSelectedBetTypeElement = { },
|
||||
selectionBetType = listOf(),
|
||||
onCreateBet = { }
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,221 @@
|
||||
package fr.iut.alldev.allin.ui.register.components
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
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.navigationBarsPadding
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.text.ClickableText
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import fr.iut.alldev.allin.R
|
||||
import fr.iut.alldev.allin.theme.AllInTheme
|
||||
import fr.iut.alldev.allin.ui.core.AllInGradientButton
|
||||
import fr.iut.alldev.allin.ui.core.AllInLoading
|
||||
import fr.iut.alldev.allin.ui.core.AllInPasswordField
|
||||
import fr.iut.alldev.allin.ui.core.AllInTextField
|
||||
|
||||
@Composable
|
||||
fun RegisterScreenContent(
|
||||
navigateToLogin: () -> Unit,
|
||||
onRegister: () -> Unit,
|
||||
keyboardActions: KeyboardActions,
|
||||
loading: Boolean,
|
||||
username: String,
|
||||
usernameFieldName: String,
|
||||
setUsername: (String) -> Unit,
|
||||
usernameError: String?,
|
||||
email: String,
|
||||
emailFieldName: String,
|
||||
setEmail: (String) -> Unit,
|
||||
emailError: String?,
|
||||
passwordFieldName: String,
|
||||
password: String,
|
||||
passwordError: String?,
|
||||
setPassword: (String) -> Unit,
|
||||
passwordValidation: String,
|
||||
passwordValidationError: String?,
|
||||
setPasswordValidation: (String) -> Unit
|
||||
) {
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxSize()
|
||||
.background(AllInTheme.themeColors.mainSurface)
|
||||
) {
|
||||
LazyColumn(
|
||||
verticalArrangement = Arrangement.Center,
|
||||
contentPadding = PaddingValues(40.dp)
|
||||
) {
|
||||
item {
|
||||
Text(
|
||||
modifier = Modifier
|
||||
.padding(top = 16.dp)
|
||||
.fillMaxWidth(),
|
||||
text = stringResource(id = R.string.Hello_x, username),
|
||||
color = AllInTheme.themeColors.onMainSurface,
|
||||
style = AllInTheme.typography.sm1,
|
||||
textAlign = TextAlign.Center,
|
||||
fontSize = 40.sp,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 1
|
||||
)
|
||||
Text(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = stringResource(id = R.string.Register_title),
|
||||
color = AllInTheme.themeColors.onMainSurface,
|
||||
style = AllInTheme.typography.sm1,
|
||||
textAlign = TextAlign.Center,
|
||||
fontSize = 40.sp
|
||||
)
|
||||
Spacer(modifier = Modifier.height(23.dp))
|
||||
Text(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = stringResource(id = R.string.Register_subtitle),
|
||||
color = AllInTheme.themeColors.onMainSurface,
|
||||
style = AllInTheme.typography.p1,
|
||||
textAlign = TextAlign.Center,
|
||||
fontSize = 23.sp
|
||||
)
|
||||
Spacer(modifier = Modifier.height(83.dp))
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(20.dp)
|
||||
) {
|
||||
AllInTextField(
|
||||
placeholder = usernameFieldName,
|
||||
value = username,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
maxChar = 20,
|
||||
onValueChange = setUsername,
|
||||
errorText = usernameError,
|
||||
imeAction = ImeAction.Next,
|
||||
keyboardActions = keyboardActions
|
||||
)
|
||||
AllInTextField(
|
||||
placeholder = emailFieldName,
|
||||
value = email,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
onValueChange = setEmail,
|
||||
errorText = emailError,
|
||||
keyboardType = KeyboardType.Email,
|
||||
imeAction = ImeAction.Next,
|
||||
keyboardActions = keyboardActions
|
||||
)
|
||||
AllInPasswordField(
|
||||
placeholder = passwordFieldName,
|
||||
value = password,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
imeAction = ImeAction.Next,
|
||||
keyboardActions = keyboardActions,
|
||||
keyboardType = KeyboardType.Password,
|
||||
errorText = passwordError,
|
||||
onValueChange = setPassword
|
||||
)
|
||||
AllInPasswordField(
|
||||
placeholder = stringResource(id = R.string.confirm_password),
|
||||
value = passwordValidation,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
imeAction = ImeAction.Done,
|
||||
keyboardActions = keyboardActions,
|
||||
keyboardType = KeyboardType.Password,
|
||||
errorText = passwordValidationError,
|
||||
onValueChange = setPasswordValidation
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(120.dp))
|
||||
Spacer(modifier = Modifier.navigationBarsPadding())
|
||||
}
|
||||
}
|
||||
Column(
|
||||
Modifier
|
||||
.align(Alignment.BottomCenter)
|
||||
.background(
|
||||
Brush.verticalGradient(
|
||||
.2f to Color.Transparent,
|
||||
.5f to AllInTheme.themeColors.background
|
||||
)
|
||||
)
|
||||
.padding(40.dp)
|
||||
.navigationBarsPadding()
|
||||
) {
|
||||
AllInGradientButton(
|
||||
text = stringResource(id = R.string.Register),
|
||||
onClick = onRegister
|
||||
)
|
||||
Spacer(modifier = Modifier.height(30.dp))
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.already_have_account),
|
||||
color = AllInTheme.themeColors.onMainSurface,
|
||||
fontSize = 15.sp,
|
||||
style = AllInTheme.typography.p1,
|
||||
modifier = Modifier.padding(end = 5.dp)
|
||||
)
|
||||
ClickableText(
|
||||
text = AnnotatedString(stringResource(id = R.string.Login)),
|
||||
style = AllInTheme.typography.p1.copy(
|
||||
color = AllInTheme.colors.allInPurple,
|
||||
fontSize = 15.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
) {
|
||||
navigateToLogin()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
AllInLoading(visible = loading)
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun RegisterScreenContentPreview() {
|
||||
AllInTheme {
|
||||
RegisterScreenContent(
|
||||
navigateToLogin = { },
|
||||
onRegister = { },
|
||||
keyboardActions = KeyboardActions(),
|
||||
loading = false,
|
||||
username = "Lekesha",
|
||||
usernameFieldName = "Justen",
|
||||
setUsername = { },
|
||||
usernameError = "Kaitlyn",
|
||||
email = "Donnell",
|
||||
emailFieldName = "Camron",
|
||||
setEmail = { },
|
||||
emailError = "Tunisia",
|
||||
passwordFieldName = "Cagney",
|
||||
password = "Neha",
|
||||
passwordError = "December",
|
||||
setPassword = { },
|
||||
passwordValidation = "Xaviera",
|
||||
passwordValidationError = "Keegan",
|
||||
setPasswordValidation = { }
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
package fr.iut.alldev.allin.ui.welcome.components
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
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.navigationBarsPadding
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.safeContentPadding
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.foundation.text.ClickableText
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import fr.iut.alldev.allin.R
|
||||
import fr.iut.alldev.allin.theme.AllInTheme
|
||||
import fr.iut.alldev.allin.ui.core.AllInButton
|
||||
import fr.iut.alldev.allin.ui.core.AllInLoading
|
||||
|
||||
@Composable
|
||||
fun WelcomeScreenContent(
|
||||
navigateToRegister: () -> Unit,
|
||||
navigateToLogin: () -> Unit,
|
||||
loading: Boolean
|
||||
) {
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.fillMaxHeight(.5f)
|
||||
.background(AllInTheme.colors.allInLoginGradient)
|
||||
)
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxSize()
|
||||
.background(
|
||||
Brush.verticalGradient(
|
||||
.2f to Color.Transparent,
|
||||
.5f to AllInTheme.themeColors.background
|
||||
)
|
||||
)
|
||||
) {
|
||||
Column(
|
||||
Modifier
|
||||
.align(Alignment.BottomCenter)
|
||||
.fillMaxWidth()
|
||||
.padding(40.dp)
|
||||
.navigationBarsPadding()
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.welcome_title),
|
||||
color = AllInTheme.themeColors.onBackground,
|
||||
fontSize = 30.sp,
|
||||
style = AllInTheme.typography.h1
|
||||
)
|
||||
Text(
|
||||
text = stringResource(id = R.string.welcome_appname),
|
||||
fontSize = 60.sp,
|
||||
style = AllInTheme.typography.h1.copy(
|
||||
brush = AllInTheme.colors.allInMainGradient
|
||||
)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(43.dp))
|
||||
Text(
|
||||
text = stringResource(id = R.string.welcome_subtitle),
|
||||
color = AllInTheme.themeColors.onBackground,
|
||||
fontSize = 15.sp,
|
||||
style = AllInTheme.typography.p1
|
||||
)
|
||||
Spacer(modifier = Modifier.height(78.dp))
|
||||
|
||||
AllInButton(
|
||||
color = AllInTheme.themeColors.tint1,
|
||||
text = stringResource(id = R.string.join),
|
||||
textColor = AllInTheme.themeColors.background,
|
||||
onClick = navigateToRegister,
|
||||
modifier = Modifier.padding(bottom = 13.dp)
|
||||
)
|
||||
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.already_have_account),
|
||||
color = AllInTheme.themeColors.tint1,
|
||||
fontSize = 15.sp,
|
||||
style = AllInTheme.typography.p1,
|
||||
modifier = Modifier.padding(end = 5.dp)
|
||||
)
|
||||
ClickableText(
|
||||
text = AnnotatedString(stringResource(id = R.string.Login)),
|
||||
style = AllInTheme.typography.p1.copy(
|
||||
color = AllInTheme.themeColors.tint1,
|
||||
fontSize = 15.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
),
|
||||
onClick = { navigateToLogin() }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AllInLoading(visible = loading)
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
@Composable
|
||||
private fun WelcomeScreenContentPreview() {
|
||||
AllInTheme {
|
||||
WelcomeScreenContent(
|
||||
navigateToRegister = { },
|
||||
navigateToLogin = { },
|
||||
loading = false
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in new issue