Skip to content

Commit

Permalink
Add compose view in test to simulate compose stack trace.
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-powell committed Jan 30, 2023
1 parent 43ee3fa commit 97af19d
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repositories {
}

android {
namespace 'app.cash.paparazzi.plugin.test'
namespace 'app.cash.paparazzi.plugin.font'
compileSdk libs.versions.compileSdk.get() as int
defaultConfig {
minSdk libs.versions.minSdk.get() as int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@ android {
minSdk libs.versions.minSdk.get() as int
vectorDrawables.useSupportLibrary = true
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion libs.versions.composeCompiler.get()
}
}

dependencies {
implementation project(':fonts-module')
implementation libs.androidx.appcompat
implementation libs.composeUi.material
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package app.cash.paparazzi.plugin.test

import android.content.Context
import android.util.AttributeSet
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.size
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.AbstractComposeView
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.dp
import app.cash.paparazzi.plugin.font.R

class ComposeView(context: Context, attrs: AttributeSet) : AbstractComposeView(context, attrs) {

@Composable
override fun Content() {
val font = FontFamily(Font(R.font.cashmarket_medium))

Column {
Text(
text = "Compose: text with custom font",
fontFamily = font
)

Image(
modifier = Modifier.size(32.dp),
painter = painterResource(R.drawable.arrow_up),
contentDescription = "arrow up"
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,19 @@
android:textSize="32sp"
tools:ignore="HardcodedText"
/>
<app.cash.paparazzi.plugin.test.ComposeView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
/>
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_weight="1"
android:gravity="center"
android:src="@drawable/arrow_up"
/>

<androidx.appcompat.widget.AppCompatImageView
android:layout_width="48dp"
android:layout_height="48dp"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 97af19d

Please sign in to comment.