cards #8

Merged
faraphel merged 12 commits from cards into main 2024-06-13 15:12:13 +02:00
3 changed files with 27 additions and 13 deletions
Showing only changes of commit 6303c1ca86 - Show all commits

View file

@ -45,4 +45,3 @@ data class ValidationEntity (
const val TABLE_NAME = "validations" const val TABLE_NAME = "validations"
} }
} }

View file

@ -43,6 +43,7 @@ fun CommunicationWifiP2pServerContent(
bwfManager: BwfManager, bwfManager: BwfManager,
client: MutableState<TaskClient?> client: MutableState<TaskClient?>
) { ) {
/*
val expandedStudentList = remember { mutableStateOf(false) } val expandedStudentList = remember { mutableStateOf(false) }
val serverPort = remember { mutableIntStateOf(DEFAULT_SERVER_PORT) } val serverPort = remember { mutableIntStateOf(DEFAULT_SERVER_PORT) }
@ -98,6 +99,7 @@ fun CommunicationWifiP2pServerContent(
"admin", "admin",
"123456789", "123456789",
"admin", "admin",
) )
// Insert the admin in the database // Insert the admin in the database
@ -115,4 +117,5 @@ fun CommunicationWifiP2pServerContent(
Text("Create") Text("Create")
} }
} }
*/
} }

View file

@ -1,9 +1,16 @@
package com.faraphel.tasks_valider.ui.screen.task package com.faraphel.tasks_valider.ui.screen.task
import android.app.Activity import android.app.Activity
import android.widget.Toast
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import com.faraphel.tasks_valider.connectivity.task.TaskClient import com.faraphel.tasks_valider.connectivity.task.TaskClient
import com.faraphel.tasks_valider.connectivity.task.session.TaskSession
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
/** /**
@ -15,6 +22,13 @@ import com.faraphel.tasks_valider.connectivity.task.TaskClient
fun TaskSessionScreen(activity: Activity, client: TaskClient) { fun TaskSessionScreen(activity: Activity, client: TaskClient) {
Text("WIP : Session Screen") Text("WIP : Session Screen")
val session = remember { mutableStateOf<TaskSession?>(null) }
if (session.value == null)
return Thread { refreshGroups(activity, client, session) }.start()
Text("Session: ${session.value!!}")
/* /*
val students = remember { mutableStateOf<List<TaskGroupEntity>?>(null) } val students = remember { mutableStateOf<List<TaskGroupEntity>?>(null) }
@ -35,21 +49,19 @@ fun TaskSessionScreen(activity: Activity, client: TaskClient) {
} }
/* fun refreshGroups(activity: Activity, client: TaskClient, session: MutableState<TaskSession?>) {
fun refreshGroups(activity: Activity, client: TaskClient, groups: MutableState<List<TaskGroupEntity>?>) { val jsonParser = Gson()
// try to obtain the list of groups // try to obtain the list of groups
val response = client.get("entities/group") val response = client.get("sessions/self")
// in case of error, notify it // in case of error, notify it
if (!response.isSuccessful) { if (!response.isSuccessful)
Toast.makeText(activity, response.message, Toast.LENGTH_LONG).show() return activity.runOnUiThread { Toast.makeText(activity, response.message, Toast.LENGTH_LONG).show() }
return
}
// parse the list of groups // parse the list of groups
groups.value = jsonParser.fromJson( session.value = jsonParser.fromJson(
response.body.toString(), response.body.string(),
object : TypeToken<List<TaskGroupEntity>>(){} object : TypeToken<TaskSession>(){}.type
) )
} }
*/