mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-24 02:15:46 +03:00
typing the use case selections and binding the label and usecase type at the same time for visibility
This commit is contained in:
parent
878371cd9a
commit
c29dc89756
3 changed files with 24 additions and 13 deletions
|
@ -31,7 +31,15 @@ sealed class OnboardingAction : VectorViewModelAction {
|
||||||
|
|
||||||
data class UpdateServerType(val serverType: ServerType) : OnboardingAction()
|
data class UpdateServerType(val serverType: ServerType) : OnboardingAction()
|
||||||
data class UpdateHomeServer(val homeServerUrl: String) : OnboardingAction()
|
data class UpdateHomeServer(val homeServerUrl: String) : OnboardingAction()
|
||||||
data class UpdateUseCase(val todo: String) : OnboardingAction()
|
data class UpdateUseCase(val useCase: UseCase) : OnboardingAction() {
|
||||||
|
enum class UseCase {
|
||||||
|
FRIENDS_FAMILY,
|
||||||
|
TEAMS,
|
||||||
|
COMMUNITIES,
|
||||||
|
SKIP
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data class UpdateSignMode(val signMode: SignMode) : OnboardingAction()
|
data class UpdateSignMode(val signMode: SignMode) : OnboardingAction()
|
||||||
data class LoginWithToken(val loginToken: String) : OnboardingAction()
|
data class LoginWithToken(val loginToken: String) : OnboardingAction()
|
||||||
data class WebLoginSuccess(val credentials: Credentials) : OnboardingAction()
|
data class WebLoginSuccess(val credentials: Credentials) : OnboardingAction()
|
||||||
|
|
|
@ -459,7 +459,7 @@ class OnboardingViewModel @AssistedInject constructor(
|
||||||
|
|
||||||
private fun handleUpdateUseCase(action: OnboardingAction.UpdateUseCase) {
|
private fun handleUpdateUseCase(action: OnboardingAction.UpdateUseCase) {
|
||||||
// TODO act on the use case selection
|
// TODO act on the use case selection
|
||||||
action.todo
|
action.useCase
|
||||||
_viewEvents.post(OnboardingViewEvents.OpenServerSelection)
|
_viewEvents.post(OnboardingViewEvents.OpenServerSelection)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,14 @@ import android.os.Bundle
|
||||||
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 android.widget.TextView
|
||||||
|
import androidx.annotation.StringRes
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.extensions.setTextWithColoredPart
|
import im.vector.app.core.extensions.setTextWithColoredPart
|
||||||
import im.vector.app.databinding.FragmentFtueAuthUseCaseBinding
|
import im.vector.app.databinding.FragmentFtueAuthUseCaseBinding
|
||||||
import im.vector.app.features.login.ServerType
|
import im.vector.app.features.login.ServerType
|
||||||
import im.vector.app.features.onboarding.OnboardingAction
|
import im.vector.app.features.onboarding.OnboardingAction
|
||||||
import me.saket.bettermovementmethod.BetterLinkMovementMethod
|
import im.vector.app.features.onboarding.OnboardingAction.UpdateUseCase.UseCase
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class FtueAuthUseCaseFragment @Inject constructor() : AbstractFtueAuthFragment<FragmentFtueAuthUseCaseBinding>() {
|
class FtueAuthUseCaseFragment @Inject constructor() : AbstractFtueAuthFragment<FragmentFtueAuthUseCaseBinding>() {
|
||||||
|
@ -40,15 +42,9 @@ class FtueAuthUseCaseFragment @Inject constructor() : AbstractFtueAuthFragment<F
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupViews() {
|
private fun setupViews() {
|
||||||
views.useCaseOptionOne.debouncedClicks {
|
views.useCaseOptionOne.setUseCase(R.string.ftue_auth_use_case_option_one, UseCase.FRIENDS_FAMILY)
|
||||||
viewModel.handle(OnboardingAction.UpdateUseCase("todo"))
|
views.useCaseOptionTwo.setUseCase(R.string.ftue_auth_use_case_option_two, UseCase.TEAMS)
|
||||||
}
|
views.useCaseOptionThree.setUseCase(R.string.ftue_auth_use_case_option_three, UseCase.COMMUNITIES)
|
||||||
views.useCaseOptionTwo.debouncedClicks {
|
|
||||||
viewModel.handle(OnboardingAction.UpdateUseCase("todo"))
|
|
||||||
}
|
|
||||||
views.useCaseOptionThree.debouncedClicks {
|
|
||||||
viewModel.handle(OnboardingAction.UpdateUseCase("todo"))
|
|
||||||
}
|
|
||||||
|
|
||||||
val partial = getString(R.string.ftue_auth_use_case_skip_partial)
|
val partial = getString(R.string.ftue_auth_use_case_skip_partial)
|
||||||
views.useCaseSkip.setTextWithColoredPart(
|
views.useCaseSkip.setTextWithColoredPart(
|
||||||
|
@ -56,7 +52,7 @@ class FtueAuthUseCaseFragment @Inject constructor() : AbstractFtueAuthFragment<F
|
||||||
partial,
|
partial,
|
||||||
underline = false,
|
underline = false,
|
||||||
colorAttribute = R.attr.colorAccent,
|
colorAttribute = R.attr.colorAccent,
|
||||||
onClick = { viewModel.handle(OnboardingAction.UpdateUseCase("todo")) }
|
onClick = { viewModel.handle(OnboardingAction.UpdateUseCase(UseCase.SKIP)) }
|
||||||
)
|
)
|
||||||
|
|
||||||
views.useCaseConnectToServer.setOnClickListener {
|
views.useCaseConnectToServer.setOnClickListener {
|
||||||
|
@ -67,4 +63,11 @@ class FtueAuthUseCaseFragment @Inject constructor() : AbstractFtueAuthFragment<F
|
||||||
override fun resetViewModel() {
|
override fun resetViewModel() {
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun TextView.setUseCase(@StringRes label: Int, useCase: UseCase) {
|
||||||
|
setText(label)
|
||||||
|
debouncedClicks {
|
||||||
|
viewModel.handle(OnboardingAction.UpdateUseCase(useCase))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue