avt.txt 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package com.example.task1.view.mainAct.components
  2. import androidx.compose.foundation.layout.Arrangement
  3. import androidx.compose.foundation.layout.Column
  4. import androidx.compose.foundation.layout.padding
  5. import androidx.compose.material3.Button
  6. import androidx.compose.material3.Icon
  7. import androidx.compose.material3.IconButton
  8. import androidx.compose.material3.Text
  9. import androidx.compose.material3.TextField
  10. import androidx.compose.runtime.Composable
  11. import androidx.compose.runtime.getValue
  12. import androidx.compose.runtime.mutableStateOf
  13. import androidx.compose.runtime.remember
  14. import androidx.compose.runtime.setValue
  15. import androidx.compose.ui.Alignment
  16. import androidx.compose.ui.Modifier
  17. import androidx.compose.ui.res.painterResource
  18. import androidx.compose.ui.text.TextStyle
  19. import androidx.compose.ui.text.input.PasswordVisualTransformation
  20. import androidx.compose.ui.text.input.VisualTransformation
  21. import androidx.compose.ui.tooling.preview.Preview
  22. import androidx.compose.ui.unit.dp
  23. import androidx.compose.ui.unit.sp
  24. import com.example.task1.R
  25. @Preview
  26. @Composable
  27. fun avt() {
  28. val viewModel = MainViewModel()
  29. val email = remember { mutableStateOf("") }
  30. val password = remember { mutableStateOf("") }
  31. Column(
  32. Modifier.padding(top = 30.dp, start = 15.dp, end = 15.dp),
  33. verticalArrangement = Arrangement.Center,
  34. horizontalAlignment = Alignment.CenterHorizontally
  35. ) {
  36. TextField(
  37. value = email.value,
  38. textStyle = TextStyle(fontSize = 25.sp),
  39. onValueChange = { newText -> email.value = newText }
  40. )
  41. var passwordVisibility: Boolean by remember { mutableStateOf(false) }
  42. TextField(value = password.value,
  43. visualTransformation = if (passwordVisibility) VisualTransformation.None else PasswordVisualTransformation(),
  44. leadingIcon = {
  45. IconButton(onClick = {
  46. passwordVisibility = !passwordVisibility
  47. }) {
  48. if(passwordVisibility) {
  49. Icon(
  50. painter = painterResource(id = R.drawable.my_baseline_person_24),
  51. contentDescription = ""
  52. )
  53. }
  54. else {
  55. Icon(
  56. painter = painterResource(id = R.drawable.my_baseline_person_off_24),
  57. contentDescription = ""
  58. )
  59. }
  60. }
  61. },
  62. onValueChange = { newText -> password.value = newText })
  63. Button(onClick = {
  64. viewModel.onSignInEmailPassword(email.value,password.value)
  65. }){
  66. Text("SigIn", fontSize = 25.sp)
  67. }
  68. Button(onClick = {
  69. viewModel.onSignUpEmail(email.value,password.value)
  70. }){
  71. Text("SigUp", fontSize = 25.sp)
  72. }
  73. }
  74. }
  75. ardaismine@gmail.com
  76. 51431356S&M