|
@@ -1,11 +1,8 @@
|
|
|
package com.vpn.fastestvpnservice.screensTV.settingsScreenAll
|
|
|
|
|
|
import android.util.Log
|
|
|
-import android.widget.Toast
|
|
|
import androidx.compose.foundation.background
|
|
|
import androidx.compose.foundation.border
|
|
|
-import androidx.compose.foundation.clickable
|
|
|
-import androidx.compose.foundation.focusable
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
import androidx.compose.foundation.layout.fillMaxHeight
|
|
@@ -15,19 +12,14 @@ import androidx.compose.foundation.layout.height
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
import androidx.compose.foundation.layout.size
|
|
|
import androidx.compose.foundation.lazy.LazyColumn
|
|
|
-import androidx.compose.foundation.lazy.LazyRow
|
|
|
import androidx.compose.foundation.lazy.items
|
|
|
import androidx.compose.foundation.lazy.itemsIndexed
|
|
|
-import androidx.compose.foundation.rememberScrollState
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
import androidx.compose.foundation.text.KeyboardActions
|
|
|
import androidx.compose.foundation.text.KeyboardOptions
|
|
|
-import androidx.compose.foundation.verticalScroll
|
|
|
-import androidx.compose.material3.DockedSearchBar
|
|
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
|
import androidx.compose.material3.Icon
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
-import androidx.compose.material3.SearchBarDefaults
|
|
|
import androidx.compose.material3.Text
|
|
|
import androidx.compose.material3.TextField
|
|
|
import androidx.compose.material3.TextFieldDefaults
|
|
@@ -41,8 +33,6 @@ import androidx.compose.runtime.rememberCoroutineScope
|
|
|
import androidx.compose.runtime.setValue
|
|
|
import androidx.compose.ui.Alignment
|
|
|
import androidx.compose.ui.Modifier
|
|
|
-import androidx.compose.ui.focus.FocusRequester
|
|
|
-import androidx.compose.ui.focus.focusRequester
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
import androidx.compose.ui.platform.LocalFocusManager
|
|
@@ -53,26 +43,39 @@ import androidx.compose.ui.text.input.ImeAction
|
|
|
import androidx.compose.ui.text.input.KeyboardType
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
+import androidx.lifecycle.viewmodel.compose.viewModel
|
|
|
import androidx.navigation.NavHostController
|
|
|
import com.vpn.fastestvpnservice.R
|
|
|
import com.vpn.fastestvpnservice.customItems.SearchServerItemTV
|
|
|
-import com.vpn.fastestvpnservice.customItems.ServerItemTV
|
|
|
-import com.vpn.fastestvpnservice.customItems.ServerSearchItem
|
|
|
+import com.vpn.fastestvpnservice.screens.isSearchModelInitialized
|
|
|
import com.vpn.fastestvpnservice.screens.searchListViewModelSplash
|
|
|
import com.vpn.fastestvpnservice.screens.serverListViewModelSplash
|
|
|
import com.vpn.fastestvpnservice.screensTV.HeaderRowSL
|
|
|
-import com.vpn.fastestvpnservice.screensTV.locations
|
|
|
+import com.vpn.fastestvpnservice.screensTV.splashViewModelSplash
|
|
|
import com.vpn.fastestvpnservice.ui.theme.customTypography
|
|
|
+import com.vpn.fastestvpnservice.viewmodels.SearchListViewModel
|
|
|
+import com.vpn.fastestvpnservice.viewmodels.ServerListViewModel
|
|
|
+import com.vpn.fastestvpnservice.viewmodels.SplashViewModel
|
|
|
import kotlinx.coroutines.delay
|
|
|
-import kotlinx.coroutines.launch
|
|
|
|
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
|
@Composable
|
|
|
fun AnySpecificScreenTV(navHostController: NavHostController) {
|
|
|
val context = LocalContext.current
|
|
|
- val searchListViewModel = searchListViewModelSplash
|
|
|
+// val searchListViewModel = searchListViewModelSplash
|
|
|
var searchText1 by remember { mutableStateOf("Test") }
|
|
|
- val isActive = searchListViewModel.isActive.observeAsState().value
|
|
|
+ if (!isSearchModelInitialized) {
|
|
|
+ splashViewModelSplash = viewModel {
|
|
|
+ SplashViewModel(context)
|
|
|
+ }
|
|
|
+ serverListViewModelSplash = viewModel {
|
|
|
+ ServerListViewModel(context = context)
|
|
|
+ }
|
|
|
+ searchListViewModelSplash = viewModel {
|
|
|
+ SearchListViewModel(context, serverListViewModelSplash, splashViewModelSplash)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ val isActive = searchListViewModelSplash.isActive.observeAsState().value
|
|
|
val scope = rememberCoroutineScope()
|
|
|
var textChanged by remember { mutableStateOf("") }
|
|
|
val keyboardController = LocalSoftwareKeyboardController.current
|
|
@@ -247,10 +250,10 @@ fun AnySpecificScreenTV(navHostController: NavHostController) {
|
|
|
Log.d("test_search_logic", "LaunchedEffect $textChanged")
|
|
|
val delay = if (textChanged.isEmpty()) 0L else 300L
|
|
|
delay(delay)
|
|
|
- searchListViewModel.getCountries(textChanged, true)
|
|
|
+ searchListViewModelSplash.getCountries(textChanged, true)
|
|
|
}
|
|
|
|
|
|
- val searchServersList = searchListViewModel.countriesList.observeAsState().value
|
|
|
+ val searchServersList = searchListViewModelSplash.countriesList.observeAsState().value
|
|
|
searchServersList?.forEachIndexed { index, server ->
|
|
|
Log.d("test_search", "SLS_ ${server.server_name} ${server.ping}")
|
|
|
}
|