@ -1,8 +1,13 @@
package fr.iut.sciencequest.view
package fr.iut.sciencequest.view
import android.widget.Toast
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.ClickableText
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.Button
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.Text
@ -12,8 +17,15 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.dp
import fr.iut.sciencequest.R
import fr.iut.sciencequest.R
@ -24,14 +36,16 @@ fun LoginScreen(goToAccount: () -> Unit, goToHome: () -> Unit) {
TopBar ( goToAccount , goToHome , stringResource ( id = R . string . connection ) )
TopBar ( goToAccount , goToHome , stringResource ( id = R . string . connection ) )
} ,
} ,
) { innerPadding ->
) { innerPadding ->
LoginContainer ( innerPadding )
LoginContainer ( Modifier . padding ( innerPadding ) )
}
}
}
}
@Composable
@Composable
fun LoginContainer ( innerPadding : PaddingValues ) {
fun LoginContainer ( modifier: Modifier ) {
Column (
Column (
modifier = Modifier . padding ( innerPadding )
modifier = modifier . fillMaxHeight ( ) ,
horizontalAlignment = Alignment . CenterHorizontally ,
verticalArrangement = Arrangement . Center
) {
) {
val defaultPseudo = stringResource ( id = R . string . Pseudo )
val defaultPseudo = stringResource ( id = R . string . Pseudo )
var pseudo by remember {
var pseudo by remember {
@ -45,11 +59,15 @@ fun LoginContainer(innerPadding : PaddingValues) {
//Text(text = stringResource(id = R.string.connection))
//Text(text = stringResource(id = R.string.connection))
TextField ( value = pseudo ,
TextField ( value = pseudo ,
onValueChange = { pseudo = it } ,
onValueChange = { pseudo = it } ,
modifier = Modifier . padding ( 20. dp )
modifier = Modifier
. padding ( 20. dp )
. fillMaxWidth ( )
)
)
TextField ( value = mdp ,
TextField ( value = mdp ,
onValueChange = { mdp = it } ,
onValueChange = { mdp = it } ,
modifier = Modifier . padding ( 20. dp )
modifier = Modifier
. padding ( 20. dp )
. fillMaxWidth ( )
)
)
Button ( onClick = { /*TODO*/ } ,
Button ( onClick = { /*TODO*/ } ,
@ -57,6 +75,52 @@ fun LoginContainer(innerPadding : PaddingValues) {
) {
) {
Text ( text = stringResource ( id = R . string . connection ) )
Text ( text = stringResource ( id = R . string . connection ) )
}
}
ClickableText (
text = AnnotatedString ( stringResource ( id = R . string . no _account ) ) ,
style = TextStyle (
textDecoration = TextDecoration . Underline ,
color = colorResource ( id = R . color . purple _200 )
) ,
onClick = registerPopup ( )
)
}
}
}
}
@Composable
fun registerClick ( text : Int ) : ( ) -> Unit {
Toast . makeText ( LocalContext . current , text , Toast . LENGTH _SHORT ) . show ( )
return { }
}
@Composable
fun registerPopup ( ) : ( Int ) -> Unit {
AlertDialog (
onDismissRequest = { } ,
title = {
Text ( text = stringResource ( id = R . string . no _account ) )
} ,
text = {
Text ( text = stringResource ( id = R . string . no _account _details ) )
} ,
confirmButton = {
Button ( onClick = registerClick ( R . string . coming _soon ) ) {
Text ( text = stringResource ( id = R . string . inscription ) )
}
} ,
dismissButton = {
Button ( onClick = { /*TODO*/ } ) {
Text ( text = stringResource ( id = R . string . continue _no _acc ) )
}
}
)
return { }
}
@Composable
@Preview
fun LoginScreenPreview ( ) {
LoginScreen ( goToAccount = { } , goToHome = { } )
}