navigate to modify-screen
This commit is contained in:
parent
2cb5712617
commit
cf161ed12c
3 changed files with 19 additions and 21 deletions
|
@ -43,6 +43,7 @@ import androidx.compose.ui.semantics.Role
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
|
import androidx.navigation.NavController
|
||||||
import fr.uparis.diamantkennel.memorisationapplication.data.SetOfQuestions
|
import fr.uparis.diamantkennel.memorisationapplication.data.SetOfQuestions
|
||||||
import fr.uparis.diamantkennel.memorisationapplication.data.SetQuestions
|
import fr.uparis.diamantkennel.memorisationapplication.data.SetQuestions
|
||||||
import fr.uparis.diamantkennel.memorisationapplication.ui.ActionHome
|
import fr.uparis.diamantkennel.memorisationapplication.ui.ActionHome
|
||||||
|
@ -55,7 +56,9 @@ import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun HomeScreen(padding: PaddingValues, model: HomeViewModel = viewModel()) {
|
fun HomeScreen(
|
||||||
|
padding: PaddingValues, navController: NavController, model: HomeViewModel = viewModel()
|
||||||
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
val setOfQuestions by model.setFlow.collectAsState(listOf())
|
val setOfQuestions by model.setFlow.collectAsState(listOf())
|
||||||
|
@ -106,7 +109,7 @@ fun HomeScreen(padding: PaddingValues, model: HomeViewModel = viewModel()) {
|
||||||
) {
|
) {
|
||||||
ShowList(setOfQuestions, currentSelection, model::updateSelection)
|
ShowList(setOfQuestions, currentSelection, model::updateSelection)
|
||||||
|
|
||||||
ActionRow(context, model)
|
ActionRow(context, model, navController)
|
||||||
|
|
||||||
Button(onClick = { Toast.makeText(context, "Start", Toast.LENGTH_SHORT).show() }) {
|
Button(onClick = { Toast.makeText(context, "Start", Toast.LENGTH_SHORT).show() }) {
|
||||||
Text(text = context.getString(R.string.main_button_start), fontSize = 30.sp)
|
Text(text = context.getString(R.string.main_button_start), fontSize = 30.sp)
|
||||||
|
@ -128,9 +131,7 @@ private fun DeleteRow(
|
||||||
modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center
|
modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center
|
||||||
) {
|
) {
|
||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = { (model::doAction)(ActionHome.DELETION_DB) },
|
||||||
(model::doAction)(ActionHome.DELETION_DB)
|
|
||||||
},
|
|
||||||
colors = ButtonDefaults.buttonColors(containerColor = colorResource(id = R.color.red))
|
colors = ButtonDefaults.buttonColors(containerColor = colorResource(id = R.color.red))
|
||||||
) {
|
) {
|
||||||
Text(text = context.getString(R.string.main_button_deletebase))
|
Text(text = context.getString(R.string.main_button_deletebase))
|
||||||
|
@ -138,37 +139,30 @@ private fun DeleteRow(
|
||||||
|
|
||||||
Spacer(modifier = Modifier.padding(2.dp))
|
Spacer(modifier = Modifier.padding(2.dp))
|
||||||
|
|
||||||
Button(enabled = selection != null,
|
Button(enabled = selection != null, onClick = {
|
||||||
onClick = {
|
(model::doAction)(ActionHome.DELETION_SELECT)
|
||||||
(model::doAction)(ActionHome.DELETION_SELECT)
|
}) {
|
||||||
}) {
|
|
||||||
Text(text = context.getString(R.string.main_button_delete))
|
Text(text = context.getString(R.string.main_button_delete))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ActionRow(
|
private fun ActionRow(context: Context, model: HomeViewModel, navController: NavController) {
|
||||||
context: Context, model: HomeViewModel
|
|
||||||
) {
|
|
||||||
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
|
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
|
||||||
Button(onClick = {
|
Button(onClick = { (model::doAction)(ActionHome.CREATION) }) {
|
||||||
(model::doAction)(ActionHome.CREATION)
|
|
||||||
}) {
|
|
||||||
Text(text = context.getString(R.string.main_button_create))
|
Text(text = context.getString(R.string.main_button_create))
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.padding(2.dp))
|
Spacer(modifier = Modifier.padding(2.dp))
|
||||||
|
|
||||||
Button(onClick = { Toast.makeText(context, "Modify", Toast.LENGTH_SHORT).show() }) {
|
Button(onClick = { navController.navigate(MODIFY_SET) }) {
|
||||||
Text(text = context.getString(R.string.main_button_modify))
|
Text(text = context.getString(R.string.main_button_modify))
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.padding(2.dp))
|
Spacer(modifier = Modifier.padding(2.dp))
|
||||||
|
|
||||||
Button(onClick = {
|
Button(onClick = { (model::doAction)(ActionHome.IMPORTATION) }) {
|
||||||
(model::doAction)(ActionHome.IMPORTATION)
|
|
||||||
}) {
|
|
||||||
Text(text = context.getString(R.string.main_button_import))
|
Text(text = context.getString(R.string.main_button_import))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ fun MainScreen() {
|
||||||
startDestination = HOME,
|
startDestination = HOME,
|
||||||
modifier = Modifier.padding(padding)
|
modifier = Modifier.padding(padding)
|
||||||
) {
|
) {
|
||||||
composable(HOME) { HomeScreen(padding) }
|
composable(HOME) { HomeScreen(padding, navController) }
|
||||||
composable(MODIFY_SET) { ModifySetScreen(padding, navController) }
|
composable(MODIFY_SET) { ModifySetScreen(padding, navController) }
|
||||||
composable(PLAY) { PlayScreen(padding, navController) }
|
composable(PLAY) { PlayScreen(padding, navController) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
package fr.uparis.diamantkennel.memorisationapplication
|
package fr.uparis.diamantkennel.memorisationapplication
|
||||||
|
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ModifySetScreen(padding: PaddingValues, navController: NavController) {
|
fun ModifySetScreen(padding: PaddingValues, navController: NavController) {
|
||||||
|
val context = LocalContext.current
|
||||||
|
|
||||||
|
Toast.makeText(context, "Modify", Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue