From 6f9f6e5be078aa7b5006a9235e700c6022e72e9a Mon Sep 17 00:00:00 2001 From: "arthur.valin" Date: Thu, 28 Sep 2023 23:19:55 +0200 Subject: [PATCH] Bet Creation Screen, starting Question Tab --- .../allin/ui/bet/components/BetScreenCard.kt | 17 +-- .../allin/ui/betcreation/BetCreationScreen.kt | 27 +++- .../components/BetCreationScreenBottomText.kt | 31 +++++ .../tabs/BetCreationScreenAnswerTab.kt | 23 +++- .../tabs/BetCreationScreenQuestionTab.kt | 125 ++++++++++++++---- .../iut/alldev/allin/ui/core/AllInRipple.kt | 18 +++ .../iut/alldev/allin/ui/core/AllInSections.kt | 94 ++++++++++++- .../alldev/allin/ui/core/AllInTextAndIcon.kt | 71 ++++++++++ .../alldev/allin/ui/core/AllInTextField.kt | 41 ++++-- .../iut/alldev/allin/ui/core/RainbowButton.kt | 54 ++++---- .../fr/iut/alldev/allin/ui/theme/Theme.kt | 6 +- src/app/src/main/res/values-fr/strings.xml | 16 +++ src/app/src/main/res/values/strings.xml | 16 +++ 13 files changed, 453 insertions(+), 86 deletions(-) create mode 100644 src/app/src/main/java/fr/iut/alldev/allin/ui/betcreation/components/BetCreationScreenBottomText.kt create mode 100644 src/app/src/main/java/fr/iut/alldev/allin/ui/core/AllInRipple.kt create mode 100644 src/app/src/main/java/fr/iut/alldev/allin/ui/core/AllInTextAndIcon.kt diff --git a/src/app/src/main/java/fr/iut/alldev/allin/ui/bet/components/BetScreenCard.kt b/src/app/src/main/java/fr/iut/alldev/allin/ui/bet/components/BetScreenCard.kt index 52b160c..ba72072 100644 --- a/src/app/src/main/java/fr/iut/alldev/allin/ui/bet/components/BetScreenCard.kt +++ b/src/app/src/main/java/fr/iut/alldev/allin/ui/bet/components/BetScreenCard.kt @@ -3,11 +3,9 @@ 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 @@ -22,7 +20,6 @@ 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 @@ -78,15 +75,11 @@ fun BetScreenCard( color = AllInTheme.themeColors.on_background_2 ) } - CompositionLocalProvider( - LocalRippleTheme provides AllInRippleTheme, - ){ - RainbowButton( - modifier = Modifier.padding(6.dp), - text = stringResource(id = R.string.Participate), - onClick = onClickParticipate - ) - } + RainbowButton( + modifier = Modifier.padding(6.dp), + text = stringResource(id = R.string.Participate), + onClick = onClickParticipate + ) } } } diff --git a/src/app/src/main/java/fr/iut/alldev/allin/ui/betcreation/BetCreationScreen.kt b/src/app/src/main/java/fr/iut/alldev/allin/ui/betcreation/BetCreationScreen.kt index d4ce957..a429869 100644 --- a/src/app/src/main/java/fr/iut/alldev/allin/ui/betcreation/BetCreationScreen.kt +++ b/src/app/src/main/java/fr/iut/alldev/allin/ui/betcreation/BetCreationScreen.kt @@ -3,7 +3,7 @@ package fr.iut.alldev.allin.ui.betcreation import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding -import androidx.compose.runtime.Composable +import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource @@ -16,11 +16,23 @@ import fr.iut.alldev.allin.ui.core.RainbowButton import fr.iut.alldev.allin.ui.core.SectionElement @Composable -fun BetCreationScreen() { +fun BetCreationScreen( + +) { + + var theme by remember{ + mutableStateOf("") + } + var phrase by remember{ + mutableStateOf("") + } + var isPublic by remember{ + mutableStateOf(true) + } Box( Modifier .fillMaxSize() - .padding(horizontal = 30.dp, vertical = 20.dp) + .padding(20.dp) ) { AllInSections( modifier = Modifier @@ -28,7 +40,14 @@ fun BetCreationScreen() { .fillMaxSize(), sections = listOf( SectionElement(stringResource(id = R.string.Question)){ - BetCreationScreenQuestionTab() + BetCreationScreenQuestionTab( + isPublic = isPublic, + setIsPublic = { isPublic = it }, + betPhrase = phrase, + setBetPhrase = { phrase = it }, + betTheme = theme, + setBetTheme = { theme = it } + ) }, SectionElement(stringResource(id = R.string.Answer)){ BetCreationScreenAnswerTab() diff --git a/src/app/src/main/java/fr/iut/alldev/allin/ui/betcreation/components/BetCreationScreenBottomText.kt b/src/app/src/main/java/fr/iut/alldev/allin/ui/betcreation/components/BetCreationScreenBottomText.kt new file mode 100644 index 0000000..fc214ea --- /dev/null +++ b/src/app/src/main/java/fr/iut/alldev/allin/ui/betcreation/components/BetCreationScreenBottomText.kt @@ -0,0 +1,31 @@ +package fr.iut.alldev.allin.ui.betcreation.components + +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.alpha +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.tooling.preview.Preview +import fr.iut.alldev.allin.ui.theme.AllInTheme + +@Composable +fun BetCreationScreenBottomText( + text: String, + modifier: Modifier = Modifier +) { + Text( + text = text, + color = AllInTheme.colors.allIn_Purple, + fontWeight = FontWeight.Bold, + style = AllInTheme.typography.h2, + modifier = modifier.alpha(.5f) + ) +} + +@Preview +@Composable +private fun BetCreationScreenBottomTextPreview() { + AllInTheme { + BetCreationScreenBottomText("Lorem Ipsum...") + } +} \ No newline at end of file diff --git a/src/app/src/main/java/fr/iut/alldev/allin/ui/betcreation/tabs/BetCreationScreenAnswerTab.kt b/src/app/src/main/java/fr/iut/alldev/allin/ui/betcreation/tabs/BetCreationScreenAnswerTab.kt index df5a4c1..27ad1f2 100644 --- a/src/app/src/main/java/fr/iut/alldev/allin/ui/betcreation/tabs/BetCreationScreenAnswerTab.kt +++ b/src/app/src/main/java/fr/iut/alldev/allin/ui/betcreation/tabs/BetCreationScreenAnswerTab.kt @@ -1,11 +1,30 @@ package fr.iut.alldev.allin.ui.betcreation.tabs -import androidx.compose.material3.Text +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.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 @Composable fun BetCreationScreenAnswerTab() { - Text(text = stringResource(id = R.string.Answer)) + Column( + Modifier + .fillMaxSize() + .padding(20.dp) + ) { + AllInTextAndIcon( + text = stringResource(id = R.string.Answer), + icon = Icons.Outlined.QuestionAnswer + ){ + Log.d("ALLINNN", "AAAA") + } + } } \ No newline at end of file diff --git a/src/app/src/main/java/fr/iut/alldev/allin/ui/betcreation/tabs/BetCreationScreenQuestionTab.kt b/src/app/src/main/java/fr/iut/alldev/allin/ui/betcreation/tabs/BetCreationScreenQuestionTab.kt index ac4311e..af16752 100644 --- a/src/app/src/main/java/fr/iut/alldev/allin/ui/betcreation/tabs/BetCreationScreenQuestionTab.kt +++ b/src/app/src/main/java/fr/iut/alldev/allin/ui/betcreation/tabs/BetCreationScreenQuestionTab.kt @@ -1,43 +1,116 @@ package fr.iut.alldev.allin.ui.betcreation.tabs -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.relocation.BringIntoViewRequester import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.outlined.HelpOutline import androidx.compose.material.icons.filled.Lock import androidx.compose.material.icons.filled.Public -import androidx.compose.material3.Text import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp import fr.iut.alldev.allin.R +import fr.iut.alldev.allin.ui.betcreation.components.BetCreationScreenBottomText import fr.iut.alldev.allin.ui.core.AllInIconChip +import fr.iut.alldev.allin.ui.core.AllInTextAndIcon +import fr.iut.alldev.allin.ui.core.AllInTextField +import fr.iut.alldev.allin.ui.theme.AllInTheme +@OptIn(ExperimentalFoundationApi::class) @Composable -fun BetCreationScreenQuestionTab() { - Column(Modifier.padding(20.dp)){ - var isPublic by remember{ - mutableStateOf(true) - } - Text(text = stringResource(id = R.string.Question)) - Spacer(modifier = Modifier.height(7.dp)) - AllInIconChip( - text = "Public", - leadingIcon = Icons.Default.Public, - onClick = { - isPublic = true - }, - isSelected = isPublic +fun BetCreationScreenQuestionTab( + betTheme: String, + setBetTheme: (String)->Unit, + betPhrase: String, + setBetPhrase: (String)->Unit, + isPublic: Boolean, + setIsPublic: (Boolean)->Unit +) { + val bringIntoViewRequester = remember { BringIntoViewRequester() } + Column( + Modifier + .fillMaxSize() + .padding(20.dp) + ){ + AllInTextAndIcon( + text = stringResource(id = R.string.Theme), + icon = Icons.AutoMirrored.Outlined.HelpOutline, + modifier = Modifier.padding(start = 11.dp, bottom = 8.dp), + onClick = {} + ) + AllInTextField( + placeholder = stringResource(id = R.string.Theme_placeholder), + value = betPhrase, + onValueChange = setBetPhrase, + bringIntoViewRequester = bringIntoViewRequester, + borderColor = AllInTheme.colors.white, + maxChar = 20, + placeholderFontSize = 13.sp, + modifier = Modifier.fillMaxWidth() + ) + Spacer(modifier = Modifier.height(12.dp)) + AllInTextAndIcon( + text = stringResource(id = R.string.Bet_Phrase), + icon = Icons.AutoMirrored.Outlined.HelpOutline, + modifier = Modifier.padding(start = 11.dp, bottom = 8.dp), + onClick = {} + ) + AllInTextField( + placeholder = stringResource(id = R.string.Bet_Phrase_placeholder), + value = betTheme, + borderColor = AllInTheme.colors.white, + onValueChange = setBetTheme, + bringIntoViewRequester = bringIntoViewRequester, + multiLine = true, + maxChar = 100, + placeholderFontSize = 13.sp, + modifier = Modifier + .fillMaxWidth() + .height(100.dp) ) - AllInIconChip( - text = "Privé", - leadingIcon = Icons.Default.Lock, - onClick = { - isPublic = false - }, - isSelected = !isPublic + Spacer(modifier = Modifier.height(35.dp)) + AllInTextAndIcon( + text = stringResource(id = R.string.Bet_privacy), + icon = Icons.AutoMirrored.Outlined.HelpOutline, + modifier = Modifier.padding(start = 11.dp, bottom = 8.dp), + onClick = {} ) + Row( + horizontalArrangement = Arrangement.spacedBy(8.dp) + ){ + AllInIconChip( + text = stringResource(id = R.string.Public), + leadingIcon = Icons.Default.Public, + onClick = { + setIsPublic(true) + }, + isSelected = isPublic + ) + AllInIconChip( + text = stringResource(id = R.string.Private), + leadingIcon = Icons.Default.Lock, + onClick = { + setIsPublic(false) + }, + isSelected = !isPublic + ) + } + + Spacer(modifier = Modifier.height(52.dp)) + Column( + verticalArrangement = Arrangement.spacedBy(17.dp) + ) { + if(isPublic){ + BetCreationScreenBottomText(text = stringResource(id = R.string.public_bottom_text_1)) + BetCreationScreenBottomText(text = stringResource(id = R.string.public_bottom_text_2)) + }else{ + BetCreationScreenBottomText(text = stringResource(id = R.string.private_bottom_text_1)) + BetCreationScreenBottomText(text = stringResource(id = R.string.private_bottom_text_2)) + BetCreationScreenBottomText(text = stringResource(id = R.string.private_bottom_text_3)) + } + } } } \ No newline at end of file diff --git a/src/app/src/main/java/fr/iut/alldev/allin/ui/core/AllInRipple.kt b/src/app/src/main/java/fr/iut/alldev/allin/ui/core/AllInRipple.kt new file mode 100644 index 0000000..0290310 --- /dev/null +++ b/src/app/src/main/java/fr/iut/alldev/allin/ui/core/AllInRipple.kt @@ -0,0 +1,18 @@ +package fr.iut.alldev.allin.ui.core + +import androidx.compose.material.ripple.LocalRippleTheme +import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.ui.graphics.Color +import fr.iut.alldev.allin.ui.theme.AllInRippleTheme + +@Composable +fun AllInRipple( + color: Color, + content: @Composable ()->Unit +) { + CompositionLocalProvider( + LocalRippleTheme provides AllInRippleTheme(color), + content = content + ) +} \ No newline at end of file diff --git a/src/app/src/main/java/fr/iut/alldev/allin/ui/core/AllInSections.kt b/src/app/src/main/java/fr/iut/alldev/allin/ui/core/AllInSections.kt index 1a55427..67ea51a 100644 --- a/src/app/src/main/java/fr/iut/alldev/allin/ui/core/AllInSections.kt +++ b/src/app/src/main/java/fr/iut/alldev/allin/ui/core/AllInSections.kt @@ -1,16 +1,22 @@ package fr.iut.alldev.allin.ui.core import android.content.res.Configuration -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column +import androidx.compose.animation.core.Spring +import androidx.compose.animation.core.spring +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.gestures.* +import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.items import androidx.compose.material3.Text import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.layout.onSizeChanged +import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.dp import fr.iut.alldev.allin.ui.theme.AllInTheme @@ -19,15 +25,56 @@ class SectionElement( val content: @Composable ()->Unit ) +enum class DragAnchors(val fraction: Float) { + Start(-2f), + Center(0f), + End(2f), +} + +@OptIn(ExperimentalFoundationApi::class) @Composable fun AllInSections( sections: List, interSectionsPadding: Dp = 56.dp, modifier: Modifier = Modifier ) { - var selected by remember{ + var selected by remember { mutableStateOf(sections.firstOrNull()) } + var wasSwiped by remember{ + mutableStateOf(false) + } + + val density = LocalDensity.current + val draggableState = remember { + AnchoredDraggableState( + initialValue = DragAnchors.Center, + positionalThreshold = { distance: Float -> distance * .5f }, + velocityThreshold = { with(density) { 50.dp.toPx() } }, + animationSpec = spring( + dampingRatio = 0.66f, + stiffness = Spring.StiffnessMediumLow, + ), + ){ + val idx = sections.indexOf(selected) + val add = when(it.fraction){ + DragAnchors.End.fraction-> { + -1 + } + DragAnchors.Start.fraction-> { + 1 + } + else -> 0 + } + selected=sections.getOrElse(idx+add){ + sections[idx] + } + if(selected!=sections[idx]){ + wasSwiped=true + } + false + } + } Column( modifier = modifier, horizontalAlignment = Alignment.CenterHorizontally @@ -43,7 +90,46 @@ fun AllInSections( ) } } - selected?.content?.let { it() } + + Box( + Modifier + .wrapContentSize() + .anchoredDraggable(draggableState, Orientation.Horizontal) + .onSizeChanged { layoutSize -> + val dragEndPoint = layoutSize.width + draggableState.updateAnchors( + DraggableAnchors { + DragAnchors + .values() + .forEach { anchor -> + anchor at dragEndPoint * anchor.fraction + } + } + ) + }, + ){ + Box( + Modifier + .wrapContentSize() + .offset { + val offset = + if ( + wasSwiped + ) { + if (!draggableState.isAnimationRunning) { + wasSwiped = false + } + -draggableState.offset.toInt() + + } else { + draggableState.offset.toInt() + } + IntOffset(x = offset, y = 0) + } + ){ + selected?.content?.let { it() } + } + } } } diff --git a/src/app/src/main/java/fr/iut/alldev/allin/ui/core/AllInTextAndIcon.kt b/src/app/src/main/java/fr/iut/alldev/allin/ui/core/AllInTextAndIcon.kt new file mode 100644 index 0000000..50fdb1b --- /dev/null +++ b/src/app/src/main/java/fr/iut/alldev/allin/ui/core/AllInTextAndIcon.kt @@ -0,0 +1,71 @@ +package fr.iut.alldev.allin.ui.core + +import android.content.res.Configuration +import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.outlined.HelpOutline +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.draw.alpha +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 androidx.compose.ui.unit.sp +import fr.iut.alldev.allin.ui.theme.AllInTheme + +@Composable +fun AllInTextAndIcon( + text: String, + icon: ImageVector, + modifier: Modifier = Modifier, + onClick: ()->Unit +) { + val interactionSource = remember { MutableInteractionSource() } + Row( + modifier = modifier + .clickable( + interactionSource = interactionSource, + indication = null, + onClick = onClick + ), + verticalAlignment = Alignment.CenterVertically + ) { + Text( + text = text, + style = AllInTheme.typography.h2, + fontWeight = FontWeight.Bold, + fontSize = 15.sp, + color = AllInTheme.themeColors.on_main_surface + ) + Spacer(modifier = Modifier.width(5.dp)) + Icon( + imageVector = icon, + contentDescription = null, + tint = AllInTheme.themeColors.on_main_surface, + modifier = Modifier + .size(15.dp) + .alpha(.8f) + ) + } + +} + +@Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) +@Composable +private fun AllInTextAndIconPreview() { + AllInTheme { + AllInTextAndIcon(text = "Texte", icon = Icons.AutoMirrored.Outlined.HelpOutline) { + } + } +} \ No newline at end of file diff --git a/src/app/src/main/java/fr/iut/alldev/allin/ui/core/AllInTextField.kt b/src/app/src/main/java/fr/iut/alldev/allin/ui/core/AllInTextField.kt index a7fbb25..d2c2817 100644 --- a/src/app/src/main/java/fr/iut/alldev/allin/ui/core/AllInTextField.kt +++ b/src/app/src/main/java/fr/iut/alldev/allin/ui/core/AllInTextField.kt @@ -2,7 +2,6 @@ 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 @@ -12,6 +11,7 @@ import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.focus.onFocusChanged +import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.text.TextRange import androidx.compose.ui.text.input.KeyboardType @@ -20,9 +20,12 @@ import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.input.VisualTransformation import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.TextUnit +import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import fr.iut.alldev.allin.ui.theme.AllInTheme import kotlinx.coroutines.launch +import racra.compose.smooth_corner_rect_library.AbsoluteSmoothCornerShape @OptIn(ExperimentalFoundationApi::class) @Composable @@ -34,11 +37,14 @@ fun AllInTextField( enabled: Boolean = true, trailingIcon: ImageVector? = null, trailingContent: @Composable (() -> Unit)? = null, + placeholderFontSize: TextUnit = 18.sp, + multiLine: Boolean = false, onValueChange: (String)->Unit, bringIntoViewRequester: BringIntoViewRequester, visualTransformation: VisualTransformation = VisualTransformation.None, keyboardType: KeyboardType = KeyboardType.Text, - keyboardActions: KeyboardActions = KeyboardActions.Default + keyboardActions: KeyboardActions = KeyboardActions.Default, + borderColor: Color = AllInTheme.colors.allIn_LightGrey300 ) { val scope = rememberCoroutineScope() var hasFocus by remember { mutableStateOf(false) } @@ -51,8 +57,8 @@ fun AllInTextField( textFieldValue = TextFieldValue(text = value, selection = TextRange(value.length)) }) - OutlinedTextField( + value = textFieldValue, modifier = modifier .onFocusChanged { hasFocus = it.hasFocus @@ -63,7 +69,7 @@ fun AllInTextField( } }, visualTransformation = visualTransformation, - value = textFieldValue, + singleLine = !multiLine, onValueChange = { if(maxChar==null || it.text.length<=maxChar) { textFieldValue = it @@ -73,10 +79,10 @@ fun AllInTextField( placeholder = { Text( text = placeholder, - fontSize = 18.sp, + fontSize = placeholderFontSize, style = AllInTheme.typography.r, color = AllInTheme.colors.allIn_LightGrey300, - maxLines = 1, + maxLines = if(multiLine) 3 else 1, overflow = TextOverflow.Ellipsis ) }, @@ -90,20 +96,18 @@ fun AllInTextField( } }, textStyle = AllInTheme.typography.r, - singleLine = true, enabled = enabled, keyboardOptions = KeyboardOptions(keyboardType = keyboardType), keyboardActions = keyboardActions, - shape = AbsoluteRoundedCornerShape(20), + shape = AbsoluteSmoothCornerShape(10.dp, 100), colors = OutlinedTextFieldDefaults.colors( cursorColor = AllInTheme.colors.allIn_Dark, - focusedBorderColor = AllInTheme.colors.allIn_LightGrey300, - unfocusedBorderColor = AllInTheme.colors.allIn_LightGrey300, + focusedBorderColor = borderColor, + unfocusedBorderColor = borderColor, focusedTextColor = AllInTheme.colors.allIn_Dark, unfocusedTextColor = AllInTheme.colors.allIn_Dark, focusedContainerColor = AllInTheme.colors.white, unfocusedContainerColor = AllInTheme.colors.white - ) ) } @@ -188,4 +192,19 @@ private fun AllInTextFieldPasswordPreview() { bringIntoViewRequester = BringIntoViewRequester() ) } +} + +@OptIn(ExperimentalFoundationApi::class) +@Preview +@Composable +private fun AllInTextFieldMultilinePreview() { + AllInTheme { + AllInTextField( + placeholder = "David sera il absent le Lundi matin en cours ?", + value = "", + onValueChange = { }, + multiLine = true, + bringIntoViewRequester = BringIntoViewRequester() + ) + } } \ No newline at end of file diff --git a/src/app/src/main/java/fr/iut/alldev/allin/ui/core/RainbowButton.kt b/src/app/src/main/java/fr/iut/alldev/allin/ui/core/RainbowButton.kt index fa8caa3..0850082 100644 --- a/src/app/src/main/java/fr/iut/alldev/allin/ui/core/RainbowButton.kt +++ b/src/app/src/main/java/fr/iut/alldev/allin/ui/core/RainbowButton.kt @@ -6,6 +6,7 @@ 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 @@ -17,35 +18,38 @@ fun RainbowButton( text: String, onClick: ()->Unit, enabled: Boolean = true, + rippleColor: Color = AllInTheme.colors.allIn_Blue, modifier: Modifier = Modifier ) { - AllInCard( - borderWidth = if(enabled) 1.dp else 2.dp, - onClick = onClick, - modifier = modifier, - enabled = enabled - ) { - val textStyle = - with(AllInTheme.typography.h2){ - if(enabled){ - copy( - brush = AllInTheme.colors.allIn_TextGradient - ) - }else{ - copy( - color = AllInTheme.themeColors.disabled_border - ) + AllInRipple(rippleColor) { + AllInCard( + borderWidth = if (enabled) 1.dp else 2.dp, + onClick = onClick, + modifier = modifier, + enabled = enabled + ) { + val textStyle = + with(AllInTheme.typography.h2) { + if (enabled) { + copy( + brush = AllInTheme.colors.allIn_TextGradient + ) + } else { + copy( + color = AllInTheme.themeColors.disabled_border + ) + } } - } - Text( - text = text, - textAlign = TextAlign.Center, - style = textStyle, - fontSize = 30.sp, - modifier = Modifier - .padding(vertical = 20.dp) - .fillMaxWidth(), + Text( + text = text, + textAlign = TextAlign.Center, + style = textStyle, + fontSize = 30.sp, + modifier = Modifier + .padding(vertical = 20.dp) + .fillMaxWidth(), ) + } } } diff --git a/src/app/src/main/java/fr/iut/alldev/allin/ui/theme/Theme.kt b/src/app/src/main/java/fr/iut/alldev/allin/ui/theme/Theme.kt index d6953fc..b1c7941 100644 --- a/src/app/src/main/java/fr/iut/alldev/allin/ui/theme/Theme.kt +++ b/src/app/src/main/java/fr/iut/alldev/allin/ui/theme/Theme.kt @@ -154,9 +154,11 @@ object AllInTheme { } -object AllInRippleTheme : RippleTheme { +class AllInRippleTheme( + val color: Color, +) : RippleTheme { @Composable - override fun defaultColor(): Color = AllInTheme.colors.allIn_Blue + override fun defaultColor(): Color = color @Composable override fun rippleAlpha(): RippleAlpha = RippleTheme.defaultRippleAlpha( diff --git a/src/app/src/main/res/values-fr/strings.xml b/src/app/src/main/res/values-fr/strings.xml index e921210..194fc56 100644 --- a/src/app/src/main/res/values-fr/strings.xml +++ b/src/app/src/main/res/values-fr/strings.xml @@ -37,9 +37,25 @@ Question Réponse Publier le bet + Thème + Études, sport, soirée… + Phrase du bet + David sera-il absent lundi matin en cours ? + Date de fin des inscriptions + Date de fin du BET + Confidentialité du bet + %d amis disponibles + Votre bet sera visible par tous les utilisateurs. + Tout le monde pourra rejoindre le BET. + Votre bet sera visible uniquement par vos amis. + Seulement vos amis pourront rejoindre le bet. + Vous pourrez inviter des amis à tout moment pendant la période d’inscription. + Oui / Non + Réponses personnalisées Populaire Public + Privé Invitation En cours Terminés diff --git a/src/app/src/main/res/values/strings.xml b/src/app/src/main/res/values/strings.xml index 14478ed..a9fa8df 100644 --- a/src/app/src/main/res/values/strings.xml +++ b/src/app/src/main/res/values/strings.xml @@ -42,9 +42,25 @@ Question Answer Publish the bet + Theme + Studies, sports, party… + Bet phrase + Will David be missing this Monday in class ? + Registration end date + Bet end date + Bet privacy + %d friends available + Your bet will be visible by all the users. + Everyone will be able to join the bet. + Your bet will only be visible by your friends. + Only your friends will be able to join the bet. + You can invite friends at any moment during the registration period. + Yes / No + Custom answers Popular Public + Private Invitation Current Finished