title: How can I get TextField value from another composable function in Jetpack Compose
body: <p>I have created one function called <code>TextInput</code> that contained <code>TextField</code></p>
  <pre><code>@Composable
  fun TextInput(
      inputType: InputType
  ) {
      var value by remember { mutableStateOf(&quot;&quot;) }
  
      TextField(
          modifier = Modifier.clip(RoundedCornerShape(30.dp)),
          value = value,
          onValueChange = { value = it },
          leadingIcon = { Icon(imageVector = inputType.icon, null) },
          label = { Text(text = inputType.label) },
          colors = TextFieldDefaults.textFieldColors(
              focusedIndicatorColor = Color.Transparent,
              unfocusedIndicatorColor = Color.Transparent,
              disabledIndicatorColor = Color.Transparent
          ),
          singleLine = true,
          keyboardOptions = inputType.keyboardOptions,
          visualTransformation = inputType.visualTransformation,
      )
  
  }
  </code></pre>
  <p>Now on click of the button <code>SIGN UP\SIGN IN</code> I want to access the value and show success/error based on validation.</p>
  <pre><code>        Button(
              onClick = {
  
                        //here
  
              },
              modifier = Modifier
                  .padding(top = 30.dp)
                  .width(200.dp),
              shape = RoundedCornerShape(20.dp)
          ) {
              Text(
                  text = &quot;SIGN IN&quot;,
  
                  )
          }
  ==================================================
          Button(
              onClick = {
  
                      //here
              },
              modifier = Modifier
                  .padding(top = 5.dp)
                  .width(200.dp),
              shape = RoundedCornerShape(20.dp)
          ) {
  
              Text(text = &quot;SIGN UP&quot;)
          }
  </code></pre>
  <p>If you want to see whole code to understand what i mean exactly.</p>
  <pre><code>@Composable
  fun Sign_in_up_Screen() {
      Column(
          horizontalAlignment = Alignment.CenterHorizontally
      ) {
  
  
          Image(
              painter = painterResource(R.drawable.login),
              contentDescription = &quot;&quot;,
              modifier = Modifier
                  .background(Color.Companion.Red)
                  .fillMaxWidth()
          )
  
          TopTextButton()
      }
  }
  
  @Composable
  fun Login_Screen() {
      val context = LocalContext.current
      Column(
          horizontalAlignment = Alignment.CenterHorizontally,
          verticalArrangement = Arrangement.spacedBy(20.dp),
          modifier = Modifier.fillMaxSize()
      ) {
  
          TextInput(InputType.Email)
          TextInput(InputType.Password)
  
          Button(
              onClick = {
  
                        //here
  
              },
              modifier = Modifier
                  .padding(top = 30.dp)
                  .width(200.dp),
              shape = RoundedCornerShape(20.dp)
          ) {
              Text(
                  text = &quot;SIGN IN&quot;,
  
                  )
          }
  
      }
  }
  
  @Composable
  fun Signup_Screen() {
      val context = LocalContext.current
      Column(
          horizontalAlignment = Alignment.CenterHorizontally,
          verticalArrangement = Arrangement.spacedBy(20.dp),
          modifier = Modifier.fillMaxSize()
      ) {
  
          TextInput(InputType.FullName)
          TextInput(InputType.Email)
          TextInput(InputType.Password)
          TextInput(InputType.ConfirmPassword)
  
          Button(
              onClick = {
  
                      //here
              },
              modifier = Modifier
                  .padding(top = 5.dp)
                  .width(200.dp),
              shape = RoundedCornerShape(20.dp)
          ) {
  
              Text(text = &quot;SIGN UP&quot;)
          }
  
      }
  }
  
  sealed class InputType(
      val label: String,
      val icon: ImageVector,
      val keyboardOptions: KeyboardOptions,
      val visualTransformation: VisualTransformation
  ) {
  
      object FullName : InputType(
          label = &quot;Full Name&quot;,
          icon = Icons.Default.Person,
          keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next),
          visualTransformation = VisualTransformation.None
      )
  
      object Email : InputType(
          label = &quot;E-mail&quot;,
          icon = Icons.Default.Email,
          keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next),
          visualTransformation = VisualTransformation.None
      )
  
      object Password : InputType(
          label = &quot;Password&quot;,
          icon = Icons.Default.Lock,
          keyboardOptions = KeyboardOptions(
              imeAction = ImeAction.Done,
              keyboardType = KeyboardType.Password
          ),
          visualTransformation = PasswordVisualTransformation()
      )
  
      object ConfirmPassword : InputType(
          label = &quot;Confirm Password&quot;,
          icon = Icons.Default.Lock,
          keyboardOptions = KeyboardOptions(
              imeAction = ImeAction.Done,
              keyboardType = KeyboardType.Password
          ),
          visualTransformation = PasswordVisualTransformation()
      )
  
  }
  
  @Composable
  fun TextInput(
      inputType: InputType
  ) {
      var value by remember { mutableStateOf(&quot;&quot;) }
  
      TextField(
          modifier = Modifier.clip(RoundedCornerShape(30.dp)),
          value = value,
          onValueChange = { value = it },
          leadingIcon = { Icon(imageVector = inputType.icon, null) },
          label = { Text(text = inputType.label) },
          colors = TextFieldDefaults.textFieldColors(
              focusedIndicatorColor = Color.Transparent,
              unfocusedIndicatorColor = Color.Transparent,
              disabledIndicatorColor = Color.Transparent
          ),
          singleLine = true,
          keyboardOptions = inputType.keyboardOptions,
          visualTransformation = inputType.visualTransformation,
      )
  
  }
  
  @Composable
  fun TopTextButton() {
  
      var screen by remember { mutableStateOf(false) }
  
      Row(
          modifier = Modifier.padding(bottom = 40.dp),
      ) {
  
          TextButton( onClick = {
              if (screen)
                  screen = !screen
          }) {
              Text(text = &quot;Sign in&quot;)
          }
  
          Spacer(Modifier.width(145.dp))
  
          TextButton(onClick = {
              if (!screen)
                  screen = !screen
          }) {
              Text(text = &quot;Sign up&quot;)
          }
      }
  
      if (!screen){
          Login_Screen()
      }
      if (screen) {
          Signup_Screen()
      }
  }
  </code></pre>
  <p>Is this code correct or should I put a function for each {Textfield}?
  So each text field has its own state</p>
  <p><strong>I am beginner android studio programming</strong></p>