|
@@ -20,6 +20,8 @@ import com.fastest.pass.account.presentation.ui.components.ClickType
|
|
import com.fastest.pass.account.presentation.viewmodels.AccountViewModel
|
|
import com.fastest.pass.account.presentation.viewmodels.AccountViewModel
|
|
import com.fastest.pass.account.utils.AccountNavigation
|
|
import com.fastest.pass.account.utils.AccountNavigation
|
|
import com.fastest.pass.account.utils.AccountRoute
|
|
import com.fastest.pass.account.utils.AccountRoute
|
|
|
|
+import com.fastest.pass.app.GenericLoader
|
|
|
|
+import com.fastest.pass.helpers.BasePreferenceHelper
|
|
import com.fastest.pass.ui.theme.FastestPassTheme
|
|
import com.fastest.pass.ui.theme.FastestPassTheme
|
|
import dagger.hilt.android.AndroidEntryPoint
|
|
import dagger.hilt.android.AndroidEntryPoint
|
|
import javax.inject.Inject
|
|
import javax.inject.Inject
|
|
@@ -31,6 +33,8 @@ class AccountFragment : BaseFragment() {
|
|
|
|
|
|
@Inject
|
|
@Inject
|
|
lateinit var navigation: AccountNavigation
|
|
lateinit var navigation: AccountNavigation
|
|
|
|
+ @Inject
|
|
|
|
+ lateinit var basePreferenceHelper: BasePreferenceHelper
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
super.onCreate(savedInstanceState)
|
|
@@ -53,13 +57,26 @@ class AccountFragment : BaseFragment() {
|
|
.background(colorResource(id = R.color.home_background_color))
|
|
.background(colorResource(id = R.color.home_background_color))
|
|
.padding(paddingValues.calculateBottomPadding())
|
|
.padding(paddingValues.calculateBottomPadding())
|
|
) {
|
|
) {
|
|
|
|
+ val logoutResponse = viewmodel.logoutResponse.value
|
|
|
|
+
|
|
|
|
+ if (logoutResponse.response?.status == true) {
|
|
|
|
+ basePreferenceHelper.setLoggedInState(false)
|
|
|
|
+ basePreferenceHelper.clearAllData()
|
|
|
|
+ viewmodel.navigateTo(AccountRoute.OpenLoginScreen)
|
|
|
|
+ }
|
|
|
|
+
|
|
AccountScreen { clickType ->
|
|
AccountScreen { clickType ->
|
|
when (clickType) {
|
|
when (clickType) {
|
|
ClickType.OPEN_LOGIN_SCREEN -> {
|
|
ClickType.OPEN_LOGIN_SCREEN -> {
|
|
viewmodel.navigateTo(AccountRoute.OpenLoginScreen)
|
|
viewmodel.navigateTo(AccountRoute.OpenLoginScreen)
|
|
}
|
|
}
|
|
|
|
+ ClickType.LOGOUT_API -> {
|
|
|
|
+ viewmodel.logout()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ GenericLoader(loader = logoutResponse.isLoading)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|