|
@@ -5,8 +5,15 @@ import android.util.Log
|
|
import android.view.LayoutInflater
|
|
import android.view.LayoutInflater
|
|
import android.view.View
|
|
import android.view.View
|
|
import android.view.ViewGroup
|
|
import android.view.ViewGroup
|
|
|
|
+import androidx.compose.material3.SnackbarHostState
|
|
|
|
+import androidx.compose.runtime.LaunchedEffect
|
|
|
|
+import androidx.compose.runtime.remember
|
|
|
|
+import androidx.compose.runtime.rememberCoroutineScope
|
|
import androidx.compose.ui.platform.ComposeView
|
|
import androidx.compose.ui.platform.ComposeView
|
|
|
|
+import androidx.compose.ui.platform.LocalContext
|
|
|
|
+import androidx.compose.ui.unit.dp
|
|
import androidx.fragment.app.viewModels
|
|
import androidx.fragment.app.viewModels
|
|
|
|
+import com.fastest.pass.R
|
|
import com.fastest.pass.app.BaseFragment
|
|
import com.fastest.pass.app.BaseFragment
|
|
import com.fastest.pass.app.GenericLoader
|
|
import com.fastest.pass.app.GenericLoader
|
|
import com.fastest.pass.forgotpassword.presentation.ui.components.ClickType
|
|
import com.fastest.pass.forgotpassword.presentation.ui.components.ClickType
|
|
@@ -15,7 +22,9 @@ import com.fastest.pass.forgotpassword.presentation.viewmodels.ForgotPasswordVie
|
|
import com.fastest.pass.forgotpassword.utils.ForgotPasswordNavigation
|
|
import com.fastest.pass.forgotpassword.utils.ForgotPasswordNavigation
|
|
import com.fastest.pass.forgotpassword.utils.ForgotPasswordRoute
|
|
import com.fastest.pass.forgotpassword.utils.ForgotPasswordRoute
|
|
import com.fastest.pass.ui.theme.FastestPassTheme
|
|
import com.fastest.pass.ui.theme.FastestPassTheme
|
|
|
|
+import com.fastest.pass.views.ShowCustomSnackBar
|
|
import dagger.hilt.android.AndroidEntryPoint
|
|
import dagger.hilt.android.AndroidEntryPoint
|
|
|
|
+import kotlinx.coroutines.launch
|
|
import javax.inject.Inject
|
|
import javax.inject.Inject
|
|
|
|
|
|
@AndroidEntryPoint
|
|
@AndroidEntryPoint
|
|
@@ -39,8 +48,30 @@ class ForgotPasswordFragment : BaseFragment() {
|
|
return ComposeView(requireActivity()).apply {
|
|
return ComposeView(requireActivity()).apply {
|
|
setContent {
|
|
setContent {
|
|
FastestPassTheme {
|
|
FastestPassTheme {
|
|
|
|
+ val coroutineScope = rememberCoroutineScope()
|
|
|
|
+ val snackBarState = remember { SnackbarHostState() }
|
|
|
|
+ val snackBarStateRed = remember { SnackbarHostState() }
|
|
val forgotPasswordResponse = viewmodel.forgotPasswordResponse.value
|
|
val forgotPasswordResponse = viewmodel.forgotPasswordResponse.value
|
|
- Log.d("forgotPasswordResponse", "forgotPasswordResponse = ${forgotPasswordResponse.response?.message}")
|
|
|
|
|
|
+ val message = forgotPasswordResponse.response?.message
|
|
|
|
+
|
|
|
|
+ Log.d(
|
|
|
|
+ "forgotPasswordResponse",
|
|
|
|
+ "forgotPasswordResponse = ${forgotPasswordResponse.response?.message}"
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ LaunchedEffect(key1 = forgotPasswordResponse.response?.status) {
|
|
|
|
+ coroutineScope.launch {
|
|
|
|
+ message?.let {
|
|
|
|
+ if (forgotPasswordResponse.response?.status == true) {
|
|
|
|
+ snackBarState.showSnackbar(it)
|
|
|
|
+ viewmodel.navigateTo(ForgotPasswordRoute.GoBackToLogin)
|
|
|
|
+ } else if (forgotPasswordResponse.response?.status == false) {
|
|
|
|
+ snackBarStateRed.showSnackbar(it)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
ForgotPasswordScreen(
|
|
ForgotPasswordScreen(
|
|
clickType = { clickType ->
|
|
clickType = { clickType ->
|
|
@@ -48,9 +79,11 @@ class ForgotPasswordFragment : BaseFragment() {
|
|
ClickType.GO_BACK -> {
|
|
ClickType.GO_BACK -> {
|
|
viewmodel.navigateTo(ForgotPasswordRoute.GoBackToLogin)
|
|
viewmodel.navigateTo(ForgotPasswordRoute.GoBackToLogin)
|
|
}
|
|
}
|
|
|
|
+
|
|
ClickType.OPEN_FORGOT_VERIFY -> {
|
|
ClickType.OPEN_FORGOT_VERIFY -> {
|
|
viewmodel.navigateTo(ForgotPasswordRoute.OpenForgotVerifyScreen)
|
|
viewmodel.navigateTo(ForgotPasswordRoute.OpenForgotVerifyScreen)
|
|
}
|
|
}
|
|
|
|
+
|
|
ClickType.FORGOT_API -> {}
|
|
ClickType.FORGOT_API -> {}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -59,10 +92,12 @@ class ForgotPasswordFragment : BaseFragment() {
|
|
viewmodel.forgotPassword(email)
|
|
viewmodel.forgotPassword(email)
|
|
}
|
|
}
|
|
)
|
|
)
|
|
-
|
|
|
|
|
|
+ ShowCustomSnackBar(snackBarState, R.color.green_text, R.color.white)
|
|
|
|
+ ShowCustomSnackBar(snackBarStateRed, R.color.red_login_button, R.color.white)
|
|
GenericLoader(loader = forgotPasswordResponse.isLoading)
|
|
GenericLoader(loader = forgotPasswordResponse.isLoading)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|
|
|
|
+
|