From b6ff6aa4cc43dcf1f6b49b91335fde9e8a7c9433 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Fri, 7 Jan 2022 12:56:06 +0000 Subject: [PATCH] adding barebones ftue use case fragment --- .../im/vector/app/core/di/FragmentModule.kt | 6 + .../features/onboarding/OnboardingAction.kt | 1 + .../onboarding/OnboardingViewModel.kt | 7 + .../ftueauth/FtueAuthUseCaseFragment.kt | 54 +++++++ .../onboarding/ftueauth/FtueAuthVariant.kt | 4 +- .../src/main/res/drawable/ic_communities.xml | 18 +++ .../res/drawable/ic_friends_and_family.xml | 16 ++ .../drawable/ic_onboarding_use_case_icon.xml | 14 ++ vector/src/main/res/drawable/ic_teams.xml | 26 ++++ .../layout/fragment_ftue_auth_use_case.xml | 144 ++++++++++++++++++ 10 files changed, 289 insertions(+), 1 deletion(-) create mode 100644 vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthUseCaseFragment.kt create mode 100644 vector/src/main/res/drawable/ic_communities.xml create mode 100644 vector/src/main/res/drawable/ic_friends_and_family.xml create mode 100644 vector/src/main/res/drawable/ic_onboarding_use_case_icon.xml create mode 100644 vector/src/main/res/drawable/ic_teams.xml create mode 100644 vector/src/main/res/layout/fragment_ftue_auth_use_case.xml diff --git a/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt b/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt index c27309fad6..626cf90592 100644 --- a/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt @@ -104,6 +104,7 @@ import im.vector.app.features.onboarding.ftueauth.FtueAuthServerSelectionFragmen import im.vector.app.features.onboarding.ftueauth.FtueAuthSignUpSignInSelectionFragment import im.vector.app.features.onboarding.ftueauth.FtueAuthSplashCarouselFragment import im.vector.app.features.onboarding.ftueauth.FtueAuthSplashFragment +import im.vector.app.features.onboarding.ftueauth.FtueAuthUseCaseFragment import im.vector.app.features.onboarding.ftueauth.FtueAuthWaitForEmailFragment import im.vector.app.features.onboarding.ftueauth.FtueAuthWebFragment import im.vector.app.features.onboarding.ftueauth.terms.FtueAuthTermsFragment @@ -449,6 +450,11 @@ interface FragmentModule { @FragmentKey(FtueAuthSplashCarouselFragment::class) fun bindFtueAuthSplashCarouselFragment(fragment: FtueAuthSplashCarouselFragment): Fragment + @Binds + @IntoMap + @FragmentKey(FtueAuthUseCaseFragment::class) + fun bindFtueAuthUseCaseFragment(fragment: FtueAuthUseCaseFragment): Fragment + @Binds @IntoMap @FragmentKey(FtueAuthWaitForEmailFragment::class) diff --git a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingAction.kt b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingAction.kt index bb1d3cc52d..ea549b214a 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingAction.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingAction.kt @@ -31,6 +31,7 @@ sealed class OnboardingAction : VectorViewModelAction { data class UpdateServerType(val serverType: ServerType) : OnboardingAction() data class UpdateHomeServer(val homeServerUrl: String) : OnboardingAction() + data class UpdateUseCase(val todo: String) : OnboardingAction() data class UpdateSignMode(val signMode: SignMode) : OnboardingAction() data class LoginWithToken(val loginToken: String) : OnboardingAction() data class WebLoginSuccess(val credentials: Credentials) : OnboardingAction() diff --git a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt index 39c2e9bcdb..5a098ebb56 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt @@ -125,6 +125,7 @@ class OnboardingViewModel @AssistedInject constructor( when (action) { is OnboardingAction.OnGetStarted -> handleSplashAction(action.resetLoginConfig, action.onboardingFlow) is OnboardingAction.OnIAlreadyHaveAnAccount -> handleSplashAction(action.resetLoginConfig, action.onboardingFlow) + is OnboardingAction.UpdateUseCase -> handleUpdateUseCase(action) is OnboardingAction.UpdateServerType -> handleUpdateServerType(action) is OnboardingAction.UpdateSignMode -> handleUpdateSignMode(action) is OnboardingAction.InitWith -> handleInitWith(action) @@ -452,6 +453,12 @@ class OnboardingViewModel @AssistedInject constructor( } } + private fun handleUpdateUseCase(action: OnboardingAction.UpdateUseCase) { + // TODO act on the use case selection + action.todo + _viewEvents.post(OnboardingViewEvents.OpenServerSelection) + } + private fun handleUpdateServerType(action: OnboardingAction.UpdateServerType) { setState { copy( diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthUseCaseFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthUseCaseFragment.kt new file mode 100644 index 0000000000..13304bf124 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthUseCaseFragment.kt @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2021 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.ftueauth + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import im.vector.app.databinding.FragmentFtueAuthUseCaseBinding +import im.vector.app.features.login.ServerType +import im.vector.app.features.onboarding.OnboardingAction +import javax.inject.Inject + +class FtueAuthUseCaseFragment @Inject constructor() : AbstractFtueAuthFragment() { + + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentFtueAuthUseCaseBinding { + return FragmentFtueAuthUseCaseBinding.inflate(inflater, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + setupViews() + } + + private fun setupViews() { + views.useCaseOptionOne.debouncedClicks { + viewModel.handle(OnboardingAction.UpdateUseCase("todo")) + } + views.useCaseOptionTwo.debouncedClicks { + viewModel.handle(OnboardingAction.UpdateUseCase("todo")) + } + views.useCaseOptionThree.debouncedClicks { + viewModel.handle(OnboardingAction.UpdateUseCase("todo")) + } + } + + override fun resetViewModel() { + // Nothing to do + } +} diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthVariant.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthVariant.kt index 08258062e7..4ef99e355e 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthVariant.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthVariant.kt @@ -210,7 +210,9 @@ class FtueAuthVariant( // This is handled by the Fragments Unit OnboardingViewEvents.OpenUseCaseSelection -> { - TODO() + activity.addFragmentToBackstack(views.loginFragmentContainer, + FtueAuthUseCaseFragment::class.java, + option = commonOption) } }.exhaustive } diff --git a/vector/src/main/res/drawable/ic_communities.xml b/vector/src/main/res/drawable/ic_communities.xml new file mode 100644 index 0000000000..f550de8106 --- /dev/null +++ b/vector/src/main/res/drawable/ic_communities.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/vector/src/main/res/drawable/ic_friends_and_family.xml b/vector/src/main/res/drawable/ic_friends_and_family.xml new file mode 100644 index 0000000000..d7ac86f240 --- /dev/null +++ b/vector/src/main/res/drawable/ic_friends_and_family.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/vector/src/main/res/drawable/ic_onboarding_use_case_icon.xml b/vector/src/main/res/drawable/ic_onboarding_use_case_icon.xml new file mode 100644 index 0000000000..35b45aa69a --- /dev/null +++ b/vector/src/main/res/drawable/ic_onboarding_use_case_icon.xml @@ -0,0 +1,14 @@ + + + + diff --git a/vector/src/main/res/drawable/ic_teams.xml b/vector/src/main/res/drawable/ic_teams.xml new file mode 100644 index 0000000000..8745cfd2d4 --- /dev/null +++ b/vector/src/main/res/drawable/ic_teams.xml @@ -0,0 +1,26 @@ + + + + + + + + + diff --git a/vector/src/main/res/layout/fragment_ftue_auth_use_case.xml b/vector/src/main/res/layout/fragment_ftue_auth_use_case.xml new file mode 100644 index 0000000000..fbc4db43be --- /dev/null +++ b/vector/src/main/res/layout/fragment_ftue_auth_use_case.xml @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +