Przeglądaj źródła

Generic loader implemented

minhaj 2 tygodni temu
rodzic
commit
43a32aabd6

+ 17 - 7
app/src/main/java/com/fastest/pass/di/GenericLoader.kt

@@ -1,5 +1,7 @@
 package com.fastest.pass.di
 
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.foundation.layout.size
 import androidx.compose.material3.CircularProgressIndicator
 import androidx.compose.runtime.Composable
@@ -8,6 +10,7 @@ import androidx.compose.runtime.getValue
 import androidx.compose.runtime.mutableFloatStateOf
 import androidx.compose.runtime.remember
 import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.res.colorResource
 import androidx.compose.ui.unit.dp
@@ -17,6 +20,7 @@ import kotlinx.coroutines.delay
 @Composable
 fun GenericLoader(loader: Boolean) {
     if (loader) {
+
         var progress by remember { mutableFloatStateOf(0.1F) }
 
         LaunchedEffect(key1 = Unit) {
@@ -29,12 +33,18 @@ fun GenericLoader(loader: Boolean) {
             }
         }
 
-        CircularProgressIndicator(
-            progress = { progress },
-            modifier = Modifier
-                .size(50.dp),
-            color = colorResource(id = R.color.yellow_text),
-            strokeWidth = 5.dp,
-        )
+        Box(modifier = Modifier.fillMaxSize(),
+            contentAlignment = Alignment.Center){
+            CircularProgressIndicator(
+                progress = { progress },
+                modifier = Modifier
+                    .size(50.dp)
+                    .align(Alignment.Center),
+                color = colorResource(id = R.color.yellow_text),
+                strokeWidth = 5.dp,
+            )
+        }
+
+
     }
 }

+ 0 - 1
app/src/main/java/com/fastest/pass/login/presentation/ui/LoginFragment.kt

@@ -10,7 +10,6 @@ import androidx.compose.foundation.layout.Box
 import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.foundation.layout.padding
 import androidx.compose.material.Scaffold
-import androidx.compose.runtime.collectAsState
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.platform.ComposeView
 import androidx.compose.ui.res.colorResource

+ 2 - 2
app/src/main/java/com/fastest/pass/login/presentation/viewmodels/LoginViewModel.kt

@@ -50,11 +50,11 @@ class LoginViewModel @Inject constructor(
                     }
 
                     is Result.Success -> {
-                        _loginResponse.value = UIState(true,result.data)
+                        _loginResponse.value = UIState(false,result.data)
                     }
 
                     is Result.Failure -> {
-
+                        _loginResponse.value = UIState(false)
                     }
                 }
             }