diff --git a/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/HomeScreen.kt b/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/HomeScreen.kt index 91acf05..7891aed 100644 --- a/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/HomeScreen.kt +++ b/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/HomeScreen.kt @@ -3,7 +3,6 @@ package fr.uparis.diamantkennel.memorisationapplication import android.app.Activity import android.content.Context import android.content.Intent -import android.widget.Toast import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.foundation.layout.Arrangement @@ -113,7 +112,9 @@ fun HomeScreen( ActionRow(context, model, navController) - Button(onClick = { Toast.makeText(context, "Start", Toast.LENGTH_SHORT).show() }) { + Button( + enabled = currentSelection != null, + onClick = { navController.navigate(PLAY) }) { Text(text = context.getString(R.string.main_button_start), fontSize = 30.sp) } diff --git a/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/PlayScreen.kt b/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/PlayScreen.kt index c1da450..736aee3 100644 --- a/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/PlayScreen.kt +++ b/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/PlayScreen.kt @@ -1,10 +1,20 @@ package fr.uparis.diamantkennel.memorisationapplication +import android.widget.Toast import androidx.compose.foundation.layout.PaddingValues import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalContext +import androidx.lifecycle.viewmodel.compose.viewModel import androidx.navigation.NavController +import fr.uparis.diamantkennel.memorisationapplication.ui.PlayViewModel @Composable -fun PlayScreen(padding: PaddingValues, navController: NavController) { +fun PlayScreen( + padding: PaddingValues, + navController: NavController, + model: PlayViewModel = viewModel() +) { + val context = LocalContext.current + Toast.makeText(context, "Start", Toast.LENGTH_SHORT).show() } diff --git a/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/ui/PlayViewModel.kt b/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/ui/PlayViewModel.kt new file mode 100644 index 0000000..7abc73c --- /dev/null +++ b/app/src/main/java/fr/uparis/diamantkennel/memorisationapplication/ui/PlayViewModel.kt @@ -0,0 +1,10 @@ +package fr.uparis.diamantkennel.memorisationapplication.ui + +import android.app.Application +import androidx.lifecycle.AndroidViewModel +import fr.uparis.diamantkennel.memorisationapplication.MemoApplication + +class PlayViewModel(application: Application) : AndroidViewModel(application) { + private val dao = (application as MemoApplication).database.memoDao() + +}