|
|
|
@ -1,10 +1,13 @@
|
|
|
|
|
package sae.android.sae_2a.game
|
|
|
|
|
|
|
|
|
|
import android.widget.GridLayout
|
|
|
|
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
|
|
|
|
import androidx.compose.foundation.Image
|
|
|
|
|
import androidx.compose.foundation.border
|
|
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
|
|
import androidx.compose.foundation.layout.PaddingValues
|
|
|
|
|
import androidx.compose.foundation.layout.Row
|
|
|
|
|
import androidx.compose.foundation.layout.Spacer
|
|
|
|
|
import androidx.compose.foundation.layout.fillMaxHeight
|
|
|
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
|
|
@ -19,8 +22,11 @@ import androidx.compose.foundation.lazy.grid.GridItemSpan
|
|
|
|
|
import androidx.compose.foundation.lazy.grid.LazyGridScope
|
|
|
|
|
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
|
|
|
|
import androidx.compose.foundation.lazy.items
|
|
|
|
|
import androidx.compose.foundation.rememberScrollState
|
|
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
|
|
import androidx.compose.foundation.verticalScroll
|
|
|
|
|
import androidx.compose.material3.Card
|
|
|
|
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
@ -34,21 +40,39 @@ import androidx.compose.ui.res.painterResource
|
|
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
|
|
import androidx.compose.ui.text.style.TextAlign
|
|
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
|
|
import androidx.navigation.compose.rememberNavController
|
|
|
|
|
import sae.android.sae_2a.R
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun VocabularyScreen(onNavigateToList: () -> Unit){
|
|
|
|
|
fun VocabularyScreen(onNavigateToList: () -> Unit, onNavigateToDetails: (Vocabulary) -> Unit = {}){
|
|
|
|
|
val vocabulary = listOf(
|
|
|
|
|
Vocabulary("test","Autheur", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple")),
|
|
|
|
|
Vocabulary("test2","Autheur2", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple"))
|
|
|
|
|
Vocabulary("test","Auteur", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple")),
|
|
|
|
|
Vocabulary("test2","Auteur2", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple")),
|
|
|
|
|
Vocabulary("test","Auteur", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple")),
|
|
|
|
|
Vocabulary("test2","Auteur2", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple")),
|
|
|
|
|
Vocabulary("test","Auteur", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple")),
|
|
|
|
|
Vocabulary("test2","Auteur2", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple")),
|
|
|
|
|
Vocabulary("test","Auteur", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple")),
|
|
|
|
|
Vocabulary("test2","Auteur2", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple")),
|
|
|
|
|
Vocabulary("test","Auteur", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple")),
|
|
|
|
|
Vocabulary("test2","Auteur2", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple")),
|
|
|
|
|
Vocabulary("test","Auteur", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple")),
|
|
|
|
|
Vocabulary("test2","Auteur2", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple")),
|
|
|
|
|
Vocabulary("test","Auteur", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple")),
|
|
|
|
|
Vocabulary("test2","Auteur2", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple")),
|
|
|
|
|
Vocabulary("test","Auteur", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple")),
|
|
|
|
|
Vocabulary("test2","Auteur2", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple")),
|
|
|
|
|
Vocabulary("test","Auteur", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple")),
|
|
|
|
|
Vocabulary("test2","Auteur2", hashMapOf("Fromage" to "Cheese", "Pomme" to "Apple")),
|
|
|
|
|
)
|
|
|
|
|
DisplayLists(vocabulary)
|
|
|
|
|
DisplayLists(vocabulary, onNavigateToDetails)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun DisplayLists(vocabulary: List<Vocabulary>) {
|
|
|
|
|
fun DisplayLists(vocabulary: List<Vocabulary>, onCardClick: (Vocabulary) -> Unit = {}){
|
|
|
|
|
LazyVerticalGrid( columns = GridCells.Adaptive(150.dp),
|
|
|
|
|
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
|
|
|
|
contentPadding = PaddingValues(10.dp),
|
|
|
|
|
verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
|
|
|
|
items(vocabulary.size) { voc ->
|
|
|
|
|
VocCard(vocabulary[voc])
|
|
|
|
@ -58,9 +82,12 @@ fun DisplayLists(vocabulary: List<Vocabulary>) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
|
|
|
@Composable
|
|
|
|
|
fun VocCard(vocabulary: Vocabulary){
|
|
|
|
|
Card(shape = RectangleShape,
|
|
|
|
|
onClick = {
|
|
|
|
|
},
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.size(150.dp, 150.dp)
|
|
|
|
|
.border(2.dp, Color.DarkGray, shape = RoundedCornerShape(8.dp, 8.dp))) {
|
|
|
|
@ -94,3 +121,84 @@ fun PreviewCard(){
|
|
|
|
|
laMap["Pomme"] = "Apple"
|
|
|
|
|
VocCard(Vocabulary("test","Autheur", laMap))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Preview
|
|
|
|
|
@Composable
|
|
|
|
|
fun PreviewVocabularyScreen(){
|
|
|
|
|
VocabularyScreen({})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@OptIn(ExperimentalFoundationApi::class)
|
|
|
|
|
@Composable
|
|
|
|
|
fun VocabularyDetails(vocabulary: Vocabulary){
|
|
|
|
|
LazyColumn(modifier = Modifier.fillMaxSize()) {
|
|
|
|
|
stickyHeader(
|
|
|
|
|
) {
|
|
|
|
|
Text(
|
|
|
|
|
vocabulary.name, fontSize = 30.sp,
|
|
|
|
|
textAlign = TextAlign.Center,
|
|
|
|
|
modifier = Modifier.fillMaxWidth()
|
|
|
|
|
)
|
|
|
|
|
Text(
|
|
|
|
|
stringResource(R.string.created_by) + (vocabulary.aut
|
|
|
|
|
?: stringResource(id = R.string.unknown)),
|
|
|
|
|
fontSize = 20.sp,
|
|
|
|
|
textAlign = TextAlign.Center,
|
|
|
|
|
modifier = Modifier.fillMaxWidth()
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
vocabulary.words.forEach { (key, value) ->
|
|
|
|
|
item {
|
|
|
|
|
WordCard(key, value)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun WordCard(key: String, value: String) {
|
|
|
|
|
Row {
|
|
|
|
|
Card(
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.fillMaxWidth()
|
|
|
|
|
.padding(10.dp)
|
|
|
|
|
.weight(0.5f)
|
|
|
|
|
) {
|
|
|
|
|
Text(text = key, fontSize = 30.sp,
|
|
|
|
|
textAlign = TextAlign.Center,
|
|
|
|
|
modifier = Modifier.fillMaxWidth())
|
|
|
|
|
}
|
|
|
|
|
Card(
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.fillMaxWidth()
|
|
|
|
|
.padding(10.dp)
|
|
|
|
|
.weight(0.5f)
|
|
|
|
|
) {
|
|
|
|
|
Text(text = value, fontSize = 30.sp,
|
|
|
|
|
textAlign = TextAlign.Center,
|
|
|
|
|
modifier = Modifier.fillMaxWidth())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Preview
|
|
|
|
|
@Composable
|
|
|
|
|
fun PreviewVocabularyDetails(){
|
|
|
|
|
val laMap = HashMap<String, String>()
|
|
|
|
|
laMap["Fromage"] = "Cheese"
|
|
|
|
|
laMap["Pomme"] = "Apple"
|
|
|
|
|
laMap["Pain"] = "Bread"
|
|
|
|
|
laMap["Eau"] = "Water"
|
|
|
|
|
laMap["Lait"] = "Milk"
|
|
|
|
|
laMap["Beurre"] = "Butter"
|
|
|
|
|
laMap["Sucre"] = "Sugar"
|
|
|
|
|
laMap["Sel"] = "Salt"
|
|
|
|
|
laMap["Poivre"] = "Pepper"
|
|
|
|
|
laMap["Farine"] = "Flour"
|
|
|
|
|
laMap["Oeuf"] = "Egg"
|
|
|
|
|
laMap["Viande"] = "Meat"
|
|
|
|
|
laMap["Poisson"] = "Fish"
|
|
|
|
|
laMap["Légume"] = "Vegetable"
|
|
|
|
|
laMap["Fruit"] = "Fruit"
|
|
|
|
|
VocabularyDetails(Vocabulary("test","Autheur", laMap))
|
|
|
|
|
}
|