Skip to content

Commit

Permalink
Bugfix/hma 8377 update summary row view to use custom icon at end (#164)
Browse files Browse the repository at this point in the history
* dynamic SummaryRowView added

* code clean up

* changelog updated

* screenshot updated for the dynamic summary view
  • Loading branch information
aliahmedbd authored Apr 26, 2024
1 parent 34d1163 commit 9f15e83
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 7 deletions.
4 changes: 4 additions & 0 deletions components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Allowed headings:

## [Unreleased]

### Fixed

* Resolved chevron icon initialization bug in `SummaryRowView`

## [4.11.0] - 2024-03-25Z

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,19 @@ class SummaryRowView @JvmOverloads constructor(
}

init {
var icon = R.drawable.components_ic_chevron_right
var iconTint = R.color.hmrc_black

attrs?.let {
val typedArray = context.theme.obtainStyledAttributes(it, R.styleable.SummaryRowView, 0, 0)
val titleText = typedArray.getString(R.styleable.SummaryRowView_title)
val titleTextAppearance = typedArray.getResourceId(
R.styleable.SummaryRowView_titleTextAppearance,
R.style.Text_Bold
)
val icon =
icon =
typedArray.getResourceId(R.styleable.SummaryRowView_icon, R.drawable.components_ic_chevron_right)
val iconTint = typedArray.getResourceId(R.styleable.SummaryRowView_iconTintColor, R.color.hmrc_black)
iconTint = typedArray.getResourceId(R.styleable.SummaryRowView_iconTintColor, R.color.hmrc_black)

val titleMaxLines = typedArray.getInt(R.styleable.SummaryRowView_titleMaxLines, -1)
val accessibilityMessage = typedArray.getString(R.styleable.SummaryRowView_accessibilityMessage)
Expand All @@ -80,9 +83,6 @@ class SummaryRowView @JvmOverloads constructor(
setTitle(titleText)
setTitleTextAppearance(titleTextAppearance)
setTitleMaxLines(titleMaxLines)
setIcon(icon)
setIconTintColor(iconTint)

accessibilityMessage?.let { message ->
setAccessibilityMessage(message)
}
Expand All @@ -95,6 +95,8 @@ class SummaryRowView @JvmOverloads constructor(
resources.getDimensionPixelSize(R.dimen.hmrc_spacing_16).let {
setPadding(it, it, it, it)
}
setIcon(icon)
setIconTintColor(iconTint)
addRipple()
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import uk.gov.hmrc.components.molecule.item.MultiColumnRowView
import uk.gov.hmrc.components.organism.summary.SummaryRowView
import uk.gov.hmrc.components.sample.R
import uk.gov.hmrc.components.sample.autoCleared
import uk.gov.hmrc.components.sample.base.BaseComponentsFragment
Expand Down Expand Up @@ -142,6 +143,25 @@ class SummaryRowFragment : BaseComponentsFragment() {
setOnClickListener { onCtaPressed() }
setIconTintColor(R.color.hmrc_blue)
}

// Example: SummaryRowView that is dynamically added
binding.containerSummaryRowView.apply {
removeAllViews()
addView(createDynamicSummaryRowView())
}
}

private fun createDynamicSummaryRowView(): SummaryRowView {
val row = MultiColumnRowView(requireContext())
row.setText(getString(R.string.long_text))
return SummaryRowView(requireContext()).apply {
readerTrait = SummaryRowView.READER_TRAIT_SIMPLE
setTitle(getString(R.string.summary_row_example_6_title))
setRows(arrayListOf(row))
setOnClickListener {
onCtaPressed()
}
}
}

private fun onCtaPressed() {
Expand Down
20 changes: 18 additions & 2 deletions sample/src/main/res/layout/fragment_summary_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,30 @@
android:id="@+id/summary_row_example_6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:icon="@drawable/ic_calendar"
app:readerTrait="simple"
app:title="@string/summary_row_placeholder_title"
app:icon="@drawable/ic_calendar" />
app:title="@string/summary_row_placeholder_title" />

</LinearLayout>

</com.google.android.material.card.MaterialCardView>

<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/hmrc_spacing_16"
android:padding="@dimen/hmrc_spacing_16">

<uk.gov.hmrc.components.container.SeparatedViewContainer
android:id="@+id/container_summary_row_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:dividerPadding="@dimen/hmrc_spacing_16"
android:orientation="vertical"
android:showDividers="middle" />

</com.google.android.material.card.MaterialCardView>

</LinearLayout>

</ScrollView>
Expand Down
2 changes: 2 additions & 0 deletions sample/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@
<string name="summary_row_example_2_accessibility_title">Fingerprint ID, on</string>
<string name="summary_row_example_2_accessibility_action">activate</string>

<string name="summary_row_example_6_title">Dynamic Summary Row Title</string>

<!-- Inset -->
<string name="inset_placeholder_text">Nested content goes here</string>
<string name="inset_example_text_line_1_description">Account Number:</string>
Expand Down

0 comments on commit 9f15e83

Please sign in to comment.