Skip to content

Instantly share code, notes, and snippets.

View vinaygaba's full-sized avatar
🚀

Vinay Gaba vinaygaba

🚀
View GitHub Profile
@vinaygaba
vinaygaba / RecomposeHighlighter.kt
Created June 26, 2022 01:26
Modifier to highlight recompositions happening on a Composable. Full credit to Google for creating this Modifier. Original link - https://github.com/android/snippets/blob/master/compose/recomposehighlighter/src/main/java/com/example/android/compose/recomposehighlighter/RecomposeHighlighter.kt
/*
* Copyright 2022 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@vinaygaba
vinaygaba / codeInsightSettings.xml
Last active October 12, 2022 01:14
Configuration setting that makes Jetpack Compose development more efficient by removing the noise from auto complete. More information in this article - https://www.jetpackcompose.app/articles/productivity-hack-to-save-tens-of-engineering-hours-when-working-with-Jetpack-Compose
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaProjectCodeInsightSettings">
<excluded-names>
<name>android.app.LauncherActivity.ListItem</name>
<name>android.graphics.drawable.Icon</name>
<name>android.graphics.fonts.FontFamily</name>
<name>android.inputmethodservice.Keyboard.Row</name>
<name>android.text.layout.Alignment</name>
<name>android.widget.GridLayout.Alignment</name>
@vinaygaba
vinaygaba / LogCompositions.kt
Created May 22, 2022 23:11
Useful for printing log statements when a composable function is being recomposed
// Full credit for this snippet goes to Sean McQuillan - https://twitter.com/objcode
class Ref(var value: Int)
// Note the inline function below which ensures that this function is essentially
// copied at the call site to ensure that its logging only recompositions from the
// original call site.
@Composable
inline fun LogCompositions(tag: String, msg: String) {
if (BuildConfig.DEBUG) {
@vinaygaba
vinaygaba / StartShowkase.kt
Created December 21, 2020 20:21
Start Showkase Activity
context.startActivity(createShowkaseBrowserIntent(context))
@vinaygaba
vinaygaba / ShowkaseRootModule.kt
Created December 21, 2020 20:18
Usage of ShowkaseRootModule
@ShowkaseRoot
class MyRootModule: ShowkaseRootModule
@vinaygaba
vinaygaba / ShowkaseTypography.kt
Last active December 21, 2020 20:17
Usage of @ShowkaseTypography
@ShowkaseTypography(
name = "Custom name for text style", 
group = "Custom group name"
val h1 = TextStyle(fontWeight = FontWeight.Light, fontSize = 96.sp)
@vinaygaba
vinaygaba / ShowkaseColor.kt
Created December 21, 2020 20:16
Usage of @ShowkaseColor
@ShowkaseColor(
name = "Primary Color",
group = "Material Design"
val primaryColor = Color(0xFF6200EE)
@vinaygaba
vinaygaba / ShowkaseComposable.kt
Last active December 21, 2020 20:15
Usage of @ShowkaseComposable
@ShowkaseComposable(
name = "Custom name for component", 
group = "Custom group name"
@Composable 
fun MyComponent() { … }
@vinaygaba
vinaygaba / ShowkasePreview.kt
Created December 21, 2020 20:14
Showkase usage with @Preview
@Preview(
name = "Custom name for component", 
group = "Custom group name"
@Composable 
fun MyComponent() { … }
@vinaygaba
vinaygaba / build.gradle
Created December 21, 2020 20:09
Showkase build.gradle
implementation "com.airbnb.android:showkase:1.0.0-alpha04"
kapt "com.airbnb.android:showkase-processor:1.0.0-alpha04"