<|start_filename|>app/src/main/java/com/vips/jetcapture/ui/theme/Color.kt<|end_filename|>
package com.vips.jetcapture.ui.theme

import androidx.compose.ui.graphics.Color

val Grey10 = Color(0xFFCFD8E6)
val Grey20 = Color(0xFFCFD8E6)
val Grey30 = Color(0xFFCFD8E6)
val Grey40 = Color(0xFF0B1522)
val Grey50 = Color(0xFF171C24)
val Blue10 = Color(0xFF083B8A)
val Grey = Color(0xFF9AA8B9)
val Blue = Color(0xFF252A30)

<|start_filename|>app/src/main/java/com/vips/jetcapture/uiComponents/customView/ProfileCardView.kt<|end_filename|>
package com.vips.jetcapture.uiComponents.customView

import android.content.Context
import android.util.AttributeSet
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.AbstractComposeView
import com.vips.jetcapture.uiComponents.ProfileCard
import com.vips.jetcapture.utils.ImageUtils
import com.vips.jetcapture.utils.ShareUtils

class ProfileCardView @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0
) : AbstractComposeView(context, attrs, defStyleAttr) {


    @Composable
    override fun Content() {
      ProfileCard()
    }

    fun capture(view: ProfileCardView) {
        val bitmap = ImageUtils.generateShareImage(view)
        ShareUtils.shareImageToOthers(context,"test", bitmap)
    }

}

<|start_filename|>app/src/main/java/com/vips/jetcapture/utils/ImageUtils.kt<|end_filename|>
package com.vips.jetcapture.utils

import android.graphics.Bitmap
import android.graphics.Canvas
import android.view.View

class ImageUtils {

    companion object{
        fun generateShareImage(view: View): Bitmap {
            val b = Bitmap.createBitmap(
                view.width,
                view.height,
                Bitmap.Config.ARGB_8888
            )
            val c = Canvas(b)
            view.layout(
                view.left,
                view.top,
                view.right,
                view.bottom
            )
            view.draw(c)
            return b
        }
    }
}

<|start_filename|>app/src/main/java/com/vips/jetcapture/uiComponents/ProfileCardComponents.kt<|end_filename|>
package com.vips.jetcapture.uiComponents

import androidx.compose.foundation.Image
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.CutCornerShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.BottomAppBar
import androidx.compose.material.Card
import androidx.compose.material.FloatingActionButton
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.vips.jetcapture.R
import com.vips.jetcapture.ui.theme.Blue
import com.vips.jetcapture.ui.theme.Grey
import com.vips.jetcapture.ui.theme.Grey30
import com.vips.jetcapture.ui.theme.appFontFamily

@Composable
fun ProfileCard() {
    Card(
        Modifier
            .fillMaxWidth()
            .wrapContentHeight()
            .padding(40.dp),
        shape = RoundedCornerShape(22.dp),
        elevation = 4.dp
    ) {
        Column(
            Modifier
                .wrapContentHeight()
                .fillMaxWidth()
                .padding(40.dp), horizontalAlignment = Alignment.CenterHorizontally
        ) {

            Spacer(modifier = Modifier.height(30.dp))

            Image(
                painter = painterResource(id = R.drawable.me),
                contentDescription = null,
                modifier = Modifier
                    .size(100.dp)
                    .shadow(
                        elevation = 20.dp,
                        shape = CircleShape,
                        clip = true
                    )
                    .clip(CircleShape)
            )

            Spacer(modifier = Modifier.height(10.dp))
            Text(
                text = stringResource(id = R.string.my_name), style = TextStyle(
                    fontFamily = appFontFamily,
                    fontWeight = FontWeight.Medium,
                    fontSize = 18.sp,
                    lineHeight = 20.sp
                )
            )

            Spacer(modifier = Modifier.height(8.dp))
            Text(
                text = "ANDROID ENGINEER", style = TextStyle(
                    fontFamily = appFontFamily,
                    fontWeight = FontWeight.Medium,
                    fontSize = 12.sp,
                    lineHeight = 20.sp
                ), color = Grey
            )

            Spacer(modifier = Modifier.height(20.dp))
            Text(
                text = "Works in", style = TextStyle(
                    fontFamily = appFontFamily,
                    fontWeight = FontWeight.Light,
                    fontSize = 12.sp,
                    lineHeight = 20.sp
                ), color = if(!isSystemInDarkTheme()) Blue else Grey30
            )

            Text(
                text = "Testbook.com", style = TextStyle(
                    fontFamily = appFontFamily,
                    fontWeight = FontWeight.Light,
                    fontSize = 12.sp,
                    lineHeight = 20.sp,
                    textDecoration = TextDecoration.Underline
                ), color  = if(!isSystemInDarkTheme()) Blue else Grey30
            )

            Spacer(modifier = Modifier.height(30.dp))
            Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
                Image(
                    painter = painterResource(id = R.drawable.twitter),
                    contentDescription = null,
                    modifier = Modifier
                        .size(20.dp)
                )

                Spacer(modifier = Modifier.width(10.dp))
                Image(
                    painter = painterResource(id = R.drawable.instagram),
                    contentDescription = null,
                    modifier = Modifier
                        .size(20.dp)
                )
                Spacer(modifier = Modifier.width(10.dp))
                Image(
                    painter = painterResource(id = R.drawable.facebook),
                    contentDescription = null,
                    modifier = Modifier
                        .size(20.dp)
                )
            }
            Spacer(modifier = Modifier.height(30.dp))
            Text(
                text = "Techie | Fitness freak | UI/UX lover | Blogger", style = TextStyle(
                    fontFamily = appFontFamily,
                    fontWeight = FontWeight.Medium,
                    fontSize = 10.sp,
                    lineHeight = 20.sp
                )
            )
        }
    }
}

