@ -14,7 +14,8 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeContentPadding
import androidx.compose.foundation.layout.safeContentPadding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Close
import androidx.compose.material3.Icon
import androidx.compose.material3.Icon
@ -29,11 +30,12 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw. scale
import androidx.compose.ui.draw. clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
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.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.unit.sp
@ -112,17 +114,22 @@ fun BetConfirmationBottomSheetAnswer(
text = text . uppercase ( ) ,
text = text . uppercase ( ) ,
color = contentColor ?: color ,
color = contentColor ?: color ,
style = AllInTheme . typography . h1 ,
style = AllInTheme . typography . h1 ,
fontSize = 3 0 .sp ,
fontSize = 3 5 .sp ,
textAlign = TextAlign . Center ,
textAlign = TextAlign . Center ,
modifier = Modifier . align ( Alignment . Center )
maxLines = 2 ,
overflow = TextOverflow . Ellipsis ,
modifier = Modifier
. align ( Alignment . Center )
. padding ( horizontal = 64. dp )
)
)
AllInCard (
Box (
radius = 50. dp ,
modifier = Modifier
backgroundColor = contentColor ?: AllInColorToken . allInPurple ,
. align ( Alignment . CenterEnd )
modifier = Modifier . align ( Alignment . CenterEnd )
. clip ( RoundedCornerShape ( 50. dp ) )
. background ( contentColor ?: AllInColorToken . allInPurple )
. padding ( vertical = 4. dp , horizontal = 8. dp )
) {
) {
Box ( Modifier . padding ( vertical = 4. dp , horizontal = 8. dp ) ) {
Text (
Text (
text = " x ${odds.formatToSimple(locale)} " ,
text = " x ${odds.formatToSimple(locale)} " ,
color = backColor ,
color = backColor ,
@ -131,7 +138,6 @@ fun BetConfirmationBottomSheetAnswer(
}
}
}
}
}
}
}
}
}
@Composable
@Composable
@ -141,14 +147,20 @@ fun ConfirmationAnswers(
onClick : ( String ) -> Unit
onClick : ( String ) -> Unit
) {
) {
val configuration = LocalConfiguration . current
val configuration = LocalConfiguration . current
val locale =
val locale = remember { ConfigurationCompat . getLocales ( configuration ) . get ( 0 ) ?: Locale . getDefault ( ) }
remember { ConfigurationCompat . getLocales ( configuration ) . get ( 0 ) ?: Locale . getDefault ( ) }
val possibleAnswers = remember {
when ( val bet = betDetail . bet ) {
is CustomBet -> bet . possibleAnswers
is MatchBet -> listOf ( bet . nameTeam1 , bet . nameTeam2 )
is YesNoBet -> listOf ( YES _VALUE , NO _VALUE )
}
}
LazyColumn (
LazyColumn (
verticalArrangement = Arrangement . spacedBy ( 8. dp )
verticalArrangement = Arrangement . spacedBy ( 8. dp )
) {
) {
when ( betDetail . bet ) {
itemsIndexed ( possibleAnswers ) { idx , it ->
is CustomBet -> items ( ( betDetail . bet as CustomBet ) . possibleAnswers ) {
betDetail . getAnswerOfResponse ( it ) ?. let {
betDetail . getAnswerOfResponse ( it ) ?. let {
val opacity by animateFloatAsState (
val opacity by animateFloatAsState (
targetValue = if ( selectedAnswer != null && selectedAnswer != it . response ) . 5f else 1f ,
targetValue = if ( selectedAnswer != null && selectedAnswer != it . response ) . 5f else 1f ,
@ -159,102 +171,17 @@ fun ConfirmationAnswers(
text = it . response ,
text = it . response ,
odds = it . odds ,
odds = it . odds ,
locale = locale ,
locale = locale ,
color = if ( possibleAnswers . size == 2 && idx == 1 ) {
AllInColorToken . allInBarPink
} else {
AllInColorToken . allInBlue
} ,
onClick = { onClick ( it . response ) } ,
onClick = { onClick ( it . response ) } ,
isSelected = selectedAnswer == it . response ,
isSelected = selectedAnswer == it . response ,
modifier = Modifier . alpha ( opacity )
modifier = Modifier . alpha ( opacity )
)
)
}
}
}
}
is MatchBet -> {
val bet = ( betDetail . bet as MatchBet )
item {
betDetail . getAnswerOfResponse ( bet . nameTeam1 ) ?. let {
val opacity by animateFloatAsState (
targetValue = if ( selectedAnswer != null && selectedAnswer != it . response ) . 5f else 1f ,
label = " "
)
BetConfirmationBottomSheetAnswer (
text = it . response ,
odds = it . odds ,
locale = locale ,
onClick = { onClick ( it . response ) } ,
isSelected = selectedAnswer == it . response ,
modifier = Modifier . alpha ( opacity )
)
}
}
item {
betDetail . getAnswerOfResponse ( bet . nameTeam2 ) ?. let {
val opacity by animateFloatAsState (
targetValue = if ( selectedAnswer != null && selectedAnswer != it . response ) . 5f else 1f ,
label = " "
)
BetConfirmationBottomSheetAnswer (
text = it . response ,
color = AllInColorToken . allInBarPink ,
odds = it . odds ,
locale = locale ,
onClick = { onClick ( it . response ) } ,
isSelected = selectedAnswer == it . response ,
modifier = Modifier
. alpha ( opacity )
)
}
}
}
is YesNoBet -> {
item {
betDetail . getAnswerOfResponse ( YES _VALUE ) ?. let {
val opacity by animateFloatAsState (
targetValue = if ( selectedAnswer != null && selectedAnswer != it . response ) . 5f else 1f ,
label = " "
)
val scale by animateFloatAsState (
targetValue = if ( selectedAnswer != null && selectedAnswer != it . response ) . 95f else 1f ,
label = " "
)
BetConfirmationBottomSheetAnswer (
text = it . response ,
odds = it . odds ,
locale = locale ,
onClick = { onClick ( it . response ) } ,
isSelected = selectedAnswer == it . response ,
modifier = Modifier
. alpha ( opacity )
. scale ( scale )
)
}
}
item {
betDetail . getAnswerOfResponse ( NO _VALUE ) ?. let {
val opacity by animateFloatAsState (
targetValue = if ( selectedAnswer != null && selectedAnswer != it . response ) . 5f else 1f ,
label = " "
)
val scale by animateFloatAsState (
targetValue = if ( selectedAnswer != null && selectedAnswer != it . response ) . 95f else 1f ,
label = " "
)
BetConfirmationBottomSheetAnswer (
text = it . response ,
color = AllInColorToken . allInBarPink ,
odds = it . odds ,
locale = locale ,
onClick = { onClick ( it . response ) } ,
isSelected = selectedAnswer == it . response ,
modifier = Modifier
. alpha ( opacity )
. scale ( scale )
)
}
}
}
}
}
}
}
}
@ -326,7 +253,7 @@ fun BetConfirmationBottomSheetContent(
}
}
}
}
Text (
Text (
text = " Ce bet est arrivé à la date de fin. Vous devez à présent distribuer les gains en validant le pari gagnant. " ,
text = stringResource ( id = R . string . bet _confirmation _text ) ,
color = AllInColorToken . allInLightGrey200 ,
color = AllInColorToken . allInLightGrey200 ,
style = AllInTheme . typography . p2 ,
style = AllInTheme . typography . p2 ,
textAlign = TextAlign . Center
textAlign = TextAlign . Center
@ -335,8 +262,8 @@ fun BetConfirmationBottomSheetContent(
Spacer ( modifier = Modifier . height ( 16. dp ) )
Spacer ( modifier = Modifier . height ( 16. dp ) )
Text (
Text (
text = " Veuillez choisir la réponse finale : " ,
text = stringResource ( id = R . string . bet _confirmation _choose _response ) ,
fontSize = 20 .sp ,
fontSize = 18 .sp ,
color = AllInColorToken . white ,
color = AllInColorToken . white ,
style = AllInTheme . typography . h1 ,
style = AllInTheme . typography . h1 ,
modifier = Modifier . fillMaxWidth ( )
modifier = Modifier . fillMaxWidth ( )
@ -374,7 +301,7 @@ private fun BetConfirmationBottomSheetContentPreview() {
endBetDate = ZonedDateTime . now ( ) ,
endBetDate = ZonedDateTime . now ( ) ,
isPublic = true ,
isPublic = true ,
betStatus = BetStatus . FINISHED ,
betStatus = BetStatus . FINISHED ,
creator = " creator " ,
creator = " creator "
) ,
) ,
answers = listOf (
answers = listOf (
BetAnswerDetail (
BetAnswerDetail (
@ -389,7 +316,7 @@ private fun BetConfirmationBottomSheetContentPreview() {
totalStakes = 150 ,
totalStakes = 150 ,
totalParticipants = 1 ,
totalParticipants = 1 ,
highestStake = 150 ,
highestStake = 150 ,
odds = 2. 0 f
odds = 2. 255 f
)
)
) ,
) ,
participations = emptyList ( ) ,
participations = emptyList ( ) ,