Skip to content

Commit

Permalink
Per question custom style (#2636)
Browse files Browse the repository at this point in the history
* per question custom style

* adding missing file.

* update default style.

* textAppearance support

* rename custom attributes.

* github documentation for custom style example.

* Address review comments.

* address review comment.

* update text format icon as component icon.

* code cleanup.

* Code refactoring and cleanup.

* custom style example with multiple question items.

* Address review comments.

* support prefix per question item custom style

* Revert dataconfig changes for custom style mapping.

* Address review comments.

* Address review comments.

* Address review comments.

* Address review comments.

* Address review comment.

---------

Co-authored-by: Santosh Pingle <[email protected]>
  • Loading branch information
santosh-pingle and Santosh Pingle committed Sep 4, 2024
1 parent 65ffde8 commit d9653b6
Show file tree
Hide file tree
Showing 15 changed files with 897 additions and 3 deletions.
149 changes: 149 additions & 0 deletions catalog/src/main/assets/component_per_question_custom_style.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
{
"resourceType": "Questionnaire",
"item": [
{
"linkId": "1",
"text": "Custom style 1",
"type": "display",
"extension": [
{
"url": "https://github.com/google/android-fhir/tree/master/datacapture/android-style",
"extension": [
{
"url": "question_text_view",
"valueString": "CustomStyle_1"
}
]
}
]
},
{
"linkId": "2",
"text": "Custom style 2",
"type": "display",
"extension": [
{
"url": "https://github.com/google/android-fhir/tree/master/datacapture/android-style",
"extension": [
{
"url": "question_text_view",
"valueString": "CustomStyle_2"
}
]
}
]
},
{
"linkId": "3",
"text": "Custom style 3",
"type": "display",
"extension": [
{
"url": "https://github.com/google/android-fhir/tree/master/datacapture/android-style",
"extension": [
{
"url": "question_text_view",
"valueString": "CustomStyle_3"
}
]
}
]
},
{
"linkId": "4",
"text": "Custom style 4",
"type": "display",
"extension": [
{
"url": "https://github.com/google/android-fhir/tree/master/datacapture/android-style",
"extension": [
{
"url": "question_text_view",
"valueString": "CustomStyle_4"
}
]
}
]
},
{
"linkId": "5",
"text": "Custom style 5",
"type": "display",
"extension": [
{
"url": "https://github.com/google/android-fhir/tree/master/datacapture/android-style",
"extension": [
{
"url": "question_text_view",
"valueString": "CustomStyle_5"
}
]
}
]
},
{
"linkId": "6",
"text": "Custom style 6",
"type": "display",
"extension": [
{
"url": "https://github.com/google/android-fhir/tree/master/datacapture/android-style",
"extension": [
{
"url": "question_text_view",
"valueString": "CustomStyle_6"
}
]
}
]
},
{
"linkId": "7",
"text": "Custom style 7",
"type": "display",
"extension": [
{
"url": "https://github.com/google/android-fhir/tree/master/datacapture/android-style",
"extension": [
{
"url": "question_text_view",
"valueString": "CustomStyle_7"
}
]
}
]
},
{
"linkId": "8",
"text": "Custom style 8",
"type": "display",
"extension": [
{
"url": "https://github.com/google/android-fhir/tree/master/datacapture/android-style",
"extension": [
{
"url": "question_text_view",
"valueString": "CustomStyle_8"
}
]
}
]
},
{
"linkId": "9",
"text": "Custom style 9",
"type": "display",
"extension": [
{
"url": "https://github.com/google/android-fhir/tree/master/datacapture/android-style",
"extension": [
{
"url": "question_text_view",
"valueString": "CustomStyle_9"
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ class ComponentListViewModel(application: Application, private val state: SavedS
R.string.component_name_location_widget,
"component_location_widget.json",
),
QUESTION_ITEM_CUSTOM_STYLE(
R.drawable.text_format_48dp,
R.string.component_name_per_question_custom_style,
"component_per_question_custom_style.json",
),
}

val viewItemList =
Expand All @@ -177,6 +182,7 @@ class ComponentListViewModel(application: Application, private val state: SavedS
ViewItem.ComponentItem(Component.ITEM_ANSWER_MEDIA),
ViewItem.ComponentItem(Component.INITIAL_VALUE),
ViewItem.ComponentItem(Component.LOCATION_WIDGET),
ViewItem.ComponentItem(Component.QUESTION_ITEM_CUSTOM_STYLE),
)

fun isComponent(context: Context, title: String) =
Expand Down
4 changes: 2 additions & 2 deletions catalog/src/main/res/drawable/ic_location_on.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="128dp"
android:height="128dp"
android:width="64dp"
android:height="64dp"
android:tint="#1A73E8"
android:viewportWidth="24"
android:viewportHeight="24"
Expand Down
15 changes: 15 additions & 0 deletions catalog/src/main/res/drawable/text_format_48dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:autoMirrored="true"
android:height="64dp"
android:viewportHeight="960"
android:viewportWidth="960"
android:width="64dp"
>

<path
android:fillColor="#1A73E8"
android:pathData="M200,760v-60h560v60L200,760ZM276,600 L451,160h58l175,440h-55l-45,-119L376,481l-45,119h-55ZM393,436h174l-85,-222h-4l-85,222Z"
/>

</vector>
36 changes: 36 additions & 0 deletions catalog/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2020 Google LLC
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.
-->
<resources>
<color name="custom_style_primary_100">#000000</color>
<color name="custom_style_primary_200">#0C0A20</color>
<color name="custom_style_primary_300">#201441</color>
<color name="custom_style_primary_400">#341F63</color>
<color name="custom_style_primary_500">#482A85</color>
<color name="custom_style_primary_600">#5C35A6</color>
<color name="custom_style_primary_700">#7F5FBA</color>
<color name="custom_style_primary_800">#A289CF</color>
<color name="custom_style_primary_900">#C5B3E3</color>
<color name="custom_style_on_primary_100">#FFFFFF</color>
<color name="custom_style_on_primary_200">#FFFFFF</color>
<color name="custom_style_on_primary_300">#FFFFFF</color>
<color name="custom_style_on_primary_400">#FFFFFF</color>
<color name="custom_style_on_primary_500">#FFFFFF</color>
<color name="custom_style_on_primary_600">#FFFFFF</color>
<color name="custom_style_on_primary_700">#FFFFFF</color>
<color name="custom_style_on_primary_800">#000000</color>
<color name="custom_style_on_primary_900">#000000</color>
</resources>
22 changes: 22 additions & 0 deletions catalog/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,26 @@
<color name="onSurfaceVariant_neutral_variant_80">#C4C7C5</color>

<color name="outline_neutral_variant_60">#8E918F</color>

<!-- colors for custom style example -->
<color name="custom_style_primary_900">#7A9FFF</color>
<color name="custom_style_primary_800">#668FFF</color>
<color name="custom_style_primary_700">#5581FF</color>
<color name="custom_style_primary_600">#476FFF</color>
<color name="custom_style_primary_500">#3B5CFF</color>
<color name="custom_style_primary_400">#3249FF</color>
<color name="custom_style_primary_300">#2936FF</color>
<color name="custom_style_primary_200">#2024FF</color>
<color name="custom_style_primary_100">#1816FF</color>
<color name="custom_style_on_primary">#FFFFFF</color>
<color name="custom_style_on_primary_900">#FFFFFF</color>
<color name="custom_style_on_primary_800">#FFFFFF</color>
<color name="custom_style_on_primary_700">#FFFFFF</color>
<color name="custom_style_on_primary_600">#FFFFFF</color>
<color name="custom_style_on_primary_500">#FFFFFF</color>
<color name="custom_style_on_primary_400">#FFFFFF</color>
<color name="custom_style_on_primary_300">#FFFFFF</color>
<color name="custom_style_on_primary_200">#FFFFFF</color>
<color name="custom_style_on_primary_100">#FFFFFF</color>

</resources>
3 changes: 3 additions & 0 deletions catalog/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
<string name="component_name_repeated_group">Repeated Group</string>
<string name="component_name_attachment">Attachment</string>
<string name="component_name_location_widget">Location Widget</string>
<string
name="component_name_per_question_custom_style"
>Per question custom style</string>
<string name="layout_name_default_text">Default</string>
<string name="layout_name_paginated">Paginated</string>
<string name="layout_name_review">Review</string>
Expand Down
Loading

0 comments on commit d9653b6

Please sign in to comment.