Starting Bet Creation Screen
continuous-integration/drone/push Build is passing Details

pull/3/head
Arthur VALIN 1 year ago
parent 455cec10ae
commit 16f3a5808f

@ -12,6 +12,6 @@
</deviceKey> </deviceKey>
</Target> </Target>
</targetSelectedWithDropDown> </targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2023-09-26T09:14:33.560818300Z" /> <timeTargetWasSelectedWithDropDown value="2023-09-27T20:38:30.723570500Z" />
</component> </component>
</project> </project>

@ -53,8 +53,8 @@ dependencies {
implementation 'androidx.activity:activity-compose:1.7.2' implementation 'androidx.activity:activity-compose:1.7.2'
implementation "androidx.compose.ui:ui:$compose_version" implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.compose.material3:material3:1.2.0-alpha07' implementation 'androidx.compose.material3:material3:1.2.0-alpha08'
implementation "androidx.navigation:navigation-compose:2.7.2" implementation "androidx.navigation:navigation-compose:2.7.3"
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
implementation 'androidx.compose.material:material-icons-core' implementation 'androidx.compose.material:material-icons-core'
implementation 'androidx.compose.material:material-icons-extended' implementation 'androidx.compose.material:material-icons-extended'

@ -0,0 +1,47 @@
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.ui.Alignment
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.betcreation.tabs.BetCreationScreenAnswerTab
import fr.iut.alldev.allin.ui.betcreation.tabs.BetCreationScreenQuestionTab
import fr.iut.alldev.allin.ui.core.AllInSections
import fr.iut.alldev.allin.ui.core.RainbowButton
import fr.iut.alldev.allin.ui.core.SectionElement
@Composable
fun BetCreationScreen() {
Box(
Modifier
.fillMaxSize()
.padding(horizontal = 30.dp, vertical = 20.dp)
) {
AllInSections(
modifier = Modifier
.align(Alignment.TopCenter)
.fillMaxSize(),
sections = listOf(
SectionElement(stringResource(id = R.string.Question)){
BetCreationScreenQuestionTab()
},
SectionElement(stringResource(id = R.string.Answer)){
BetCreationScreenAnswerTab()
}
)
)
RainbowButton(
text = stringResource(id = R.string.Publish),
modifier = Modifier
.align(Alignment.BottomCenter)
.padding(bottom = 14.dp),
onClick = {
}
)
}
}

@ -0,0 +1,11 @@
package fr.iut.alldev.allin.ui.betcreation.tabs
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import fr.iut.alldev.allin.R
@Composable
fun BetCreationScreenAnswerTab() {
Text(text = stringResource(id = R.string.Answer))
}

@ -0,0 +1,43 @@
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.material.icons.Icons
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 fr.iut.alldev.allin.R
import fr.iut.alldev.allin.ui.core.AllInIconChip
@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
)
AllInIconChip(
text = "Privé",
leadingIcon = Icons.Default.Lock,
onClick = {
isPublic = false
},
isSelected = !isPublic
)
}
}

