extracting usecase enum to its own file
This commit is contained in:
parent
42e6c54e8f
commit
5d0c55b617
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.app.features.onboarding
|
||||||
|
|
||||||
|
enum class FtueUseCase {
|
||||||
|
FRIENDS_FAMILY,
|
||||||
|
TEAMS,
|
||||||
|
COMMUNITIES,
|
||||||
|
SKIP
|
||||||
|
}
|
|
@ -31,15 +31,7 @@ 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 useCase: UseCase) : OnboardingAction() {
|
data class UpdateUseCase(val useCase: FtueUseCase) : 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()
|
||||||
|
|
|
@ -27,7 +27,7 @@ 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 im.vector.app.features.onboarding.OnboardingAction.UpdateUseCase.UseCase
|
import im.vector.app.features.onboarding.FtueUseCase
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class FtueAuthUseCaseFragment @Inject constructor() : AbstractFtueAuthFragment<FragmentFtueAuthUseCaseBinding>() {
|
class FtueAuthUseCaseFragment @Inject constructor() : AbstractFtueAuthFragment<FragmentFtueAuthUseCaseBinding>() {
|
||||||
|
@ -42,9 +42,9 @@ class FtueAuthUseCaseFragment @Inject constructor() : AbstractFtueAuthFragment<F
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupViews() {
|
private fun setupViews() {
|
||||||
views.useCaseOptionOne.setUseCase(R.string.ftue_auth_use_case_option_one, UseCase.FRIENDS_FAMILY)
|
views.useCaseOptionOne.setUseCase(R.string.ftue_auth_use_case_option_one, FtueUseCase.FRIENDS_FAMILY)
|
||||||
views.useCaseOptionTwo.setUseCase(R.string.ftue_auth_use_case_option_two, UseCase.TEAMS)
|
views.useCaseOptionTwo.setUseCase(R.string.ftue_auth_use_case_option_two, FtueUseCase.TEAMS)
|
||||||
views.useCaseOptionThree.setUseCase(R.string.ftue_auth_use_case_option_three, UseCase.COMMUNITIES)
|
views.useCaseOptionThree.setUseCase(R.string.ftue_auth_use_case_option_three, FtueUseCase.COMMUNITIES)
|
||||||
|
|
||||||
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(
|
||||||
|
@ -52,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(UseCase.SKIP)) }
|
onClick = { viewModel.handle(OnboardingAction.UpdateUseCase(FtueUseCase.SKIP)) }
|
||||||
)
|
)
|
||||||
|
|
||||||
views.useCaseConnectToServer.setOnClickListener {
|
views.useCaseConnectToServer.setOnClickListener {
|
||||||
|
@ -64,7 +64,7 @@ class FtueAuthUseCaseFragment @Inject constructor() : AbstractFtueAuthFragment<F
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun TextView.setUseCase(@StringRes label: Int, useCase: UseCase) {
|
private fun TextView.setUseCase(@StringRes label: Int, useCase: FtueUseCase) {
|
||||||
setText(label)
|
setText(label)
|
||||||
debouncedClicks {
|
debouncedClicks {
|
||||||
viewModel.handle(OnboardingAction.UpdateUseCase(useCase))
|
viewModel.handle(OnboardingAction.UpdateUseCase(useCase))
|
||||||
|
|
Loading…
Reference in New Issue