Explorar o código

working on api structure modification

minhaj hai 2 semanas
pai
achega
214d26ea85
Modificáronse 39 ficheiros con 196 adicións e 171 borrados
  1. 2 2
      app/src/main/AndroidManifest.xml
  2. 1 1
      app/src/main/java/com/fastest/pass/account/presentation/ui/fragment/AccountFragment.kt
  3. 1 3
      app/src/main/java/com/fastest/pass/browse/presentation/ui/fragment/BrowseFragment.kt
  4. 1 4
      app/src/main/java/com/fastest/pass/browse/presentation/ui/fragment/NewItemBrowseFragment.kt
  5. 1 8
      app/src/main/java/com/fastest/pass/dashboard/presentation/ui/fragment/DashboardFragment.kt
  6. 1 1
      app/src/main/java/com/fastest/pass/App.kt
  7. 21 13
      app/src/main/java/com/fastest/pass/di/AppModule.kt
  8. 1 1
      app/src/main/java/com/fastest/pass/BaseFragment.kt
  9. 22 0
      app/src/main/java/com/fastest/pass/di/BaseUseCase.kt
  10. 40 0
      app/src/main/java/com/fastest/pass/di/GenericLoader.kt
  11. 2 3
      app/src/main/java/com/fastest/pass/MainActivity.kt
  12. 7 0
      app/src/main/java/com/fastest/pass/di/UIState.kt
  13. 8 0
      app/src/main/java/com/fastest/pass/di/WebResponse.kt
  14. 1 1
      app/src/main/java/com/fastest/pass/forgotpassword/presentation/ui/ForgotPasswordFragment.kt
  15. 1 2
      app/src/main/java/com/fastest/pass/forgotpassword/presentation/ui/ForgotPasswordVerifyFragment.kt
  16. 1 8
      app/src/main/java/com/fastest/pass/home/presentation/ui/fragment/AddNewItemsFragment.kt
  17. 1 6
      app/src/main/java/com/fastest/pass/home/presentation/ui/fragment/HomeFragment.kt
  18. 1 3
      app/src/main/java/com/fastest/pass/home/presentation/ui/fragment/NewItemFormFragment.kt
  19. 1 2
      app/src/main/java/com/fastest/pass/login/data/model/LoginResponse.kt
  20. 2 1
      app/src/main/java/com/fastest/pass/login/data/model/LoginResult.kt
  21. 3 5
      app/src/main/java/com/fastest/pass/login/data/remote/LoginApiService.kt
  22. 4 16
      app/src/main/java/com/fastest/pass/login/data/repository/LoginRepositoryImpl.kt
  23. 5 14
      app/src/main/java/com/fastest/pass/login/di/LoginModule.kt
  24. 3 2
      app/src/main/java/com/fastest/pass/login/domain/repository/LoginRepository.kt
  25. 6 4
      app/src/main/java/com/fastest/pass/login/domain/usecase/LoginUseCase.kt
  26. 12 8
      app/src/main/java/com/fastest/pass/login/presentation/ui/LoginFragment.kt
  27. 3 6
      app/src/main/java/com/fastest/pass/login/presentation/ui/components/LoginScreen.kt
  28. 37 6
      app/src/main/java/com/fastest/pass/login/presentation/viewmodels/LoginViewModel.kt
  29. 1 2
      app/src/main/java/com/fastest/pass/masterlogin/presentation/ui/MasterLoginFragment.kt
  30. 1 2
      app/src/main/java/com/fastest/pass/mastersignup/presentation/ui/MasterSignUpFragment.kt
  31. 1 1
      app/src/main/java/com/fastest/pass/security/presentation/ui/fragment/SecurityFragment.kt
  32. 1 2
      app/src/main/java/com/fastest/pass/signup/presentation/ui/SignUpFragment.kt
  33. 0 12
      app/src/main/java/com/fastest/pass/splash/data/remote/SplashApiService.kt
  34. 0 12
      app/src/main/java/com/fastest/pass/splash/data/repository/SplashRepositoryImpl.kt
  35. 0 5
      app/src/main/java/com/fastest/pass/splash/domain/repository/SplashRepository.kt
  36. 0 9
      app/src/main/java/com/fastest/pass/splash/domain/usecase/SplashUseCase.kt
  37. 1 3
      app/src/main/java/com/fastest/pass/splash/presentation/ui/SplashFragment.kt
  38. 1 2
      app/src/main/java/com/fastest/pass/splash/presentation/viewmodels/SplashViewModel.kt
  39. 1 1
      app/src/main/java/com/fastest/pass/welcome/presentation/ui/fragment/WelcomeFragment.kt

+ 2 - 2
app/src/main/AndroidManifest.xml

@@ -6,7 +6,7 @@
     <uses-permission android:name="android.permission.INTERNET" />
 
     <application
-        android:name=".App"
+        android:name="com.fastest.pass.di.App"
         android:allowBackup="true"
         android:dataExtractionRules="@xml/data_extraction_rules"
         android:fullBackupContent="@xml/backup_rules"
@@ -17,7 +17,7 @@
         android:theme="@style/Theme.FastestPass"
         tools:targetApi="31">
         <activity