@ -22,10 +22,13 @@ fun AllInCard(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
onClick: (()->Unit)? = null, onClick: (()->Unit)? = null,
radius: Dp = 15.dp, radius: Dp = 15.dp,
enabled: Boolean = true,
backgroundColor: Color = AllInTheme.themeColors.background, backgroundColor: Color = AllInTheme.themeColors.background,
disabledBackgroundColor: Color = AllInTheme.themeColors.disabled,
backgroundBrush: Brush? = null, backgroundBrush: Brush? = null,
borderWidth: Dp? = null, borderWidth: Dp? = null,
borderColor: Color = AllInTheme.themeColors.border, borderColor: Color = AllInTheme.themeColors.border,
disabledBorderColor: Color = AllInTheme.themeColors.disabled_border,
borderBrush: Brush? = null, borderBrush: Brush? = null,
content: @Composable ()->Unit content: @Composable ()->Unit
) { ) {
@ -39,14 +42,16 @@ fun AllInCard(
} }
val cardBorders = borderWidth?.let{ val cardBorders = borderWidth?.let{
width -> borderBrush?.let{BorderStroke(width, it)} width -> borderBrush?.let{BorderStroke(width, it)}
?: BorderStroke(width, borderColor) ?: BorderStroke(width, if(enabled) borderColor else disabledBorderColor)
} }
val cardColors = CardDefaults.cardColors( val cardColors = CardDefaults.cardColors(
containerColor = if(backgroundBrush!=null) Color.Transparent else backgroundColor containerColor = if(backgroundBrush!=null) Color.Transparent else backgroundColor,
disabledContainerColor = disabledBackgroundColor
) )
onClick?.let { onClick?.let {
Card( Card(
modifier = cardModifier, modifier = cardModifier,
enabled = enabled,
onClick = it, onClick = it,
shape = cardShape, shape = cardShape,
border = cardBorders, border = cardBorders,

@ -3,16 +3,18 @@ package fr.iut.alldev.allin.ui.core
import android.content.res.Configuration import android.content.res.Configuration
import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.* import androidx.compose.material3.*
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
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.graphics.Color
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
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.dp
import fr.iut.alldev.allin.ui.theme.AllInTheme import fr.iut.alldev.allin.ui.theme.AllInTheme
import racra.compose.smooth_corner_rect_library.AbsoluteSmoothCornerShape
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
@ -20,30 +22,32 @@ fun AllInChip(
text: String, text: String,
isSelected: Boolean = false, isSelected: Boolean = false,
onClick: ()->Unit = {}, onClick: ()->Unit = {},
modifier: Modifier = Modifier modifier: Modifier = Modifier,
radius: Dp = 50.dp,
selectedColor: Color = AllInTheme.colors.allIn_Purple,
unselectedColor: Color = AllInTheme.themeColors.background,
) { ) {
Card( Card(
modifier = modifier, modifier = modifier,
shape = RoundedCornerShape(50), shape = AbsoluteSmoothCornerShape(radius, 100),
onClick = onClick, onClick = onClick,
border = if(!isSelected) BorderStroke(1.dp, AllInTheme.themeColors.border) else null, border = if(!isSelected) BorderStroke(1.dp, AllInTheme.themeColors.border) else null,
colors = CardDefaults.cardColors( colors = CardDefaults.cardColors(
containerColor = with(AllInTheme){ containerColor = if(isSelected) selectedColor else unselectedColor
if(isSelected) colors.allIn_Purple else themeColors.background
}
) )
) { ) {
Box{ Box {
Text( Text(
text = text, text = text,
modifier = Modifier modifier = Modifier
.align(Alignment.Center)
.padding(vertical = 8.dp, horizontal = 22.dp) .padding(vertical = 8.dp, horizontal = 22.dp)
.alpha(if(isSelected) 0f else 1f), .alpha(if (isSelected) 0f else 1f),
textAlign = TextAlign.Center, textAlign = TextAlign.Center,
style = AllInTheme.typography.r, style = AllInTheme.typography.r,
color = AllInTheme.themeColors.on_background_2 color = AllInTheme.themeColors.on_background_2
) )
if(isSelected) { if (isSelected) {
Text( Text(
text = text, text = text,
modifier = modifier.align(Alignment.Center), modifier = modifier.align(Alignment.Center),

@ -0,0 +1,90 @@
package fr.iut.alldev.allin.ui.core
import android.content.res.Configuration
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Public
import androidx.compose.material3.*
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.graphics.vector.ImageVector
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.dp
import androidx.compose.ui.unit.sp
import fr.iut.alldev.allin.ui.theme.AllInTheme
import racra.compose.smooth_corner_rect_library.AbsoluteSmoothCornerShape
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AllInIconChip(
text: String,
isSelected: Boolean = false,
onClick: ()->Unit = {},
modifier: Modifier = Modifier,
radius: Dp = 15.dp,
selectedColor: Color = AllInTheme.colors.allIn_Purple,
unselectedColor: Color = AllInTheme.themeColors.background,
leadingIcon: ImageVector
) {
val contentColor = if(isSelected) AllInTheme.colors.white else selectedColor
Card(
modifier = modifier,
shape = AbsoluteSmoothCornerShape(radius, 100),
onClick = onClick,
border = if(!isSelected) BorderStroke(1.dp, AllInTheme.themeColors.border) else null,
colors = CardDefaults.cardColors(
containerColor = if(isSelected) selectedColor else unselectedColor
)
) {
Row(
horizontalArrangement = Arrangement.spacedBy(7.dp),
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.padding(vertical = 15.dp, horizontal = 18.dp)
) {
Icon(
imageVector = leadingIcon,
contentDescription = null,
tint = contentColor
)
Text(
text = text,
textAlign = TextAlign.Center,
style = AllInTheme.typography.h1,
color = contentColor,
fontSize = 18.sp
)
}
}
}
@Preview
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
private fun AllInIconChipPreviewUnselected() {
AllInTheme {
AllInIconChip(
text = "Public",
isSelected = false,
leadingIcon = Icons.Default.Public
)
}
}
@Preview
@Composable
private fun AllInIconChipPreviewSelected() {
AllInTheme {
AllInIconChip(
text = "Public",
isSelected = true,
leadingIcon = Icons.Default.Public
)
}
}

@ -0,0 +1,69 @@
package fr.iut.alldev.allin.ui.core
import android.content.res.Configuration
import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.text.ClickableText
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.sp
import fr.iut.alldev.allin.ui.theme.AllInTheme
@Composable
fun AllInSectionButton(
text: String,
isSelected: Boolean,
onClick: (Int)->Unit
) {
val style = if(isSelected){
AllInTheme.typography.h3.copy(
color = AllInTheme.themeColors.on_main_surface,
fontSize = 15.sp,
textAlign = TextAlign.Center,
fontWeight = FontWeight.ExtraBold
)
}else{
AllInTheme.typography.h3.copy(
color = AllInTheme.themeColors.on_background_2,
fontSize = 15.sp,
textAlign = TextAlign.Center,
fontWeight = FontWeight.SemiBold
)
}
ClickableText(
text = AnnotatedString(text),
style = style,
onClick = onClick,
modifier = Modifier.animateContentSize()
)
}
@Preview
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
private fun AllInSectionButtonPreview() {
AllInTheme {
AllInSectionButton(
text = "Test",
isSelected = false,
onClick = {}
)
}
}
@Preview
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
private fun AllInSectionButtonSelectedPreview() {
AllInTheme {
AllInSectionButton(
text = "Test",
isSelected = true,
onClick = {}
)
}
}

@ -0,0 +1,66 @@
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.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.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import fr.iut.alldev.allin.ui.theme.AllInTheme
class SectionElement(
val text: String,
val content: @Composable ()->Unit
)
@Composable
fun AllInSections(
sections: List<SectionElement>,
interSectionsPadding: Dp = 56.dp,
modifier: Modifier = Modifier
) {
var selected by remember{
mutableStateOf(sections.firstOrNull())
}
Column(
modifier = modifier,
horizontalAlignment = Alignment.CenterHorizontally
) {
LazyRow(
horizontalArrangement = Arrangement.spacedBy(interSectionsPadding)
) {
items(sections) { section ->
AllInSectionButton(
text = section.text,
isSelected = selected == section,
onClick = { selected = section }
)
}
}
selected?.content?.let { it() }
}
}
@Preview
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
private fun AllInSectionsPreview() {
AllInTheme {
AllInSections(
sections = listOf(
SectionElement("Page 1") {
Text("This is page 1")
},
SectionElement("Page 2") {
Text("This is page 2")
},
)
)
}
}

@ -1,5 +1,6 @@
package fr.iut.alldev.allin.ui.core package fr.iut.alldev.allin.ui.core
import android.content.res.Configuration
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text import androidx.compose.material3.Text
@ -15,15 +16,31 @@ import fr.iut.alldev.allin.ui.theme.AllInTheme
fun RainbowButton( fun RainbowButton(
text: String, text: String,
onClick: ()->Unit, onClick: ()->Unit,
enabled: Boolean = true,
modifier: Modifier = Modifier modifier: Modifier = Modifier
) { ) {
AllInCard(borderWidth = 1.dp, onClick = onClick, 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
)
}
}
Text( Text(
text = text, text = text,
textAlign = TextAlign.Center, textAlign = TextAlign.Center,
style = AllInTheme.typography.h2.copy( style = textStyle,
brush = AllInTheme.colors.allIn_TextGradient
),
fontSize = 30.sp, fontSize = 30.sp,
modifier = Modifier modifier = Modifier
.padding(vertical = 20.dp) .padding(vertical = 20.dp)
@ -33,9 +50,19 @@ fun RainbowButton(
} }
@Preview @Preview
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable @Composable
private fun RainbowButtonPreview() { private fun RainbowButtonPreview() {
AllInTheme { AllInTheme {
RainbowButton(text = "Participer", onClick = { }) RainbowButton(text = "Participer", onClick = { })
} }
}
@Preview
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
private fun RainbowButtonDisabledPreview() {
AllInTheme {
RainbowButton(text = "Participer", onClick = { }, enabled = false)
}
} }

@ -6,14 +6,15 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController import androidx.navigation.compose.rememberNavController
import fr.iut.alldev.allin.ui.bet.BetScreen import fr.iut.alldev.allin.ui.bet.BetScreen
import fr.iut.alldev.allin.ui.betcreation.BetCreationScreen
import fr.iut.alldev.allin.ui.login.LoginScreen import fr.iut.alldev.allin.ui.login.LoginScreen
import fr.iut.alldev.allin.ui.navigation.drawer.AllInDrawer import fr.iut.alldev.allin.ui.navigation.drawer.AllInDrawer
import fr.iut.alldev.allin.ui.profile.Profile
import fr.iut.alldev.allin.ui.register.RegisterScreen import fr.iut.alldev.allin.ui.register.RegisterScreen
import fr.iut.alldev.allin.ui.theme.AllInTheme import fr.iut.alldev.allin.ui.theme.AllInTheme
import fr.iut.alldev.allin.ui.welcome.WelcomeScreen import fr.iut.alldev.allin.ui.welcome.WelcomeScreen
@ -22,15 +23,16 @@ object Routes {
const val WELCOME = "WELCOME" const val WELCOME = "WELCOME"
const val REGISTER = "REGISTER" const val REGISTER = "REGISTER"
const val LOGIN = "LOGIN" const val LOGIN = "LOGIN"
const val BET = "BET" const val DASHBOARD = "DASHBOARD"
const val PUBLIC_BETS = "PUBLIC_BETS"
const val BET_CREATION = "BET_CREATION"
const val BET_HISTORY = "BET_HISTORY" const val BET_HISTORY = "BET_HISTORY"
const val FRIENDS = "FRIENDS" const val FRIENDS = "FRIENDS"
const val CURRENT_BETS = "CURRENT_BETS" const val CURRENT_BETS = "CURRENT_BETS"
const val DASHBOARD = "DASHBOARD"
} }
private fun NavHostController.popUpTo(route: String, baseRoute: String){ internal fun NavHostController.popUpTo(route: String, baseRoute: String){
this.navigate(route) { this.navigate(route) {
launchSingleTop = true launchSingleTop = true
popUpTo(baseRoute) { popUpTo(baseRoute) {
@ -64,53 +66,21 @@ fun AllInNavHost(modifier: Modifier = Modifier,
fadeOut( fadeOut(
animationSpec = tween(1500) animationSpec = tween(1500)
) )
}, },
modifier = modifier.fillMaxSize().background(AllInTheme.themeColors.main_surface), modifier = modifier.fillMaxSize().background(AllInTheme.themeColors.main_surface),
) { ) {
allInWelcomeScreen(navController)
composable(route = Routes.WELCOME){ allInRegisterScreen(navController)
WelcomeScreen( allInLoginScreen(navController)
onClickJoin = { allInDashboard()
navController.popUpTo(Routes.REGISTER, Routes.WELCOME)
},
onClickLogin = {
navController.popUpTo(Routes.LOGIN, Routes.WELCOME)
}
)
}
composable(route = Routes.REGISTER){
RegisterScreen(
onClickRegister = {
navController.popUpTo(Routes.DASHBOARD, Routes.REGISTER)
},
onClickLogin = {
navController.popUpTo(Routes.LOGIN, Routes.REGISTER)
}
)
}
composable(route = Routes.LOGIN){
LoginScreen(
onClickRegister = {
navController.popUpTo(Routes.REGISTER, Routes.LOGIN)
},
onClickLogin = {
navController.popUpTo(Routes.DASHBOARD, Routes.LOGIN)
}
)
}
composable(
route = Routes.DASHBOARD,
){
AllInDrawer()
}
} }
} }
@Composable @Composable
fun AllInDashboard( internal fun AllInDrawerNavHost(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
navController: NavHostController = rememberNavController(), navController: NavHostController,
startDestination: String = Routes.BET startDestination: String = Routes.PUBLIC_BETS
) { ) {
NavHost( NavHost(
navController = navController, navController = navController,
@ -119,7 +89,59 @@ fun AllInDashboard(
enterTransition = { EnterTransition.None }, enterTransition = { EnterTransition.None },
exitTransition = { ExitTransition.None } exitTransition = { ExitTransition.None }
) { ) {
composable(route = Routes.BET) { BetScreen() } composable(route = Routes.PUBLIC_BETS) { BetScreen() }
composable(route = Routes.BET_HISTORY) { Profile() } composable(route = Routes.BET_CREATION) { BetCreationScreen() }
}
}
private fun NavGraphBuilder.allInWelcomeScreen(
navController: NavHostController
){
composable(route = Routes.WELCOME){
WelcomeScreen(
onClickJoin = {
navController.popUpTo(Routes.REGISTER, Routes.WELCOME)
},
onClickLogin = {
navController.popUpTo(Routes.LOGIN, Routes.WELCOME)
}
)
}
}
private fun NavGraphBuilder.allInRegisterScreen(
navController: NavHostController
){
composable(route = Routes.REGISTER){
RegisterScreen(
onClickRegister = {
navController.popUpTo(Routes.DASHBOARD, Routes.REGISTER)
},
onClickLogin = {
navController.popUpTo(Routes.LOGIN, Routes.REGISTER)
}
)
}
}
private fun NavGraphBuilder.allInLoginScreen(
navController: NavHostController
){
composable(route = Routes.LOGIN){
LoginScreen(
onClickRegister = {
navController.popUpTo(Routes.REGISTER, Routes.LOGIN)
},
onClickLogin = {
navController.popUpTo(Routes.DASHBOARD, Routes.LOGIN)
}
)
}
}
private fun NavGraphBuilder.allInDashboard() {
composable(
route = Routes.DASHBOARD,
){
AllInDrawer()
} }
} }

@ -17,8 +17,9 @@ import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController import androidx.navigation.compose.rememberNavController
import fr.iut.alldev.allin.R import fr.iut.alldev.allin.R
import fr.iut.alldev.allin.ui.core.topbar.AllInTopBar import fr.iut.alldev.allin.ui.core.topbar.AllInTopBar
import fr.iut.alldev.allin.ui.navigation.AllInDashboard import fr.iut.alldev.allin.ui.navigation.AllInDrawerNavHost
import fr.iut.alldev.allin.ui.navigation.Routes import fr.iut.alldev.allin.ui.navigation.Routes
import fr.iut.alldev.allin.ui.navigation.popUpTo
import fr.iut.alldev.allin.ui.theme.AllInTheme import fr.iut.alldev.allin.ui.theme.AllInTheme
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlin.math.abs import kotlin.math.abs
@ -30,8 +31,14 @@ sealed class TopLevelDestination(
val subtitle: Int, val subtitle: Int,
val emoji: Int val emoji: Int
) { ) {
object BET : TopLevelDestination( object PUBLIC_BETS : TopLevelDestination(
route = Routes.BET, route = Routes.PUBLIC_BETS,
title = R.string.public_bets,
subtitle = R.string.public_bets_subtitle,
emoji = R.drawable.globe
)
object BET_CREATION : TopLevelDestination(
route = Routes.BET_CREATION,
title = R.string.create_a_bet, title = R.string.create_a_bet,
subtitle = R.string.create_a_bet_subtitle, subtitle = R.string.create_a_bet_subtitle,
emoji = R.drawable.video_game emoji = R.drawable.video_game
@ -57,7 +64,8 @@ sealed class TopLevelDestination(
} }
val topLevelDestinations = listOf( val topLevelDestinations = listOf(
TopLevelDestination.BET, TopLevelDestination.PUBLIC_BETS,
TopLevelDestination.BET_CREATION,
TopLevelDestination.BET_HISTORY, TopLevelDestination.BET_HISTORY,
TopLevelDestination.FRIENDS, TopLevelDestination.FRIENDS,
TopLevelDestination.CURRENT_BETS TopLevelDestination.CURRENT_BETS
@ -67,8 +75,7 @@ val topLevelDestinations = listOf(
fun AllInDrawer( fun AllInDrawer(
navController: NavHostController = rememberNavController(), navController: NavHostController = rememberNavController(),
drawerState: DrawerState = rememberDrawerState(initialValue = DrawerValue.Closed), drawerState: DrawerState = rememberDrawerState(initialValue = DrawerValue.Closed),
startDestination: String = Routes.BET startDestination: String = Routes.PUBLIC_BETS
) { ) {
val scope = rememberCoroutineScope() val scope = rememberCoroutineScope()
val drawerOffset = derivedStateOf { drawerState.offset.value } val drawerOffset = derivedStateOf { drawerState.offset.value }
@ -107,18 +114,10 @@ fun AllInDrawer(
title = stringResource(item.title).uppercase(), title = stringResource(item.title).uppercase(),
subtitle = stringResource(item.subtitle), subtitle = stringResource(item.subtitle),
emoji = painterResource(id = item.emoji), emoji = painterResource(id = item.emoji),
onClick = { scope.launch { drawerState.close() } onClick = {
navController.navigate(item.route){ scope.launch { drawerState.close() }
launchSingleTop = true navController.popUpTo(item.route, startDestination)
popUpTo( },
startDestination
) {
saveState = true
inclusive = true
}
restoreState = true
}
},
modifier = Modifier.padding(vertical = 5.dp, horizontal = 13.dp) modifier = Modifier.padding(vertical = 5.dp, horizontal = 13.dp)
) )
} }
@ -148,7 +147,7 @@ fun AllInDrawer(
.background(AllInTheme.themeColors.main_surface), .background(AllInTheme.themeColors.main_surface),
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
) { ) {
AllInDashboard( AllInDrawerNavHost(
navController = navController navController = navController
) )
} }

@ -95,7 +95,9 @@ data class AllInThemeColors(
val tint_1: Color, val tint_1: Color,
val background_2: Color, val background_2: Color,
val on_background_2: Color, val on_background_2: Color,
val border: Color val border: Color,
val disabled: Color,
val disabled_border: Color
) )
internal val LocalThemeColors = staticCompositionLocalOf { internal val LocalThemeColors = staticCompositionLocalOf {
@ -107,6 +109,8 @@ internal val LocalThemeColors = staticCompositionLocalOf {
tint_1 = Color.Unspecified, tint_1 = Color.Unspecified,
background_2 = Color.Unspecified, background_2 = Color.Unspecified,
on_background_2 = Color.Unspecified, on_background_2 = Color.Unspecified,
border = Color.Unspecified border = Color.Unspecified,
disabled = Color.Unspecified,
disabled_border = Color.Unspecified
) )
} }

@ -107,7 +107,9 @@ fun AllInTheme(
tint_1 = customColors.white, tint_1 = customColors.white,
background_2 = customColors.allIn_Dark, background_2 = customColors.allIn_Dark,
on_background_2 = customColors.allIn_LightGrey200, on_background_2 = customColors.allIn_LightGrey200,
border = customColors.allIn_DarkGrey100 border = customColors.allIn_DarkGrey100,
disabled = customColors.allIn_DarkGrey200,
disabled_border = customColors.allIn_DarkGrey100
) )
}else{ }else{
AllInThemeColors( AllInThemeColors(
@ -118,7 +120,10 @@ fun AllInTheme(
tint_1 = customColors.allIn_LoginPurple, tint_1 = customColors.allIn_LoginPurple,
background_2 = customColors.allIn_LightGrey50, background_2 = customColors.allIn_LightGrey50,
on_background_2 = customColors.allIn_LightGrey300, on_background_2 = customColors.allIn_LightGrey300,
border = customColors.allIn_LightGrey100 border = customColors.allIn_LightGrey100,
disabled = customColors.allIn_LightGrey100,
disabled_border = customColors.allIn_LightGrey200
) )
} }
@ -126,7 +131,6 @@ fun AllInTheme(
LocalColors provides customColors, LocalColors provides customColors,
LocalTypography provides customTypography, LocalTypography provides customTypography,
LocalThemeColors provides customTheme LocalThemeColors provides customTheme
){ ){
content() content()
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

@ -13,6 +13,8 @@
<string name="bets">Bets</string> <string name="bets">Bets</string>
<string name="best_win">Meilleur gain</string> <string name="best_win">Meilleur gain</string>
<string name="friends">Amis</string> <string name="friends">Amis</string>
<string name="public_bets">Bets publiques</string>
<string name="public_bets_subtitle">Parcourez les bets les plus populaires du moment.</string>
<string name="create_a_bet">Créer un bet</string> <string name="create_a_bet">Créer un bet</string>
<string name="create_a_bet_subtitle">Créez un nouveau bet et faites participer vos amis.</string> <string name="create_a_bet_subtitle">Créez un nouveau bet et faites participer vos amis.</string>
<string name="bet_history">Historique des bets</string> <string name="bet_history">Historique des bets</string>
@ -31,6 +33,10 @@
<!--Login Page--> <!--Login Page-->
<string name="Login_title">Te revoilà !</string> <string name="Login_title">Te revoilà !</string>
<string name="Login_subtitle">Bon retour parmis nous tu nous as manqué !</string> <string name="Login_subtitle">Bon retour parmis nous tu nous as manqué !</string>
<!--Bet Creation Page-->
<string name="Question">Question</string>
<string name="Answer">Réponse</string>
<string name="Publish">Publier le bet</string>
<!--Bet Page--> <!--Bet Page-->
<string name="Popular">Populaire</string> <string name="Popular">Populaire</string>
<string name="Public">Public</string> <string name="Public">Public</string>

@ -17,6 +17,8 @@
<string name="bets">Bets</string> <string name="bets">Bets</string>
<string name="best_win">Best win</string> <string name="best_win">Best win</string>
<string name="friends">Friends</string> <string name="friends">Friends</string>
<string name="public_bets">Public bets</string>
<string name="public_bets_subtitle">Browse the most popular bets of the moment.</string>
<string name="create_a_bet">Create a bet</string> <string name="create_a_bet">Create a bet</string>
<string name="create_a_bet_subtitle">Create a net bet and get your friends participating.</string> <string name="create_a_bet_subtitle">Create a net bet and get your friends participating.</string>
<string name="bet_history">Bet history</string> <string name="bet_history">Bet history</string>
@ -36,6 +38,10 @@
<!--Login Page--> <!--Login Page-->
<string name="Login_title">Welcome back !</string> <string name="Login_title">Welcome back !</string>
<string name="Login_subtitle">We missed you.</string> <string name="Login_subtitle">We missed you.</string>
<!--Bet Creation Page-->
<string name="Question">Question</string>
<string name="Answer">Answer</string>
<string name="Publish">Publish the bet</string>
<!--Bet Page--> <!--Bet Page-->
<string name="Popular">Popular</string> <string name="Popular">Popular</string>
<string name="Public">Public</string> <string name="Public">Public</string>

Loading…
Cancel
Save