Skip to content

Commit

Permalink
[#597] Review: Circle size of OdsComponentCircleImage is now hardcoded
Browse files Browse the repository at this point in the history
  • Loading branch information
florentmaitre committed Sep 20, 2023
1 parent 10fb233 commit 329ee24
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp
import com.orange.ods.R
import com.orange.ods.compose.component.OdsComposable
import com.orange.ods.compose.component.button.OdsTextButton
Expand Down Expand Up @@ -123,34 +122,29 @@ class OdsBannerButton(private val text: String, private val onClick: () -> Unit)
*/
class OdsBannerImage : OdsComponentCircleImage {

private companion object {

private val CircleSize = 40.dp
}

/**
* Creates an instance of [OdsBannerImage].
*
* @param painter The painter to draw.
* @param contentDescription The content description associated to this [OdsBannerImage].
*/
constructor(painter: Painter, contentDescription: String) : super(painter, contentDescription, CircleSize)
constructor(painter: Painter, contentDescription: String) : super(painter, contentDescription)

/**
* Creates an instance of [OdsBannerImage].
*
* @param imageVector The image vector to draw.
* @param contentDescription The content description associated to this [OdsBannerImage].
*/
constructor(imageVector: ImageVector, contentDescription: String) : super(imageVector, contentDescription, CircleSize)
constructor(imageVector: ImageVector, contentDescription: String) : super(imageVector, contentDescription)

/**
* Creates an instance of [OdsBannerImage].
*
* @param bitmap The image bitmap to draw.
* @param contentDescription The content description associated to this [OdsBannerImage].
*/
constructor(bitmap: ImageBitmap, contentDescription: String) : super(bitmap, contentDescription, CircleSize)
constructor(bitmap: ImageBitmap, contentDescription: String) : super(bitmap, contentDescription)
}

@UiModePreviews.Default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import com.orange.ods.compose.component.button.OdsTextButton
import com.orange.ods.compose.component.button.OdsTextButtonStyle
import com.orange.ods.compose.component.content.OdsComponentCircleImage
Expand Down Expand Up @@ -133,32 +132,27 @@ class OdsCardImage private constructor(
*/
class OdsCardThumbnail : OdsComponentCircleImage {

private companion object {

private val CircleSize = 40.dp
}

/**
* Creates an instance of [OdsCardThumbnail].
*
* @param painter The painter to draw.
* @param contentDescription The content description associated to this [OdsCardThumbnail].
*/
constructor(painter: Painter, contentDescription: String) : super(painter, contentDescription, CircleSize)
constructor(painter: Painter, contentDescription: String) : super(painter, contentDescription)

/**
* Creates an instance of [OdsCardThumbnail].
*
* @param imageVector The image vector to draw.
* @param contentDescription The content description associated to this [OdsCardThumbnail].
*/
constructor(imageVector: ImageVector, contentDescription: String) : super(imageVector, contentDescription, CircleSize)
constructor(imageVector: ImageVector, contentDescription: String) : super(imageVector, contentDescription)

/**
* Creates an instance of [OdsCardThumbnail].
*
* @param bitmap The image bitmap to draw.
* @param contentDescription The content description associated to this [OdsCardThumbnail].
*/
constructor(bitmap: ImageBitmap, contentDescription: String) : super(bitmap, contentDescription, CircleSize)
constructor(bitmap: ImageBitmap, contentDescription: String) : super(bitmap, contentDescription)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

abstract class OdsComponentCircleImage private constructor(
graphicsObject: Any,
contentDescription: String,
private val circleSize: Dp
contentDescription: String
) : OdsComponentImage(graphicsObject, contentDescription, contentScale = ContentScale.Crop) {

/**
Expand All @@ -33,29 +32,29 @@ abstract class OdsComponentCircleImage private constructor(
* @param painter The painter to draw.
* @param contentDescription The content description associated to this [OdsComponentCircleImage].
*/
constructor(painter: Painter, contentDescription: String, circleSize: Dp) : this(painter as Any, contentDescription, circleSize)
constructor(painter: Painter, contentDescription: String) : this(painter as Any, contentDescription)

/**
* Creates an instance of [OdsComponentCircleImage].
*
* @param imageVector The image vector to draw.
* @param contentDescription The content description associated to this [OdsComponentCircleImage].
*/
constructor(imageVector: ImageVector, contentDescription: String, circleSize: Dp) : this(imageVector as Any, contentDescription, circleSize)
constructor(imageVector: ImageVector, contentDescription: String) : this(imageVector as Any, contentDescription)

/**
* Creates an instance of [OdsComponentCircleImage].
*
* @param bitmap The image bitmap to draw.
* @param contentDescription The content description associated to this [OdsComponentCircleImage].
*/
constructor(bitmap: ImageBitmap, contentDescription: String, circleSize: Dp) : this(bitmap as Any, contentDescription, circleSize)
constructor(bitmap: ImageBitmap, contentDescription: String) : this(bitmap as Any, contentDescription)

@Composable
override fun Content(modifier: Modifier) {
super.Content(
modifier = modifier
.size(circleSize)
.size(40.dp)
.clip(CircleShape)
)
}
Expand Down

0 comments on commit 329ee24

Please sign in to comment.