|
|
|
@ -1,15 +1,7 @@
|
|
|
|
|
package com.example.what_the_fantasy.ui.screens
|
|
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
|
import android.os.Bundle
|
|
|
|
|
import android.util.Patterns
|
|
|
|
|
import android.widget.ImageView
|
|
|
|
|
import androidx.activity.ComponentActivity
|
|
|
|
|
import androidx.activity.compose.setContent
|
|
|
|
|
import androidx.activity.enableEdgeToEdge
|
|
|
|
|
import androidx.compose.foundation.Image
|
|
|
|
|
import androidx.compose.foundation.background
|
|
|
|
|
import androidx.compose.foundation.border
|
|
|
|
|
import androidx.compose.foundation.clickable
|
|
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
|
@ -25,16 +17,13 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
|
|
import androidx.compose.foundation.text.KeyboardActions
|
|
|
|
|
import androidx.compose.foundation.text.KeyboardOptions
|
|
|
|
|
import androidx.compose.material.icons.Icons
|
|
|
|
|
import androidx.compose.material.icons.filled.Check
|
|
|
|
|
import androidx.compose.material.icons.filled.CheckCircle
|
|
|
|
|
import androidx.compose.material.icons.filled.Edit
|
|
|
|
|
import androidx.compose.material.icons.rounded.Face
|
|
|
|
|
import androidx.compose.material3.Button
|
|
|
|
|
import androidx.compose.material3.ButtonDefaults
|
|
|
|
|
import androidx.compose.material3.Icon
|
|
|
|
|
import androidx.compose.material3.IconButton
|
|
|
|
|
import androidx.compose.material3.OutlinedTextField
|
|
|
|
|
import androidx.compose.material3.Scaffold
|
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
import androidx.compose.runtime.getValue
|
|
|
|
@ -44,10 +33,7 @@ import androidx.compose.runtime.setValue
|
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
import androidx.compose.ui.draw.clip
|
|
|
|
|
import androidx.compose.ui.geometry.Offset
|
|
|
|
|
import androidx.compose.ui.graphics.Brush
|
|
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
|
|
import androidx.compose.ui.res.painterResource
|
|
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
|
|
import androidx.compose.ui.text.TextStyle
|
|
|
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
|
|
@ -55,22 +41,17 @@ import androidx.compose.ui.text.input.ImeAction
|
|
|
|
|
import androidx.compose.ui.text.input.KeyboardType
|
|
|
|
|
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
|
|
|
|
import androidx.compose.ui.text.input.VisualTransformation
|
|
|
|
|
import androidx.compose.ui.tooling.preview.Preview
|
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
|
|
import androidx.navigation.NavController
|
|
|
|
|
import coil.compose.AsyncImage
|
|
|
|
|
import com.example.what_the_fantasy.Logs.LogsUsers
|
|
|
|
|
import com.example.what_the_fantasy.R
|
|
|
|
|
import com.example.what_the_fantasy.data.local.QuestionStub
|
|
|
|
|
import com.example.what_the_fantasy.data.local.UserStub
|
|
|
|
|
import com.example.what_the_fantasy.data.model.User
|
|
|
|
|
import com.example.what_the_fantasy.data.services.IServices
|
|
|
|
|
//import com.example.what_the_fantasy.data.local.UserStub.users
|
|
|
|
|
import com.example.what_the_fantasy.data.services.ServicesStub
|
|
|
|
|
import com.example.what_the_fantasy.ui.components.ErrorMessageProfileComponent
|
|
|
|
|
import com.example.what_the_fantasy.ui.components.NavBar
|
|
|
|
|
import com.example.what_the_fantasy.ui.components.SpaceHeightComponent
|
|
|
|
|
import com.example.what_the_fantasy.ui.components.TitlePageComponent
|
|
|
|
|
import com.example.what_the_fantasy.ui.theme.What_The_FantasyTheme
|
|
|
|
|
import com.example.what_the_fantasy.ui.theme.gradienBox
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
@ -127,9 +108,11 @@ fun ProfilPage(index: Int,
|
|
|
|
|
// Bouton
|
|
|
|
|
//ButtonProfile(R.string.ButtonAddQuoteprofile, 18, Color.Black, Color.White,navUnLog) // Pas encore de navigation definie
|
|
|
|
|
//SpaceHeightComponent(16)
|
|
|
|
|
ButtonProfile(R.string.ButtonLanguageprofile, 18, Color.Black, Color.White,navUnLog) // Pas encore de navigation definie
|
|
|
|
|
ButtonLanguage(R.string.ButtonLanguageprofile, 18, Color.Black, Color.White,services, user)
|
|
|
|
|
SpaceHeightComponent(16)
|
|
|
|
|
ButtonProfile(R.string.ButtonUnlogprofile, 18, Color.Black, Color.White, navUnLog)
|
|
|
|
|
ButtonUnLog(R.string.ButtonUnlogprofile, 18, Color.Black, Color.White,navUnLog)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -156,8 +139,8 @@ fun EditEmail(userEmail: String, index: Int, service: IServices) {
|
|
|
|
|
var emailError by remember { mutableStateOf(false) }
|
|
|
|
|
|
|
|
|
|
fun onDoneEditing() {
|
|
|
|
|
service.EditEmail(email, index)
|
|
|
|
|
isEditingEmail = false
|
|
|
|
|
isEditingEmail =!service.EditEmail(email, index)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isEditingEmail) {
|
|
|
|
@ -242,8 +225,7 @@ fun EditUsername(userName: String, index: Int, service : IServices) {
|
|
|
|
|
var isEditingUsername by remember { mutableStateOf(false) }
|
|
|
|
|
|
|
|
|
|
fun onDoneEditing() {
|
|
|
|
|
service.EditUsername(username, index)
|
|
|
|
|
isEditingUsername = false
|
|
|
|
|
isEditingUsername= !service.EditUsername(username, index)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isEditingUsername) {
|
|
|
|
@ -459,13 +441,34 @@ fun DisplayPassword(onEdit: () -> Unit) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun ButtonProfile(textResId : Int, size :Int, colorTexte : Color, colorButton : Color,navController: () -> Unit){
|
|
|
|
|
fun ButtonUnLog(textResId : Int, size :Int, colorTexte : Color, colorButton : Color,navController: () -> Unit){
|
|
|
|
|
val text = stringResource(id = textResId)
|
|
|
|
|
val logsUser = LogsUsers() //gestion des logs pour les utilisateurs
|
|
|
|
|
|
|
|
|
|
Button(
|
|
|
|
|
onClick = { navController() },
|
|
|
|
|
onClick = {
|
|
|
|
|
navController()
|
|
|
|
|
logsUser.unlogInformationUserConnect("UserUnLog")
|
|
|
|
|
},
|
|
|
|
|
colors = ButtonDefaults.buttonColors(containerColor = colorButton),
|
|
|
|
|
modifier = Modifier.fillMaxWidth(),
|
|
|
|
|
) {
|
|
|
|
|
Text(text, fontSize = size.sp, color = colorTexte)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun ButtonLanguage(textResId : Int, size :Int, colorTexte : Color, colorButton : Color, service: IServices, user : User){
|
|
|
|
|
val text = stringResource(id = textResId)
|
|
|
|
|
val currentLangage = remember { mutableStateOf(user.langage) }
|
|
|
|
|
Button(
|
|
|
|
|
onClick = {
|
|
|
|
|
service.ChangeLangage(user)
|
|
|
|
|
currentLangage.value = user.langage
|
|
|
|
|
},
|
|
|
|
|
colors = ButtonDefaults.buttonColors(containerColor = colorButton),
|
|
|
|
|
modifier = Modifier.fillMaxWidth(),
|
|
|
|
|
) {
|
|
|
|
|
Text("${text} (${currentLangage.value})", fontSize = size.sp, color = colorTexte)
|
|
|
|
|
}
|
|
|
|
|
}
|