package
com.example.newcanaryproject
import
android.app.Activity
import
android.content.Context
import
android.os.Bundle
import
android.webkit.WebSettings.TextSize
import
androidx.activity.ComponentActivity
import
androidx.activity.compose.setContent
import
androidx.compose.foundation.Image
import
androidx.compose.foundation.background
import
androidx.compose.foundation.layout.*
import
androidx.compose.foundation.shape.RoundedCornerShape
import
androidx.compose.material.*
import
androidx.compose.runtime.Composable
import
androidx.compose.ui.Alignment
import
androidx.compose.ui.Modifier
import
androidx.compose.ui.draw.BlurredEdgeTreatment
import
androidx.compose.ui.draw.blur
import
androidx.compose.ui.draw.clip
import
androidx.compose.ui.draw.drawWithContent
import
androidx.compose.ui.geometry.Offset
import
androidx.compose.ui.geometry.Rect
import
androidx.compose.ui.geometry.Size
import
androidx.compose.ui.graphics.*
import
androidx.compose.ui.layout.ContentScale
import
androidx.compose.ui.platform.LocalContext
import
androidx.compose.ui.res.painterResource
import
androidx.compose.ui.text.font.FontWeight
import
androidx.compose.ui.text.style.TextAlign
import
androidx.compose.ui.unit.Density
import
androidx.compose.ui.unit.LayoutDirection
import
androidx.compose.ui.unit.dp
import
androidx.compose.ui.unit.sp
import
androidx.core.content.ContextCompat
import
com.example.newcanaryproject.ui.theme.NewCanaryProjectTheme
import
com.example.newcanaryproject.ui.theme.greenColor
import
com.github.fernandodev.easyratingdialog.library.EasyRatingDialog
class
MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super
.onCreate(savedInstanceState)
setContent {
NewCanaryProjectTheme {
Surface(
modifier = Modifier.fillMaxSize(), color = MaterialTheme.colors.background
) {
Scaffold(
topBar = {
TopAppBar(backgroundColor = greenColor,
title = {
Text(
text =
"GFG"
,
modifier = Modifier.fillMaxWidth(),
textAlign = TextAlign.Center,
color = Color.White
)
})
}) {
mirrorImage(LocalContext.current)
}
}
}
}
}
}
@Composable
fun mirrorImage(context: Context) {
Column(
modifier = Modifier
.fillMaxHeight()
.fillMaxWidth()
.background(Color.White), horizontalAlignment = Alignment.CenterHorizontally
) {
Spacer(modifier = Modifier.height(
100
.dp))
Text(
text =
"Mirror in Android"
,
textAlign = TextAlign.Center,
color = greenColor,
fontWeight = FontWeight.Bold,
modifier = Modifier
.padding(
10
.dp)
.fillMaxWidth()
)
Spacer(modifier = Modifier.height(
40
.dp))
MirrorImage {
Image(
painterResource(id = R.drawable.android),
contentDescription =
"Android"
,
contentScale = ContentScale.Crop,
modifier = Modifier
.width(
200
.dp)
.height(
200
.dp)
.clip(
RoundedCornerShape(
24
.dp)
)
)
}
}
}
@Composable
fun MirrorImage(image:
@Composable
() -> Unit) {
Column {
image()
Box(modifier = Modifier
.graphicsLayer {
alpha =
0
.70f
rotationZ = 180f
}
.drawWithContent {
val colors = listOf(Color.White, Color.Transparent)
drawContent()
drawRect(
brush = Brush.verticalGradient(colors),
blendMode = BlendMode.DstIn
)
}
.blur(radiusX =
1
.dp, radiusY =
3
.dp, BlurredEdgeTreatment.Unbounded)
) {
image()
}
}
}