Skip to main content
Version: Next

challengecard

README.md

:OCCalorieCounter - A Custom Composable UI Component

This OCCalorieCounter is a custom Jetpack Compose component designed to trigger an action.

Features:

  • Can display incremental/decremental values for Calorie Counter.
  • Incremental default value can be configured.
  • Decrement counter is disabled when count goes below 0.
  • Animations are provided when counter is increased/decreased.
  • Text can be customized.
  • Icons can be customized

:How to use OCCalorieCounter

  1. Add the necessary imports:

    import your.package.name.OCCalorieCounter

  2. Use the OCCalorieCounter within your Composable:

        OCCalorieCounter(
    calorieIcon = {
    Image(
    painter = painterResource(R.drawable.ic_calorie),
    contentDescription = null,
    modifier = Modifier.padding(end = dimensions.eightDPSpacing, top = dimensions.twoDPSpacing)
    )
    },
    incrementButton = {
    Image(
    painter = painterResource(R.drawable.ic_increment_counter),
    contentDescription = null,
    )
    },
    decrementButton = {
    Icon(
    painter = painterResource(R.drawable.ic_decrement_counter),
    contentDescription = null,
    tint = colors.buttonPrimaryOnBackgoundDisabled
    )
    },
    )

Parameters:

  • modifier: Outlined card can be modified with modifier
  • defaultCounterValue: Represents the default value for the counter
  • defaultNetValue: Represents the default value for total calories
  • standardFactor: Represents the factor by which the calorie gets multiplied
  • incrementButton: Composable image Increment Button
  • decrementButton: Composable image Decrement Button
  • counterActivityUnit: Configuration to change text for Counter Label text
  • counterDetailsText: Configuration to change text for Counter details text
  • calorieMeasureUnit: Configuration to change unit for Calorie measurement
  • calorieIcon: Composable image for unit measurement
  • returnNetCalorie: Function callback to return net calorie