Skip to content

Commit

Permalink
Sdc gallery app, implement single choice workflow. (#1008)
Browse files Browse the repository at this point in the history
* Sdc gallery app landing page
1. Show Bottom navigation bar with Components and Layouts menus.
2. Implements components screen.
3. Implements layouts screen.
4. Handles bottom navigation clicks.
5. Update actionbar.

* Rename file name.

* Update components and layouts vector icons.

* Sdc gallery app single choice workflow.

* Update it as boolean choice.

* Address review comments.

* Boolean choice component icon.

* Spotless apply

* Build failures

* Delete gallery drawables.

* fix package name in nav graph

* Spotless apply.

* Delete gallery color resource

* Single choice workflow.

* theme attributes for color value.

* bottom view margin

* textcolor on checked state.

* Address review comments.

* Remove unwanted file.

* Delete unwanted file.

* Add filename field to the component enum.
  • Loading branch information
santosh-pingle committed Jan 27, 2022
1 parent da168b4 commit f50b322
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 23 deletions.
61 changes: 61 additions & 0 deletions catalog/src/main/assets/single_choice_questionnaire.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"resourceType": "Questionnaire",
"item": [
{
"extension": [
{
"url": "http:https://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
"valueCodeableConcept": {
"coding": [
{
"system": "http:https://hl7.org/fhir/questionnaire-item-control",
"code": "radio-button",
"display": "Radio Button"
}
]
}
}
],
"linkId": "1",
"text": "What is the highest level of education achieved?",
"type": "choice",
"answerOption": [
{
"valueCoding": {
"system": "http:https://terminology.hl7.org/CodeSystem/v2-0532",
"code": "Y",
"display": "Does not know level of education"
}
},
{
"valueCoding": {
"system": "http:https://terminology.hl7.org/CodeSystem/v2-0532",
"code": "no",
"display": "No education"
}
},
{
"valueCoding": {
"system": "http:https://terminology.hl7.org/CodeSystem/v2-0532",
"code": "primary",
"display": "Primary school"
}
},
{
"valueCoding": {
"system": "http:https://terminology.hl7.org/CodeSystem/v2-0532",
"code": "secondary",
"display": "Secondary school"
}
},
{
"valueCoding": {
"system": "http:https://terminology.hl7.org/CodeSystem/v2-0532",
"code": "higher",
"display": "Higher education"
}
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class ComponentListFragment : Fragment(R.layout.component_list_fragment) {
private fun onItemClick(component: ComponentListViewModel.Component) {
// TODO Remove check when all components questionnaire json are updated.
// https://github.com/google/android-fhir/issues/1076
if (viewModel.getQuestionnaire(component).isEmpty()) {
if (component.questionnaireFile.isEmpty()) {
return
}
launchQuestionnaireFragment(component)
Expand All @@ -76,7 +76,7 @@ class ComponentListFragment : Fragment(R.layout.component_list_fragment) {
.navigate(
ComponentListFragmentDirections.actionComponentsFragmentToGalleryQuestionnaireFragment(
context?.getString(component.textId) ?: "",
viewModel.getQuestionnaire(component)
component.questionnaireFile
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,29 @@ class ComponentListViewModel(application: Application, private val state: SavedS
return Component.values().toList()
}

fun getQuestionnaire(component: Component): String {
return when (component) {
Component.BOOLEAN_CHOICE -> "boolean_choice_questionnaire.json"
else -> "" // TODO remove else when all components cases are added to the when.
// https://github.com/google/android-fhir/issues/1076
}
}

enum class Component(@DrawableRes val iconId: Int, @StringRes val textId: Int) {
SINGLE_CHOICE(R.drawable.ic_singlechoice, R.string.component_name_single_choice),
BOOLEAN_CHOICE(R.drawable.ic_booleanchoice, R.string.component_name_boolean_choice),
MULTIPLE_CHOICE(R.drawable.ic_multiplechoice, R.string.component_name_multiple_choice),
DROPDOWN(R.drawable.ic_group_1278, R.string.component_name_dropdown),
MODAL(R.drawable.ic_modal, R.string.component_name_modal),
OPEN_CHOICE(R.drawable.ic_openchoice, R.string.component_name_open_choice),
TEXT_FIELD(R.drawable.ic_textfield, R.string.component_name_text_field),
DATE_PICKER(R.drawable.ic_datepicker, R.string.component_name_date_picker),
TIME_PICKER(R.drawable.ic_timepicker, R.string.component_name_time_picker),
SLIDER(R.drawable.ic_slider, R.string.component_name_slider),
IMAGE(R.drawable.ic_image, R.string.component_name_image),
enum class Component(
@DrawableRes val iconId: Int,
@StringRes val textId: Int,
val questionnaireFile: String
) {
SINGLE_CHOICE(
R.drawable.ic_singlechoice,
R.string.component_name_single_choice,
"single_choice_questionnaire.json"
),
BOOLEAN_CHOICE(
R.drawable.ic_booleanchoice,
R.string.component_name_boolean_choice,
"boolean_choice_questionnaire.json"
),
MULTIPLE_CHOICE(R.drawable.ic_multiplechoice, R.string.component_name_multiple_choice, ""),
DROPDOWN(R.drawable.ic_group_1278, R.string.component_name_dropdown, ""),
MODAL(R.drawable.ic_modal, R.string.component_name_modal, ""),
OPEN_CHOICE(R.drawable.ic_openchoice, R.string.component_name_open_choice, ""),
TEXT_FIELD(R.drawable.ic_textfield, R.string.component_name_text_field, ""),
DATE_PICKER(R.drawable.ic_datepicker, R.string.component_name_date_picker, ""),
TIME_PICKER(R.drawable.ic_timepicker, R.string.component_name_time_picker, ""),
SLIDER(R.drawable.ic_slider, R.string.component_name_slider, ""),
IMAGE(R.drawable.ic_image, R.string.component_name_image, ""),
}
}
1 change: 0 additions & 1 deletion catalog/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
<fragment
android:id="@+id/galleryQuestionnaireFragment"
android:name="com.google.android.fhir.catalog.DemoQuestionnaireFragment"
android:label="fragment_dummy"
tools:layout="@layout/fragment_demo_questionnaire"
>
<argument android:name="questionnaireTitleKey" app:argType="string" />
Expand Down
1 change: 1 addition & 0 deletions catalog/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
name="Questionnaire.Widget.AppCompat.CompoundButton.RadioButton"
parent="Widget.MaterialComponents.CompoundButton.RadioButton"
>
<item name="android:textColor">@color/checked_text_color</item>
<item
name="materialThemeOverlay"
>@style/ThemeOverlay.App.RadioButton</item>
Expand Down

0 comments on commit f50b322

Please sign in to comment.