-            android:name=".MainActivity"
+            android:name="com.fastest.pass.di.MainActivity"
             android:exported="true"
             >
 <!--            <meta-data-->

+ 1 - 1
app/src/main/java/com/fastest/pass/account/presentation/ui/fragment/AccountFragment.kt

@@ -13,7 +13,7 @@ import androidx.compose.ui.Modifier
 import androidx.compose.ui.platform.ComposeView
 import androidx.compose.ui.res.colorResource
 import androidx.fragment.app.viewModels
-import com.fastest.pass.BaseFragment
+import com.fastest.pass.di.BaseFragment
 import com.fastest.pass.R
 import com.fastest.pass.account.presentation.ui.components.AccountScreen
 import com.fastest.pass.account.presentation.ui.components.ClickType

+ 1 - 3
app/src/main/java/com/fastest/pass/browse/presentation/ui/fragment/BrowseFragment.kt

@@ -10,13 +10,11 @@ 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.material.Text
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.platform.ComposeView
 import androidx.compose.ui.res.colorResource
 import androidx.fragment.app.activityViewModels
-import androidx.fragment.app.viewModels
-import com.fastest.pass.BaseFragment
+import com.fastest.pass.di.BaseFragment
 import com.fastest.pass.R
 import com.fastest.pass.browse.presentation.ui.components.BrowseScreen
 import com.fastest.pass.browse.presentation.ui.components.ClickTypeItemBrowse

+ 1 - 4
app/src/main/java/com/fastest/pass/browse/presentation/ui/fragment/NewItemBrowseFragment.kt

@@ -13,19 +13,16 @@ 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.platform.LocalContext
 import androidx.compose.ui.res.colorResource
-import androidx.fragment.app.FragmentActivity
 import androidx.fragment.app.activityViewModels
 import androidx.fragment.app.viewModels
-import com.fastest.pass.BaseFragment
+import com.fastest.pass.di.BaseFragment
 import com.fastest.pass.R
 import com.fastest.pass.browse.presentation.ui.components.ClickTypeItemBrowse
 import com.fastest.pass.browse.presentation.ui.components.ClickTypeNewItemBrowse
 import com.fastest.pass.browse.presentation.ui.components.NewItemBrowseScreen
 import com.fastest.pass.browse.presentation.viewmodels.BrowseViewModel
 import com.fastest.pass.browse.presentation.viewmodels.NewItemBrowseViewmodel
-import com.fastest.pass.browse.utils.BrowseRoute
 import com.fastest.pass.browse.utils.NewItemBrowseNavigation
 import com.fastest.pass.browse.utils.NewItemBrowseRoute
 import com.fastest.pass.ui.theme.FastestPassTheme

+ 1 - 8
app/src/main/java/com/fastest/pass/dashboard/presentation/ui/fragment/DashboardFragment.kt

@@ -5,23 +5,16 @@ import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
 import androidx.compose.foundation.background
-import androidx.compose.foundation.border
 import androidx.compose.foundation.layout.Box
 import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.foundation.layout.navigationBarsPadding
-import androidx.compose.foundation.layout.padding
-import androidx.compose.material3.Scaffold
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.platform.ComposeView
 import androidx.compose.ui.res.colorResource
-import com.fastest.pass.BaseFragment
+import com.fastest.pass.di.BaseFragment
 import com.fastest.pass.R
 import com.fastest.pass.dashboard.presentation.ui.component.BottomTab
 import com.fastest.pass.ui.theme.FastestPassTheme
