```struct SignInView : View { @State var creat...
# compose
j
Copy code
struct SignInView : View {
    @State var createAccount = false
    @State var forgotPassword = false
    
    var body: some View {
        ZStack{
            VStack(alignment: .center, spacing: 15) {
            if(!createAccount && !forgotPassword){
                Text("Sign In").font(.title).bold().foregroundColor(.white)
                TextField("Email Address", text: self.$email)
            }
            if(createAccount){
                Text("Create Account").font(.title).bold().foregroundColor(.white)
                TextField("Email Address", text: self.$email)
                SecureField("Password", text: self.$password)
                SecureField("Confirm Password", text: self.$confirm)
                Button(action: {self.createUserAccount()}) {
                    Text("Create Account")
                }
            } else if (forgotPassword) {
                Text("Forgot Password").font(.title).bold().foregroundColor(.white)
                TextField("Email Address", text: self.$email)
                Button(action: {self.sendResetCode()}) {
                    Text("Email Reset Code")
                }
                TextField("Reset Code", text: self.$code)
                Button(action: {self.resetPassword()}) {
                    Text("Reset Password")
                }
            }
        }
    }
}
a
@Composable fun HelloContent() { Column(modifier = Modifier.padding(16.dp)) { var name by remember { mutableStateOf("") } if (name.isNotEmpty()) { Text( text = "Hello, $name!", modifier = Modifier.padding(bottom = 8.dp), style = MaterialTheme.typography.h5 ) } OutlinedTextField( value = name, onValueChange = { name = it }, label = { Text("Name") } ) } }
compose has a remember mechanism combined with mutableStateOf
j
ah ok
var name by remember { mutableStateOf("") }
is kind of like
@State *var* createAccount = *false*
a
yes !
j
Is
1.0.0-beta01
to early to use this?
Copy code
@Composable
fun SigninForm() {
    Box(Modifier.fillMaxSize(), Alignment.Center) {
        Box(Modifier.fillMaxSize(), Alignment.Center){
            val path = Uri.parse("file:///android_asset/background.mp4")
            VideoPlayer(uri = path)
        }
        var signInState by remember { mutableStateOf("login") }
        if(signInState == "login") {
            Login()
        }else if(signInState == "signup"){
            Signup()
        } else if(signInState == "signup"){
            ForgotPassword()
        }
    }
}
I get an error on
Copy code
var signInState by remember { mutableStateOf("login") }
Type 'TypeVariable(T)' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate
I needed to inlcude
Copy code
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
💯 1
✔️ 1
a
it’s annoying that android studio doesn’t auto import