-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor RoborazziComposeConfigBuilder #590
Conversation
19832ae
to
31ac20b
Compare
The release note will be like this. Add support for heightDp, widthDp, showBackground, and backgroundColor of Compose Preview parametersWe have introduced Experimental Compose Preview Support in 1.22.0, but it does not yet support all parameters of the Introduce RoborazziComposeOptionsTo accommodate the changes in preview parameters, we’ve made the API more flexible. We’ve added the RoborazziComposeOptions parameter to ComposablePreview.captureRoboImage() and the composable function version, captureRoboImage{}. Previously, the API was limited; for example, you couldn’t access the ActivityScenario or the composable function directly. Now, you have full control over these components. Thank you for your code review @sergio-sastre Here’s an example of a custom option: captureRoboImage(
roborazziComposeOptions = RoborazziComposeOptions {
// We have several options to configure the test environment.
fontScale(2f)
// We can also configure the activity scenario and the composable content.
addOption(
object : RoborazziComposeComposableOption,
RoborazziComposeActivityScenarioOption {
override fun configureWithActivityScenario(scenario: ActivityScenario<out Activity>) {
scenario.onActivity {
it.window.decorView.setBackgroundColor(Color.BLUE)
}
}
override fun configureWithComposable(content: @Composable () -> Unit): @Composable () -> Unit {
return {
Box(Modifier
.padding(10.dp)
.background(color = androidx.compose.ui.graphics.Color.Red)
.padding(10.dp)
) {
content()
}
}
}
}
)
},
) {
Text("Hello Compose!")
} Breaking change: fun ComposablePreview.applyToRobolectricConfiguration()As part of our changes to how composables are set up, the applyToRobolectricConfiguration() function is now deprecated and error. Instead, you can use the following:
We believe this migration can be done smoothly. However, if you encounter any issues, please don’t hesitate to reach out. What's Changed
Full Changelog: 1.34.0...1.35.0 |
...anner-support/src/main/java/com/github/takahirom/roborazzi/RoborazziPreviewScannerSupport.kt
Outdated
Show resolved
Hide resolved
31ac20b
to
c212768
Compare
@@ -13,49 +13,52 @@ import sergio.sastre.composable.preview.scanner.core.preview.ComposablePreview | |||
fun ComposablePreview<AndroidPreviewInfo>.captureRoboImage( | |||
filePath: String, | |||
roborazziOptions: RoborazziOptions = provideRoborazziContext().options, | |||
configBuilder: RoborazziComposeConfigBuilder = this.toRoborazziComposeConfigBuilder() | |||
roborazziComposeOptions: RoborazziComposeOptions = this.toRoborazziComposeOptions() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sergio-sastre
Thank you for reviewing PRs. I was almost ready to release this, but while writing the release notes, I realized it might be a bit strange to pass a builder to the APIs. Additionally, the names RoborazziComposeConfig
and RoborazziComposeConfigBuilder
felt odd because RoborazziComposeConfig
is not actually created by RoborazziComposeConfigBuilder
.
I also think we don’t have a strong preference for using Config
over Options
, especially since we’re already using RoborazziOptions
. Therefore, I renamed it to RoborazziComposeOptions
.
I made some adjustments. Could you take a look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sergio-sastre This is going to block other tasks, so I'll merge this now. If you have any concerns, let me know. I think we can address them in a patch release.
7e2ac43
to
d451213
Compare
Snapshot diff report
|
d451213
to
7a4511d
Compare
No description provided.