-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for CustomPreviewAnnotations in Showkase 🚿 🌈 (#303)
* Add processing functions in showkase processor to write to internal custom annotation and return components annotated by the annotation * Add support for crossmodule custom annotation Retrieving metadata from classpath * Add test for processing test for KSP * Add comment about autogenetated file for the showkaseCustomAnnotationMetadata file gen * Add supported custom annotation types to supported types * Add ShowkaseBrowser tests and processor test for CustomPreviewAnnotation cases * Add paparazzi test for custom preview annotation * Add processor test for Custom preview annotation with injected preview parameter * Fix detekt issue * Regenerate paparazzi pictures * Fix detekt issue * update ksp flag on running kapt ui test we are checking if the flag is present, not that it is true * Update paparazzi screenshots * Add scroll actions so ensure we are verifying the components With the custom annotation feature we are having a bit to many components for the test emulator. We need to scroll town the page in the test to ensure that the components that we are verifying are visible * Address review comments * Remove compiler args for custom previews This was done because we figured out that the metadata generation strategy works and this will give a better result to the enduser. * Address review comments * Remove redundant annotation check * Add Seccond sample submodule * Add showkase browser test submodule and multimodular tests * Regenerate screenshots to screenshot tests for new submodule * Add case for multi modular processing and make it work for KAPT * Update compiler args to be seperate args * Add missing compiler arg in test * Regenerate screenshot tests
- Loading branch information
Showing
126 changed files
with
1,673 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
plugins { | ||
id 'com.android.library' | ||
id 'kotlin-android' | ||
} | ||
|
||
if (project.hasProperty('useKsp')) { | ||
apply plugin: 'com.google.devtools.ksp' | ||
} else { | ||
apply plugin: 'kotlin-kapt' | ||
kapt { | ||
correctErrorTypes = true | ||
arguments { | ||
arg("multiPreviewType", "com.airbnb.android.submodule.showkasesample.FontPreview") | ||
} | ||
} | ||
} | ||
|
||
android { | ||
compileSdkVersion 32 | ||
|
||
defaultConfig { | ||
minSdkVersion 21 | ||
targetSdkVersion 32 | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_11 | ||
targetCompatibility JavaVersion.VERSION_11 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '11' | ||
} | ||
buildFeatures { | ||
compose true | ||
} | ||
composeOptions { | ||
kotlinCompilerVersion "${versions.kotlinCompilerVersion}" | ||
kotlinCompilerExtensionVersion "${versions.composeCompiler}" | ||
|
||
} | ||
// Added to avoid this error - | ||
// Execution failed for task ':app:mergeDebugAndroidTestJavaResource'. | ||
// > A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction | ||
// > 2 files found with path 'META-INF/AL2.0' from inputs: | ||
packagingOptions { | ||
exclude 'META-INF/AL2.0' | ||
exclude 'META-INF/LGPL2.1' | ||
} | ||
} | ||
|
||
dependencies { | ||
// Support Libraries | ||
implementation deps.support.appCompat | ||
implementation deps.support.ktx | ||
implementation deps.support.lifecycleExtensions | ||
|
||
// Showkase | ||
implementation project(':showkase') | ||
implementation project(':sample-submodule') | ||
|
||
if (project.hasProperty('useKsp')) { | ||
ksp project(':showkase-processor') | ||
} else { | ||
kapt project(':showkase-processor') | ||
} | ||
|
||
// Compose | ||
implementation deps.compose.activityCompose | ||
implementation deps.compose.composeRuntime | ||
implementation deps.compose.constraintLayout | ||
implementation deps.compose.core | ||
implementation deps.compose.foundation | ||
implementation deps.compose.tooling | ||
implementation deps.compose.layout | ||
implementation deps.compose.material | ||
implementation deps.compose.savedInstanceState | ||
implementation deps.compose.uiLiveData | ||
androidTestImplementation deps.compose.uiTest | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="com.airbnb.android.second.submodule"> | ||
|
||
</manifest> |
12 changes: 12 additions & 0 deletions
12
...le-submodule-2/src/main/java/com/airbnb/android/submodule/showkasesample/SamplePreview.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.airbnb.android.submodule.showkasesample | ||
|
||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
|
||
@FontPreview | ||
@Composable | ||
fun TextPreview() { | ||
Text( | ||
text = "Some Font Preview" | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="name">Sample Second Submodule</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
sample-submodule/src/main/java/com/airbnb/android/submodule/showkasesample/FontPreview.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.airbnb.android.submodule.showkasesample | ||
|
||
import androidx.compose.ui.tooling.preview.Preview | ||
|
||
@Preview(name = "Normal font size", group = "FontPreview", fontScale = 1f) | ||
annotation class FontPreview |
6 changes: 6 additions & 0 deletions
6
sample-submodule/src/main/java/com/airbnb/android/submodule/showkasesample/LocalePreview.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.airbnb.android.submodule.showkasesample | ||
|
||
import androidx.compose.ui.tooling.preview.Preview | ||
|
||
@Preview(name = "Norwegian", group = "LocalePreview", locale = "nb") | ||
annotation class LocalePreview |
9 changes: 9 additions & 0 deletions
9
sample-submodule/src/main/java/com/airbnb/android/submodule/showkasesample/Names.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.airbnb.android.submodule.showkasesample | ||
|
||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
|
||
@Composable | ||
fun TownNamesPreview() { | ||
Text(text = "New York") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-830 Bytes
(61%)
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+956 Bytes
(140%)
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.58 KB
(57%)
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-321 Bytes
(87%)
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.16 KB
(150%)
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-6.03 KB
(29%)
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-5.46 KB
(31%)
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.51 KB
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.94 KB
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.7 KB
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2.02 KB
(49%)
...howkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+418 Bytes
(130%)
...howkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.75 KB
(320%)
...howkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.81 KB
(42%)
...howkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-816 Bytes
(62%)
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.05 KB
(150%)
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.51 KB
(58%)
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-432 Bytes
(84%)
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.02 KB
(140%)
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-5.92 KB
(30%)
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-5.26 KB
(33%)
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.5 KB
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.84 KB
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.67 KB
...owkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2.09 KB
(48%)
...howkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+376 Bytes
(130%)
...howkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_7.png
Oops, something went wrong.
Binary file modified
BIN
+2.76 KB
(310%)
...howkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_8.png
Oops, something went wrong.
Binary file modified
BIN
-1.88 KB
(41%)
...howkasesample.MyScreenshotTest_ShowkaseCodegen_composable_screenshot_test_9.png
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
sample/src/main/java/com/airbnb/android/showkasesample/CustomShape.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.airbnb.android.showkasesample | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.airbnb.android.submodule.showkasesample.FontPreview | ||
|
||
@Preview(name = "Shape 100 by 100", group = "Shapes", widthDp = 100, heightDp = 100) | ||
@Preview(name = "Shape 150 by 150", group = "Shapes", widthDp = 150, heightDp = 150) | ||
annotation class CustomShape | ||
|
||
@CustomShape | ||
@Composable | ||
fun CustomRoundedBlueSquare() { | ||
Box(modifier = Modifier | ||
.size(40.dp) | ||
.background(Color.Blue) | ||
.clip(RoundedCornerShape(8.dp))) | ||
} | ||
|
||
@FontPreview | ||
@Composable | ||
fun CustomRoundedSquareWithText() { | ||
Box(Modifier.size(100.dp).clip(RoundedCornerShape(8.dp))) { | ||
Text("This is a rounded square!") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...c/main/java/com/airbnb/android/showkase/annotation/ShowkaseMultiPreviewCodegenMetadata.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.airbnb.android.showkase.annotation | ||
@Target(AnnotationTarget.FUNCTION) | ||
annotation class ShowkaseMultiPreviewCodegenMetadata( | ||
val previewName: String, | ||
val previewGroup: String, | ||
val supportTypeQualifiedName: String, | ||
val packageName: String, | ||
val showkaseWidth: Int, | ||
val showkaseHeight: Int, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Oops, something went wrong.