Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the next button navigation view to a default long scroll #2134

Merged
merged 20 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0ccb597
Configurable bottom navigation to be part of page scroll
LZRS Sep 21, 2023
538055b
Merge branch 'master' into 1764-scroll-to-bottom-to-enable-next
LZRS Sep 22, 2023
bb4b5a2
Merge remote-tracking branch 'upstream/master' into 1764-scroll-to-bo…
LZRS Sep 25, 2023
42bcee5
Merge branch 'master' into 1764-scroll-to-bottom-to-enable-next
f-odhiambo Sep 27, 2023
3742e58
Merge remote-tracking branch 'upstream/master' into 1764-scroll-to-bo…
LZRS Oct 18, 2023
a2e410c
Merge branch 'master' into 1764-scroll-to-bottom-to-enable-next
LZRS Oct 18, 2023
eaec177
Merge remote-tracking branch 'upstream/master' into 1764-scroll-to-bo…
LZRS Oct 25, 2023
5ed31e7
Shared layout for bottom navigation items, for scroll and sticky
LZRS Oct 26, 2023
d291427
Merge remote-tracking branch 'upstream/master' into 1764-scroll-to-bo…
LZRS Oct 31, 2023
fbb6ba3
Use separate recyclerview for bottom navigation items
LZRS Nov 1, 2023
d7ab77e
Merge remote-tracking branch 'upstream/master' into 1764-scroll-to-bo…
LZRS Feb 28, 2024
b2db3d9
Merge branch 'master' into 1764-scroll-to-bottom-to-enable-next
LZRS Mar 12, 2024
e62105f
Merge remote-tracking branch 'upstream/master' into 1764-scroll-to-bo…
LZRS Mar 21, 2024
a5e0df3
Merge remote-tracking branch 'upstream/master' into 1764-scroll-to-bo…
LZRS Apr 23, 2024
09a0010
Merge remote-tracking branch 'upstream/master' into 1764-scroll-to-bo…
LZRS May 1, 2024
53242bb
Merge branch 'master' into 1764-scroll-to-bottom-to-enable-next
jingtang10 Jun 21, 2024
3fbb72d
Fix build errors
jingtang10 Jun 21, 2024
716c855
Remove unnecessary disabled state
jingtang10 Jun 21, 2024
a0c61d9
Delete the unnecessary navigation recycler view
jingtang10 Jun 21, 2024
23d038d
Simplify unnecessary .apply
jingtang10 Jun 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.fhir.datacapture.validation.Invalid
import com.google.android.fhir.datacapture.views.NavigationViewHolder
import com.google.android.fhir.datacapture.views.factories.QuestionnaireItemViewHolderFactory
import com.google.android.material.progressindicator.LinearProgressIndicator
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -93,8 +94,11 @@ class QuestionnaireFragment : Fragment() {
view.findViewById<RecyclerView>(R.id.questionnaire_edit_recycler_view)
val questionnaireReviewRecyclerView =
view.findViewById<RecyclerView>(R.id.questionnaire_review_recycler_view)
val bottomNavigationRecyclerView =
view.findViewById<RecyclerView>(R.id.questionnaire_bottom_navigation_recycler_view)

// This container frame floats at the bottom of the view to make navigation controls visible at
// all times when the user scrolls. Use
// [QuestionnaireFragment.Builder.setShowNavigationInDefaultLongScroll] to disable this.
val bottomNavContainerFrame = view.findViewById<View>(R.id.bottom_nav_container_frame)

viewModel.setOnCancelButtonClickListener {
QuestionnaireCancelDialogFragment()
Expand Down Expand Up @@ -137,10 +141,6 @@ class QuestionnaireFragment : Fragment() {
questionnaireReviewRecyclerView.adapter = questionnaireReviewAdapter
questionnaireReviewRecyclerView.layoutManager = LinearLayoutManager(view.context)

val bottomNavigationAdapter = QuestionnaireNavigationAdapter()
bottomNavigationRecyclerView.adapter = bottomNavigationAdapter
bottomNavigationRecyclerView.layoutManager = LinearLayoutManager(view.context)

// Listen to updates from the view model.
viewLifecycleOwner.lifecycleScope.launchWhenCreated {
viewModel.questionnaireStateFlow.collect { state ->
Expand All @@ -151,27 +151,34 @@ class QuestionnaireFragment : Fragment() {
questionnaireReviewAdapter.submitList(
state.items,
)
bottomNavigationAdapter.submitList(state.bottomNavItems)
questionnaireReviewRecyclerView.visibility = View.VISIBLE

reviewModeEditButton.visibility =
if (displayMode.showEditButton) {
View.VISIBLE
} else {
View.GONE
}

// Set bottom navigation
bottomNavContainerFrame.visibility = View.VISIBLE
NavigationViewHolder(bottomNavContainerFrame)
.bind(state.bottomNavItems.single().questionnaireNavigationUIState)

// Hide progress indicator
questionnaireProgressIndicator.visibility = View.GONE
}
is DisplayMode.EditMode -> {
// Set items
questionnaireReviewRecyclerView.visibility = View.GONE
questionnaireEditAdapter.submitList(state.items)
bottomNavigationAdapter.submitList(state.bottomNavItems)
questionnaireEditRecyclerView.visibility = View.VISIBLE
reviewModeEditButton.visibility = View.GONE

// Set bottom navigation
bottomNavContainerFrame.visibility = View.VISIBLE
NavigationViewHolder(bottomNavContainerFrame)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

state.bottomNavItems.single() crashes when QuestionnaireFragment.Builder.setShowNavigationInDefaultLongScroll is set to true since it's empty

.bind(state.bottomNavItems.single().questionnaireNavigationUIState)

// Set progress indicator
questionnaireProgressIndicator.visibility = View.VISIBLE
if (displayMode.pagination.isPaginated) {
Expand Down Expand Up @@ -206,7 +213,7 @@ class QuestionnaireFragment : Fragment() {
questionnaireEditRecyclerView.visibility = View.GONE
questionnaireProgressIndicator.visibility = View.GONE
reviewModeEditButton.visibility = View.GONE
bottomNavigationRecyclerView.visibility = View.GONE
bottomNavContainerFrame.visibility = View.GONE
}
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,9 @@ class QuestionnaireItemViewHolder(
internal class RepeatedGroupHeaderItemViewHolder(
itemView: View,
) : RecyclerView.ViewHolder(itemView) {

private val header: TextView
private val delete: View

init {
header = itemView.findViewById(R.id.repeated_group_instance_header_title)
delete = itemView.findViewById(R.id.repeated_group_instance_header_delete_button)
}
private val header: TextView = itemView.findViewById(R.id.repeated_group_instance_header_title)
private val delete: View =
itemView.findViewById(R.id.repeated_group_instance_header_delete_button)

fun bind(repeatedGroupHeader: QuestionnaireAdapterItem.RepeatedGroupHeader) {
header.text =
Expand Down
16 changes: 8 additions & 8 deletions datacapture/src/main/res/layout/questionnaire_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:scrollbars="vertical"
app:layout_constraintBottom_toTopOf="@+id/questionnaire_bottom_navigation_recycler_view"
app:layout_constraintBottom_toTopOf="@+id/bottom_nav_container_frame"
app:layout_constraintTop_toBottomOf="@+id/questionnaire_progress_indicator"
/>

Expand All @@ -61,19 +61,19 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:scrollbars="vertical"
app:layout_constraintBottom_toTopOf="@+id/questionnaire_bottom_navigation_recycler_view"
app:layout_constraintBottom_toTopOf="@+id/bottom_nav_container_frame"
app:layout_constraintTop_toBottomOf="@+id/review_mode_edit_button"
/>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/questionnaire_bottom_navigation_recycler_view"
android:layout_width="0dp"
<FrameLayout
android:id="@+id/bottom_nav_container_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:listitem="@layout/pagination_navigation_view"
tools:itemCount="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
/>
>
<include layout="@layout/pagination_navigation_view" />
</FrameLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -4324,6 +4324,7 @@ class QuestionnaireViewModelTest {
when (it) {
is QuestionnaireAdapterItem.Question -> it.item.questionnaireItem.linkId
is QuestionnaireAdapterItem.RepeatedGroupHeader -> "RepeatedGroupHeader:${it.index}"
is QuestionnaireAdapterItem.Navigation -> TODO()
}
},
)
Expand Down
Loading