Issue related to animations on home theme 1 fragment

Scaling animation on press of view
Hindi texts for sidebar

Differentiating side bar between signed in and guest user

logout api integration
guest api integration on login page

completed flow of login and logout from inside screens
This commit is contained in:
2024-05-28 20:57:12 +05:30
parent de09dd3406
commit 31964a64dc
38 changed files with 401 additions and 68 deletions

View File

@@ -12,6 +12,12 @@ import com.woka.utils.WokaBaseActivity
class OnboardActivity : WokaBaseActivity() {
companion object {
const val ONBOARD_ACTIVITY_INTENT = "onboard_act_intent"
const val LOG_IN_INTENT = "login_intent"
}
private var player: MediaPlayer? = null
override fun onCreate(savedInstanceState: Bundle?) {
@@ -24,12 +30,17 @@ class OnboardActivity : WokaBaseActivity() {
insets
}
// val hostFragment = supportFragmentManager.findFragmentById(R.id.fc_onboard) as NavHostFragment
// hostFragment.navController.navigate(R.id.action_onboardFragment_to_signInFragment,
// null,
// NavOptions.Builder()
// .setPopUpTo(R.id.onboardFragment, true)
// .build())
if (intent.getStringExtra(ONBOARD_ACTIVITY_INTENT) == LOG_IN_INTENT) {
val hostFragment =
supportFragmentManager.findFragmentById(R.id.fc_onboard) as NavHostFragment
hostFragment.navController.navigate(
R.id.action_onboardFragment_to_signInFragment,
null,
NavOptions.Builder()
.setPopUpTo(R.id.onboardFragment, true)
.build()
)
}
player = MediaPlayer.create(this, R.raw.audiotwo)
player?.isLooping = true

View File

@@ -143,6 +143,8 @@ class SelectAvatarFragment : Fragment() {
userPrefs?.accessToken = result.remember_token?:"no_token_received"
userPrefs?.userType = UserType.createUserType(result.user_type)
userPrefs?.loadUserData()
startActivity(Intent(activity, HomeActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
})

View File

@@ -109,8 +109,44 @@ class SignInFragment : Fragment() {
}
is ApiResult.Success -> {
progressView.hide()
toast(it.message)
gotoHomeActivity()
it.data?.result?.let {data->
toast(it.message)
// saving to user prefs
userPrefs?.accessToken = data.remember_token?:"no_value_received"
userPrefs?.userType = UserType.createUserType(data.user_type)
gotoHomeActivity()
}
}
null -> {}
}
}
viewModel.guestLogin.observe(viewLifecycleOwner){
when (it){
is ApiResult.Error -> {
progressView.hide()
toast(it.errorMessage)
}
is ApiResult.Loading -> {
progressView.show()
}
is ApiResult.Success -> {
progressView.hide()
it.data?.let {data ->
toast(it.message)
userPrefs?.userType = UserType.GUEST
userPrefs?.guestUserName = data.fullname
activity?.let { activity->
startActivity(Intent(activity, HomeActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
})
activity.finish()
}
}
}
null -> {}
}
@@ -120,6 +156,7 @@ class SignInFragment : Fragment() {
override fun onDestroyView() {
super.onDestroyView()
viewModel.clearLoginLiveData()
viewModel.clearGuestLoginData()
}
private fun clickEvents() {
@@ -135,6 +172,18 @@ class SignInFragment : Fragment() {
activity?.onBackPressedDispatcher?.onBackPressed()
}
continueAsGuest.setOnClickListener {
if (userPrefs?.guestUserName == null){
// no guest available
viewModel.guestLogin()
}else{
startActivity(Intent(activity, HomeActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
})
activity?.finish()
}
}
createAccount.setOnClickListener {
findNavController().navigate(R.id.action_signInFragment_to_age_select_fragment)
}
@@ -158,6 +207,9 @@ class SignInFragment : Fragment() {
}
private fun gotoHomeActivity(){
userPrefs?.loadUserData()
activity?.let { activity->
startActivity(Intent(activity, HomeActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)

View File

@@ -30,7 +30,7 @@ import kotlinx.coroutines.launch
/*
Root fragment to the launcher activity i.e. WelcomeActivity
*/
class SplashFragment : Fragment(), Observer<ApiResult<UserDataResponse>> {
class SplashFragment : Fragment(), Observer<ApiResult<UserDataResponse>?> {
private lateinit var binding: FragmentSplashBinding
@@ -113,7 +113,7 @@ class SplashFragment : Fragment(), Observer<ApiResult<UserDataResponse>> {
}
}
override fun onChanged(value: ApiResult<UserDataResponse>) {
override fun onChanged(value: ApiResult<UserDataResponse>?) {
// on user data loaded
when (value){
is ApiResult.Error -> {
@@ -123,6 +123,8 @@ class SplashFragment : Fragment(), Observer<ApiResult<UserDataResponse>> {
is ApiResult.Success -> {
goForward()
}
null -> {}
}
}
}