123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780 |
- package com.vpn.fastestvpnservice.customItems
- import android.content.res.Configuration
- import android.util.Log
- import androidx.compose.foundation.background
- import androidx.compose.foundation.border
- import androidx.compose.foundation.clickable
- import androidx.compose.foundation.interaction.MutableInteractionSource
- import androidx.compose.foundation.layout.Arrangement
- import androidx.compose.foundation.layout.Box
- import androidx.compose.foundation.layout.Row
- import androidx.compose.foundation.layout.Spacer
- 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.foundation.layout.wrapContentWidth
- import androidx.compose.foundation.shape.CircleShape
- import androidx.compose.material3.Icon
- import androidx.compose.material3.IconButton
- import androidx.compose.material3.MaterialTheme
- import androidx.compose.material3.Surface
- import androidx.compose.material3.Text
- import androidx.compose.runtime.Composable
- import androidx.compose.runtime.getValue
- import androidx.compose.runtime.mutableStateOf
- import androidx.compose.runtime.remember
- import androidx.compose.runtime.rememberCoroutineScope
- 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.draw.clip
- import androidx.compose.ui.draw.paint
- import androidx.compose.ui.graphics.Color
- import androidx.compose.ui.layout.ContentScale
- import androidx.compose.ui.platform.LocalContext
- import androidx.compose.ui.res.colorResource
- import androidx.compose.ui.res.painterResource
- import androidx.compose.ui.text.style.TextOverflow
- import androidx.compose.ui.tooling.preview.Preview
- import androidx.compose.ui.unit.dp
- import androidx.compose.ui.unit.sp
- import androidx.lifecycle.viewmodel.compose.viewModel
- import androidx.navigation.NavHostController
- import androidx.navigation.compose.rememberNavController
- import com.vpn.fastestvpnservice.R
- import com.vpn.fastestvpnservice.beans.Server
- import com.vpn.fastestvpnservice.beans.favListServer
- import com.vpn.fastestvpnservice.beans.toChangeServer
- import com.vpn.fastestvpnservice.constants.AppEnum
- import com.vpn.fastestvpnservice.constants.smartConnect
- import com.vpn.fastestvpnservice.helpers.BasePreferenceHelper
- import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.onServer
- import com.vpn.fastestvpnservice.screens.serverListViewModelSplash
- import com.vpn.fastestvpnservice.sealedClass.BottomBarScreen
- import com.vpn.fastestvpnservice.sealedClass.Screen
- import com.vpn.fastestvpnservice.utils.Utils
- import com.vpn.fastestvpnservice.viewmodels.HomeViewModel
- @Composable
- fun ServerItem(server: Server, navHostController: NavHostController, serverPing: Int = 0) {
- val context = LocalContext.current
- val scope = rememberCoroutineScope()
- var isServerClicked by remember { mutableStateOf(false) }
- val homeViewModel: HomeViewModel = viewModel{ HomeViewModel(context, scope) }
- val basePreferenceHelper = BasePreferenceHelper(context)
- var isFavorite by remember { mutableStateOf(server.isFavourited) }
- val isServerFavourited: Boolean = server.isFavourited == true
- Log.d("test-server_fav_d", "$isFavorite")
- Box(
- modifier = Modifier
- .fillMaxWidth()
- .background(color = MaterialTheme.colorScheme.background)
- .padding(bottom = 1.dp)
- ) {
- // val serverListViewModel: ServerListViewModel = viewModel{
- // ServerListViewModel(context)
- // }
- // val splashViewModel: SplashViewModel = viewModel{
- // SplashViewModel(context)
- // }
- if (isServerClicked) {
- Log.d("ServerCallbacks", "isServerClicked $isServerClicked")
- onServer.onServerSelected(
- context,
- homeViewModel,
- onClick = { isServerClicked = false },
- true,
- server
- )
- navHostController.popBackStack()
- }
- // val icon = if (server.enable == 1) Utils.getDrawable(context, server.iso)
- // else Utils.getDrawableGray(context, server.iso)
- val icon = Utils.getDrawable(context, server.iso)
- var isFreeAccount: Boolean = false
- basePreferenceHelper.getProduct()?.identifier?.let {
- if (it == AppEnum.FREE.key) {
- isFreeAccount = true
- } else {
- isFreeAccount = false
- }
- }
- Box(
- // verticalAlignment = Alignment.Top,
- // horizontalArrangement = Arrangement.Start,
- modifier = Modifier
- .fillMaxWidth()
- .padding(start = 12.dp, end = 7.dp, top = 12.dp)
- .background(Color.Transparent)
- .clickable(
- indication = null,
- interactionSource = remember { MutableInteractionSource() }
- ) {
- if (!isFreeAccount) {
- if (toChangeServer.value) {
- basePreferenceHelper.saveSmartList(smartConnect[2])
- basePreferenceHelper.setSmartServerObject(server)
- navHostController.popBackStack()
- } else {
- isServerClicked = true
- }
- // basePreferenceHelper.setServerObject(server)
- } else {
- basePreferenceHelper.setSubscriptionServerObject(server)
- Screen.Subscription.isTrue = true
- navHostController.navigate(
- Screen.Subscription.route
- )
- }
- },
- contentAlignment = Alignment.CenterStart
- ) {
- // var ping by rememberSaveable { mutableIntStateOf(0) }
- //
- // fun updatePing(newPing: Int) {
- // ping = newPing
- // }
- //
- // LaunchedEffect(key1 = Unit) {
- // Log.d("test_new_ping", "Inside LE")
- //// while (true) {
- // Ping.onAddress(server.ip as String).setTimeOutMillis(1000).doPing(
- // object : Ping.PingListener{
- // override fun onResult(pingResult: PingResult?) {
- // pingResult?.let {
- // Log.d("test_new_ping_t", "pingResult = ${it.timeTaken.toInt()}, ping = $ping")
- // if (ping == 0) updatePing(it.timeTaken.toInt())
- // }
- // }
- // override fun onError(e: Exception?) {}
- // override fun onFinished(pingStats: PingStats?) {}
- // }
- // )
- //// delay(3 * 1000)
- //// }
- // }
- if (icon != 0) {
- Icon(
- painter = painterResource(id = icon),
- contentDescription = "Server Logo",
- tint = Color.Unspecified,
- modifier = Modifier
- .padding(top = 0.dp, bottom = 15.dp)
- .size(24.dp)
- .clip(CircleShape)
- .border(1.dp, colorResource(id = R.color.gray_opac_04), CircleShape)
- .paint(
- painter = painterResource(id = icon),
- contentScale = ContentScale.FillBounds
- )
- .align(Alignment.CenterStart)
- )
- Surface(
- modifier = Modifier
- .padding(start = 40.dp, bottom = 15.dp, end = 110.dp)
- .align(Alignment.CenterStart)
- .background(Color.Transparent),
- color = Color.Transparent
- ) {
- Text(
- text = "${server.server_name}",
- style = MaterialTheme.typography.labelMedium,
- color = MaterialTheme.colorScheme.primary,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis,
- modifier = Modifier
- .align(Alignment.CenterStart)
- )
- }
- // Spacer(modifier = Modifier.weight(1F))
- Text(
- text = "$serverPing ms",
- style = MaterialTheme.typography.displayMedium,
- color = colorResource(id = R.color.blue_text),
- modifier = Modifier
- .padding(end = 50.dp, bottom = 15.dp)
- .align(Alignment.CenterEnd)
- )
- // Spacer(modifier = Modifier.weight(1F))
- IconButton(
- modifier = Modifier
- .padding(bottom = 15.dp, end = 4.dp)
- .size(25.dp)
- .align(Alignment.CenterEnd),
- onClick = {
- isFavorite = !isFavorite!!
- serverListViewModelSplash.favAndUnFav(server)
- }
- ) {
- Icon(
- painter = if (isServerFavourited) painterResource(
- id = R.drawable.fav_server3x
- ) else painterResource(
- id = R.drawable.unfav_server3x
- ),
- contentDescription = "Server Logo",
- tint = Color.Unspecified,
- modifier = Modifier.size(22.dp, 21.dp)
- )
- }
- }
- }
- if (icon != 0) {
- Surface(
- modifier = Modifier
- .padding(start = 0.dp, end = 0.dp)
- .height(1.dp)
- .fillMaxWidth()
- .alpha(0.6F)
- .align(Alignment.BottomCenter),
- color = colorResource(id = R.color.gray_icon)
- ) {}
- }
- }
- }
- @Composable
- fun FavoriteServerItem(
- server: Server,
- navHostController: NavHostController,
- serverPing: Int
- ) {
- val context = LocalContext.current
- val basePreferenceHelper = BasePreferenceHelper(context)
- // val serverListViewModel: ServerListViewModel = viewModel {
- // ServerListViewModel(context = context)
- // }
- // val splashViewModel: SplashViewModel = viewModel{
- // SplashViewModel(context)
- // }
- val scope = rememberCoroutineScope()
- val homeViewModel: HomeViewModel = viewModel {
- HomeViewModel(context, scope)
- }
- var isFavorite by remember { mutableStateOf(server.isFavourited) }
- val isServerFavourited: Boolean = server.isFavourited == true
- Log.d("test-server_fav_d", "$isFavorite")
- var isFavServerClicked by remember { mutableStateOf(false) }
- if (isFavServerClicked) {
- Log.d("ServerCallbacks", "isServerClicked $isFavServerClicked")
- onServer.onServerSelected(
- context,
- homeViewModel,
- onClick = { isFavServerClicked = false },
- true,
- server
- )
- navHostController.popBackStack(BottomBarScreen.Home.route, false)
- }
- Box(
- modifier = Modifier
- .fillMaxWidth()
- .background(MaterialTheme.colorScheme.background)
- .padding(bottom = 1.dp)
- ) {
- // val icon = if (server.enable == 1) Utils.getDrawable(context, server.iso)
- // else Utils.getDrawableGray(context, server.iso)
- val icon = Utils.getDrawable(context, server.iso)
- var isFreeAccount: Boolean = false
- basePreferenceHelper.getProduct()?.identifier?.let {
- isFreeAccount = if (it == AppEnum.FREE.key) {
- true
- } else {
- false
- }
- }
- Box(
- // verticalAlignment = Alignment.Top,
- // horizontalArrangement = Arrangement.Start,
- modifier = Modifier
- .fillMaxWidth()
- .padding(start = 12.dp, end = 7.dp, top = 12.dp)
- .clickable(
- indication = null,
- interactionSource = remember { MutableInteractionSource() }
- ) {
- if (!isFreeAccount) {
- isFavServerClicked = true
- } else {
- basePreferenceHelper.setSubscriptionServerObject(server)
- Screen.Subscription.isTrue = true
- navHostController.navigate(
- Screen.Subscription.route
- )
- }
- }
- ) {
- // var ping by rememberSaveable { mutableIntStateOf(0) }
- // fun updatePing(newPing: Int) {
- // ping = newPing
- // }
- // LaunchedEffect(key1 = Unit) {
- // Ping.onAddress(server.ip as String).setTimeOutMillis(1000).doPing(
- // object : Ping.PingListener{
- // override fun onResult(pingResult: PingResult?) {
- // android.os.Handler(Looper.getMainLooper()).post {
- // pingResult?.let {
- // if (ping == 0) updatePing(it.timeTaken.toInt())
- // }
- // }
- // }
- //
- // override fun onError(e: Exception?) {}
- // override fun onFinished(pingStats: PingStats?) {}
- // }
- // )
- // }
- if (icon != 0) {
- Icon(
- painter = painterResource(id = icon),
- contentDescription = "Server Logo",
- tint = Color.Unspecified,
- modifier = Modifier
- .padding(bottom = 15.dp)
- .size(24.dp)
- .clip(CircleShape)
- .border(1.dp, colorResource(id = R.color.gray_opac_04), CircleShape)
- .paint(
- painter = painterResource(id = icon),
- contentScale = ContentScale.FillBounds
- )
- )
- Surface(
- modifier = Modifier
- .padding(start = 40.dp, bottom = 15.dp, end = 110.dp)
- .align(Alignment.CenterStart)
- .background(Color.Transparent),
- color = Color.Transparent
- ) {
- Text(
- text = server.server_name!!,
- color = MaterialTheme.colorScheme.primary,
- style = MaterialTheme.typography.labelMedium,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis,
- modifier = Modifier
- .align(Alignment.CenterStart)
- )
- }
- // Spacer(modifier = Modifier.weight(1F))
- Text(
- text = "$serverPing ms",
- color = colorResource(id = R.color.blue_text),
- style = MaterialTheme.typography.displayMedium,
- modifier = Modifier
- .padding(end = 50.dp, bottom = 15.dp)
- .align(Alignment.CenterEnd)
- )
- // Spacer(modifier = Modifier.weight(1F))
- IconButton(
- onClick = {
- isFavorite = !isFavorite!!
- serverListViewModelSplash.favAndUnFav(server)
- },
- modifier = Modifier
- .padding(bottom = 15.dp, end = 4.dp)
- .size(25.dp)
- .align(Alignment.CenterEnd),
- // .clickable(
- // indication = null,
- // interactionSource = remember { MutableInteractionSource() }
- // ) { },
- ) {
- Icon(
- painter = if (isServerFavourited) painterResource(
- id = R.drawable.fav_server3x
- ) else painterResource(
- id = R.drawable.unfav_server3x
- ),
- contentDescription = "Server Logo",
- tint = Color.Unspecified,
- modifier = Modifier.size(22.dp, 21.dp)
- )
- }
- }
- }
- if (icon != 0) {
- Surface(
- modifier = Modifier
- .padding(start = 0.dp, end = 0.dp)
- .height(1.dp)
- .fillMaxWidth()
- .alpha(0.6F)
- .align(Alignment.BottomCenter),
- color = colorResource(id = R.color.gray_icon)
- ) {}
- }
- }
- }
- @Composable
- fun ServerSearchItem(
- server: Server,
- navHostController: NavHostController,
- bgColor: Color = Color.White,
- textColor: Color = MaterialTheme.colorScheme.primary,
- isServerCallbackShown: Boolean = true,
- serverPing: Int,
- onServerDisable: () -> Unit
- ) {
- val context = LocalContext.current
- val scope = rememberCoroutineScope()
- val basePreferenceHelper = BasePreferenceHelper(context)
- // val serverListViewModel: ServerListViewModel = viewModel {
- // ServerListViewModel(context = context)
- // }
- // val splashViewModel: SplashViewModel = viewModel{
- // SplashViewModel(context)
- // }
- // val searchListViewModel: SearchListViewModel = viewModel{
- // SearchListViewModel(context, serverListViewModel, splashViewModel)
- // }
- val homeViewModel: HomeViewModel = viewModel{
- HomeViewModel(context, scope)
- }
- var isSearchServerClicked by remember {
- mutableStateOf(false)
- }
- var isFavorite by remember { mutableStateOf(server.isFavourited) }
- val isServerFavourited: Boolean = server.isFavourited == true
- Log.d("test-server_fav_d", "$isFavorite")
- if (isSearchServerClicked) {
- Log.d("ServerCallbacks", "isServerClicked $isSearchServerClicked")
- onServer.onServerSelected(
- context,
- homeViewModel,
- onClick = { isSearchServerClicked = false },
- true,
- server
- )
- navHostController.popBackStack()
- }
- Box(
- modifier = Modifier
- .fillMaxWidth()
- .background(color = MaterialTheme.colorScheme.onBackground)
- .padding(bottom = 1.dp)
- ) {
- // val icon = if (server.enable == 1) Utils.getDrawable(context, server.iso)
- // else Utils.getDrawableGray(context, server.iso)
- val icon = Utils.getDrawable(context, server.iso)
- var isFreeAccount: Boolean = false
- basePreferenceHelper.getProduct()?.identifier?.let {
- if (it == AppEnum.FREE.key) {
- isFreeAccount = true
- } else {
- isFreeAccount = false
- }
- }
- Box(
- // verticalAlignment = Alignment.Top,
- // horizontalArrangement = Arrangement.Start,
- modifier = Modifier
- .fillMaxWidth()
- .padding(start = 12.dp, end = 7.dp, top = 12.dp)
- .clickable(
- indication = null,
- interactionSource = remember { MutableInteractionSource() }
- ) {
- if (!isFreeAccount) {
- if (toChangeServer.value) {
- basePreferenceHelper.saveSmartList(smartConnect[2])
- basePreferenceHelper.setSmartServerObject(server)
- navHostController.popBackStack()
- } else {
- isSearchServerClicked = isServerCallbackShown
- }
- // basePreferenceHelper.setServerObject(server)
- if (!isServerCallbackShown) {
- onServerDisable()
- }
- } else {
- basePreferenceHelper.setSubscriptionServerObject(server)
- Screen.Subscription.isTrue = true
- navHostController.navigate(
- Screen.Subscription.route
- )
- }
- }
- )
- {
- // var ping by rememberSaveable { mutableIntStateOf(0) }
- // fun updatePing(newPing: Int) {
- // ping = newPing
- // }
- // LaunchedEffect(key1 = Unit) {
- // Log.d("test_new_ping", "Inside LE")
- //// while (true) {
- // Ping.onAddress(server.ip as String).setTimeOutMillis(1000).doPing(
- // object : Ping.PingListener{
- // override fun onResult(pingResult: PingResult?) {
- // pingResult?.let {
- // Log.d("test_new_ping", "pingResult = ${it.timeTaken.toInt()}")
- // if (ping == 0) updatePing(it.timeTaken.toInt())
- // }
- // }
- // override fun onError(e: Exception?) {}
- // override fun onFinished(pingStats: PingStats?) {}
- // }
- // )
- //// delay(3 * 1000)
- //// }
- // }
- if (icon != 0) {
- Icon(
- painter = painterResource(id = icon),
- contentDescription = "Server Logo",
- tint = Color.Unspecified,
- modifier = Modifier
- .padding(bottom = 15.dp)
- .size(24.dp)
- .clip(CircleShape)
- .border(1.dp, colorResource(id = R.color.gray_opac_04), CircleShape)
- .paint(
- painter = painterResource(id = icon),
- contentScale = ContentScale.FillBounds
- )
- .align(Alignment.CenterStart)
- )
- Surface(
- modifier = Modifier
- .padding(start = 40.dp, bottom = 15.dp, end = 110.dp)
- .align(Alignment.CenterStart)
- .background(Color.Transparent),
- color = Color.Transparent
- ) {
- Text(
- text = server.server_name!!,
- color = textColor,
- style = MaterialTheme.typography.labelMedium,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis,
- modifier = Modifier
- .align(Alignment.CenterStart)
- )
- }
- // Spacer(modifier = Modifier.weight(1F))
- Text(
- text = "$serverPing ms",
- color = colorResource(id = R.color.blue_text),
- style = MaterialTheme.typography.displayMedium,
- modifier = Modifier
- .padding(end = 50.dp, bottom = 15.dp)
- .align(Alignment.CenterEnd)
- )
- IconButton(
- modifier = Modifier
- .padding(bottom = 15.dp, end = 4.dp)
- .size(25.dp)
- .align(Alignment.CenterEnd),
- onClick = {
- isFavorite = !isFavorite!!
- serverListViewModelSplash.favAndUnFav(server)
- }) {
- Icon(
- painter = if (isServerFavourited) painterResource(
- id = R.drawable.fav_server3x
- ) else painterResource(
- id = R.drawable.unfav_server3x
- ),
- contentDescription = "Server Logo",
- tint = Color.Unspecified,
- modifier = Modifier.size(22.dp, 21.dp),
- )
- }
- }
- }
- if (icon != 0) {
- Surface(
- modifier = Modifier
- .padding(start = 0.dp, end = 0.dp)
- .height(1.dp)
- .fillMaxWidth()
- .alpha(0.6F)
- .align(Alignment.BottomCenter),
- color = colorResource(id = R.color.gray_icon)
- ) {}
- }
- }
- }
- @Composable
- fun ServerSpecificItem(
- server: Server,
- navHostController: NavHostController,
- onServerDisable: () -> Unit
- ) {
- val context = LocalContext.current
- val scope = rememberCoroutineScope()
- val basePreferenceHelper = BasePreferenceHelper(context)
- // val serverListViewModel: ServerListViewModel = viewModel {
- // ServerListViewModel(context = context)
- // }
- // val splashViewModel: SplashViewModel = viewModel{
- // SplashViewModel(context)
- // }
- // val searchListViewModel: SearchListViewModel = viewModel{
- // SearchListViewModel(context, serverListViewModel, splashViewModel)
- // }
- // val homeViewModel: HomeViewModel = viewModel{
- // HomeViewModel(context, scope)
- // }
- var isSearchServerClicked by remember {
- mutableStateOf(false)
- }
- Box(
- modifier = Modifier
- .fillMaxWidth()
- .background(color = MaterialTheme.colorScheme.background)
- .padding(bottom = 1.dp)
- ) {
- // val icon = if (server.enable == 1) Utils.getDrawable(context, server.iso)
- // else Utils.getDrawableGray(context, server.iso)
- val icon = Utils.getDrawable(context, server.iso)
- var isFreeAccount: Boolean = false
- basePreferenceHelper.getProduct()?.identifier?.let {
- if (it == AppEnum.FREE.key) {
- isFreeAccount = true
- } else {
- isFreeAccount = false
- }
- }
- Row(
- verticalAlignment = Alignment.Top,
- horizontalArrangement = Arrangement.Start,
- modifier = Modifier
- .fillMaxWidth()
- .padding(start = 12.dp, end = 7.dp, top = 12.dp)
- .clickable(
- indication = null,
- interactionSource = remember { MutableInteractionSource() }
- ) {
- if (!isFreeAccount) {
- // MainActivity.isSelectedServersShown = true
- // basePreferenceHelper.setServerObject(server)
- basePreferenceHelper.saveSmartList(smartConnect[2])
- basePreferenceHelper.setSmartServerObject(server)
- onServerDisable()
- } else {
- basePreferenceHelper.setSubscriptionServerObject(server)
- Screen.Subscription.isTrue = true
- navHostController.navigate(
- Screen.Subscription.route
- )
- }
- }
- ) {
- if (icon != 0) {
- Icon(
- painter = painterResource(id = icon),
- contentDescription = "Server Logo",
- tint = Color.Unspecified,
- modifier = Modifier
- .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.FillBounds
- )
- )
- server.server_name?.let {
- Text(
- text = it,
- color = MaterialTheme.colorScheme.primary,
- style = MaterialTheme.typography.labelMedium,
- modifier = Modifier
- .padding(start = 16.dp, bottom = 18.dp)
- .align(Alignment.CenterVertically)
- )
- }
- }
- }
- if (icon != 0) {
- Surface(
- modifier = Modifier
- .padding(start = 0.dp, end = 0.dp)
- .height(1.dp)
- .fillMaxWidth()
- .alpha(0.6F)
- .align(Alignment.BottomCenter),
- color = colorResource(id = R.color.gray_icon)
- ) {}
- }
- }
- }
- @Preview
- @Composable
- fun ServerItemPreview() {
- ServerItem(server = favListServer[0], rememberNavController())
- }
- @Preview
- @Composable
- fun FavoriteServerItemPreview() {
- FavoriteServerItem(server = favListServer[0], rememberNavController(), 0)
- }
- @Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
- @Composable
- fun FavoriteServerItemPreviewDark() {
- FavoriteServerItem(server = favListServer[0], rememberNavController(), 0)
- }
- @Preview
- @Composable
- fun ServerSearchItemPreview() {
- ServerSearchItem(server = favListServer[0], rememberNavController(), serverPing = 0) {}
- }
|