From 3e31e9326a781258448d55dac4efe8fd3c32410f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=E2=89=A1ZRS?= <12814349+LZRS@users.noreply.github.com> Date: Thu, 26 Oct 2023 12:37:31 +0300 Subject: [PATCH] Shared layout for bottom navigation items, for scroll and sticky --- .../datacapture/QuestionnaireAdapterItem.kt | 2 +- .../datacapture/QuestionnaireEditAdapter.kt | 4 +- .../fhir/datacapture/QuestionnaireFragment.kt | 87 ++++++----- .../QuestionnaireNavigationViewUIState.kt | 33 ++++ .../QuestionnairePageNavigationState.kt | 32 ---- .../datacapture/QuestionnaireReviewAdapter.kt | 2 +- .../datacapture/QuestionnaireViewModel.kt | 142 +++++++++--------- .../datacapture/views/NavigationViewHolder.kt | 56 +++---- .../res/layout/pagination_navigation_view.xml | 12 +- .../res/layout/questionnaire_fragment.xml | 90 +---------- .../datacapture/QuestionnaireViewModelTest.kt | 6 +- 11 files changed, 202 insertions(+), 264 deletions(-) create mode 100644 datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireNavigationViewUIState.kt delete mode 100644 datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnairePageNavigationState.kt diff --git a/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireAdapterItem.kt b/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireAdapterItem.kt index 25e9b607ef..b0ae4b85f0 100644 --- a/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireAdapterItem.kt +++ b/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireAdapterItem.kt @@ -23,6 +23,6 @@ internal sealed interface QuestionnaireAdapterItem { /** A row for a question in a Questionnaire RecyclerView. */ data class Question(val item: QuestionnaireViewItem) : QuestionnaireAdapterItem - data class Navigation(val questionnairePageNavigationState: QuestionnairePageNavigationState) : + data class Navigation(val questionnaireNavigationUIState: QuestionnaireNavigationUIState) : QuestionnaireAdapterItem } diff --git a/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireEditAdapter.kt b/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireEditAdapter.kt index b34b17da89..b7b9939ae6 100644 --- a/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireEditAdapter.kt +++ b/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireEditAdapter.kt @@ -115,7 +115,7 @@ internal class QuestionnaireEditAdapter( } is QuestionnaireAdapterItem.Navigation -> { holder as NavigationViewHolder - holder.bind(item.questionnairePageNavigationState) + holder.bind(item.questionnaireNavigationUIState) } } } @@ -293,7 +293,7 @@ internal object DiffCallbacks { } is QuestionnaireAdapterItem.Navigation -> { newItem is QuestionnaireAdapterItem.Navigation && - oldItem.questionnairePageNavigationState == newItem.questionnairePageNavigationState + oldItem.questionnaireNavigationUIState == newItem.questionnaireNavigationUIState } } } diff --git a/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireFragment.kt b/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireFragment.kt index 63aea13a1b..2b82552736 100644 --- a/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireFragment.kt +++ b/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireFragment.kt @@ -21,7 +21,6 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.Button import androidx.annotation.VisibleForTesting import androidx.appcompat.view.ContextThemeWrapper import androidx.core.content.res.use @@ -93,8 +92,9 @@ class QuestionnaireFragment : Fragment() { view.findViewById(R.id.questionnaire_edit_recycler_view) val questionnaireReviewRecyclerView = view.findViewById(R.id.questionnaire_review_recycler_view) - val bottomNavGroup = view.findViewById(R.id.bottom_nav_group) - view.findViewById