|
@@ -33,13 +33,16 @@ import androidx.compose.material.Surface
|
|
|
import androidx.compose.material.Text
|
|
|
import androidx.compose.material3.Button
|
|
|
import androidx.compose.material3.ButtonDefaults
|
|
|
+import androidx.compose.material3.CircularProgressIndicator
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
import androidx.compose.runtime.Composable
|
|
|
import androidx.compose.runtime.CompositionLocalProvider
|
|
|
import androidx.compose.runtime.DisposableEffect
|
|
|
import androidx.compose.runtime.LaunchedEffect
|
|
|
+import androidx.compose.runtime.MutableState
|
|
|
import androidx.compose.runtime.getValue
|
|
|
import androidx.compose.runtime.livedata.observeAsState
|
|
|
+import androidx.compose.runtime.mutableFloatStateOf
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
import androidx.compose.runtime.remember
|
|
|
import androidx.compose.runtime.rememberUpdatedState
|
|
@@ -90,6 +93,7 @@ import com.vpn.fastestvpnservice.ui.theme.FastestVPNTheme
|
|
|
import com.vpn.fastestvpnservice.utils.Utils
|
|
|
import com.vpn.fastestvpnservice.viewmodels.BillingViewModel
|
|
|
import com.vpn.fastestvpnservice.viewmodels.SubscriptionViewModel
|
|
|
+import kotlinx.coroutines.delay
|
|
|
import kotlin.random.Random
|
|
|
import kotlin.random.nextInt
|
|
|
|
|
@@ -106,6 +110,7 @@ fun SubscriptionScreen(navHostController: NavHostController, activity: Component
|
|
|
var selectedPosition: Int = 0
|
|
|
var skuDetailsList: List<SkuDetails>? = null
|
|
|
val basePreferenceHelper = BasePreferenceHelper(context)
|
|
|
+ var isLoaderShow by remember { mutableStateOf(true) }
|
|
|
|
|
|
Box(
|
|
|
modifier = Modifier
|
|
@@ -118,6 +123,29 @@ fun SubscriptionScreen(navHostController: NavHostController, activity: Component
|
|
|
subscriptionViewModel.getProducts()
|
|
|
}
|
|
|
|
|
|
+ if (isLoaderShow) {
|
|
|
+ var progress by remember { mutableFloatStateOf(0.1F) }
|
|
|
+
|
|
|
+ LaunchedEffect(key1 = Unit) {
|
|
|
+ while (true) {
|
|
|
+ for (i in 1..100) {
|
|
|
+ progress = i.toFloat()/100F
|
|
|
+ delay(150)
|
|
|
+ }
|
|
|
+ progress = 0.1F
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ CircularProgressIndicator(
|
|
|
+ progress = { progress },
|
|
|
+ modifier = Modifier
|
|
|
+ .size(50.dp)
|
|
|
+ .align(Alignment.Center),
|
|
|
+ color = colorResource(id = R.color.yellow_text),
|
|
|
+ strokeWidth = 5.dp,
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
HeaderRowSS(navHostController = navHostController)
|
|
|
|
|
|
Column(
|
|
@@ -148,29 +176,26 @@ fun SubscriptionScreen(navHostController: NavHostController, activity: Component
|
|
|
CompositionLocalProvider(
|
|
|
LocalOverscrollConfiguration provides null
|
|
|
) {
|
|
|
- val featuresList = subscriptionViewModel.featuresListSorted.observeAsState().value
|
|
|
+ val selectedPosition1 = SubscriptionViewModel.selectedPosition
|
|
|
+ val featuresList = subscriptionViewModel.featuresListSortedItems.observeAsState().value
|
|
|
featuresList?.let {
|
|
|
Log.d("test_subscription_list", "featuresListSorted[SS] size = ${it.size}")
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- val productsData = subscriptionViewModel.featuresListSorted.observeAsState().value
|
|
|
val selectPriceList = subscriptionViewModel.selectPriceList.observeAsState().value
|
|
|
- val selectedPosition1 = subscriptionViewModel.mutableLiveDataNumber.observeAsState().value
|
|
|
|
|
|
LazyColumn {
|
|
|
|
|
|
-// selectedPosition = getSelectedPosition()
|
|
|
-
|
|
|
- productsData?.let {
|
|
|
+ featuresList?.let {
|
|
|
|
|
|
it.let {
|
|
|
Log.d("test_api_response_p",
|
|
|
"Products screen = ${it.size}, selectedPosition = $selectedPosition1")
|
|
|
|
|
|
if (it.size > 0) {
|
|
|
- val features = selectedPosition1?.let { it1 -> it.get(it1).features }
|
|
|
- features?.let {
|
|
|
+ isLoaderShow = false
|
|
|
+// val features = selectedPosition1.let { it1 -> it.features }
|
|
|
+ it.let {
|
|
|
items(items = it) {item ->
|
|
|
SubscriptionDataItem(item = item)
|
|
|
}
|
|
@@ -200,7 +225,7 @@ fun SubscriptionScreen(navHostController: NavHostController, activity: Component
|
|
|
|
|
|
onClick = {
|
|
|
selectedPosition = getSelectedPosition()
|
|
|
- Toast.makeText(context, "$selectedPosition", Toast.LENGTH_SHORT).show()
|
|
|
+// Toast.makeText(context, "$selectedPosition", Toast.LENGTH_SHORT).show()
|
|
|
Log.d("test_button", "onClick")
|
|
|
// subscriptionViewModel.mutableLiveDataNumber.value = 1
|
|
|
Log.d("SubscriptionViewModel", "liveData ${skuDetailsListsSubs}")
|