|
@@ -9,7 +9,9 @@ import android.os.Bundle
|
|
|
import android.util.Log
|
|
|
import android.widget.Toast
|
|
|
import androidx.compose.animation.AnimatedVisibility
|
|
|
+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.gestures.detectTapGestures
|
|
@@ -29,6 +31,8 @@ import androidx.compose.foundation.layout.height
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
import androidx.compose.foundation.layout.size
|
|
|
import androidx.compose.foundation.layout.width
|
|
|
+import androidx.compose.foundation.lazy.LazyColumn
|
|
|
+import androidx.compose.foundation.lazy.items
|
|
|
import androidx.compose.foundation.selection.selectable
|
|
|
import androidx.compose.material.icons.Icons
|
|
|
import androidx.compose.material.icons.automirrored.filled.CallSplit
|
|
@@ -59,6 +63,7 @@ import androidx.compose.material3.SwitchDefaults
|
|
|
import androidx.compose.material3.Text
|
|
|
import androidx.compose.material3.rememberModalBottomSheetState
|
|
|
import androidx.compose.runtime.Composable
|
|
|
+import androidx.compose.runtime.CompositionLocalProvider
|
|
|
import androidx.compose.runtime.LaunchedEffect
|
|
|
import androidx.compose.runtime.MutableState
|
|
|
import androidx.compose.runtime.getValue
|
|
@@ -89,6 +94,7 @@ import androidx.compose.ui.unit.TextUnit
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
import androidx.core.content.ContextCompat.startActivity
|
|
|
+import androidx.lifecycle.viewmodel.compose.viewModel
|
|
|
import androidx.navigation.NavHostController
|
|
|
import androidx.navigation.compose.rememberNavController
|
|
|
import com.vpn.fastestvpnservice.R
|
|
@@ -97,10 +103,14 @@ import com.vpn.fastestvpnservice.beans.isDarkTheme
|
|
|
import com.vpn.fastestvpnservice.beans.themesList
|
|
|
import com.vpn.fastestvpnservice.constants.AppEnum
|
|
|
import com.vpn.fastestvpnservice.constants.smartConnect
|
|
|
+import com.vpn.fastestvpnservice.customItems.ServerSearchItem
|
|
|
import com.vpn.fastestvpnservice.helpers.BasePreferenceHelper
|
|
|
import com.vpn.fastestvpnservice.navigation.navigationAnimation
|
|
|
import com.vpn.fastestvpnservice.sealedClass.BottomBarScreen
|
|
|
import com.vpn.fastestvpnservice.sealedClass.Screen
|
|
|
+import com.vpn.fastestvpnservice.viewmodels.SearchListViewModel
|
|
|
+import com.vpn.fastestvpnservice.viewmodels.ServerListViewModel
|
|
|
+import com.vpn.fastestvpnservice.viewmodels.SplashViewModel
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
@@ -129,7 +139,8 @@ fun Settings(navHostController: NavHostController) {
|
|
|
icon = R.drawable.smart_connect3x,
|
|
|
text = "Smart Connect",
|
|
|
isRowShown = false,
|
|
|
- isSheetShown = true
|
|
|
+ isSheetShown = true,
|
|
|
+ navHostController
|
|
|
)
|
|
|
}
|
|
|
|
|
@@ -158,7 +169,8 @@ fun Settings(navHostController: NavHostController) {
|
|
|
icon = R.drawable.smart_connect3x,
|
|
|
text = "Smart Connect",
|
|
|
isRowShown = true,
|
|
|
- isSheetShown = false
|
|
|
+ isSheetShown = false,
|
|
|
+ navHostController
|
|
|
)
|
|
|
AddRowSwitch(
|
|
|
icon = R.drawable.adblock3x,
|
|
@@ -742,20 +754,32 @@ fun AddRowDarkLightTheme(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-@OptIn(ExperimentalMaterial3Api::class)
|
|
|
+@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
|
|
|
@Composable
|
|
|
fun ColumnScope.AddRowSettingsSmart(
|
|
|
icon: Int,
|
|
|
text: String,
|
|
|
isRowShown: Boolean,
|
|
|
- isSheetShown: Boolean
|
|
|
+ isSheetShown: Boolean,
|
|
|
+ navHostController: NavHostController
|
|
|
) {
|
|
|
var isSmartSheetOpen by remember { mutableStateOf(isSheetShown) }
|
|
|
var isAnySpecificSheetOpen by remember { mutableStateOf(false) }
|
|
|
val sheetState = rememberModalBottomSheetState()
|
|
|
+ val sheetStateAny = rememberModalBottomSheetState()
|
|
|
val context = LocalContext.current
|
|
|
val basePreferenceHelper = BasePreferenceHelper(context)
|
|
|
|
|
|
+ val splashViewModel: SplashViewModel = viewModel{
|
|
|
+ SplashViewModel(context)
|
|
|
+ }
|
|
|
+ val serverListViewModel: ServerListViewModel = viewModel {
|
|
|
+ ServerListViewModel(context = context)
|
|
|
+ }
|
|
|
+ val searchListViewModel: SearchListViewModel = viewModel{
|
|
|
+ SearchListViewModel(context, serverListViewModel, splashViewModel)
|
|
|
+ }
|
|
|
+
|
|
|
var selectedSmartConnect by remember {
|
|
|
mutableStateOf(basePreferenceHelper.getSmartList()) }
|
|
|
|
|
@@ -865,12 +889,13 @@ fun ColumnScope.AddRowSettingsSmart(
|
|
|
onClick = {
|
|
|
selectedSmartConnect = smart
|
|
|
basePreferenceHelper.saveSmartList(smart)
|
|
|
+ isSmartSheetOpen = false
|
|
|
|
|
|
- if (smart == smartConnect[0]) {
|
|
|
- Log.d("smartLocationList", "$smart")
|
|
|
+ if (smart == smartConnect[2]) {
|
|
|
+ Log.d("smartLocationList Row", smart)
|
|
|
+ isAnySpecificSheetOpen = true
|
|
|
}
|
|
|
|
|
|
- isSmartSheetOpen = false
|
|
|
},
|
|
|
)
|
|
|
// .indication(
|
|
@@ -887,6 +912,11 @@ fun ColumnScope.AddRowSettingsSmart(
|
|
|
selectedSmartConnect = smart
|
|
|
basePreferenceHelper.saveSmartList(smart)
|
|
|
isSmartSheetOpen = false
|
|
|
+
|
|
|
+ if (smart == smartConnect[2]) {
|
|
|
+ Log.d("smartLocationList RB", smart)
|
|
|
+ isAnySpecificSheetOpen = true
|
|
|
+ }
|
|
|
},
|
|
|
colors = RadioButtonDefaults.colors(
|
|
|
selectedColor = colorResource(id = R.color.radio_button_blue),
|
|
@@ -909,70 +939,36 @@ fun ColumnScope.AddRowSettingsSmart(
|
|
|
onDismissRequest = { isAnySpecificSheetOpen = false
|
|
|
BottomBarScreen.Settings.isTrue = false
|
|
|
},
|
|
|
- sheetState = sheetState,
|
|
|
- containerColor = MaterialTheme.colorScheme.background
|
|
|
+ sheetState = sheetStateAny,
|
|
|
+ containerColor = MaterialTheme.colorScheme.background,
|
|
|
+ modifier = Modifier.padding(top = 50.dp)
|
|
|
) {
|
|
|
Box(modifier = Modifier
|
|
|
.background(Color.Transparent)
|
|
|
.fillMaxWidth()
|
|
|
- .height(550.dp)
|
|
|
+ .fillMaxHeight()
|
|
|
.padding(start = 0.dp, top = 10.dp),
|
|
|
) {
|
|
|
Column(
|
|
|
verticalArrangement = Arrangement.Top,
|
|
|
horizontalAlignment = Alignment.Start
|
|
|
) {
|
|
|
- AddTextSettings(
|
|
|
- text = "Any Connect",
|
|
|
- size = 18.sp,
|
|
|
- color = MaterialTheme.colorScheme.primary,
|
|
|
- bottomPadding = 20.dp,
|
|
|
- startPadding = 16.dp,
|
|
|
- style = MaterialTheme.typography.titleMedium
|
|
|
- )
|
|
|
- smartConnect.forEach { smart ->
|
|
|
- Row(
|
|
|
+ CompositionLocalProvider(
|
|
|
+ LocalOverscrollConfiguration provides null
|
|
|
+ ) {
|
|
|
+ LazyColumn(
|
|
|
modifier = Modifier
|
|
|
- .fillMaxWidth()
|
|
|
- .background(Color.Transparent)
|
|
|
- .padding(start = 2.dp)
|
|
|
- .selectable(
|
|
|
- selected = selectedSmartConnect == smart,
|
|
|
- onClick = {
|
|
|
- selectedSmartConnect = smart
|
|
|
- basePreferenceHelper.saveSmartList(smart)
|
|
|
-
|
|
|
- if (smart == smartConnect[0]) {
|
|
|
- Log.d("smartLocationList", "$smart")
|
|
|
- }
|
|
|
-
|
|
|
- isAnySpecificSheetOpen = false
|
|
|
- },
|
|
|
- )
|
|
|
-// .indication(
|
|
|
-// indication = null,
|
|
|
-// interactionSource = remember {
|
|
|
-// MutableInteractionSource()
|
|
|
-// }
|
|
|
-// )
|
|
|
- ,
|
|
|
- verticalAlignment = Alignment.CenterVertically
|
|
|
+ .padding(top = 0.dp, bottom = 0.dp),
|
|
|
) {
|
|
|
- RadioButton(selected = smart == selectedSmartConnect,
|
|
|
- onClick = {
|
|
|
- selectedSmartConnect = smart
|
|
|
- basePreferenceHelper.saveSmartList(smart)
|
|
|
- isAnySpecificSheetOpen = false
|
|
|
- },
|
|
|
- colors = RadioButtonDefaults.colors(
|
|
|
- selectedColor = colorResource(id = R.color.radio_button_blue),
|
|
|
- unselectedColor = colorResource(id = R.color.gray_icon),)
|
|
|
- )
|
|
|
- Text(text = smart,
|
|
|
- modifier = Modifier.padding(start = 12.dp),
|
|
|
- color = MaterialTheme.colorScheme.primary,
|
|
|
- style = MaterialTheme.typography.bodySmall
|
|
|
- )
|
|
|
+ val searchServersList = searchListViewModel.countriesList.value
|
|
|
+ items(items = searchServersList!!) { server ->
|
|
|
+ ServerSearchItem(
|
|
|
+ server, navHostController = navHostController,
|
|
|
+ MaterialTheme.colorScheme.background,
|
|
|
+ MaterialTheme.colorScheme.primary, false,
|
|
|
+ onServerDisable = { isAnySpecificSheetOpen = false }
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|