@ -9,6 +9,7 @@ import androidx.compose.animation.fadeOut
import androidx.compose.animation.shrinkVertically
import androidx.compose.animation.shrinkVertically
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.animation.slideOutVertically
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
@ -20,7 +21,9 @@ import androidx.compose.foundation.layout.padding
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.items
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.Send
import androidx.compose.material.icons.automirrored.filled.Send
@ -43,7 +46,9 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.dp
@ -52,6 +57,7 @@ import com.example.what_the_fantasy.R
import coil.compose.AsyncImage
import coil.compose.AsyncImage
import com.example.what_the_fantasy.data.model.Comment
import com.example.what_the_fantasy.data.model.Comment
import com.example.what_the_fantasy.data.services.IServices
import com.example.what_the_fantasy.data.services.IServices
import com.example.what_the_fantasy.logs.LogsUsers
import com.example.what_the_fantasy.ui.components.NavBar
import com.example.what_the_fantasy.ui.components.NavBar
import com.example.what_the_fantasy.ui.states.CurrentUserState
import com.example.what_the_fantasy.ui.states.CurrentUserState
import com.example.what_the_fantasy.ui.theme.colorBackground
import com.example.what_the_fantasy.ui.theme.colorBackground
@ -93,7 +99,8 @@ fun QuotePage(
Box (
Box (
modifier = Modifier
modifier = Modifier
. fillMaxSize ( )
. fillMaxSize ( )
. background ( MaterialTheme . colorScheme . background ) ,
. background ( MaterialTheme . colorScheme . background )
. verticalScroll ( rememberScrollState ( ) ) ,
contentAlignment = Alignment . Center
contentAlignment = Alignment . Center
) {
) {
Column ( modifier = Modifier
Column ( modifier = Modifier
@ -112,7 +119,7 @@ fun QuotePage(
FunctionalIcon (
FunctionalIcon (
isFavorite = favorite ,
isFavorite = favorite ,
userId = currentUserState . id ,
userId = currentUserState . id ,
i d = quoteId ,
quoteI d = quoteId ,
context = context ,
context = context ,
service = service
service = service
)
)
@ -133,6 +140,17 @@ fun QuotePage(
nameId = R . string . charac ,
nameId = R . string . charac ,
text = quote . character
text = quote . character
)
)
InfoQuoteText (
nameId = R . string . date ,
text = quote . date . toString ( )
)
InfoQuoteText (
nameId = R . string . type ,
text = quote . type . toString ( )
)
Row (
Row (
modifier = Modifier
modifier = Modifier
. padding ( top = 10. dp )
. padding ( top = 10. dp )
@ -191,7 +209,9 @@ fun ImageQuote(imageUrl : String){
}
}
@Composable
@Composable
fun FunctionalIcon ( isFavorite : Boolean , userId : Int , id : Int , context : Context , service : IServices ) {
fun FunctionalIcon ( isFavorite : Boolean , userId : Int , quoteId : Int , context : Context , service : IServices ) {
val logsUsers = LogsUsers ( )
Row ( modifier = Modifier
Row ( modifier = Modifier
. fillMaxWidth ( )
. fillMaxWidth ( )
) {
) {
@ -201,9 +221,10 @@ fun FunctionalIcon(isFavorite: Boolean, userId : Int, id : Int, context : Contex
val sendIntent = Intent ( ) . apply {
val sendIntent = Intent ( ) . apply {
action = Intent . ACTION _SEND
action = Intent . ACTION _SEND
// lien a changer quand le site sra deployer
// lien a changer quand le site sra deployer
putExtra ( Intent . EXTRA _TEXT , " http://wfWebsite/quote/ $ i d" )
putExtra ( Intent . EXTRA _TEXT , " http://wfWebsite/quote/ $ quoteI d" )
type = " text/plain "
type = " text/plain "
addFlags ( Intent . FLAG _ACTIVITY _NEW _TASK )
addFlags ( Intent . FLAG _ACTIVITY _NEW _TASK )
logsUsers . shareInformationUser ( " ShareQuote " , quoteId , userId )
}
}
val shareIntent = Intent . createChooser ( sendIntent , null )
val shareIntent = Intent . createChooser ( sendIntent , null )
@ -213,6 +234,7 @@ fun FunctionalIcon(isFavorite: Boolean, userId : Int, id : Int, context : Contex
} ,
} ,
modifier = Modifier . padding ( start = 15. dp )
modifier = Modifier . padding ( start = 15. dp )
) {
) {
Icon (
Icon (
Icons . Default . Share ,
Icons . Default . Share ,
contentDescription = stringResource ( R . string . share ) ,
contentDescription = stringResource ( R . string . share ) ,
@ -225,16 +247,21 @@ fun FunctionalIcon(isFavorite: Boolean, userId : Int, id : Int, context : Contex
} ,
} ,
modifier = Modifier . padding ( start = 20. dp )
modifier = Modifier . padding ( start = 20. dp )
) {
) {
Icon (
Image (
Icons . Default . MailOutline ,
painter = painterResource ( id = R . drawable . message ) ,
contentDescription = stringResource ( R . string . comment ) ,
contentDescription = " message " ,
tint = MaterialTheme . colorScheme . onPrimary ,
modifier = Modifier . size ( 30. dp ) ,
colorFilter = ColorFilter . tint ( MaterialTheme . colorScheme . onPrimary )
)
)
}
}
if ( isFavorite ) {
if ( isFavorite ) {
IconButton (
IconButton (
onClick = { service . SupFav ( userId = userId , QuoteId = id ) } , //sup fav
onClick = {
service . SupFav ( userId = userId , QuoteId = quoteId )
logsUsers . favoriteInformationUserFalse ( " Favorite " , quoteId , userId )
} , //sup fav
modifier = Modifier . padding ( start = 20. dp )
modifier = Modifier . padding ( start = 20. dp )
) {
) {
Icon (
Icon (
@ -247,7 +274,10 @@ fun FunctionalIcon(isFavorite: Boolean, userId : Int, id : Int, context : Contex
}
}
else {
else {
IconButton (
IconButton (
onClick = { service . AddFav ( userId = userId , QuoteId = id ) } , //add fav
onClick = {
service . AddFav ( userId = userId , QuoteId = quoteId )
logsUsers . favoriteInformationUserTrue ( " Favorite " , quoteId , userId )
} , //add fav
modifier = Modifier . padding ( start = 50. dp )
modifier = Modifier . padding ( start = 50. dp )
) {
) {
Icon (
Icon (