Skip to content

Instantly share code, notes, and snippets.

View raipankaj's full-sized avatar

Pankaj Rai raipankaj

View GitHub Profile
@raipankaj
raipankaj / mirror.kt
Created June 10, 2022 07:37
Mirror effect Jetpack Compose
@Composable
fun Mirror(content: @Composable () -> Unit) {
Column {
content()
Box(modifier = Modifier
.graphicsLayer {
alpha = 0.99f
rotationZ = 180f
}
.drawWithContent {
@raipankaj
raipankaj / review.kt
Created May 17, 2022 14:17
Adding in-app review flow in composable
val reviewManager = remember {
ReviewManagerFactory.create(localContext)
}
val reviewInfo = rememberReviewTask(reviewManager)
LaunchedEffect(key1 = reviewInfo) {
reviewInfo?.let {
reviewManager.launchReviewFlow(localContext as Activity, reviewInfo)
}
@raipankaj
raipankaj / InAppTrigger.kt
Created May 17, 2022 14:14
Trigger In App flow
LaunchedEffect(key1 = reviewInfo) {
reviewInfo?.let {
reviewManager.launchReviewFlow(localContext as Activity, reviewInfo)
}
}
@raipankaj
raipankaj / ReviewInfo.kt
Created May 17, 2022 14:10
remember block creation
@Composable
fun rememberReviewTask(reviewManager: ReviewManager): ReviewInfo? {
var reviewInfo: ReviewInfo? by remember {
mutableStateOf(null)
}
reviewManager.requestReviewFlow().addOnCompleteListener {
if (it.isSuccessful) {
reviewInfo = it.result
}
}
@raipankaj
raipankaj / ReviewManager.kt
Created May 17, 2022 14:07
In-App review - Review Manager
val localContext = LocalContext.current
val reviewManager = remember {
ReviewManagerFactory.create(localContext)
}
@raipankaj
raipankaj / reviewlistener.kt
Created May 17, 2022 14:06
In-App review - ReviewInfo object
reviewManager.requestReviewFlow().addOnCompleteListener {
if (it.isSuccessful) {
reviewInfo = it.result
}
}
@raipankaj
raipankaj / build.gradle
Created April 18, 2022 05:35
Downloadable font lib
implementation "androidx.compose.ui:ui-text-google-fonts:1.2.0-alpha07"
@raipankaj
raipankaj / font_certs.xml
Created April 18, 2022 05:19
Certificate for downloadable font
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="com_google_android_gms_fonts_certs">
<item>@array/com_google_android_gms_fonts_certs_dev</item>
<item>@array/com_google_android_gms_fonts_certs_prod</item>
</array>
<string-array name="com_google_android_gms_fonts_certs_dev">
<item>
MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAeFw0wODA0MTUyMzM2NTZaFw0zNTA5MDEyMzM2NTZaMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBANbOLggKv+IxTdGNs8/TGFy0PTP6DHThvbbR24kT9ixcOd9W+EaBPWW+wPPKQmsHxajtWjmQwWfna8mZuSeJS48LIgAZlKkpFeVyxW0qMBujb8X8ETrWy550NaFtI6t9+u7hZeTfHwq
@raipankaj
raipankaj / Type.kt
Created April 18, 2022 05:17
Download font support in Jetpack Compose
@OptIn(ExperimentalTextApi::class)
private fun getGoogleFontFamily(
name: String,
provider: GoogleFont.Provider = googleFontProvider,
weights: List<FontWeight>
): FontFamily {
return FontFamily(
weights.map {
Font(GoogleFont(name), provider, it)
@raipankaj
raipankaj / Type.kt
Created April 18, 2022 05:14
Google provider for downloading font
@OptIn(ExperimentalTextApi::class)
private val googleFontProvider: GoogleFont.Provider by lazy {
GoogleFont.Provider(
providerAuthority = "com.google.android.gms.fonts",
providerPackage = "com.google.android.gms",
certificates = R.array.com_google_android_gms_fonts_certs
)
}