Skip to content

Commit

Permalink
Improve counter UI
Browse files Browse the repository at this point in the history
Swap location of plus and minus buttons
Add colors to the plus and minus buttons
  • Loading branch information
KangarooKoala committed Mar 18, 2024
1 parent ca62547 commit 122afd9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 13 additions & 10 deletions app/src/main/java/com/scouting/app/components/InputComponents.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.KeyboardType
Expand Down Expand Up @@ -104,36 +105,38 @@ fun CounterBar(
) {
IconButton(
onClick = {
temporaryCount += incrementStep
temporaryCount -= incrementStep
onValueChange.invoke(temporaryCount)
},
modifier = Modifier.padding(start = 5.dp),
modifier = Modifier.padding(end = 5.dp),
enabled = enabled,
colors = IconButtonDefaults.iconButtonColors(
disabledContentColor = MaterialTheme.colorScheme.onBackground
)
) {
Icon(
painter = painterResource(id = R.drawable.ic_add_circle),
contentDescription = stringResource(id = R.string.ic_add_circle_content_desc),
modifier = Modifier.size(30.dp)
painter = painterResource(id = R.drawable.ic_subtract_circle),
contentDescription = stringResource(id = R.string.ic_subtract_circle_content_desc),
modifier = Modifier.size(30.dp),
tint = colorResource(id = R.color.minus)
)
}
IconButton(
onClick = {
temporaryCount -= incrementStep
temporaryCount += incrementStep
onValueChange.invoke(temporaryCount)
},
modifier = Modifier.padding(end = 5.dp),
modifier = Modifier.padding(start = 5.dp),
enabled = enabled,
colors = IconButtonDefaults.iconButtonColors(
disabledContentColor = MaterialTheme.colorScheme.onBackground
)
) {
Icon(
painter = painterResource(id = R.drawable.ic_subtract_circle),
contentDescription = stringResource(id = R.string.ic_subtract_circle_content_desc),
modifier = Modifier.size(30.dp)
painter = painterResource(id = R.drawable.ic_add_circle),
contentDescription = stringResource(id = R.string.ic_add_circle_content_desc),
modifier = Modifier.size(30.dp),
tint = colorResource(id = R.color.plus)
)
}
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="plus">#20E000</color>
<color name="minus">#E00000</color>
<color name="ic_launcher_background">#CBC3FF</color>
</resources>

0 comments on commit 122afd9

Please sign in to comment.