Bet Creation Screen : Answer tab
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
6f9f6e5be0
commit
16c6cb2309
@ -0,0 +1,29 @@
|
||||
package fr.iut.alldev.allin.ext
|
||||
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.HelpOutline
|
||||
import androidx.compose.material.icons.filled.Edit
|
||||
import androidx.compose.material.icons.filled.SportsSoccer
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import fr.iut.alldev.allin.R
|
||||
import fr.iut.alldev.allin.data.model.BetType
|
||||
|
||||
@Composable
|
||||
fun BetType.getTitle(): String {
|
||||
return when (this) {
|
||||
BetType.YES_NO -> stringResource(id = R.string.yes_no)
|
||||
BetType.MATCH -> stringResource(id = R.string.sport_match)
|
||||
BetType.CUSTOM -> stringResource(id = R.string.custom_answers)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun BetType.getIcon(): ImageVector {
|
||||
return when (this) {
|
||||
BetType.YES_NO -> Icons.AutoMirrored.Default.HelpOutline
|
||||
BetType.MATCH -> Icons.Default.SportsSoccer
|
||||
BetType.CUSTOM -> Icons.Default.Edit
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package fr.iut.alldev.allin.ui.betcreation.components
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
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.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import fr.iut.alldev.allin.ui.core.AllInCoinCount
|
||||
import fr.iut.alldev.allin.ui.core.AllInRadioButton
|
||||
import fr.iut.alldev.allin.ui.core.ProfilePicture
|
||||
import fr.iut.alldev.allin.ui.theme.AllInTheme
|
||||
|
||||
@Composable
|
||||
fun BetCreationScreenFriendLine(
|
||||
username: String,
|
||||
allCoinsAmount: Int,
|
||||
isSelected: Boolean,
|
||||
onClick: ()->Unit
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable(onClick = onClick)
|
||||
.background(
|
||||
if (isSelected) AllInTheme.colors.allIn_Purple.copy(alpha = .13f)
|
||||
else AllInTheme.themeColors.background
|
||||
)
|
||||
.padding(15.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(7.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
AllInRadioButton(
|
||||
checked = isSelected,
|
||||
modifier = Modifier.padding(end = 7.dp)
|
||||
)
|
||||
ProfilePicture(modifier = Modifier.size(25.dp))
|
||||
Text(
|
||||
text = username,
|
||||
fontWeight = FontWeight.Bold,
|
||||
style = AllInTheme.typography.h2,
|
||||
color = AllInTheme.themeColors.on_main_surface,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
AllInCoinCount(
|
||||
amount = allCoinsAmount,
|
||||
color = AllInTheme.colors.allIn_Purple
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
@Composable
|
||||
private fun BetCreationScreenFriendLinePreview() {
|
||||
AllInTheme {
|
||||
BetCreationScreenFriendLine(
|
||||
username = "David",
|
||||
allCoinsAmount = 542,
|
||||
isSelected = false) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
@Composable
|
||||
private fun BetCreationScreenFriendLineSelectedPreview() {
|
||||
AllInTheme {
|
||||
BetCreationScreenFriendLine(
|
||||
username = "David",
|
||||
allCoinsAmount = 542,
|
||||
isSelected = true) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,30 +1,54 @@
|
||||
package fr.iut.alldev.allin.ui.betcreation.tabs
|
||||
|
||||
import android.util.Log
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.QuestionAnswer
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import fr.iut.alldev.allin.R
|
||||
import fr.iut.alldev.allin.ui.core.AllInTextAndIcon
|
||||
import fr.iut.alldev.allin.data.model.BetType
|
||||
import fr.iut.alldev.allin.ext.getTitle
|
||||
import fr.iut.alldev.allin.ui.betcreation.components.BetCreationScreenBottomText
|
||||
import fr.iut.alldev.allin.ui.core.AllInSelectionBox
|
||||
import fr.iut.alldev.allin.ui.core.SelectionElement
|
||||
|
||||
@Composable
|
||||
fun BetCreationScreenAnswerTab() {
|
||||
Column(
|
||||
Modifier
|
||||
.fillMaxSize()
|
||||
.padding(20.dp)
|
||||
fun BetCreationScreenAnswerTab(
|
||||
modifier: Modifier = Modifier,
|
||||
selected: SelectionElement,
|
||||
selectedBetType: BetType,
|
||||
setSelected: (SelectionElement)->Unit,
|
||||
elements: List<SelectionElement>
|
||||
) {
|
||||
AllInTextAndIcon(
|
||||
text = stringResource(id = R.string.Answer),
|
||||
icon = Icons.Outlined.QuestionAnswer
|
||||
var isOpen by remember{
|
||||
mutableStateOf(false)
|
||||
}
|
||||
|
||||
Column(modifier) {
|
||||
AllInSelectionBox(
|
||||
isOpen = isOpen,
|
||||
setIsOpen = { isOpen = it },
|
||||
selected = selected,
|
||||
setSelected = setSelected,
|
||||
elements = elements
|
||||
)
|
||||
Spacer(modifier = Modifier.height(26.dp))
|
||||
when(selectedBetType){
|
||||
BetType.YES_NO -> {
|
||||
Column(
|
||||
modifier = Modifier.padding(vertical = 20.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(17.dp)
|
||||
) {
|
||||
Log.d("ALLINNN", "AAAA")
|
||||
BetCreationScreenBottomText(text = stringResource(id = R.string.yes_no_bottom_text_1))
|
||||
BetCreationScreenBottomText(text = stringResource(id = R.string.yes_no_bottom_text_2))
|
||||
}
|
||||
}
|
||||
BetType.MATCH -> {
|
||||
BetCreationScreenBottomText(text = selectedBetType.getTitle())
|
||||
}
|
||||
BetType.CUSTOM -> {
|
||||
BetCreationScreenBottomText(text = selectedBetType.getTitle())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package fr.iut.alldev.allin.ui.core
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.size
|
||||
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.graphics.Color
|
||||
import androidx.compose.ui.res.painterResource
|
||||
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.theme.AllInTheme
|
||||
|
||||
@Composable
|
||||
fun AllInCoinCount(
|
||||
modifier: Modifier = Modifier,
|
||||
amount: Int,
|
||||
color: Color
|
||||
) {
|
||||
Row(
|
||||
modifier = modifier,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(7.dp)
|
||||
) {
|
||||
Text(
|
||||
text = amount.toString(),
|
||||
fontWeight = FontWeight.ExtraBold,
|
||||
color = color,
|
||||
style = AllInTheme.typography.h1,
|
||||
fontSize = 16.sp
|
||||
)
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.allcoin),
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.size(13.dp),
|
||||
tint = color
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
@Composable
|
||||
private fun AllInCoinCountPreview() {
|
||||
AllInTheme {
|
||||
AllInCoinCount(amount = 542, color = AllInTheme.colors.allIn_Purple)
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package fr.iut.alldev.allin.ui.core
|
||||
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import fr.iut.alldev.allin.ui.theme.AllInTheme
|
||||
|
||||
@Composable
|
||||
fun AllInRadioButton(
|
||||
modifier: Modifier = Modifier,
|
||||
checked: Boolean,
|
||||
unCheckedColor: Color = Color.Transparent
|
||||
) {
|
||||
AllInCard(
|
||||
radius = 100.dp,
|
||||
borderColor = AllInTheme.colors.allIn_Mint,
|
||||
borderWidth = if(!checked) 1.dp else null,
|
||||
backgroundColor = if (checked) AllInTheme.colors.allIn_Purple else unCheckedColor,
|
||||
modifier = modifier.size(12.dp)
|
||||
){}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun AllInRadioButtonNotCheckedPreview() {
|
||||
AllInTheme {
|
||||
AllInRadioButton(checked = false)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun AllInRadioButtonNotCheckedFilledPreview() {
|
||||
AllInTheme {
|
||||
AllInRadioButton(checked = false, unCheckedColor = AllInTheme.colors.allIn_Mint)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun AllInRadioButtonCheckedPreview() {
|
||||
AllInTheme {
|
||||
AllInRadioButton(checked = true)
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package fr.iut.alldev.allin.ui.core
|
||||
|
||||
import androidx.compose.animation.animateContentSize
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ExpandLess
|
||||
import androidx.compose.material.icons.filled.ExpandMore
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import fr.iut.alldev.allin.ui.theme.AllInTheme
|
||||
|
||||
@Composable
|
||||
fun AllInRetractableCard(
|
||||
modifier: Modifier = Modifier,
|
||||
text: String,
|
||||
boldText: String = "",
|
||||
isOpen: Boolean,
|
||||
setIsOpen: (Boolean)->Unit,
|
||||
borderWidth: Dp? = null,
|
||||
interactionSource: MutableInteractionSource = MutableInteractionSource(),
|
||||
content: @Composable ()->Unit
|
||||
) {
|
||||
AllInCard(
|
||||
modifier = modifier,
|
||||
borderWidth = borderWidth,
|
||||
borderColor = AllInTheme.colors.allIn_Purple.copy(.5f)
|
||||
){
|
||||
Column(
|
||||
Modifier.animateContentSize()
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.clickable(
|
||||
interactionSource = interactionSource,
|
||||
indication = null,
|
||||
onClick = { setIsOpen(!isOpen) }
|
||||
)
|
||||
.padding(horizontal = 12.dp, vertical = 10.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(7.dp)
|
||||
) {
|
||||
HighlightedText(
|
||||
text = text,
|
||||
query = boldText,
|
||||
highlightStyle = SpanStyle(
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = AllInTheme.themeColors.on_main_surface,
|
||||
fontStyle = AllInTheme.typography.h2.fontStyle
|
||||
),
|
||||
color = AllInTheme.themeColors.on_background_2,
|
||||
style = AllInTheme.typography.r,
|
||||
fontSize = 16.sp,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
Icon(
|
||||
imageVector = with(Icons.Default){
|
||||
if(isOpen) ExpandLess else ExpandMore
|
||||
},
|
||||
contentDescription = null,
|
||||
tint = AllInTheme.colors.allIn_Purple,
|
||||
modifier = Modifier.size(30.dp)
|
||||
)
|
||||
}
|
||||
if(isOpen){
|
||||
HorizontalDivider(color = AllInTheme.themeColors.border)
|
||||
content()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,156 @@
|
||||
package fr.iut.alldev.allin.ui.core
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.animation.animateContentSize
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.HelpOutline
|
||||
import androidx.compose.material.icons.filled.*
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
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.vector.ImageVector
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import fr.iut.alldev.allin.ui.theme.AllInTheme
|
||||
|
||||
|
||||
class SelectionElement(
|
||||
val text: String,
|
||||
val iconVector: ImageVector
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun AllInSelectionLine(
|
||||
text: String,
|
||||
iconVector: ImageVector,
|
||||
modifier: Modifier = Modifier,
|
||||
onClick: ()->Unit,
|
||||
trailingIcon: ImageVector? = null,
|
||||
interactionSource: MutableInteractionSource
|
||||
){
|
||||
Row(
|
||||
modifier = modifier
|
||||
.clickable(
|
||||
interactionSource = interactionSource,
|
||||
indication = null,
|
||||
onClick = onClick
|
||||
)
|
||||
.padding(horizontal = 12.dp, vertical = 10.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(7.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = iconVector,
|
||||
contentDescription = null,
|
||||
tint = AllInTheme.colors.allIn_Purple,
|
||||
modifier = Modifier.size(20.dp)
|
||||
)
|
||||
Text(
|
||||
text = text,
|
||||
color = AllInTheme.colors.allIn_Purple,
|
||||
style = AllInTheme.typography.h2,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
trailingIcon?.let {
|
||||
Icon(
|
||||
imageVector = trailingIcon,
|
||||
contentDescription = null,
|
||||
tint = AllInTheme.colors.allIn_Purple,
|
||||
modifier = Modifier
|
||||
.size(30.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
fun AllInSelectionBox(
|
||||
modifier: Modifier = Modifier,
|
||||
isOpen: Boolean,
|
||||
setIsOpen: (Boolean)->Unit,
|
||||
selected: SelectionElement,
|
||||
setSelected: (SelectionElement)->Unit,
|
||||
elements: List<SelectionElement>
|
||||
) {
|
||||
val interactionSource = remember { MutableInteractionSource() }
|
||||
AllInCard(modifier){
|
||||
Column(
|
||||
Modifier.animateContentSize()
|
||||
) {
|
||||
AllInSelectionLine(
|
||||
text = selected.text,
|
||||
iconVector = selected.iconVector,
|
||||
onClick = { setIsOpen(!isOpen) },
|
||||
interactionSource = interactionSource,
|
||||
trailingIcon = with(Icons.Default){
|
||||
if(isOpen) ExpandLess else ExpandMore
|
||||
}
|
||||
)
|
||||
if(isOpen){
|
||||
HorizontalDivider(color = AllInTheme.themeColors.border)
|
||||
elements.filter { it != selected }.forEach{
|
||||
element ->
|
||||
AllInSelectionLine(
|
||||
text = element.text,
|
||||
iconVector = element.iconVector,
|
||||
interactionSource = interactionSource,
|
||||
onClick = {
|
||||
setSelected(element)
|
||||
setIsOpen(false)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
@Composable
|
||||
private fun AllInSelectionBoxClosedPreview() {
|
||||
AllInTheme {
|
||||
val elements = listOf(
|
||||
SelectionElement("Oui/Non", Icons.AutoMirrored.Default.HelpOutline),
|
||||
SelectionElement("Sport", Icons.Default.SportsFootball),
|
||||
SelectionElement("Perso", Icons.Default.PinEnd)
|
||||
)
|
||||
AllInSelectionBox(
|
||||
isOpen = false,
|
||||
selected = elements[0],
|
||||
elements = elements,
|
||||
setSelected = {},
|
||||
setIsOpen = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
@Composable
|
||||
private fun AllInSelectionBoxOpenPreview() {
|
||||
AllInTheme {
|
||||
val elements = listOf(
|
||||
SelectionElement("Oui/Non", Icons.AutoMirrored.Default.HelpOutline),
|
||||
SelectionElement("Sport", Icons.Default.SportsFootball),
|
||||
SelectionElement("Perso", Icons.Default.Edit)
|
||||
)
|
||||
AllInSelectionBox(
|
||||
isOpen = true,
|
||||
selected = elements[0],
|
||||
elements = elements,
|
||||
setSelected = {},
|
||||
setIsOpen = {},
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package fr.iut.alldev.allin.data.model
|
||||
|
||||
enum class BetType {
|
||||
YES_NO,
|
||||
MATCH,
|
||||
CUSTOM
|
||||
}
|
Loading…
Reference in new issue