Kaynağa Gözat

working on logout API

Khubaib 10 ay önce
ebeveyn
işleme
571c0f27a3

+ 26 - 7
app/src/main/java/com/vpn/fastestvpnservice/screens/bottomNavBarScreens/AccountScreen.kt

@@ -7,10 +7,13 @@ import android.os.Handler
 import android.os.Looper
 import android.util.Log
 import android.widget.Toast
+import androidx.compose.foundation.BorderStroke
 import androidx.compose.foundation.ExperimentalFoundationApi
 import androidx.compose.foundation.Image
 import androidx.compose.foundation.LocalOverscrollConfiguration
 import androidx.compose.foundation.background
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.focusable
 import androidx.compose.foundation.gestures.detectTapGestures
 import androidx.compose.foundation.layout.Arrangement
 import androidx.compose.foundation.layout.Box
@@ -48,6 +51,9 @@ import androidx.compose.runtime.setValue
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.draw.alpha
+import androidx.compose.ui.focus.FocusRequester
+import androidx.compose.ui.focus.focusRequester
+import androidx.compose.ui.focus.onFocusChanged
 import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.graphics.ColorFilter
 import androidx.compose.ui.graphics.painter.Painter
@@ -512,6 +518,10 @@ fun BoxScope.LogoutDialog(
     val homeViewModel: HomeViewModel = viewModel {
         HomeViewModel(context, scope)
     }
+    var isButtonFocused1 by remember { mutableStateOf(false) }
+    var isButtonFocused2 by remember { mutableStateOf(false) }
+    val focusRequester = remember { FocusRequester() }
+
     Surface(
         color = colorResource(id = R.color.white),
         modifier = Modifier
@@ -524,17 +534,20 @@ fun BoxScope.LogoutDialog(
             verticalArrangement = Arrangement.Top,
             horizontalAlignment = Alignment.CenterHorizontally,
             modifier = Modifier
-                .background(MaterialTheme.colorScheme.onBackground)
+//                .background(MaterialTheme.colorScheme.onBackground)
+                .background(Color.White)
         ) {
             Log.d("islogoutClicked", "AlertDialog")
 
             Text(text = title,
-                color = MaterialTheme.colorScheme.primary,
+//                color = MaterialTheme.colorScheme.primary,
+                color = colorResource(id = R.color.dark_blue_gray_text),
                 style = MaterialTheme.typography.bodyMedium,
                 modifier = Modifier.padding(top = 45.dp)
             )
             Text(text = desc,
-                color = MaterialTheme.colorScheme.primary,
+//                color = MaterialTheme.colorScheme.primary,
+                color = colorResource(id = R.color.dark_blue_gray_text),
                 style = MaterialTheme.typography.labelSmall,
                 maxLines = 2,
                 modifier = Modifier.padding(top = 26.dp)
@@ -557,15 +570,19 @@ fun BoxScope.LogoutDialog(
                             start = 15.dp, end = 5.dp,
                             bottom = 0.dp, top = 0.dp
                         )
+                        .onFocusChanged {
+                            isButtonFocused1 = it.isFocused
+                        }
                         .background(colorResource(id = R.color.transparent))
                         .weight(1F)
                         .height(52.dp),
 
                     shape = RoundedCornerShape(15.dp),
                     colors = ButtonDefaults.buttonColors(
-                        contentColor = colorResource(id = R.color.white),
+                        contentColor = if (isButtonFocused1) colorResource(id = R.color.dark_blue_gray_text) else colorResource(id = R.color.white),
                         containerColor = colorResource(id = R.color.light_blue),
                     ),
+                    border = BorderStroke(2.dp, if (isButtonFocused1) colorResource(id = R.color.dark_blue_gray_text) else colorResource(id = R.color.light_blue))
                 )
                 {
                     Text(text = "No",
@@ -610,15 +627,17 @@ fun BoxScope.LogoutDialog(
                             bottom = 0.dp, top = 0.dp
                         )
                         .background(colorResource(id = R.color.transparent))
+                        .onFocusChanged {
+                            isButtonFocused2 = it.isFocused
+                        }
                         .weight(1F)
                         .height(52.dp),
                     shape = RoundedCornerShape(15.dp),
                     colors = ButtonDefaults.buttonColors(
-                        contentColor = colorResource(id = R.color.white),
+                        contentColor = if (isButtonFocused2) colorResource(id = R.color.dark_blue_gray_text) else colorResource(id = R.color.white),
                         containerColor = colorResource(id = R.color.red),
                     ),
-//                                border = BorderStroke(2.dp,
-//                                    colorResource(id = R.color.gray_icon))
+                    border = BorderStroke(2.dp, if (isButtonFocused2) colorResource(id = R.color.dark_blue_gray_text) else colorResource(id = R.color.red))
                 )
                 {
                     Text(text = "Yes",

+ 3 - 11
app/src/main/java/com/vpn/fastestvpnservice/screensTV/AccountScreenTV.kt

@@ -83,6 +83,7 @@ import com.vpn.fastestvpnservice.navigation.isFourthItemPressed
 import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.LogoutDialog
 import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.act
 import com.vpn.fastestvpnservice.sealedClass.Screen
+import com.vpn.fastestvpnservice.sealedClass.ScreenTV
 import com.vpn.fastestvpnservice.utils.VPNConnectionsUtil
 import com.vpn.fastestvpnservice.utils.isTablet
 import com.vpn.fastestvpnservice.viewmodels.AccountViewModel
@@ -290,7 +291,7 @@ fun AccountTV(navHostController: NavHostController,
                     basePreferenceHelper.setLoggedInState(false)
                     basePreferenceHelper.clearAllData()
                     settingsNavHostController.popBackStack()
-                    settingsNavHostController.navigate(Screen.Started.route)
+                    settingsNavHostController.navigate(ScreenTV.LoginTV.route)
 
                     val widgetIntent = Intent(context, SimpleAppWidget::class.java)
                     widgetIntent.action = SimpleAppWidget.ACTION_LOGOUT
@@ -511,17 +512,8 @@ fun ColumnScope.AddRowAccountIconTV(
 //                Toast.makeText(
 //                    context, text, Toast.LENGTH_SHORT
 //                ).show()
+                onClick()
             }
-//            .border(
-//                1.dp, Color.Blue, RoundedCornerShape(40.dp)
-//            )
-//            .clip(RoundedCornerShape(40.dp))
-//            .pointerInput(Unit) {
-//                detectTapGestures {
-//                    onClick()
-//                }
-//            }
-
         ,
         horizontalArrangement = Arrangement.Start,
         verticalAlignment = Alignment.CenterVertically