Doing some refactoring
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
7ccef99118
commit
455cec10ae
@ -0,0 +1,109 @@
|
||||
package fr.iut.alldev.allin.ui.bet.components
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.ripple.LocalRippleTheme
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Alignment.Companion.CenterHorizontally
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.painter.Painter
|
||||
import androidx.compose.ui.res.pluralStringResource
|
||||
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.ui.core.AllInCard
|
||||
import fr.iut.alldev.allin.ui.core.RainbowButton
|
||||
import fr.iut.alldev.allin.ui.core.bet.BetDateTimeRow
|
||||
import fr.iut.alldev.allin.ui.core.bet.BetProfilePictureRow
|
||||
import fr.iut.alldev.allin.ui.core.bet.BetTitleHeader
|
||||
import fr.iut.alldev.allin.ui.theme.AllInRippleTheme
|
||||
import fr.iut.alldev.allin.ui.theme.AllInTheme
|
||||
|
||||
@Composable
|
||||
fun BetScreenCard(
|
||||
creator: String,
|
||||
category: String,
|
||||
title: String,
|
||||
date: String,
|
||||
time: String,
|
||||
players: List<Painter?>,
|
||||
modifier: Modifier = Modifier,
|
||||
onClickParticipate: ()->Unit
|
||||
) {
|
||||
AllInCard(
|
||||
modifier = modifier,
|
||||
radius = 16.dp
|
||||
){
|
||||
Column(
|
||||
Modifier.padding(horizontal = 19.dp, vertical = 11.dp)
|
||||
) {
|
||||
BetTitleHeader(
|
||||
title = title,
|
||||
category = category,
|
||||
creator = creator,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
Spacer(modifier = Modifier.height(11.dp))
|
||||
BetDateTimeRow(label = stringResource(id = R.string.Starting), date = date, time = time)
|
||||
}
|
||||
HorizontalDivider(
|
||||
thickness = 1.dp,
|
||||
color = AllInTheme.themeColors.border
|
||||
)
|
||||
Column(
|
||||
Modifier
|
||||
.background(AllInTheme.themeColors.background_2)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.align(CenterHorizontally)
|
||||
.padding(7.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
){
|
||||
BetProfilePictureRow(pictures = players)
|
||||
Spacer(modifier = Modifier.width(12.dp))
|
||||
Text(
|
||||
text = pluralStringResource(
|
||||
id = R.plurals.n_players_waiting,
|
||||
players.size,
|
||||
players.size
|
||||
),
|
||||
style = AllInTheme.typography.m,
|
||||
color = AllInTheme.themeColors.on_background_2
|
||||
)
|
||||
}
|
||||
CompositionLocalProvider(
|
||||
LocalRippleTheme provides AllInRippleTheme,
|
||||
){
|
||||
RainbowButton(
|
||||
modifier = Modifier.padding(6.dp),
|
||||
text = stringResource(id = R.string.Participate),
|
||||
onClick = onClickParticipate
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
@Composable
|
||||
private fun BetScreenCardPreview() {
|
||||
AllInTheme {
|
||||
BetScreenCard(
|
||||
creator = "Lucas",
|
||||
category = "Études",
|
||||
title = "Emre va réussir son TP de CI/CD mercredi?",
|
||||
date = "12 Sept.",
|
||||
time = "13:00",
|
||||
players = List(3){ null },
|
||||
onClickParticipate = {}
|
||||
)
|
||||
}
|
||||
}
|
@ -1,165 +0,0 @@
|
||||
package fr.iut.alldev.allin.ui.bet.components
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.ripple.LocalRippleTheme
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Alignment.Companion.CenterEnd
|
||||
import androidx.compose.ui.Alignment.Companion.CenterHorizontally
|
||||
import androidx.compose.ui.Modifier
|
||||
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 androidx.compose.ui.zIndex
|
||||
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.core.ProfilePicture
|
||||
import fr.iut.alldev.allin.ui.core.RainbowButton
|
||||
import fr.iut.alldev.allin.ui.theme.AllInRippleTheme
|
||||
import fr.iut.alldev.allin.ui.theme.AllInTheme
|
||||
|
||||
@Composable
|
||||
fun BetScreenCard(
|
||||
creator: String,
|
||||
category: String,
|
||||
title: String,
|
||||
date: String,
|
||||
time: String,
|
||||
nbPlayer: Int,
|
||||
modifier: Modifier = Modifier,
|
||||
onClickParticipate: ()->Unit
|
||||
) {
|
||||
AllInCard(
|
||||
modifier = modifier,
|
||||
radius = 16.dp
|
||||
){
|
||||
Column(Modifier.fillMaxWidth()) {
|
||||
Row(
|
||||
Modifier
|
||||
.align(Alignment.End)
|
||||
.padding(top = 12.dp, end = 10.dp)) {
|
||||
HighlightedText(
|
||||
text = stringResource(id = R.string.Proposed_by_x, creator),
|
||||
query = creator,
|
||||
highlightStyle = SpanStyle(
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = AllInTheme.themeColors.on_main_surface
|
||||
),
|
||||
fontSize = 12.sp,
|
||||
style = AllInTheme.typography.s,
|
||||
color = AllInTheme.themeColors.on_background_2
|
||||
)
|
||||
}
|
||||
Column(Modifier.padding(horizontal = 19.dp, vertical = 11.dp)) {
|
||||
Text(
|
||||
text = category,
|
||||
fontSize = 15.sp,
|
||||
color = AllInTheme.themeColors.on_background_2,
|
||||
style = AllInTheme.typography.m
|
||||
)
|
||||
Text(
|
||||
text = title,
|
||||
fontSize = 20.sp,
|
||||
color = AllInTheme.themeColors.on_main_surface,
|
||||
style = AllInTheme.typography.h1
|
||||
)
|
||||
Spacer(modifier = Modifier.height(11.dp))
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.Starting),
|
||||
fontSize = 15.sp,
|
||||
style = AllInTheme.typography.m,
|
||||
color = AllInTheme.themeColors.on_background_2
|
||||
)
|
||||
DateTimeChip(
|
||||
text = date,
|
||||
modifier = Modifier.padding(horizontal = 8.dp)
|
||||
)
|
||||
DateTimeChip(time)
|
||||
}
|
||||
}
|
||||
HorizontalDivider(
|
||||
thickness = 1.dp,
|
||||
color = AllInTheme.themeColors.border
|
||||
)
|
||||
Column(
|
||||
Modifier
|
||||
.background(AllInTheme.themeColors.background_2)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.align(CenterHorizontally)
|
||||
.padding(7.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
){
|
||||
val nRepeat = remember{
|
||||
if (nbPlayer > 5) 5 else nbPlayer
|
||||
}
|
||||
|
||||
Box(
|
||||
Modifier.width((nRepeat*17).dp)
|
||||
){
|
||||
repeat(nRepeat) {
|
||||
ProfilePicture(
|
||||
size = 35.dp,
|
||||
modifier = Modifier
|
||||
.align(CenterEnd)
|
||||
.offset(x = (it * -17).dp)
|
||||
.zIndex(-it.toFloat())
|
||||
)
|
||||
}
|
||||
}
|
||||
Spacer(modifier = Modifier.width(12.dp))
|
||||
Text(
|
||||
text = pluralStringResource(
|
||||
id = R.plurals.n_players_waiting,
|
||||
nbPlayer,
|
||||
nbPlayer
|
||||
),
|
||||
style = AllInTheme.typography.m,
|
||||
color = AllInTheme.themeColors.on_background_2
|
||||
)
|
||||
}
|
||||
CompositionLocalProvider(
|
||||
LocalRippleTheme provides AllInRippleTheme,
|
||||
){
|
||||
RainbowButton(
|
||||
modifier = Modifier.padding(6.dp),
|
||||
text = stringResource(id = R.string.Participate),
|
||||
onClick = onClickParticipate
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
@Composable
|
||||
private fun BetScreenCardPreview() {
|
||||
AllInTheme {
|
||||
BetScreenCard(
|
||||
creator = "Lucas",
|
||||
category = "Études",
|
||||
title = "Emre va réussir son TP de CI/CD mercredi?",
|
||||
date = "12 Sept.",
|
||||
time = "13:00",
|
||||
nbPlayer = 4,
|
||||
onClickParticipate = {}
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package fr.iut.alldev.allin.ui.core.bet
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
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 BetDateTimeRow(
|
||||
label: String,
|
||||
date: String,
|
||||
time: String,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
modifier = modifier
|
||||
) {
|
||||
Text(
|
||||
text = label,
|
||||
fontSize = 15.sp,
|
||||
style = AllInTheme.typography.m,
|
||||
color = AllInTheme.themeColors.on_background_2
|
||||
)
|
||||
BetDateTimeChip(date)
|
||||
BetDateTimeChip(time)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
@Composable
|
||||
private fun BetDateTimeRowPreview() {
|
||||
AllInTheme{
|
||||
BetDateTimeRow(label = "Commence le", date = "11 Sept.", time = "13:00")
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package fr.iut.alldev.allin.ui.core.bet
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.offset
|
||||
import androidx.compose.foundation.layout.width
|
||||
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.painter.Painter
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.zIndex
|
||||
import fr.iut.alldev.allin.R
|
||||
import fr.iut.alldev.allin.ui.core.ProfilePicture
|
||||
import fr.iut.alldev.allin.ui.theme.AllInTheme
|
||||
|
||||
@Composable
|
||||
fun BetProfilePictureRow(
|
||||
pictures: List<Painter?>,
|
||||
maxLength: Int = 5,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val nRepeat = remember{
|
||||
if (pictures.size > maxLength) maxLength else pictures.size
|
||||
}
|
||||
|
||||
Box(
|
||||
modifier.width((nRepeat*17).dp)
|
||||
){
|
||||
pictures.forEachIndexed { index, painter ->
|
||||
ProfilePicture(
|
||||
image = painter,
|
||||
size = 35.dp,
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterEnd)
|
||||
.offset(x = (index * -17).dp)
|
||||
.zIndex(-index.toFloat())
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun BetProfilePictureRowPreview() {
|
||||
AllInTheme {
|
||||
BetProfilePictureRow(pictures = listOf(
|
||||
painterResource(id = R.drawable.money_with_wings),
|
||||
null,
|
||||
painterResource(id = R.drawable.money_with_wings)
|
||||
))
|
||||
}
|
||||
}
|
||||
@Preview
|
||||
@Composable
|
||||
private fun BetProfilePictureRowMaxPreview() {
|
||||
AllInTheme {
|
||||
BetProfilePictureRow(pictures = listOf(
|
||||
painterResource(id = R.drawable.money_with_wings),
|
||||
null,
|
||||
painterResource(id = R.drawable.money_with_wings),
|
||||
null,
|
||||
painterResource(id = R.drawable.money_with_wings),
|
||||
null
|
||||
))
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package fr.iut.alldev.allin.ui.core.bet
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.layout.*
|
||||
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.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.HighlightedText
|
||||
import fr.iut.alldev.allin.ui.theme.AllInTheme
|
||||
|
||||
@Composable
|
||||
fun BetTitleHeader(
|
||||
title: String,
|
||||
category: String,
|
||||
creator: String,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Column(modifier) {
|
||||
Row(
|
||||
Modifier.align(Alignment.End)
|
||||
) {
|
||||
HighlightedText(
|
||||
text = stringResource(id = R.string.Proposed_by_x, creator),
|
||||
query = creator,
|
||||
highlightStyle = SpanStyle(
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = AllInTheme.themeColors.on_main_surface
|
||||
),
|
||||
fontSize = 12.sp,
|
||||
style = AllInTheme.typography.s,
|
||||
color = AllInTheme.themeColors.on_background_2
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(11.dp))
|
||||
Text(
|
||||
text = category,
|
||||
fontSize = 15.sp,
|
||||
color = AllInTheme.themeColors.on_background_2,
|
||||
style = AllInTheme.typography.m
|
||||
)
|
||||
Text(
|
||||
text = title,
|
||||
fontSize = 20.sp,
|
||||
color = AllInTheme.themeColors.on_main_surface,
|
||||
style = AllInTheme.typography.h1
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
@Composable
|
||||
private fun BetTitleHeaderPreview() {
|
||||
AllInTheme {
|
||||
BetTitleHeader(title = "Emre va réussir son TP de CI/CD mercredi?", category = "Études", creator = "Lucas")
|
||||
}
|
||||
}
|
Loading…
Reference in new issue