From 2f57ac9d826d221058ac5ef2b54b1f5b7b678458 Mon Sep 17 00:00:00 2001 From: "kevin.modejar" Date: Fri, 7 Mar 2025 12:01:15 +0100 Subject: [PATCH] debut mvvm et commentaire --- .../data/mvvm/AppViewModel.kt | 9 +++++++ .../what_the_fantasy/ui/screens/QuotePage.kt | 27 +++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/mvvm/AppViewModel.kt diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/mvvm/AppViewModel.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/mvvm/AppViewModel.kt new file mode 100644 index 0000000..2a845ae --- /dev/null +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/data/mvvm/AppViewModel.kt @@ -0,0 +1,9 @@ +package com.example.what_the_fantasy.data.mvvm + +import androidx.lifecycle.ViewModel +import com.example.what_the_fantasy.data.model.Quiz +import com.example.what_the_fantasy.data.model.Quote + +class AppViewModel: ViewModel() { + +} \ No newline at end of file diff --git a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt index 16dcfac..2a6aa15 100644 --- a/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt +++ b/What_The_Fantasy/app/src/main/java/com/example/what_the_fantasy/ui/screens/QuotePage.kt @@ -20,6 +20,10 @@ import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -41,6 +45,8 @@ import com.example.what_the_fantasy.ui.theme.iconText import com.example.what_the_fantasy.ui.theme.likeIcon import com.example.what_the_fantasy.ui.theme.whiteBackcgroundText +var isCommentVisible by mutableStateOf(false) + @Composable fun QuotePage( quoteId : Int, @@ -51,6 +57,7 @@ fun QuotePage( navQuiz: (Int) -> Unit, navProfil:(Int) -> Unit) { + // utiliser ViewModel var quote = service.getQuote(quoteId) ?: return val context = LocalContext.current NavBar(onProfile = true, @@ -118,6 +125,13 @@ fun QuotePage( } } } + if(isCommentVisible){ + Box(modifier = Modifier.fillMaxWidth().background(Color.White)){ + Column { + + } + } + } } } @@ -175,7 +189,14 @@ fun FunctionalIcon(isFavorite: Boolean, id : Int, context : Context){ ) } IconButton( - onClick = { }, //Go to comment + onClick = { + if(isCommentVisible){ + isCommentVisible = false + } + else{ + isCommentVisible = true + } + }, //Go to comment modifier = Modifier.padding(start = 20.dp) ){ Icon( @@ -251,4 +272,6 @@ fun LikeInfo(likes : Int){ contentDescription = stringResource(R.string.favorite), tint = iconText, ) -} \ No newline at end of file +} + +