Skip to content

Commit

Permalink
Fix modifiers to adjust tap targets (#47)
Browse files Browse the repository at this point in the history
* Fix modifiers to adjust tap targets

Fixes touch targets to entire rows making the click area equal to the row area instead of being smaller.

* Reorder param
  • Loading branch information
ankur2136 authored Oct 11, 2023
1 parent 458226b commit 6adaded
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions ccp/src/main/java/com/togitech/ccp/component/CountryDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ private fun CountryRowItem(
) {
Row(
Modifier
.clickable(onClick = { onSelect() })
.padding(
horizontal = rowPadding,
vertical = rowPadding * ROW_PADDING_VERTICAL_SCALING,
)
.fillMaxWidth()
.clickable(onClick = { onSelect() }),
.fillMaxWidth(),
horizontalArrangement = Arrangement.Start,
verticalAlignment = Alignment.CenterVertically,
) {
Expand Down
10 changes: 7 additions & 3 deletions ccp/src/main/java/com/togitech/ccp/component/TogiCodeDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ internal fun TogiCodeDialog(
showCountryCode: Boolean,
showFlag: Boolean,
textStyle: TextStyle,
modifier: Modifier = Modifier,
) {
val context = LocalContext.current

Expand All @@ -61,7 +60,7 @@ internal fun TogiCodeDialog(
}

Column(
modifier = modifier
modifier = Modifier
.clickable(
interactionSource = interactionSource,
indication = null,
Expand All @@ -70,6 +69,7 @@ internal fun TogiCodeDialog(
},
) {
CountryRow(
modifier = Modifier.padding(DEFAULT_PADDING),
showCountryCode = showCountryCode,
showFlag = showFlag,
country = country,
Expand All @@ -78,7 +78,9 @@ internal fun TogiCodeDialog(

if (isOpenDialog) {
CountryDialog(
modifier = Modifier.fillMaxWidth().clip(RoundedCornerShape(DEFAULT_ROUNDING)),
modifier = Modifier
.fillMaxWidth()
.clip(RoundedCornerShape(DEFAULT_ROUNDING)),
onDismissRequest = { isOpenDialog = false },
onSelect = { countryItem ->
onCountryChange(countryItem)
Expand All @@ -102,7 +104,9 @@ private fun CountryRow(
showFlag: Boolean,
country: CountryData,
textStyle: TextStyle,
modifier: Modifier = Modifier,
) = Row(
modifier = modifier,
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.togitech.ccp.component
import android.util.Log
import androidx.compose.foundation.focusable
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
Expand Down Expand Up @@ -204,7 +203,6 @@ fun TogiCountryCodePicker(
},
leadingIcon = {
TogiCodeDialog(
modifier = Modifier.padding(DEFAULT_PADDING),
selectedCountry = country,
includeOnly = includeOnly,
onCountryChange = { countryData ->
Expand Down

0 comments on commit 6adaded

Please sign in to comment.