Adding welcome, register and login screens
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
fb6de1cf70
commit
b6831c2322
@ -0,0 +1,94 @@
|
||||
package fr.iut.alldev.allin.ext
|
||||
|
||||
import android.graphics.BlurMaskFilter
|
||||
import android.graphics.Shader
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.drawBehind
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.LinearGradientShader
|
||||
import androidx.compose.ui.graphics.Paint
|
||||
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
|
||||
import androidx.compose.ui.graphics.toArgb
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
fun Modifier.shadow(
|
||||
color: Color = Color.Black,
|
||||
offsetX: Dp = 0.dp,
|
||||
offsetY: Dp = 0.dp,
|
||||
blurRadius: Dp = 0.dp,
|
||||
alpha: Float = 1f,
|
||||
cornerRadius: Dp = 0.dp
|
||||
) = then(
|
||||
drawBehind {
|
||||
drawIntoCanvas { canvas ->
|
||||
val paint = Paint()
|
||||
val frameworkPaint = paint.asFrameworkPaint()
|
||||
if (blurRadius != 0.dp) {
|
||||
frameworkPaint.maskFilter =
|
||||
BlurMaskFilter(blurRadius.toPx(), BlurMaskFilter.Blur.NORMAL)
|
||||
}
|
||||
frameworkPaint.color = color.toArgb()
|
||||
frameworkPaint.alpha = (255*alpha).toInt()
|
||||
val leftPixel = offsetX.toPx()
|
||||
val topPixel = offsetY.toPx()
|
||||
val rightPixel = size.width + topPixel
|
||||
val bottomPixel = size.height + leftPixel
|
||||
|
||||
canvas.drawRoundRect(
|
||||
left = leftPixel,
|
||||
top = topPixel,
|
||||
right = rightPixel,
|
||||
bottom = bottomPixel,
|
||||
paint = paint,
|
||||
radiusX = cornerRadius.toPx(),
|
||||
radiusY = cornerRadius.toPx()
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
fun Modifier.shadow(
|
||||
colors: List<Color> = listOf(Color.Black),
|
||||
offsetX: Dp = 0.dp,
|
||||
offsetY: Dp = 0.dp,
|
||||
blurRadius: Dp = 0.dp,
|
||||
cornerRadius: Dp = 0.dp,
|
||||
alpha: Float = 1f
|
||||
) = then(
|
||||
drawBehind {
|
||||
drawIntoCanvas { canvas ->
|
||||
val shader: Shader =
|
||||
LinearGradientShader(
|
||||
Offset(0f, 0f),
|
||||
Offset(size.width, 0f),
|
||||
colors
|
||||
)
|
||||
val paint = Paint()
|
||||
val frameworkPaint = paint.asFrameworkPaint()
|
||||
if (blurRadius != 0.dp) {
|
||||
frameworkPaint.maskFilter =
|
||||
BlurMaskFilter(blurRadius.toPx(), BlurMaskFilter.Blur.NORMAL)
|
||||
}
|
||||
frameworkPaint.shader = shader
|
||||
frameworkPaint.alpha = (255*alpha).toInt()
|
||||
val leftPixel = offsetX.toPx()
|
||||
val topPixel = offsetY.toPx()
|
||||
val rightPixel = size.width + topPixel
|
||||
val bottomPixel = size.height + leftPixel
|
||||
|
||||
canvas.drawRoundRect(
|
||||
left = leftPixel,
|
||||
top = topPixel,
|
||||
right = rightPixel,
|
||||
bottom = bottomPixel,
|
||||
paint = paint,
|
||||
radiusX = cornerRadius.toPx(),
|
||||
radiusY = cornerRadius.toPx()
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
@ -0,0 +1,131 @@
|
||||
package fr.iut.alldev.allin.ui.bet.components
|
||||
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.pluralStringResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
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.ui.core.AllInCard
|
||||
import fr.iut.alldev.allin.ui.core.HighlightedText
|
||||
import fr.iut.alldev.allin.ui.theme.AllInTheme
|
||||
import kotlin.math.ceil
|
||||
|
||||
@Composable
|
||||
fun BetScreenPopularCard(
|
||||
nbPlayers: Int,
|
||||
points: Float,
|
||||
pointUnit: String,
|
||||
title: String,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
AllInCard(
|
||||
modifier = modifier,
|
||||
backgroundColor = AllInTheme.colors.allIn_Dark,
|
||||
borderWidth = 2.dp,
|
||||
borderBrush = AllInTheme.colors.allIn_MainGradient
|
||||
) {
|
||||
Column(modifier = Modifier.padding(13.dp)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.allin_fire),
|
||||
modifier = Modifier.size(15.dp),
|
||||
contentDescription = null,
|
||||
tint = AllInTheme.colors.allIn_Pink
|
||||
)
|
||||
Spacer(modifier = Modifier.width(3.dp))
|
||||
Text(
|
||||
text = stringResource(id = R.string.Popular),
|
||||
color = AllInTheme.colors.allIn_Pink,
|
||||
fontSize = 17.sp,
|
||||
style = AllInTheme.typography.h2
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = title,
|
||||
color = AllInTheme.colors.white,
|
||||
fontSize = 20.sp,
|
||||
style = AllInTheme.typography.h1,
|
||||
modifier = Modifier.padding(vertical = 22.dp)
|
||||
)
|
||||
Row(modifier = Modifier.align(alignment = Alignment.CenterHorizontally)) {
|
||||
HighlightedText(
|
||||
text = pluralStringResource(
|
||||
id = R.plurals.n_players,
|
||||
nbPlayers,
|
||||
nbPlayers
|
||||
),
|
||||
query = nbPlayers.toString(),
|
||||
highlightStyle = SpanStyle(
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = AllInTheme.colors.allIn_Pink
|
||||
),
|
||||
color = AllInTheme.colors.white,
|
||||
style = AllInTheme.typography.r,
|
||||
fontSize = 15.sp
|
||||
)
|
||||
Text(
|
||||
text = " - ",
|
||||
color = AllInTheme.colors.white,
|
||||
style = AllInTheme.typography.r,
|
||||
fontSize = 15.sp
|
||||
)
|
||||
val pointsText = if (points % 1 == 0f){
|
||||
stringResource(id = R.string.int_and_unit, points.toInt(), pointUnit)
|
||||
}else{
|
||||
stringResource(id = R.string.float_and_unit, points, pointUnit)
|
||||
}
|
||||
HighlightedText(
|
||||
text = pluralStringResource(
|
||||
id = R.plurals.n_points_at_stake,
|
||||
if(pointUnit.isEmpty()) ceil(points).toInt() else 2,
|
||||
pointsText
|
||||
),
|
||||
query = pointsText,
|
||||
highlightStyle = SpanStyle(
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = AllInTheme.colors.allIn_Pink
|
||||
),
|
||||
color = AllInTheme.colors.white,
|
||||
style = AllInTheme.typography.r,
|
||||
fontSize = 15.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun BetScreenPopularCardPreview() {
|
||||
AllInTheme {
|
||||
BetScreenPopularCard(
|
||||
nbPlayers = 12,
|
||||
points = 2.35f,
|
||||
pointUnit = "k",
|
||||
title = "Emre va réussir son TP de CI/CD mercredi?"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun BetScreenPopularCardSingularPreview() {
|
||||
AllInTheme {
|
||||
BetScreenPopularCard(
|
||||
nbPlayers = 1,
|
||||
points = 1.0f,
|
||||
pointUnit = "",
|
||||
title = "Emre va réussir son TP de CI/CD mercredi?"
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package fr.iut.alldev.allin.ui.core
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import fr.iut.alldev.allin.ui.theme.AllInTheme
|
||||
|
||||
@Composable
|
||||
fun AllInButton(
|
||||
color: Color,
|
||||
text: String,
|
||||
textColor: Color,
|
||||
modifier: Modifier = Modifier,
|
||||
onClick: ()->Unit
|
||||
) {
|
||||
AllInCard(onClick = onClick, modifier = modifier, radius = 50.dp, backgroundColor = color) {
|
||||
Text(
|
||||
text = text,
|
||||
textAlign = TextAlign.Center,
|
||||
style = AllInTheme.typography.h2,
|
||||
color = textColor,
|
||||
fontSize = 20.sp,
|
||||
modifier = Modifier
|
||||
.padding(vertical = 15.dp)
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun AllInButtonPreview() {
|
||||
AllInTheme {
|
||||
AllInButton(
|
||||
color = AllInTheme.colors.allIn_LoginPurple,
|
||||
text = "Connexion",
|
||||
textColor = Color.White
|
||||
) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package fr.iut.alldev.allin.ui.core
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import fr.iut.alldev.allin.ext.shadow
|
||||
import fr.iut.alldev.allin.ui.theme.AllInTheme
|
||||
|
||||
@Composable
|
||||
fun AllInGradientButton(
|
||||
text: String,
|
||||
modifier: Modifier = Modifier,
|
||||
onClick: ()->Unit
|
||||
) {
|
||||
AllInCard(
|
||||
onClick = onClick,
|
||||
modifier = modifier.shadow(
|
||||
colors = listOf(
|
||||
AllInTheme.colors.allIn_Pink,
|
||||
AllInTheme.colors.allIn_Blue
|
||||
),
|
||||
blurRadius = 20.dp,
|
||||
alpha = .5f,
|
||||
cornerRadius = 15.dp
|
||||
),
|
||||
radius = 10.dp,
|
||||
backgroundBrush = AllInTheme.colors.allIn_MainGradient
|
||||
) {
|
||||
Text(
|
||||
text = text,
|
||||
textAlign = TextAlign.Center,
|
||||
style = AllInTheme.typography.h2,
|
||||
color = AllInTheme.colors.white,
|
||||
fontSize = 20.sp,
|
||||
modifier = Modifier
|
||||
.padding(vertical = 15.dp)
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun AllInGradientButtonPreview() {
|
||||
AllInTheme {
|
||||
AllInGradientButton(
|
||||
text = "Connexion"
|
||||
) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,188 @@
|
||||
package fr.iut.alldev.allin.ui.core
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.relocation.BringIntoViewRequester
|
||||
import androidx.compose.foundation.shape.AbsoluteRoundedCornerShape
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Visibility
|
||||
import androidx.compose.material.icons.filled.VisibilityOff
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.onFocusChanged
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.text.TextRange
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
||||
import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.compose.ui.text.input.VisualTransformation
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.sp
|
||||
import fr.iut.alldev.allin.ui.theme.AllInTheme
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun AllInTextField(
|
||||
placeholder: String,
|
||||
value: String,
|
||||
maxChar: Int? = null,
|
||||
modifier: Modifier = Modifier,
|
||||
enabled: Boolean = true,
|
||||
trailingIcon: ImageVector? = null,
|
||||
trailingContent: @Composable (() -> Unit)? = null,
|
||||
onValueChange: (String)->Unit,
|
||||
bringIntoViewRequester: BringIntoViewRequester,
|
||||
visualTransformation: VisualTransformation = VisualTransformation.None,
|
||||
keyboardType: KeyboardType = KeyboardType.Text,
|
||||
keyboardActions: KeyboardActions = KeyboardActions.Default
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
var hasFocus by remember { mutableStateOf(false) }
|
||||
|
||||
var textFieldValue by remember {
|
||||
mutableStateOf(TextFieldValue(text = value, selection = TextRange(value.length)))
|
||||
}
|
||||
|
||||
LaunchedEffect(key1 = value, block = {
|
||||
textFieldValue = TextFieldValue(text = value, selection = TextRange(value.length))
|
||||
})
|
||||
|
||||
|
||||
OutlinedTextField(
|
||||
modifier = modifier
|
||||
.onFocusChanged {
|
||||
hasFocus = it.hasFocus
|
||||
if (it.isFocused) {
|
||||
scope.launch {
|
||||
bringIntoViewRequester.bringIntoView()
|
||||
}
|
||||
}
|
||||
},
|
||||
visualTransformation = visualTransformation,
|
||||
value = textFieldValue,
|
||||
onValueChange = {
|
||||
if(maxChar==null || it.text.length<=maxChar) {
|
||||
textFieldValue = it
|
||||
onValueChange(it.text)
|
||||
}
|
||||
},
|
||||
placeholder = {
|
||||
Text(
|
||||
text = placeholder,
|
||||
fontSize = 18.sp,
|
||||
style = AllInTheme.typography.r,
|
||||
color = AllInTheme.colors.allIn_LightGrey300
|
||||
)
|
||||
},
|
||||
trailingIcon = trailingContent ?: trailingIcon?.let{
|
||||
@Composable {
|
||||
Icon(
|
||||
imageVector = it,
|
||||
contentDescription = null,
|
||||
tint = AllInTheme.colors.allIn_LightGrey300
|
||||
)
|
||||
}
|
||||
},
|
||||
textStyle = AllInTheme.typography.r,
|
||||
singleLine = true,
|
||||
enabled = enabled,
|
||||
keyboardOptions = KeyboardOptions(keyboardType = keyboardType),
|
||||
keyboardActions = keyboardActions,
|
||||
shape = AbsoluteRoundedCornerShape(20),
|
||||
colors = OutlinedTextFieldDefaults.colors(
|
||||
cursorColor = AllInTheme.colors.allIn_Dark,
|
||||
focusedBorderColor = AllInTheme.colors.allIn_LightGrey300,
|
||||
unfocusedBorderColor = AllInTheme.colors.allIn_LightGrey300,
|
||||
focusedTextColor = AllInTheme.colors.allIn_Dark,
|
||||
unfocusedTextColor = AllInTheme.colors.allIn_Dark,
|
||||
focusedContainerColor = AllInTheme.colors.white,
|
||||
unfocusedContainerColor = AllInTheme.colors.white
|
||||
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun AllInPasswordField(
|
||||
placeholder: String,
|
||||
value: String,
|
||||
modifier: Modifier = Modifier,
|
||||
keyboardType: KeyboardType = KeyboardType.Password,
|
||||
keyboardActions: KeyboardActions = KeyboardActions.Default,
|
||||
onValueChange: (String)->Unit,
|
||||
bringIntoViewRequester: BringIntoViewRequester,
|
||||
isHiddenByDefault: Boolean = true
|
||||
){
|
||||
var hidden by remember{
|
||||
mutableStateOf(isHiddenByDefault)
|
||||
}
|
||||
AllInTextField(
|
||||
modifier = modifier,
|
||||
placeholder = placeholder,
|
||||
keyboardActions = keyboardActions,
|
||||
visualTransformation = if (hidden) PasswordVisualTransformation() else VisualTransformation.None,
|
||||
value = value,
|
||||
onValueChange = onValueChange,
|
||||
bringIntoViewRequester = bringIntoViewRequester,
|
||||
trailingContent = {
|
||||
IconButton(
|
||||
onClick = { hidden = !hidden }
|
||||
) {
|
||||
Icon(
|
||||
imageVector = if (hidden) Icons.Default.VisibilityOff else Icons.Default.Visibility,
|
||||
contentDescription = null,
|
||||
tint = AllInTheme.colors.allIn_LightGrey300
|
||||
)
|
||||
}
|
||||
},
|
||||
keyboardType = keyboardType
|
||||
)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Preview
|
||||
@Composable
|
||||
private fun AllInTextFieldPlaceholderPreview() {
|
||||
AllInTheme {
|
||||
AllInTextField(
|
||||
placeholder = "Email",
|
||||
value = "",
|
||||
onValueChange = { },
|
||||
bringIntoViewRequester = BringIntoViewRequester()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Preview
|
||||
@Composable
|
||||
private fun AllInTextFieldValuePreview() {
|
||||
AllInTheme {
|
||||
AllInTextField(
|
||||
placeholder = "Email",
|
||||
value = "JohnDoe@mail.com",
|
||||
onValueChange = { },
|
||||
bringIntoViewRequester = BringIntoViewRequester()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Preview
|
||||
@Composable
|
||||
private fun AllInTextFieldPasswordPreview() {
|
||||
AllInTheme {
|
||||
val (value, setValue) = mutableStateOf("")
|
||||
AllInPasswordField(
|
||||
placeholder = "Password",
|
||||
value = value,
|
||||
onValueChange = setValue,
|
||||
bringIntoViewRequester = BringIntoViewRequester()
|
||||
)
|
||||
}
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
package fr.iut.alldev.allin.ui.home.components
|
||||
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.AbsoluteRoundedCornerShape
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.shadow
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.pluralStringResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
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.ui.core.AllInCard
|
||||
import fr.iut.alldev.allin.ui.core.HighlightedText
|
||||
import fr.iut.alldev.allin.ui.theme.AllInTheme
|
||||
import kotlin.math.ceil
|
||||
|
||||
@Composable
|
||||
fun HomePopularCards(
|
||||
nbPlayers: Int,
|
||||
points: Float,
|
||||
pointUnit: String,
|
||||
title: String,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Box(modifier.padding(3.dp)) {
|
||||
AllInCard(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.shadow(
|
||||
elevation = 2.dp,
|
||||
shape = AbsoluteRoundedCornerShape(15)
|
||||
)
|
||||
.padding(2.dp),
|
||||
backgroundColor = AllInTheme.colors.allIn_Dark,
|
||||
borderWidth = 2.dp,
|
||||
borderBrush = AllInTheme.colors.allIn_MainGradient
|
||||
) {
|
||||
Column(modifier = Modifier.padding(13.dp)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.allin_fire),
|
||||
modifier = Modifier.size(20.dp),
|
||||
contentDescription = null,
|
||||
tint = AllInTheme.colors.allIn_Pink
|
||||
)
|
||||
Spacer(modifier = Modifier.width(3.dp))
|
||||
Text(
|
||||
text = stringResource(id = R.string.Popular),
|
||||
color = AllInTheme.colors.allIn_Pink,
|
||||
fontSize = 17.sp,
|
||||
style = AllInTheme.typography.h2
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = title,
|
||||
color = AllInTheme.colors.white,
|
||||
fontSize = 20.sp,
|
||||
style = AllInTheme.typography.h1,
|
||||
modifier = Modifier.padding(vertical = 22.dp)
|
||||
)
|
||||
Row(modifier = Modifier.align(alignment = Alignment.CenterHorizontally)) {
|
||||
HighlightedText(
|
||||
text = pluralStringResource(
|
||||
id = R.plurals.n_players,
|
||||
nbPlayers,
|
||||
nbPlayers
|
||||
),
|
||||
query = nbPlayers.toString(),
|
||||
highlightStyle = SpanStyle(
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = AllInTheme.colors.allIn_Pink
|
||||
),
|
||||
color = AllInTheme.colors.white,
|
||||
style = AllInTheme.typography.r,
|
||||
fontSize = 15.sp
|
||||
)
|
||||
Text(
|
||||
text = " - ",
|
||||
color = AllInTheme.colors.white,
|
||||
style = AllInTheme.typography.r,
|
||||
fontSize = 15.sp
|
||||
)
|
||||
val pointsText = if (points % 1 == 0f){
|
||||
stringResource(id = R.string.int_and_unit, points.toInt(), pointUnit)
|
||||
}else{
|
||||
stringResource(id = R.string.float_and_unit, points, pointUnit)
|
||||
}
|
||||
HighlightedText(
|
||||
text = pluralStringResource(
|
||||
id = R.plurals.n_points_at_stake,
|
||||
if(pointUnit.isEmpty()) ceil(points).toInt() else 2,
|
||||
pointsText
|
||||
),
|
||||
query = pointsText,
|
||||
highlightStyle = SpanStyle(
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = AllInTheme.colors.allIn_Pink
|
||||
),
|
||||
color = AllInTheme.colors.white,
|
||||
style = AllInTheme.typography.r,
|
||||
fontSize = 15.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun HomePopularCardsPreview() {
|
||||
AllInTheme {
|
||||
HomePopularCards(
|
||||
nbPlayers = 12,
|
||||
points = 2.35f,
|
||||
pointUnit = "k",
|
||||
title = "Emre va réussir son TP de CI/CD mercredi?"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun HomePopularCardsSingularPreview() {
|
||||
AllInTheme {
|
||||
HomePopularCards(
|
||||
nbPlayers = 1,
|
||||
points = 1.0f,
|
||||
pointUnit = "",
|
||||
title = "Emre va réussir son TP de CI/CD mercredi?"
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
package fr.iut.alldev.allin.ui.login
|
||||
|
||||
import androidx.compose.foundation.*
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.relocation.BringIntoViewRequester
|
||||
import androidx.compose.foundation.text.ClickableText
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import fr.iut.alldev.allin.R
|
||||
import fr.iut.alldev.allin.ui.core.AllInGradientButton
|
||||
import fr.iut.alldev.allin.ui.core.AllInPasswordField
|
||||
import fr.iut.alldev.allin.ui.core.AllInTextField
|
||||
import fr.iut.alldev.allin.ui.theme.AllInTheme
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun LoginScreen(
|
||||
onClickLogin: ()->Unit,
|
||||
onClickRegister: ()->Unit
|
||||
) {
|
||||
|
||||
val bringIntoViewRequester = BringIntoViewRequester()
|
||||
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxSize()
|
||||
.background(AllInTheme.themeColors.main_surface)
|
||||
.padding(horizontal = 44.dp)
|
||||
.verticalScroll(rememberScrollState())
|
||||
) {
|
||||
Column(
|
||||
Modifier.align(Alignment.Center)
|
||||
) {
|
||||
Text(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = stringResource(id = R.string.Login_title),
|
||||
color = AllInTheme.themeColors.on_main_surface,
|
||||
style = AllInTheme.typography.h3,
|
||||
textAlign = TextAlign.Center,
|
||||
fontSize = 40.sp
|
||||
)
|
||||
Spacer(modifier = Modifier.height(23.dp))
|
||||
Text(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = stringResource(id = R.string.Login_subtitle),
|
||||
color = AllInTheme.themeColors.on_main_surface,
|
||||
style = AllInTheme.typography.r,
|
||||
textAlign = TextAlign.Center,
|
||||
fontSize = 30.sp
|
||||
)
|
||||
Spacer(modifier = Modifier.height(83.dp))
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(20.dp)
|
||||
) {
|
||||
AllInTextField(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
placeholder = stringResource(id = R.string.username),
|
||||
value = "",
|
||||
onValueChange = { },
|
||||
bringIntoViewRequester = bringIntoViewRequester
|
||||
)
|
||||
AllInPasswordField(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
placeholder = stringResource(id = R.string.password),
|
||||
value = "",
|
||||
onValueChange = { },
|
||||
bringIntoViewRequester = bringIntoViewRequester
|
||||
)
|
||||
}
|
||||
ClickableText(
|
||||
text = AnnotatedString(stringResource(id = R.string.forgot_password)),
|
||||
style = AllInTheme.typography.m.copy(
|
||||
color = AllInTheme.themeColors.on_main_surface,
|
||||
fontSize = 15.sp,
|
||||
),
|
||||
modifier = Modifier
|
||||
.align(Alignment.End)
|
||||
.padding(top = 15.dp)
|
||||
){
|
||||
// TODO : Forgot password
|
||||
}
|
||||
Spacer(modifier = Modifier.height(67.dp))
|
||||
}
|
||||
Column(
|
||||
Modifier
|
||||
.align(Alignment.BottomCenter)
|
||||
.padding(bottom = 32.dp)
|
||||
) {
|
||||
AllInGradientButton(
|
||||
text = stringResource(id = R.string.Login),
|
||||
onClick = onClickLogin,
|
||||
modifier = Modifier
|
||||
)
|
||||
Spacer(modifier = Modifier.height(30.dp))
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.no_account),
|
||||
color = AllInTheme.themeColors.on_main_surface,
|
||||
fontSize = 15.sp,
|
||||
style = AllInTheme.typography.r,
|
||||
modifier = Modifier.padding(end = 5.dp)
|
||||
)
|
||||
ClickableText(
|
||||
text = AnnotatedString(stringResource(id = R.string.Register)),
|
||||
style = AllInTheme.typography.r.copy(
|
||||
color = AllInTheme.colors.allIn_Purple,
|
||||
fontSize = 15.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
) {
|
||||
onClickRegister()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,145 @@
|
||||
package fr.iut.alldev.allin.ui.register
|
||||
|
||||
import androidx.compose.foundation.*
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.relocation.BringIntoViewRequester
|
||||
import androidx.compose.foundation.text.ClickableText
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
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.KeyboardType
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import fr.iut.alldev.allin.R
|
||||
import fr.iut.alldev.allin.ui.core.AllInGradientButton
|
||||
import fr.iut.alldev.allin.ui.core.AllInPasswordField
|
||||
import fr.iut.alldev.allin.ui.core.AllInTextField
|
||||
import fr.iut.alldev.allin.ui.theme.AllInTheme
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun RegisterScreen(
|
||||
onClickRegister: ()->Unit,
|
||||
onClickLogin: ()->Unit
|
||||
) {
|
||||
var username by remember{
|
||||
mutableStateOf("")
|
||||
}
|
||||
val bringIntoViewRequester = remember { BringIntoViewRequester() }
|
||||
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxSize()
|
||||
.background(AllInTheme.themeColors.main_surface)
|
||||
.padding(horizontal = 44.dp)
|
||||
.verticalScroll(rememberScrollState())
|
||||
) {
|
||||
Column(
|
||||
Modifier.align(Alignment.Center)
|
||||
) {
|
||||
Text(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = stringResource(id = R.string.Hello_x, username),
|
||||
color = AllInTheme.themeColors.on_main_surface,
|
||||
style = AllInTheme.typography.h3,
|
||||
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.on_main_surface,
|
||||
style = AllInTheme.typography.h3,
|
||||
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.on_main_surface,
|
||||
style = AllInTheme.typography.r,
|
||||
textAlign = TextAlign.Center,
|
||||
fontSize = 30.sp
|
||||
)
|
||||
Spacer(modifier = Modifier.height(83.dp))
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(20.dp)
|
||||
) {
|
||||
AllInTextField(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
placeholder = stringResource(id = R.string.username),
|
||||
value = username,
|
||||
onValueChange = { username = it },
|
||||
maxChar = 20,
|
||||
bringIntoViewRequester = bringIntoViewRequester
|
||||
)
|
||||
AllInTextField(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
placeholder = stringResource(id = R.string.email),
|
||||
value = "",
|
||||
onValueChange = { },
|
||||
keyboardType = KeyboardType.Email,
|
||||
bringIntoViewRequester = bringIntoViewRequester
|
||||
)
|
||||
AllInPasswordField(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
placeholder = stringResource(id = R.string.password),
|
||||
value = "",
|
||||
onValueChange = { },
|
||||
bringIntoViewRequester = bringIntoViewRequester
|
||||
)
|
||||
AllInPasswordField(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
placeholder = stringResource(id = R.string.confirm_password),
|
||||
value = "",
|
||||
onValueChange = { },
|
||||
bringIntoViewRequester = bringIntoViewRequester
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(67.dp))
|
||||
}
|
||||
Column(
|
||||
Modifier
|
||||
.align(Alignment.BottomCenter)
|
||||
.padding(bottom = 32.dp)
|
||||
) {
|
||||
AllInGradientButton(
|
||||
text = stringResource(id = R.string.Register),
|
||||
onClick = onClickRegister
|
||||
)
|
||||
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.on_main_surface,
|
||||
fontSize = 15.sp,
|
||||
style = AllInTheme.typography.r,
|
||||
modifier = Modifier.padding(end = 5.dp)
|
||||
)
|
||||
ClickableText(
|
||||
text = AnnotatedString(stringResource(id = R.string.Login)),
|
||||
style = AllInTheme.typography.r.copy(
|
||||
color = AllInTheme.colors.allIn_Purple,
|
||||
fontSize = 15.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
) {
|
||||
onClickLogin()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package fr.iut.alldev.allin.ui.welcome
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
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.ui.core.AllInButton
|
||||
import fr.iut.alldev.allin.ui.theme.AllInTheme
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun WelcomeScreen(
|
||||
onClickJoin: ()->Unit,
|
||||
onClickLogin: ()->Unit
|
||||
) {
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.fillMaxHeight(.5f)
|
||||
.background(AllInTheme.colors.allIn_LoginGradient)
|
||||
)
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxSize()
|
||||
.background(
|
||||
Brush.verticalGradient(
|
||||
.2f to Color.Transparent,
|
||||
.5f to AllInTheme.themeColors.background
|
||||
)
|
||||
)
|
||||
){
|
||||
Column(
|
||||
Modifier
|
||||
.align(Alignment.BottomCenter)
|
||||
.fillMaxWidth()
|
||||
.fillMaxHeight(.5f)
|
||||
.padding(horizontal = 45.dp)
|
||||
){
|
||||
Text(
|
||||
text = stringResource(id = R.string.welcome_title),
|
||||
color = AllInTheme.themeColors.on_background,
|
||||
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.allIn_MainGradient
|
||||
)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(43.dp))
|
||||
Text(
|
||||
text = stringResource(id = R.string.welcome_subtitle),
|
||||
color = AllInTheme.themeColors.on_background,
|
||||
fontSize = 15.sp,
|
||||
style = AllInTheme.typography.r
|
||||
)
|
||||
Spacer(modifier = Modifier.height(78.dp))
|
||||
AllInButton(
|
||||
color = AllInTheme.themeColors.tint_1,
|
||||
text = stringResource(id = R.string.join),
|
||||
textColor = AllInTheme.themeColors.background,
|
||||
onClick = onClickJoin,
|
||||
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.tint_1,
|
||||
fontSize = 15.sp,
|
||||
style = AllInTheme.typography.r,
|
||||
modifier = Modifier.padding(end = 5.dp)
|
||||
)
|
||||
ClickableText(
|
||||
text = AnnotatedString(stringResource(id = R.string.Login)),
|
||||
style = AllInTheme.typography.r.copy(
|
||||
color = AllInTheme.themeColors.tint_1,
|
||||
fontSize = 15.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
){
|
||||
onClickLogin()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
@Composable
|
||||
private fun WelcomeScreenPreview() {
|
||||
AllInTheme{
|
||||
WelcomeScreen(onClickJoin = {}, onClickLogin = {})
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
#Mon Sep 18 15:30:53 CEST 2023
|
||||
#Mon Sep 25 00:27:11 CEST 2023
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
Loading…
Reference in new issue