@Preview
@Composable
fun Preview() {
    ProfileCard()
}




<|start_filename|>app/src/main/java/com/vips/jetcapture/MainActivity.kt<|end_filename|>
package com.vips.jetcapture

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.CutCornerShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.BottomAppBar
import androidx.compose.material.ExtendedFloatingActionButton
import androidx.compose.material.FabPosition
import androidx.compose.material.FloatingActionButton
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import com.vips.jetcapture.uiComponents.customView.ProfileCardView
import com.vips.jetcapture.ui.theme.JetCaptureTheme

class MainActivity : ComponentActivity() {

    private var jetCaptureView: MutableState<ProfileCardView>? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            JetCaptureTheme {
                BuildUI()
            }
        }
    }

    @Composable
    private fun BuildUI() {
        Surface(
            color = MaterialTheme.colors.primaryVariant,
            modifier = Modifier.fillMaxSize()
        ) {
            Scaffold(
                bottomBar = {
                    BottomAppBar(
                        elevation = 10.dp,
                        cutoutShape = RoundedCornerShape(18.dp),
                        backgroundColor = MaterialTheme.colors.secondary
                    ) {}
                },
                floatingActionButton = {
                    ExtendedFloatingActionButton({
                        Text(text = "Capture ProfileView", color = Color.White)},
                        onClick = { jetCaptureView?.value?.capture(jetCaptureView?.value as ProfileCardView) },
                        shape = RoundedCornerShape(18.dp),
                        icon = {
                            Image(
                                painter = painterResource(id = R.drawable.ic_baseline_camera_alt_24),
                                contentDescription = null
                            )
                        }
                    )
                },
                isFloatingActionButtonDocked = true,
                floatingActionButtonPosition = FabPosition.Center,
                backgroundColor = MaterialTheme.colors.primaryVariant
            ) {
                Box(modifier = Modifier.fillMaxSize()) {
                        ProfileUI()
                }
            }
        }
    }

    @Composable
    private fun ProfileUI() {
        jetCaptureView = remember { mutableStateOf(ProfileCardView(this@MainActivity)) }
        AndroidView(modifier = Modifier.wrapContentSize(),
            factory = {
                ProfileCardView(it).apply {
                    post {
                        jetCaptureView?.value = this
                    }
                }
            }
        )
    }
}

<|start_filename|>app/src/main/java/com/vips/jetcapture/ui/theme/Type.kt<|end_filename|>
package com.vips.jetcapture.ui.theme

import androidx.compose.material.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
import com.vips.jetcapture.R

val appFontFamily = FontFamily(
    Font(resId = R.font.gothambllack, weight = FontWeight.Normal),
    Font(resId = R.font.gothambold, weight = FontWeight.Medium),
    Font(resId = R.font.gothamlight, weight = FontWeight.Light),
)

val TitleDefault = TextStyle(
    fontFamily = appFontFamily,
    fontWeight = FontWeight.Medium,
    fontSize = 14.sp,
    lineHeight = 20.sp
)

val Typography = Typography(
    body1 = TextStyle(
        fontFamily = FontFamily.Default,
        fontWeight = FontWeight.Normal,
        fontSize = 16.sp
    ),

    subtitle1 = TitleDefault


)



<|start_filename|>app/src/main/java/com/vips/jetcapture/utils/ShareUtils.kt<|end_filename|>
package com.vips.jetcapture.utils

import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
import android.net.Uri
import androidx.core.content.FileProvider
import java.io.File
import java.io.FileOutputStream
import java.io.OutputStream
import java.lang.Exception

class ShareUtils {

    companion object{
        fun saveBitmapAndGetUri(context: Context, bitmap: Bitmap): Uri? {
            val path: String = context.externalCacheDir.toString() + "/testImg.jpg"
            var out: OutputStream? = null
            val file = File(path)
            try {
                out = FileOutputStream(file)
                bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out)
                out.flush()
                out.close()
            } catch (e: Exception) {
                e.printStackTrace()
            }
            return FileProvider.getUriForFile(
                context, context.packageName + ".com.vips.jetcapture.provider", file
            )
        }

        fun shareImageToOthers(context: Context, text: String?, bitmap: Bitmap?) {
            val imageUri: Uri? = bitmap?.let { saveBitmapAndGetUri(context, it) }
            val chooserIntent = Intent(Intent.ACTION_SEND)
            chooserIntent.type = "image/*"
            chooserIntent.putExtra(Intent.EXTRA_TEXT, text)
            chooserIntent.putExtra(Intent.EXTRA_STREAM, imageUri)
            chooserIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
            try {
                context.startActivity(chooserIntent)
            } catch (ex: Exception) {
            }
        }
    }
}