소스 검색

set border background color for server logo circleshape

Khubaib 1 년 전
부모
커밋
f354fb478f

+ 6 - 140
app/src/main/java/com/vpn/fastestvpnservice/customItems/CountryItem.kt

@@ -3,7 +3,9 @@ package com.vpn.fastestvpnservice.customItems
 import android.os.Looper
 import android.util.Log
 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.gestures.detectTapGestures
 import androidx.compose.foundation.interaction.MutableInteractionSource
@@ -132,12 +134,7 @@ fun CountryItem(
         }
 
         countrySize.let { size ->
-//            var locationsSize: Int = 0
-//            val countriesServersData = basePreferenceHelper.getServerData().get(0).servers
-//            countriesServersData?.let {
-//                val serversGroup = serverListViewModel.getServerGroupList(server, it)
-//                locationsSize = serversGroup.size
-//            }
+
             Column {
                 /* Country Location's Row */
                 Row(
@@ -174,6 +171,7 @@ fun CountryItem(
                             .padding(bottom = 16.dp)
                             .size(24.dp)
                             .clip(CircleShape)
+                            .border(1.dp, colorResource(id = R.color.gray_opac_04), CircleShape)
                             .paint(
                                 painter = painterResource(id = icon),
                                 contentScale = ContentScale.FillHeight
@@ -235,114 +233,7 @@ fun CountryItem(
                     .align(Alignment.BottomCenter),
                 color = colorResource(id = R.color.gray_icon)
             ) {}
-
-
-//                    else {
-//                        Log.d("test_return_ping","C[1]=> " + server.server_name + server.ping)
-//                        Row(
-//                            verticalAlignment = Alignment.Top,
-//                            horizontalArrangement = Arrangement.Start,
-//                            modifier = Modifier
-//                                .fillMaxWidth()
-//                                .padding(start = 16.dp, end = 7.dp, top = 12.dp)
-//                                .clickable(
-//                                    indication = null,
-//                                    interactionSource = remember { MutableInteractionSource() }
-//                                ) {
-//                                    basePreferenceHelper.setServerObject(server)
-//                                    isServerServerClicked = true
-////                                    navHostController.popBackStack()
-//                                }
-//                        ) {
-//                            val icon = if (server.enable == 1) Utils.getDrawable(context, server.iso)
-//                            else Utils.getDrawableGray(context, server.iso)
-//
-//                            Icon(
-//                                painter = painterResource(id = icon),
-//                                contentDescription = "Server Logo",
-//                                tint = Color.Unspecified,
-//                                modifier = Modifier
-//                                    .padding(bottom = 16.dp)
-//                                    .size(24.dp)
-//                                    .clip(CircleShape)
-//                                    .paint(
-//                                        painter = painterResource(id = icon),
-//                                        contentScale = ContentScale.FillHeight
-//                                    )
-//                            )
-//                            val serverTitle = if (category.lowercase().toString() == "servers") server.country else server.server_name
-//                            Text(text = serverTitle!!,
-//                                style = MaterialTheme.typography.labelMedium,
-//                                color = MaterialTheme.colorScheme.primary,
-//                                modifier = Modifier
-//                                    .padding(start = 16.dp, bottom = 18.dp)
-//                                    .align(Alignment.CenterVertically)
-//                            )
-//                            Spacer(modifier = Modifier.weight(1F))
-//                            val pings = server.ping
-//                            Text(
-//                                text = "${server.ping} ms",
-//                                style = MaterialTheme.typography.displayMedium,
-//                                color = colorResource(id = R.color.blue_text),
-//                                modifier = Modifier
-//                                    .padding(end = 30.dp, bottom = 18.dp)
-//                                    .align(Alignment.CenterVertically)
-//                            )
-//                            var isFavorite by rememberSaveable { mutableStateOf(server.isFavourited) }
-//
-//                            IconButton(
-//                                modifier = Modifier
-//                                    .padding(bottom = 18.dp, end = 8.dp)
-//                                    .size(21.dp, 20.dp)
-//                                    .align(Alignment.CenterVertically),
-//                                onClick = {
-//                                    isFavorite = !isFavorite!!
-//                                    serverListViewModel.favAndUnFav(server)
-//                                }
-//                            )
-//                            {
-////                                val favResponse = serverListViewModel.mutableLiveDataFavUnFav.observeAsState().value
-////                                favResponse?.let {
-////                                    Log.d("test_fav_response", it.message.toString())
-////                                    splashViewModel.serverDataApi()
-////                                    serverListViewModel.mutableLiveDataFavUnFav.value = null
-////                                }
-//
-//                                Icon(
-////                                    .clickable(
-////                                        indication = null,
-////                                        interactionSource = remember { MutableInteractionSource() }
-////                                    ) {  },
-//
-//                                    painter = if (isFavorite == true) painterResource(
-//                                        id = R.drawable.fav_server3x) else painterResource(
-//                                        id = R.drawable.unfav_server3x),
-//
-//                                    contentDescription = "Server Logo",
-//                                    tint = Color.Unspecified,
-//                                )
-//                            }
-//                        }
-
-//                    Log.d("test_servers_count", "${server.server_name} ${server.countryServers?.size}")
-                        /* Country Location's Row -> 1 Location() */
-
-//                        var ping by remember { mutableIntStateOf(0) }
-//                        Ping.onAddress(server.ip as String).setTimeOutMillis(1000).doPing(
-//                            object : Ping.PingListener{
-//                                override fun onResult(pingResult: PingResult?) {
-//                                    android.os.Handler(Looper.getMainLooper()).post {
-//                                        val ping = pingResult?.timeTaken?.toInt()!!
-//                                        server.ping = ping
-//                                        Log.d("test_ping", "ping = $ping")
-//                                    }
-//                                }
-//
-//                                override fun onError(e: Exception?) {}
-//                                override fun onFinished(pingStats: PingStats?) {}
-//                            }
-//                        )
-                    }
+        }
     }
 }
 
@@ -448,7 +339,6 @@ fun ColumnScope.ExpandableRow(
                                 .alpha(0.4F)
                         )
                         Spacer(modifier = Modifier.weight(1F))
-
                         Text(text = "$ping ms",
                             style = MaterialTheme.typography.displayMedium,
                             color = colorResource(id = R.color.blue_text),
@@ -456,7 +346,6 @@ fun ColumnScope.ExpandableRow(
                                 .padding(start = 0.dp, end = 30.dp)
                                 .align(Alignment.CenterVertically)
                         )
-
                         IconButton(
                             modifier = Modifier
                                 .padding(bottom = 0.dp, end = 16.dp)
@@ -469,10 +358,6 @@ fun ColumnScope.ExpandableRow(
                         )
                         {
                             Icon(
-//                                    .clickable(
-//                                        indication = null,
-//                                        interactionSource = remember { MutableInteractionSource() }
-//                                    ) {  },
                                 painter = if (isServerFavourited) painterResource(
                                     id = R.drawable.fav_server3x) else painterResource(
                                     id = R.drawable.unfav_server3x),
@@ -482,14 +367,12 @@ fun ColumnScope.ExpandableRow(
                             )
                         }
                     }
-
                     Surface(
                         modifier = Modifier
                             .padding(top = 0.dp, end = 0.dp)
                             .height(1.dp)
                             .fillMaxWidth()
-                            .alpha(0.6F)
-                        ,
+                            .alpha(0.6F),
                         color = colorResource(id = R.color.gray_icon)
                     ) {}
                 }
@@ -497,23 +380,6 @@ fun ColumnScope.ExpandableRow(
     }
 }
 
-fun calculatePing(server: Server, onPingResult: (Int) -> Unit) {
-    Ping.onAddress(server.ip as String).setTimeOutMillis(1000).doPing(
-        object : Ping.PingListener{
-            override fun onResult(pingResult: PingResult?) {
-                android.os.Handler(Looper.getMainLooper()).post {
-                    val ping = pingResult?.timeTaken?.toInt()!!
-                    onPingResult(ping)
-                    Log.d("test_ping", "ping[0] = $ping")
-                }
-            }
-
-            override fun onError(e: java.lang.Exception?) {}
-            override fun onFinished(pingStats: PingStats?) {}
-        }
-    )
-}
-
 @Preview
 @Composable
 fun CountryItemPreview() {

+ 4 - 0
app/src/main/java/com/vpn/fastestvpnservice/customItems/ServerItem.kt

@@ -175,6 +175,7 @@ fun ServerItem(server: Server, navHostController: NavHostController, serverPing:
                     .padding(bottom = 16.dp)
                     .size(24.dp)
                     .clip(CircleShape)
+                    .border(1.dp, colorResource(id = R.color.gray_opac_04), CircleShape)
                     .paint(
                         painter = painterResource(id = icon),
                         contentScale = ContentScale.FillHeight
@@ -321,6 +322,7 @@ fun FavoriteServerItem(server: Server, navHostController: NavHostController) {
                     .padding(bottom = 16.dp)
                     .size(24.dp)
                     .clip(CircleShape)
+                    .border(1.dp, colorResource(id = R.color.gray_opac_04), CircleShape)
                     .paint(
                         painter = painterResource(id = icon),
                         contentScale = ContentScale.FillHeight
@@ -495,6 +497,7 @@ fun ServerSearchItem(
                     .padding(bottom = 16.dp)
                     .size(24.dp)
                     .clip(CircleShape)
+                    .border(1.dp, colorResource(id = R.color.gray_opac_04), CircleShape)
                     .paint(
                         painter = painterResource(id = icon),
                         contentScale = ContentScale.FillHeight
@@ -612,6 +615,7 @@ fun ServerSpecificItem(
                     .padding(bottom = 16.dp)
                     .size(24.dp)
                     .clip(CircleShape)
+                    .border(1.dp, colorResource(id = R.color.gray_opac_04), CircleShape)
                     .paint(
                         painter = painterResource(id = icon),
                         contentScale = ContentScale.FillHeight