-import com.fastest.pass.welcome.presentation.ui.component.ClickType.LOGIN_CLICK
-import com.fastest.pass.welcome.presentation.ui.component.ClickType.SIGNUP_CLICK
-import com.fastest.pass.welcome.presentation.ui.component.WelcomeTutorial
-import com.fastest.pass.welcome.utils.WelcomeNavigationRoute
 
 class DashboardFragment : BaseFragment() {
 

+ 1 - 1
app/src/main/java/com/fastest/pass/App.kt

@@ -1,4 +1,4 @@
-package com.fastest.pass
+package com.fastest.pass.di
 
 import android.app.Application
 import dagger.hilt.android.HiltAndroidApp

+ 21 - 13
app/src/main/java/com/fastest/pass/di/AppModule.kt

@@ -1,33 +1,41 @@
 package com.fastest.pass.di
 
-import com.fastest.pass.splash.data.repository.SplashRepositoryImpl
-import com.fastest.pass.splash.data.remote.SplashApiService
-import com.fastest.pass.splash.domain.repository.SplashRepository
 import dagger.Module
 import dagger.Provides
 import dagger.hilt.InstallIn
 import dagger.hilt.components.SingletonComponent
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
 import retrofit2.Retrofit
 import retrofit2.converter.gson.GsonConverterFactory
+import java.util.concurrent.TimeUnit
 import javax.inject.Singleton
 
 @Module
-@InstallIn(SingletonComponent::class)
+@InstallIn(SingletonComponent::class) // Singleton scope for app-wide use
 object AppModule {
 
-    @Singleton
+    // Provide the Base URL here
+    private const val BASE_URL = "https://api.fastestpass.com/v1/"
+
+
     @Provides
-    fun provideApiService(): SplashApiService {
-        return Retrofit.Builder()
-            .baseUrl("https://testing.com")
-            .addConverterFactory(GsonConverterFactory.create())
+    @Singleton
+    fun provideOkHttpClient(): OkHttpClient {
+        return OkHttpClient.Builder()
+            .connectTimeout(120, TimeUnit.SECONDS)
+            .readTimeout(120, TimeUnit.SECONDS)
+            .addInterceptor(HttpLoggingInterceptor().apply { level = HttpLoggingInterceptor.Level.BODY })
             .build()
-            .create(SplashApiService::class.java)
     }
 
-    @Singleton
     @Provides
-    fun provideSplashRepository(splashApiService: SplashApiService): SplashRepository {
-        return SplashRepositoryImpl(splashApiService)
+    @Singleton
+    fun provideRetrofit(okHttpClient: OkHttpClient): Retrofit {
+        return Retrofit.Builder()
+            .baseUrl(BASE_URL) // Centralized base URL
+            .client(okHttpClient) // Use the OkHttpClient provided above
+            .addConverterFactory(GsonConverterFactory.create())
+            .build()
     }
 }

+ 1 - 1
app/src/main/java/com/fastest/pass/BaseFragment.kt

@@ -1,4 +1,4 @@
-package com.fastest.pass
+package com.fastest.pass.di
 
 import android.os.Bundle
 import android.util.Log

+ 22 - 0
app/src/main/java/com/fastest/pass/di/BaseUseCase.kt

@@ -0,0 +1,22 @@
+package com.fastest.pass.di
+
+sealed class Result<out T> {
+    data class Success<out T>(val data: T) : Result<T>()
+    data class Failure(val exception: Throwable) : Result<Nothing>()
+    object Loading : Result<Nothing>()
+}
+
+abstract class BaseUseCase<in Params, ResultType> {
+
+    abstract suspend fun execute(params: Params): ResultType
+
+    suspend operator fun invoke(params: Params, onResult: (Result<ResultType>) -> Unit) {
+        try {
+            onResult(Result.Loading) // Notify loading state
+            val result = execute(params) // Execute the actual logic (subclass implementation)
+            onResult(Result.Success(result)) // Wrap the result in Result.Success
+        } catch (e: Exception) {
+            onResult(Result.Failure(e)) // Handle exception as failure
+        }
+    }
+}

+ 40 - 0
app/src/main/java/com/fastest/pass/di/GenericLoader.kt

@@ -0,0 +1,40 @@
+package com.fastest.pass.di
+
+import androidx.compose.foundation.layout.size
+import androidx.compose.material3.CircularProgressIndicator
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableFloatStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.res.colorResource
+import androidx.compose.ui.unit.dp
+import com.fastest.pass.R
+import kotlinx.coroutines.delay
+
+@Composable
+fun GenericLoader(loader: Boolean) {
+    if (loader) {
+        var progress by remember { mutableFloatStateOf(0.1F) }
+
+        LaunchedEffect(key1 = Unit) {
+            while (true) {
+                for (i in 1..100) {
+                    progress = i.toFloat() / 100F
+                    delay(50)
+                }
+                progress = 0.1F
+            }
+        }
+
+        CircularProgressIndicator(
+            progress = { progress },
+            modifier = Modifier
+                .size(50.dp),
+            color = colorResource(id = R.color.yellow_text),
+            strokeWidth = 5.dp,
+        )
+    }
+}

+ 2 - 3
app/src/main/java/com/fastest/pass/MainActivity.kt

@@ -1,13 +1,12 @@
-package com.fastest.pass
+package com.fastest.pass.di
 
 import android.app.AlertDialog
 import android.os.Bundle
-import android.util.Log
 import androidx.activity.enableEdgeToEdge
 import androidx.fragment.app.FragmentActivity
 import androidx.navigation.NavController
-import androidx.navigation.Navigation.findNavController
 import androidx.navigation.fragment.NavHostFragment
+import com.fastest.pass.R
 import dagger.hilt.android.AndroidEntryPoint
 
 @AndroidEntryPoint

+ 7 - 0
app/src/main/java/com/fastest/pass/di/UIState.kt

@@ -0,0 +1,7 @@
+package com.fastest.pass.di
+
+data class UIState<T>(
+    var isLoading:Boolean = false,
+    var response :T? = null,
+
+)

+ 8 - 0
app/src/main/java/com/fastest/pass/di/WebResponse.kt

@@ -0,0 +1,8 @@
+package com.fastest.pass.di
+
+data class WebResponse<T>(
+    val status: Boolean,
+    val message: String,
+    val data: T? = null
+)
+

+ 1 - 1
app/src/main/java/com/fastest/pass/forgotpassword/presentation/ui/ForgotPasswordFragment.kt

@@ -6,7 +6,7 @@ import android.view.View
 import android.view.ViewGroup
 import androidx.compose.ui.platform.ComposeView
 import androidx.fragment.app.viewModels
-import com.fastest.pass.BaseFragment
+import com.fastest.pass.di.BaseFragment
 import com.fastest.pass.forgotpassword.presentation.ui.components.ClickType
 import com.fastest.pass.forgotpassword.presentation.ui.components.ForgotPasswordScreen
 import com.fastest.pass.forgotpassword.presentation.viewmodels.ForgotPasswordViewmodel

+ 1 - 2
app/src/main/java/com/fastest/pass/forgotpassword/presentation/ui/ForgotPasswordVerifyFragment.kt

@@ -5,9 +5,8 @@ import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
 import androidx.compose.ui.platform.ComposeView
-import androidx.fragment.app.Fragment
 import androidx.fragment.app.viewModels
-import com.fastest.pass.BaseFragment
+import com.fastest.pass.di.BaseFragment
 import com.fastest.pass.forgotpassword.presentation.ui.components.ClickTypeForgotVerify
 import com.fastest.pass.forgotpassword.presentation.ui.components.ForgotPasswordVerifyScreen
 import com.fastest.pass.forgotpassword.presentation.viewmodels.ForgotPasswordVerifyViewModel

+ 1 - 8
app/src/main/java/com/fastest/pass/home/presentation/ui/fragment/AddNewItemsFragment.kt

@@ -1,34 +1,27 @@
 package com.fastest.pass.home.presentation.ui.fragment
 
 import android.os.Bundle
-import android.util.Log
 import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
-import android.widget.Toast
 import androidx.compose.foundation.background
 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
 import androidx.fragment.app.activityViewModels
-import androidx.fragment.app.viewModels
-import com.fastest.pass.BaseFragment
+import com.fastest.pass.di.BaseFragment
 import com.fastest.pass.R
 import com.fastest.pass.home.presentation.ui.components.AddNewItemsScreen
 import com.fastest.pass.home.presentation.ui.components.ClickTypeAddNewItem
 import com.fastest.pass.home.presentation.viewmodels.AddNewItemsViewModel
 import com.fastest.pass.home.utils.AddNewItemsNavigation
 import com.fastest.pass.home.utils.AddNewItemsRoute
-import com.fastest.pass.login.presentation.ui.components.LoginScreen
-import com.fastest.pass.security.presentation.ui.components.SecurityScreen
 import com.fastest.pass.ui.theme.FastestPassTheme
 import dagger.hilt.android.AndroidEntryPoint
-import kotlinx.coroutines.flow.collect
 import javax.inject.Inject
 
 @AndroidEntryPoint

+ 1 - 6
app/src/main/java/com/fastest/pass/home/presentation/ui/fragment/HomeFragment.kt

@@ -9,12 +9,11 @@ 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.material.Text
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.platform.ComposeView
 import androidx.compose.ui.res.colorResource
 import androidx.fragment.app.viewModels
-import com.fastest.pass.BaseFragment
+import com.fastest.pass.di.BaseFragment
 import com.fastest.pass.R
 import com.fastest.pass.home.presentation.ui.components.ClickType
 import com.fastest.pass.home.presentation.ui.components.HomeScreen
@@ -22,10 +21,6 @@ import com.fastest.pass.home.presentation.viewmodels.HomeViewModel
 import com.fastest.pass.home.utils.HomeNavigation
 import com.fastest.pass.home.utils.HomeRoute
 import com.fastest.pass.ui.theme.FastestPassTheme
-import com.fastest.pass.welcome.presentation.ui.component.ClickType.LOGIN_CLICK
-import com.fastest.pass.welcome.presentation.ui.component.ClickType.SIGNUP_CLICK
-import com.fastest.pass.welcome.presentation.ui.component.WelcomeTutorial
-import com.fastest.pass.welcome.utils.WelcomeNavigationRoute
 import dagger.hilt.android.AndroidEntryPoint
 import javax.inject.Inject
 

+ 1 - 3
app/src/main/java/com/fastest/pass/home/presentation/ui/fragment/NewItemFormFragment.kt

@@ -16,15 +16,13 @@ import androidx.compose.ui.platform.ComposeView
 import androidx.compose.ui.res.colorResource
 import androidx.fragment.app.activityViewModels
 import androidx.fragment.app.viewModels
-import androidx.lifecycle.ViewModelProvider
-import com.fastest.pass.BaseFragment
+import com.fastest.pass.di.BaseFragment
 import com.fastest.pass.R
 import com.fastest.pass.home.presentation.ui.components.ClickTypeAddNewItem
 import com.fastest.pass.home.presentation.ui.components.ClickTypeNewItemForm
 import com.fastest.pass.home.presentation.ui.components.NewItemFormScreen
 import com.fastest.pass.home.presentation.viewmodels.AddNewItemsViewModel
 import com.fastest.pass.home.presentation.viewmodels.NewItemFormViewModel
-import com.fastest.pass.home.utils.AddNewItemsRoute
 import com.fastest.pass.home.utils.NewItemFormNavigation
 import com.fastest.pass.home.utils.NewItemFormRoute
 import com.fastest.pass.ui.theme.FastestPassTheme

+ 1 - 2
app/src/main/java/com/fastest/pass/login/data/model/LoginResponse.kt

@@ -1,8 +1,7 @@
 package com.fastest.pass.login.data.model
 
-data class LoginResponse<T>(
+data class LoginResponse(
     val status: Boolean,
     val message: String,
-    val data: T? = null
 )
 

+ 2 - 1
app/src/main/java/com/fastest/pass/login/data/model/LoginResult.kt

@@ -1,3 +1,4 @@
+/*
 package com.fastest.pass.login.data.model
 
 sealed class LoginResult {
@@ -5,4 +6,4 @@ sealed class LoginResult {
     data object Loading : LoginResult()
     data class Success(val loginResponse: LoginResponse<Any>) : LoginResult()
     data class Error(val message: String) : LoginResult()
-}
+}*/

+ 3 - 5
app/src/main/java/com/fastest/pass/login/data/remote/LoginApiService.kt

@@ -1,16 +1,14 @@
 package com.fastest.pass.login.data.remote
 
+import com.fastest.pass.di.WebResponse
 import com.fastest.pass.login.data.model.LoginRequest
 import com.fastest.pass.login.data.model.LoginResponse
-import com.fastest.pass.login.data.model.LoginResult
-import retrofit2.Call
 import retrofit2.http.Body
-import retrofit2.http.FormUrlEncoded
 import retrofit2.http.POST
 
 interface LoginApiService {
 
-//    @FormUrlEncoded
+    //    @FormUrlEncoded
     @POST("login")
-    suspend fun login(@Body loginRequest: LoginRequest): LoginResponse<Any>
+    suspend fun login(@Body loginRequest: LoginRequest): WebResponse<LoginResponse>
 }

+ 4 - 16
app/src/main/java/com/fastest/pass/login/data/repository/LoginRepositoryImpl.kt

@@ -1,9 +1,8 @@
 package com.fastest.pass.login.data.repository
 
-import android.util.Log
+import com.fastest.pass.di.WebResponse
 import com.fastest.pass.login.data.model.LoginRequest
 import com.fastest.pass.login.data.model.LoginResponse
-import com.fastest.pass.login.data.model.LoginResult
 import com.fastest.pass.login.data.remote.LoginApiService
 import com.fastest.pass.login.domain.repository.LoginRepository
 import javax.inject.Inject
@@ -11,20 +10,9 @@ import javax.inject.Inject
 class LoginRepositoryImpl @Inject constructor(
     private val loginApiService: LoginApiService
 ) : LoginRepository {
-    override suspend fun loginRepository(email: String, password: String) : Pair<LoginResult, LoginResponse<Any>> {
-        Log.d("test_api_login", "loginRepository() , LoginRepositoryImpl")
-         return try {
-            Log.d("test_api_login", "loginResponse = ?")
-            val loginResponse = loginApiService.login(LoginRequest(email, password))
-            Log.d("test_api_login", "loginResponse = = ${loginResponse.message}")
-            if (loginResponse.status) {
-                Pair(LoginResult.Success(loginResponse), loginResponse)
-            } else {
-                Pair(LoginResult.Error(loginResponse.message), loginResponse)
-            }
-        } catch (e: Exception) {
-            Pair(LoginResult.Error(e.message ?: "Error"), LoginResponse(false, e.message ?: "Error"))
-        }
+
+    override suspend fun loginRepository(loginRequest: LoginRequest): WebResponse<LoginResponse> {
+        return loginApiService.login(loginRequest)
     }
 
 }

+ 5 - 14
app/src/main/java/com/fastest/pass/login/di/LoginModule.kt

@@ -4,6 +4,7 @@ import android.util.Log
 import com.fastest.pass.login.data.remote.LoginApiService
 import com.fastest.pass.login.data.repository.LoginRepositoryImpl
 import com.fastest.pass.login.domain.repository.LoginRepository
+import com.fastest.pass.login.domain.usecase.LoginUseCase
 import com.fastest.pass.login.utils.LoginNavigation
 import dagger.Module
 import dagger.Provides
@@ -28,20 +29,8 @@ object LoginModule {
 
     @Provides
     @Singleton
-    fun provideLoginApiService(): LoginApiService {
-        Log.d("test_api_login", "provideLoginApiService() , LoginModule")
-
-        val httpClient: OkHttpClient.Builder = OkHttpClient.Builder()
-        httpClient.connectTimeout(120, TimeUnit.SECONDS)
-        httpClient.readTimeout(120, TimeUnit.SECONDS)
-
-        val logging = HttpLoggingInterceptor()
-
-        return Retrofit.Builder()
-            .baseUrl("https://api.fastestpass.com/v1/")
-            .addConverterFactory(GsonConverterFactory.create())
-            .build()
-            .create(LoginApiService::class.java)
+    fun provideLoginApiService(retrofit: Retrofit): LoginApiService {
+        return retrofit.create(LoginApiService::class.java)
     }
 
     @Provides
@@ -50,4 +39,6 @@ object LoginModule {
         Log.d("test_api_login", "provideLoginRepository() , LoginModule")
         return LoginRepositoryImpl(loginApiService)
     }
+
+
 }

+ 3 - 2
app/src/main/java/com/fastest/pass/login/domain/repository/LoginRepository.kt

@@ -1,8 +1,9 @@
 package com.fastest.pass.login.domain.repository
 
+import com.fastest.pass.di.WebResponse
+import com.fastest.pass.login.data.model.LoginRequest
 import com.fastest.pass.login.data.model.LoginResponse
-import com.fastest.pass.login.data.model.LoginResult
 
 interface LoginRepository {
-    suspend fun loginRepository(email: String, password: String) : Pair<LoginResult, LoginResponse<Any>>
+    suspend fun loginRepository(loginRequest: LoginRequest): WebResponse<LoginResponse>
 }

+ 6 - 4
app/src/main/java/com/fastest/pass/login/domain/usecase/LoginUseCase.kt

@@ -1,16 +1,18 @@
 package com.fastest.pass.login.domain.usecase
 
 import android.util.Log
+import com.fastest.pass.di.BaseUseCase
+import com.fastest.pass.di.WebResponse
+import com.fastest.pass.login.data.model.LoginRequest
 import com.fastest.pass.login.data.model.LoginResponse
-import com.fastest.pass.login.data.model.LoginResult
 import com.fastest.pass.login.domain.repository.LoginRepository
 import javax.inject.Inject
 
 class LoginUseCase @Inject constructor(
     private val loginRepository: LoginRepository
-) {
-    suspend operator fun invoke(email: String, password: String) : Pair<LoginResult, LoginResponse<Any>> {
+): BaseUseCase<LoginRequest, WebResponse<LoginResponse>>()  {
+    override suspend fun execute(params: LoginRequest): WebResponse<LoginResponse> {
         Log.d("test_api_login", "invoke() , LoginUseCase")
-        return loginRepository.loginRepository(email, password)
+        return loginRepository.loginRepository(params)
     }
 }

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

@@ -14,10 +14,10 @@ import androidx.compose.runtime.collectAsState
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.platform.ComposeView
 import androidx.compose.ui.res.colorResource
-import androidx.fragment.app.Fragment
 import androidx.fragment.app.viewModels
-import com.fastest.pass.BaseFragment
+import com.fastest.pass.di.BaseFragment
 import com.fastest.pass.R
+import com.fastest.pass.di.GenericLoader
 import com.fastest.pass.login.presentation.ui.components.ClickType
 import com.fastest.pass.login.presentation.ui.components.LoginScreen
 import com.fastest.pass.login.presentation.viewmodels.LoginViewModel
@@ -56,14 +56,15 @@ class LoginFragment : BaseFragment() {
                                 .background(colorResource(id = R.color.white))
                                 .padding(paddingValues.calculateBottomPadding())
                         ) {
-                            val loader = viewmodel.loader.collectAsState()
-                            val loginResponse = viewmodel.loginResponse.collectAsState()
 
-                            if (loginResponse.value.status) {
+                            val loginResponse = viewmodel.loginResponse.value
+
+
+                            loginResponse.response?.data?.let {
                                 viewmodel.navigateTo(LoginRoute.OpenDashBoardScreen)
                             }
 
-                            LoginScreen(loader.value, clickType = { clickType ->
+                            LoginScreen(clickType = { clickType ->
                                 when (clickType) {
                                     ClickType.SIGNUP_CLICK -> {
                                         viewmodel.navigateTo(LoginRoute.OpenSignUp)
@@ -82,12 +83,15 @@ class LoginFragment : BaseFragment() {
                                     }
                                     ClickType.LOGIN_CLICK -> {
                                         Log.d("test_api_login", "LOGIN_CLICK => LoginFragment")
-                                        viewmodel.onLoginClicked("eng.asix@gmail.com", "password")
+                                        viewmodel.login("eng.asix@gmail.com", "password")
                                     }
                                 }
                             }, onLoginClickCredentials = { email , password ->
-                                viewmodel.onLoginClicked(email, password)
+                                viewmodel.login(email, password)
                             })
+
+                            GenericLoader(loginResponse.isLoading)
+
                         }
                     }
                 }

+ 3 - 6
app/src/main/java/com/fastest/pass/login/presentation/ui/components/LoginScreen.kt

@@ -80,7 +80,6 @@ enum class ClickType {
 
 @Composable
 fun LoginScreen(
-    loader: Boolean,
     clickType: (ClickType) -> Unit,
     onLoginClickCredentials: (String, String) -> Unit
 ) {
@@ -90,12 +89,10 @@ fun LoginScreen(
     var passwordLogin by remember { mutableStateOf("") }
     val snackBarStateRed = remember { SnackbarHostState() }
 
-    Log.d("loginResult", "loader = $loader")
-
     Box(
         modifier = Modifier
             .background(colorResource(id = R.color.blue_login))
-            .alpha(if (loader) 0.7f else 1f)
+            .alpha(1f)
             .fillMaxSize()
             .statusBarsPadding()
             .pointerInput(Unit) {
@@ -158,7 +155,7 @@ fun LoginScreen(
             }
         }
 
-        if (loader) {
+       /* if (loader) {
             var progress by remember { mutableFloatStateOf(0.1F) }
 
             LaunchedEffect(key1 = Unit) {
@@ -179,7 +176,7 @@ fun LoginScreen(
                 color = colorResource(id = R.color.yellow_text),
                 strokeWidth = 5.dp,
             )
-        }
+        }*/
 
     }
 }

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

@@ -1,17 +1,21 @@
 package com.fastest.pass.login.presentation.viewmodels
 
 import android.util.Log
+import androidx.compose.runtime.State
+import androidx.compose.runtime.mutableStateOf
 import androidx.lifecycle.ViewModel
 import androidx.lifecycle.viewModelScope
+import com.fastest.pass.di.UIState
+import com.fastest.pass.di.WebResponse
+import com.fastest.pass.login.data.model.LoginRequest
 import com.fastest.pass.login.data.model.LoginResponse
-import com.fastest.pass.login.data.model.LoginResult
 import com.fastest.pass.login.domain.usecase.LoginUseCase
 import com.fastest.pass.login.utils.LoginRoute
 import dagger.hilt.android.lifecycle.HiltViewModel
 import kotlinx.coroutines.flow.MutableStateFlow
 import kotlinx.coroutines.launch
 import javax.inject.Inject
-
+import com.fastest.pass.di.Result
 @HiltViewModel
 class LoginViewModel @Inject constructor(
     private val loginUseCase: LoginUseCase
@@ -20,8 +24,14 @@ class LoginViewModel @Inject constructor(
     private val _router = MutableStateFlow<LoginRoute>(LoginRoute.OpenNoneScreen)
     val router: MutableStateFlow<LoginRoute> = _router
 
-    private val _loginResponse = MutableStateFlow<LoginResponse<Any>>(LoginResponse(false, ""))
-    val loginResponse: MutableStateFlow<LoginResponse<Any>> = _loginResponse
+  /*  private val _loginResponse = MutableStateFlow<LoginResponse<Any>>(LoginResponse(false, ""))
+    val loginResponse: MutableStateFlow<LoginResponse<Any>> = _loginResponse*/
+
+    private var _loginResponse =
+        mutableStateOf(UIState<WebResponse<LoginResponse>>())
+    val loginResponse: State<UIState<WebResponse<LoginResponse>>> =
+        _loginResponse
+
 
     private val _loader = MutableStateFlow<Boolean>(false)
     val loader: MutableStateFlow<Boolean> = _loader
@@ -30,7 +40,28 @@ class LoginViewModel @Inject constructor(
         _router.value = loginRoute
     }
 
-    fun onLoginClicked(email: String, password: String) {
+    fun login(email: String, password: String) {
+        viewModelScope.launch {
+            val request = LoginRequest(email, password)
+            loginUseCase(request) { result ->
+                when (result) {
+                    is Result.Loading -> {
+                        _loginResponse.value = UIState(true)
+                    }
+
+                    is Result.Success -> {
+                        _loginResponse.value = UIState(true,result.data)
+                    }
+
+                    is Result.Failure -> {
+
+                    }
+                }
+            }
+        }
+    }
+
+   /* fun onLoginClicked(email: String, password: String) {
         viewModelScope.launch {
             _loader.value = true
             Log.d("test_api_login", "onLoginClicked => LoginViewModel")
@@ -42,5 +73,5 @@ class LoginViewModel @Inject constructor(
             }
             Log.d("loginResult", "loginResult = ${loginResult.second.message}")
         }
-    }
+    }*/
 }

+ 1 - 2
app/src/main/java/com/fastest/pass/masterlogin/presentation/ui/MasterLoginFragment.kt

@@ -5,9 +5,8 @@ import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
 import androidx.compose.ui.platform.ComposeView
-import androidx.fragment.app.Fragment
 import androidx.fragment.app.viewModels
-import com.fastest.pass.BaseFragment
+import com.fastest.pass.di.BaseFragment
 import com.fastest.pass.masterlogin.presentation.ui.components.ClickType
 import com.fastest.pass.masterlogin.presentation.ui.components.MasterLoginScreen
 import com.fastest.pass.masterlogin.presentation.viewmodels.MasterLoginViewModel

+ 1 - 2
app/src/main/java/com/fastest/pass/mastersignup/presentation/ui/MasterSignUpFragment.kt

@@ -5,9 +5,8 @@ import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
 import androidx.compose.ui.platform.ComposeView
-import androidx.fragment.app.Fragment
 import androidx.fragment.app.viewModels
-import com.fastest.pass.BaseFragment
+import com.fastest.pass.di.BaseFragment
 import com.fastest.pass.mastersignup.presentation.ui.components.ClickType
 import com.fastest.pass.mastersignup.presentation.ui.components.MasterSignUpScreen
 import com.fastest.pass.mastersignup.presentation.viewmodels.MasterSignUpViewModel

+ 1 - 1
app/src/main/java/com/fastest/pass/security/presentation/ui/fragment/SecurityFragment.kt

@@ -12,7 +12,7 @@ import androidx.compose.material.Scaffold
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.platform.ComposeView
 import androidx.compose.ui.res.colorResource
-import com.fastest.pass.BaseFragment
+import com.fastest.pass.di.BaseFragment
 import com.fastest.pass.R
 import com.fastest.pass.security.presentation.ui.components.SecurityScreen
 import com.fastest.pass.ui.theme.FastestPassTheme

+ 1 - 2
app/src/main/java/com/fastest/pass/signup/presentation/ui/SignUpFragment.kt

@@ -5,9 +5,8 @@ import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
 import androidx.compose.ui.platform.ComposeView
-import androidx.fragment.app.Fragment
 import androidx.fragment.app.viewModels
-import com.fastest.pass.BaseFragment
+import com.fastest.pass.di.BaseFragment
 import com.fastest.pass.signup.presentation.ui.components.ClickType
 import com.fastest.pass.signup.presentation.ui.components.SignUpScreen
 import com.fastest.pass.signup.presentation.viewmodels.SignUpViewModel

+ 0 - 12
app/src/main/java/com/fastest/pass/splash/data/remote/SplashApiService.kt

@@ -1,12 +0,0 @@
-package com.fastest.pass.splash.data.remote
-
-import retrofit2.Call
-import retrofit2.http.FormUrlEncoded
-import retrofit2.http.GET
-
-interface SplashApiService {
-
-    @FormUrlEncoded
-    @GET("splash")
-    suspend fun splash(): Call<Any?>
-}

+ 0 - 12
app/src/main/java/com/fastest/pass/splash/data/repository/SplashRepositoryImpl.kt

@@ -1,12 +0,0 @@
-package com.fastest.pass.splash.data.repository
-
-import com.fastest.pass.splash.data.remote.SplashApiService
-import com.fastest.pass.splash.domain.repository.SplashRepository
-
-class SplashRepositoryImpl(
-    private val splashApiService: SplashApiService
-): SplashRepository {
-    override suspend fun splashRepository(){
-
-    }
-}

+ 0 - 5
app/src/main/java/com/fastest/pass/splash/domain/repository/SplashRepository.kt

@@ -1,5 +0,0 @@
-package com.fastest.pass.splash.domain.repository
-
-interface SplashRepository {
-    suspend fun splashRepository()
-}

+ 0 - 9
app/src/main/java/com/fastest/pass/splash/domain/usecase/SplashUseCase.kt

@@ -1,9 +0,0 @@
-package com.fastest.pass.splash.domain.usecase
-
-import com.fastest.pass.splash.domain.repository.SplashRepository
-import javax.inject.Inject
-
-class SplashUseCase @Inject constructor(
-    private val splashRepository: SplashRepository
-) {
-}

+ 1 - 3
app/src/main/java/com/fastest/pass/splash/presentation/ui/SplashFragment.kt

@@ -5,14 +5,12 @@ import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
 import androidx.compose.ui.platform.ComposeView
-import androidx.fragment.app.Fragment
 import com.fastest.pass.splash.presentation.ui.components.SplashScreen
 import com.fastest.pass.splash.presentation.viewmodels.SplashViewModel
 import dagger.hilt.android.AndroidEntryPoint
 import androidx.fragment.app.viewModels
-import com.fastest.pass.BaseFragment
+import com.fastest.pass.di.BaseFragment
 import com.fastest.pass.splash.utils.SplashNavigation
-import com.fastest.pass.splash.utils.SplashRoute
 import com.fastest.pass.ui.theme.FastestPassTheme
 import javax.inject.Inject
 

+ 1 - 2
app/src/main/java/com/fastest/pass/splash/presentation/viewmodels/SplashViewModel.kt

@@ -4,7 +4,6 @@ import androidx.lifecycle.LiveData
 import androidx.lifecycle.MutableLiveData
 import androidx.lifecycle.ViewModel
 import androidx.lifecycle.viewModelScope
-import com.fastest.pass.splash.domain.usecase.SplashUseCase
 import com.fastest.pass.splash.utils.SplashRoute
 import dagger.hilt.android.lifecycle.HiltViewModel
 import kotlinx.coroutines.delay
@@ -13,7 +12,7 @@ import kotlinx.coroutines.launch
 import javax.inject.Inject
 
 @HiltViewModel
-class SplashViewModel @Inject constructor(var splashUseCase: SplashUseCase) : ViewModel() {
+class SplashViewModel @Inject constructor() : ViewModel() {
 
     private val _navigateToLogin = MutableLiveData<Boolean>(false)
     val navigateToLogin: LiveData<Boolean> = _navigateToLogin

+ 1 - 1
app/src/main/java/com/fastest/pass/welcome/presentation/ui/fragment/WelcomeFragment.kt

@@ -13,7 +13,7 @@ import androidx.compose.ui.Modifier
 import androidx.compose.ui.platform.ComposeView
 import androidx.compose.ui.res.colorResource
 import androidx.fragment.app.viewModels
-import com.fastest.pass.BaseFragment
+import com.fastest.pass.di.BaseFragment
 import com.fastest.pass.R
 import com.fastest.pass.ui.theme.FastestPassTheme
 import com.fastest.pass.welcome.presentation.ui.component.ClickType.LOGIN_CLICK