From a961761649a82a8dc918d6e806a439bde34cdd89 Mon Sep 17 00:00:00 2001 From: Nickolas Date: Thu, 30 Nov 2023 01:22:34 -0800 Subject: [PATCH] logout added to admin view --- .../belindas_closet/screen/AdminView.kt | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/example/belindas_closet/screen/AdminView.kt b/app/src/main/java/com/example/belindas_closet/screen/AdminView.kt index 860ed6da..024185fc 100644 --- a/app/src/main/java/com/example/belindas_closet/screen/AdminView.kt +++ b/app/src/main/java/com/example/belindas_closet/screen/AdminView.kt @@ -1,36 +1,70 @@ package com.example.belindas_closet.screen +import android.widget.Toast import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material.icons.filled.Edit +import androidx.compose.material.icons.filled.ExitToApp +import androidx.compose.material.icons.filled.Menu import androidx.compose.material3.Button +import androidx.compose.material3.DrawerValue +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.RectangleShape +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.navigation.NavHostController +import com.example.belindas_closet.MainActivity import com.example.belindas_closet.R import com.example.belindas_closet.Routes +@OptIn(ExperimentalMaterial3Api::class) @Composable fun AdminView(navController: NavHostController) { + val current = LocalContext.current Row( modifier = Modifier - .size(125.dp) - .padding(top = 10.dp, start = 10.dp), + .height(75.dp) + .padding(10.dp) + .fillMaxWidth(), verticalAlignment = Alignment.Top, - horizontalArrangement = Arrangement.Start + horizontalArrangement = Arrangement.SpaceBetween ) { NSCLogo() + Icon(Icons.Filled.ExitToApp, contentDescription="Logout", + modifier = Modifier.clickable { + MainActivity.getPref().edit().remove("token").commit() + MainActivity.getPref().edit().remove("userRole").commit() + navController.navigate(Routes.Home.route) + Toast.makeText( + current, + "Logged Out", + Toast.LENGTH_SHORT + ).show() + }) } Row( modifier = Modifier