Skip to content

Instantly share code, notes, and snippets.

@RaheemJnr
Created October 4, 2021 08:01
Show Gist options
  • Save RaheemJnr/31cbe46441f01c9f9851e101995f51e3 to your computer and use it in GitHub Desktop.
Save RaheemJnr/31cbe46441f01c9f9851e101995f51e3 to your computer and use it in GitHub Desktop.
@Composable
fun LoginSCreen() {
//context
val context = LocalContext.current
// a coroutine scope
val scope = rememberCoroutineScope()
// we instantiate the saveEmail class
val dataStore = StoreUserEmail(context)
Column(modifier = Modifier.fillMaxSize()) {
var email by rememberSaveable { mutableStateOf("") }
//
Text(
modifier = Modifier
.padding(16.dp, 0.dp)
.alpha(0.6f),
text = "EMAIL",
fontWeight = FontWeight.SemiBold,
color = Color.Gray,
fontSize = 12.sp
)
//email field
OutlinedTextField(
value = email,
onValueChange = { email = it },
keyboardOptions = KeyboardOptions.Default.copy(
keyboardType
= KeyboardType.Email
),
modifier = Modifier
.padding(16.dp, 0.dp, 16.dp, 0.dp)
.fillMaxWidth(),
)
Spacer(modifier = Modifier.height(16.dp))
Button(
onClick = {
//launch the class in a coroutine scope
scope.launch {
dataStore.saveEmail(email)
}
},
modifier = Modifier
.fillMaxWidth()
.height(60.dp)
.padding(16.dp, 0.dp, 16.dp, 0.dp),
) {
Text(
style = MaterialTheme.typography.subtitle1,
color = Color.White,
text = "Save Email",
)
}
Spacer(modifier = Modifier.height(32.dp))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment