|
|
@ -1,5 +1,6 @@
|
|
|
|
package com.example.what_the_fantasy.ui.components
|
|
|
|
package com.example.what_the_fantasy.ui.components
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.compose.foundation.Image
|
|
|
|
import androidx.compose.foundation.background
|
|
|
|
import androidx.compose.foundation.background
|
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
@ -10,7 +11,9 @@ import androidx.compose.foundation.layout.Row
|
|
|
|
import androidx.compose.foundation.layout.fillMaxHeight
|
|
|
|
import androidx.compose.foundation.layout.fillMaxHeight
|
|
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
|
|
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
import androidx.compose.foundation.layout.size
|
|
|
|
import androidx.compose.foundation.layout.size
|
|
|
|
|
|
|
|
import androidx.compose.foundation.shape.CircleShape
|
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
|
import androidx.compose.material.icons.Icons
|
|
|
|
import androidx.compose.material.icons.Icons
|
|
|
|
import androidx.compose.material.icons.rounded.*
|
|
|
|
import androidx.compose.material.icons.rounded.*
|
|
|
@ -18,10 +21,10 @@ import androidx.compose.material3.BottomAppBar
|
|
|
|
import androidx.compose.material3.Icon
|
|
|
|
import androidx.compose.material3.Icon
|
|
|
|
import androidx.compose.material3.IconButton
|
|
|
|
import androidx.compose.material3.IconButton
|
|
|
|
import androidx.compose.material3.IconButtonColors
|
|
|
|
import androidx.compose.material3.IconButtonColors
|
|
|
|
import androidx.compose.material3.IconToggleButton
|
|
|
|
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
|
import androidx.compose.material3.NavigationBar
|
|
|
|
import androidx.compose.material3.NavigationBar
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
|
|
|
import androidx.compose.runtime.collectAsState
|
|
|
|
import androidx.compose.runtime.getValue
|
|
|
|
import androidx.compose.runtime.getValue
|
|
|
|
import androidx.compose.runtime.setValue
|
|
|
|
import androidx.compose.runtime.setValue
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
@ -32,20 +35,24 @@ import androidx.compose.ui.graphics.painter.Painter
|
|
|
|
import androidx.compose.ui.graphics.vector.ImageVector
|
|
|
|
import androidx.compose.ui.graphics.vector.ImageVector
|
|
|
|
import androidx.compose.ui.res.painterResource
|
|
|
|
import androidx.compose.ui.res.painterResource
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
|
|
|
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
|
|
|
|
|
|
import coil.compose.rememberAsyncImagePainter
|
|
|
|
|
|
|
|
import coil.compose.rememberImagePainter
|
|
|
|
import com.example.what_the_fantasy.R
|
|
|
|
import com.example.what_the_fantasy.R
|
|
|
|
import com.example.what_the_fantasy.ui.theme.*
|
|
|
|
import com.example.what_the_fantasy.ui.states.CurrentUserState
|
|
|
|
|
|
|
|
import com.example.what_the_fantasy.ui.viewModels.CurrentUserViewModel
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
@Composable
|
|
|
|
fun NavBar(onProfile : Boolean = false,
|
|
|
|
fun NavBar(onProfile : Boolean = false,
|
|
|
|
onFavorite : Boolean = false,
|
|
|
|
onFavorite : Boolean = false,
|
|
|
|
onAccueil : Boolean = false,
|
|
|
|
onAccueil : Boolean = false,
|
|
|
|
onQuiz : Boolean = false,
|
|
|
|
onQuiz : Boolean = false,
|
|
|
|
index:Int,
|
|
|
|
currentUserVM : CurrentUserViewModel,
|
|
|
|
|
|
|
|
currentUserState : CurrentUserState,
|
|
|
|
navControllerProfil: (Int) -> Unit,
|
|
|
|
navControllerProfil: (Int) -> Unit,
|
|
|
|
navControllerFavorite:(Int) -> Unit,
|
|
|
|
navControllerFavorite:(Int) -> Unit,
|
|
|
|
navControllerAccueil: (Int) -> Unit,
|
|
|
|
navControllerAccueil: (Int) -> Unit,
|
|
|
|
navControllerQuiz: (Int) -> Unit,
|
|
|
|
navControllerQuiz: (Int) -> Unit,
|
|
|
|
|
|
|
|
|
|
|
|
content : @Composable ()-> Unit ) {
|
|
|
|
content : @Composable ()-> Unit ) {
|
|
|
|
|
|
|
|
|
|
|
|
var theme by remember { mutableStateOf(true) }
|
|
|
|
var theme by remember { mutableStateOf(true) }
|
|
|
@ -64,7 +71,7 @@ fun NavBar(onProfile : Boolean = false ,
|
|
|
|
Arrangement.SpaceBetween,
|
|
|
|
Arrangement.SpaceBetween,
|
|
|
|
verticalAlignment = Alignment.Bottom
|
|
|
|
verticalAlignment = Alignment.Bottom
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
ButtonIconVectorInt(Icons.Rounded.AccountCircle,"Profile",navControllerProfil,index,onProfile)
|
|
|
|
ButtonIconVectorInt(currentUserState.imagePath,"Profile",navControllerProfil,currentUserState.id,onProfile)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IconButton(onClick = { theme=!theme},
|
|
|
|
IconButton(onClick = { theme=!theme},
|
|
|
@ -100,17 +107,17 @@ fun NavBar(onProfile : Boolean = false ,
|
|
|
|
ButtonIconPainterInt(painterResource(
|
|
|
|
ButtonIconPainterInt(painterResource(
|
|
|
|
if(onFavorite)R.drawable.favorite_button_full
|
|
|
|
if(onFavorite)R.drawable.favorite_button_full
|
|
|
|
else R.drawable.favorite_button_empty
|
|
|
|
else R.drawable.favorite_button_empty
|
|
|
|
),"Favorite",navControllerFavorite,index,onFavorite)
|
|
|
|
),"Favorite",navControllerFavorite,currentUserState.id,onFavorite)
|
|
|
|
|
|
|
|
|
|
|
|
ButtonIconPainterInt(painterResource(
|
|
|
|
ButtonIconPainterInt(painterResource(
|
|
|
|
if(onAccueil)R.drawable.home_button_full
|
|
|
|
if(onAccueil)R.drawable.home_button_full
|
|
|
|
else R.drawable.home_button_empty
|
|
|
|
else R.drawable.home_button_empty
|
|
|
|
),"Accueil",navControllerAccueil,index,onAccueil)
|
|
|
|
),"Accueil",navControllerAccueil,currentUserState.id,onAccueil)
|
|
|
|
|
|
|
|
|
|
|
|
ButtonIconPainterInt(painterResource(
|
|
|
|
ButtonIconPainterInt(painterResource(
|
|
|
|
if(onQuiz)R.drawable.quiz_button_full
|
|
|
|
if(onQuiz)R.drawable.quiz_button_full
|
|
|
|
else R.drawable.quiz_button_empty
|
|
|
|
else R.drawable.quiz_button_empty
|
|
|
|
),"Quiz",navControllerQuiz,index,onQuiz)
|
|
|
|
),"Quiz",navControllerQuiz,currentUserState.id,onQuiz)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -118,7 +125,7 @@ fun NavBar(onProfile : Boolean = false ,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
@Composable
|
|
|
|
fun ButtonIconVectorInt(img : ImageVector, name : String, nav : (Int)->Unit ,index: Int,onPage : Boolean){
|
|
|
|
fun ButtonIconVectorInt(img : String, name : String, nav : (Int)->Unit ,index: Int,onPage : Boolean){
|
|
|
|
IconButton(onClick = {nav(index)},
|
|
|
|
IconButton(onClick = {nav(index)},
|
|
|
|
enabled = !onPage,
|
|
|
|
enabled = !onPage,
|
|
|
|
colors = IconButtonColors(Color.Transparent, MaterialTheme.colorScheme.onBackground,//couleur quand il n'est pas selectionné
|
|
|
|
colors = IconButtonColors(Color.Transparent, MaterialTheme.colorScheme.onBackground,//couleur quand il n'est pas selectionné
|
|
|
@ -126,10 +133,13 @@ fun ButtonIconVectorInt(img : ImageVector, name : String, nav : (Int)->Unit ,ind
|
|
|
|
modifier = Modifier
|
|
|
|
modifier = Modifier
|
|
|
|
.size(60.dp)
|
|
|
|
.size(60.dp)
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
Icon(img,
|
|
|
|
|
|
|
|
|
|
|
|
Image(
|
|
|
|
|
|
|
|
painter = rememberAsyncImagePainter(img),
|
|
|
|
contentDescription = name,
|
|
|
|
contentDescription = name,
|
|
|
|
modifier = Modifier
|
|
|
|
modifier = Modifier
|
|
|
|
.fillMaxSize()
|
|
|
|
.fillMaxSize()
|
|
|
|
|
|
|
|
.clip(CircleShape) // Pour rendre l'image circulaire
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|