mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
extracy logout button to it's own comosable function
This commit is contained in:
parent
386a47b73b
commit
be51a17315
1 changed files with 19 additions and 15 deletions
|
|
@ -20,8 +20,6 @@ import com.google.android.gms.auth.api.signin.GoogleSignInOptions
|
|||
|
||||
@Composable
|
||||
fun HomeView(viewModel: LoginViewModel) {
|
||||
val context = LocalContext.current
|
||||
|
||||
Column(
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
|
|
@ -31,18 +29,24 @@ fun HomeView(viewModel: LoginViewModel) {
|
|||
.padding(horizontal = 6.dp)
|
||||
) {
|
||||
Text("You have a valid auth token. Nice. Go save something in Chrome!")
|
||||
|
||||
Button(onClick = {
|
||||
// Sign out google users
|
||||
val signInOptions = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
|
||||
.build()
|
||||
|
||||
val googleSignIn = GoogleSignIn.getClient(context, signInOptions)
|
||||
googleSignIn.signOut()
|
||||
|
||||
viewModel.logout()
|
||||
}) {
|
||||
Text(text = "Logout")
|
||||
}
|
||||
LogoutButton { viewModel.logout() }
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun LogoutButton(actionHandler: () -> Unit) {
|
||||
val context = LocalContext.current
|
||||
|
||||
Button(onClick = {
|
||||
// Sign out google users
|
||||
val signInOptions = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
|
||||
.build()
|
||||
|
||||
val googleSignIn = GoogleSignIn.getClient(context, signInOptions)
|
||||
googleSignIn.signOut()
|
||||
|
||||
actionHandler()
|
||||
}) {
|
||||
Text(text = "Logout")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue