-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wip] configure passing bottom nav state params
- Loading branch information
Showing
11 changed files
with
245 additions
and
143 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
datacapture/src/main/java/com/google/android/fhir/datacapture/DisplayMode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.google.android.fhir.datacapture | ||
|
||
sealed class DisplayMode { | ||
class EditMode(val pagination: QuestionnairePagination) : DisplayMode() | ||
data class ReviewMode(val showEditButton: Boolean, val showSubmitButton: Boolean) : DisplayMode() | ||
|
||
// Sentinel displayMode that's used in setting the initial default QuestionnaireState | ||
object InitMode : DisplayMode() | ||
} |
49 changes: 49 additions & 0 deletions
49
datacapture/src/main/java/com/google/android/fhir/datacapture/NavigationViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.google.android.fhir.datacapture | ||
|
||
import android.view.View | ||
import android.widget.Button | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.google.android.fhir.datacapture.DisplayMode | ||
|
||
class NavigationViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) { | ||
|
||
fun bind(displayMode: DisplayMode){ | ||
val paginationPreviousButton = itemView.findViewById<View>(R.id.pagination_previous_button) | ||
val paginationNextButton = itemView.findViewById<View>(R.id.pagination_next_button) | ||
val submitButton = itemView.findViewById<Button>(R.id.submit_questionnaire) | ||
val reviewModeButton = itemView.findViewById<View>(R.id.review_mode_button) | ||
|
||
when(displayMode){ | ||
is DisplayMode.ReviewMode -> { | ||
// Set button visibility | ||
submitButton.visibility = if (displayMode.showSubmitButton) View.VISIBLE else View.GONE | ||
reviewModeButton.visibility = View.GONE | ||
paginationPreviousButton.visibility = View.GONE | ||
paginationNextButton.visibility = View.GONE | ||
} | ||
is DisplayMode.EditMode -> { | ||
// Set button visibility | ||
submitButton.visibility = | ||
if (displayMode.pagination.showSubmitButton) View.VISIBLE else View.GONE | ||
reviewModeButton.visibility = | ||
if (displayMode.pagination.showReviewButton) View.VISIBLE else View.GONE | ||
if (displayMode.pagination.isPaginated) { | ||
paginationPreviousButton.visibility = View.VISIBLE | ||
paginationPreviousButton.isEnabled = displayMode.pagination.hasPreviousPage | ||
paginationNextButton.visibility = View.VISIBLE | ||
paginationNextButton.isEnabled = displayMode.pagination.hasNextPage | ||
} else { | ||
paginationPreviousButton.visibility = View.GONE | ||
paginationNextButton.visibility = View.GONE | ||
} | ||
} | ||
is DisplayMode.InitMode -> { | ||
paginationPreviousButton.visibility = View.GONE | ||
paginationNextButton.visibility = View.GONE | ||
submitButton.visibility = View.GONE | ||
reviewModeButton.visibility = View.GONE | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnairePage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.google.android.fhir.datacapture | ||
|
||
/** A single page in the questionnaire. This is used for the UI to render pagination controls. */ | ||
data class QuestionnairePage( | ||
val index: Int, | ||
val enabled: Boolean, | ||
val hidden: Boolean, | ||
) |
13 changes: 13 additions & 0 deletions
13
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnairePagination.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.google.android.fhir.datacapture | ||
|
||
/** | ||
* Pagination information of the questionnaire. This is used for the UI to render pagination | ||
* controls. Includes information for each page and the current page index. | ||
*/ | ||
data class QuestionnairePagination( | ||
val isPaginated: Boolean = false, | ||
val pages: List<QuestionnairePage>, | ||
val currentPageIndex: Int, | ||
val showSubmitButton: Boolean = false, | ||
val showReviewButton: Boolean = false, | ||
) |
Oops, something went wrong.