finnition Search

SearchPage
brongniart 3 months ago
parent a4e874b8fc
commit da07d3fe25

@ -1,7 +1,10 @@
package com.example.what_the_fantasy.data.model
import androidx.compose.ui.res.stringResource
import com.example.what_the_fantasy.R
enum class SrcType (val value: String) {
Movie("@string/movie"),
VideoGame("@string/videoGame"),
Series("@string/series"),
Movie("movie" ),
VideoGame("videoGame"),
Series("series"),
}

@ -40,7 +40,7 @@ data class QuizEnd(val userIndex: Int, val idQuiz: Int, val pts: Int)
data class OneQuote(val quoteId: Int, val userIndex: Int)
@Serializable
data class Search(val userIndex: Int,val type : String = "", val search: String = "")
data class Search(val userIndex: Int,val type : String = "contenue", val search: String = "")
@Serializable
data object SignUp

@ -98,6 +98,7 @@ fun IdentifiantTextField(textIdentifiantResId : Int) : String{
.fillMaxWidth()
.padding(top = 8.dp),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
maxLines = 1,
shape = RoundedCornerShape(16.dp) // Bords arrondis
)
}
@ -118,6 +119,7 @@ fun PassWdTextField(textpasswdResId : Int) : String{
.fillMaxWidth()
.padding(top = 8.dp),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password),
maxLines = 1,
visualTransformation = if (passwordVisible) VisualTransformation.None else PasswordVisualTransformation(),
trailingIcon = {
IconButton(onClick = { passwordVisible = !passwordVisible }) {

@ -2,19 +2,34 @@ package com.example.what_the_fantasy.ui.screens
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.selection.selectable
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Search
import androidx.compose.material3.Button
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.RadioButton
import androidx.compose.material3.SearchBar
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
@ -24,20 +39,27 @@ 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
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.pointer.motionEventSpy
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.what_the_fantasy.R
import com.example.what_the_fantasy.data.local.DailyQuoteStub
import com.example.what_the_fantasy.data.local.QuoteStub
import com.example.what_the_fantasy.data.model.SrcType
import com.example.what_the_fantasy.data.services.IServices
import com.example.what_the_fantasy.data.services.ServicesStub
import com.example.what_the_fantasy.ui.components.NavBar
import com.example.what_the_fantasy.ui.components.QuoteLittle
import com.example.what_the_fantasy.ui.theme.colorBackground
import com.example.what_the_fantasy.ui.theme.colorNavBar
@Composable
fun SearchPage(
@ -54,7 +76,10 @@ fun SearchPage(
) {
var itemCount by remember { mutableStateOf(15) }
val quotes = services.search(type,search,itemCount)
var newSearch by remember { mutableStateOf(search) }
val filtre = listOf("contenue","personnage","titre")
val (newFiltre, onFiltreSelected) = remember { mutableStateOf(type) }
NavBar(
onAccueil = true,
@ -62,7 +87,7 @@ fun SearchPage(
navControllerAccueil = navAccueil,
navControllerProfil = navProfil,
navControllerQuiz = navQuiz,
navControllerSearch = {navSearch("","")}
navControllerSearch = {navSearch("contenue","")}
) {
Column(
modifier = Modifier
@ -79,22 +104,59 @@ fun SearchPage(
.padding(16.dp),
textAlign = TextAlign.Center
)
Row(){
Column (horizontalAlignment = Alignment.CenterHorizontally
){
OutlinedTextField(
value = newSearch,
onValueChange = { newSearch = it },
label = { Text(newSearch) },
textStyle = TextStyle(color = Color.White),
modifier = Modifier
.padding(top = 2.dp)
.fillMaxWidth()
.padding(top = 8.dp),
.height(50.dp),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
shape = RoundedCornerShape(16.dp) // Bords arrondis
maxLines = 1,
shape = CircleShape, // Bords arrondis
trailingIcon = {
IconButton(onClick = { navSearch(newFiltre, newSearch) } ,
modifier = Modifier
.size(50.dp)
.clip(CircleShape)
) {
Icon(Icons.Rounded.Search,
contentDescription = stringResource(R.string.TitleSearch),
Modifier
.fillMaxSize()
.background(Color.Magenta,CircleShape)
)
}
}
)
Button(onClick = { navSearch("", newSearch) }) {
Text(
"Search",
color = Color.White
)
Row(horizontalArrangement = Arrangement.SpaceAround) {
filtre.forEach{ type ->
Row(
Modifier
.height(56.dp)
.selectable(
selected = (type == newFiltre),
onClick = { onFiltreSelected(type) },
role = Role.RadioButton
)
.padding(horizontal = 16.dp),
verticalAlignment = Alignment.CenterVertically
) {
RadioButton(
selected = (type == newFiltre),
onClick = null // null recommended for accessibility with screen readers
)
Text(
text = type,
style = MaterialTheme.typography.bodyLarge,
modifier = Modifier.padding(start = 16.dp),
color = Color.White
)
}
}
}
}
LazyColumn(modifier = Modifier.weight(1f)) {

Loading…
Cancel
Save