-
Notifications
You must be signed in to change notification settings - Fork 1.3k
KMT-879: Make org.jetbrains.compose.ui.tooling.preview.PreviewParameterProvider an actual implementation of androidx.compose.ui.tooling.preview.PreviewParameterProvider on Android (#5319)
#5323
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
Merged
Kpotko
merged 1 commit into
release/1.8
from
ilia.bogdanovich/KMT-879-preview-parameters-1.8
May 20, 2025
Merged
Conversation
This file contains hidden or 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
…terProvider` an actual implementation of `androidx.compose.ui.tooling.preview.PreviewParameterProvider` on Android (#5319) This is required for the preview parameters to be correctly picked up by the preview adapter in IDE, which expects the provider to be a subclass of AndroidX's interface, and fails with the `ClassCastException` otherwise. ## Release Notes ### Fixes - Multiple Platforms - Support Preview parameters for Previews in common source sets in IJ and AS. Note: IDEs also need to implement support on their end. Please check the respective IDE release notes to confirm this is supported. Example usage: ``` import androidx.compose.runtime.Composable import org.jetbrains.compose.ui.tooling.preview.Preview import org.jetbrains.compose.ui.tooling.preview.PreviewParameter import org.jetbrains.compose.ui.tooling.preview.PreviewParameterProvider class MyPreviewParameterProvider : PreviewParameterProvider<String> { override val values = sequenceOf("Hello, Compose!", "Hello, World!") } /** * This function will generate two preview images with different texts. */ @Preview @composable fun MyPreview(@PreviewParameter(MyPreviewParameterProvider::class) text: String) { Text(text) } ```
Kpotko
approved these changes
May 20, 2025
igordmn
added a commit
that referenced
this pull request
Jul 2, 2025
When the 1.8.2 release was prepared, the release notes from #5323 were malformed by stripping empty lines: ``` - Support Preview parameters for Previews in common source sets in IJ and AS. Note: IDEs also need to implement support on their end. Please check the respective IDE release notes to confirm this is supported [#5323](#5323) Example usage: \\\ import androidx.compose.runtime.Composable import org.jetbrains.compose.ui.tooling.preview.Preview import org.jetbrains.compose.ui.tooling.preview.PreviewParameter import org.jetbrains.compose.ui.tooling.preview.PreviewParameterProvider class MyPreviewParameterProvider : PreviewParameterProvider<String> { override val values = sequenceOf("Hello, Compose!", "Hello, World!") } /** * This function will generate two preview images with different texts */ @Preview @composable fun MyPreview(@PreviewParameter(MyPreviewParameterProvider::class) text: String) { Text(text) } \\\ ``` The correct release notes are: ``` - Support Preview parameters for Previews in common source sets in IJ and AS. Note: IDEs also need to implement support on their end. Please check the respective IDE release notes to confirm this is supported [#5323](#5323) Example usage: \\\ import androidx.compose.runtime.Composable import org.jetbrains.compose.ui.tooling.preview.Preview import org.jetbrains.compose.ui.tooling.preview.PreviewParameter import org.jetbrains.compose.ui.tooling.preview.PreviewParameterProvider class MyPreviewParameterProvider : PreviewParameterProvider<String> { override val values = sequenceOf("Hello, Compose!", "Hello, World!") } /** * This function will generate two preview images with different texts. */ @Preview @composable fun MyPreview(@PreviewParameter(MyPreviewParameterProvider::class) text: String) { Text(text) } \\\ ``` To fix this issue, the parsing is changed. Previously `ChangelogEntry` represented a single line, even if it is part of a single change. Now it represents the change as a whole. ## Testing These commands give the same result, with the exception that multiline release notes are handled correctly now: ``` kotlin changelog.main.kts v1.8.1..v1.9.0-alpha02 kotlin changelog.main.kts v1.8.1..v1.8.2 kotlin changelog.main.kts v1.8.0..v1.8.1 kotlin changelog.main.kts v1.8.0-beta02..v1.8.0-rc01 ``` ## Release Notes N/A
igordmn
added a commit
that referenced
this pull request
Jul 2, 2025
When the 1.8.2 release was prepared, the release notes from #5323 were malformed by stripping empty lines: ``` - Support Preview parameters for Previews in common source sets in IJ and AS. Note: IDEs also need to implement support on their end. Please check the respective IDE release notes to confirm this is supported [#5323](#5323) Example usage: \\\ import androidx.compose.runtime.Composable import org.jetbrains.compose.ui.tooling.preview.Preview import org.jetbrains.compose.ui.tooling.preview.PreviewParameter import org.jetbrains.compose.ui.tooling.preview.PreviewParameterProvider class MyPreviewParameterProvider : PreviewParameterProvider<String> { override val values = sequenceOf("Hello, Compose!", "Hello, World!") } /** * This function will generate two preview images with different texts */ @Preview @composable fun MyPreview(@PreviewParameter(MyPreviewParameterProvider::class) text: String) { Text(text) } \\\ ``` The correct release notes are: ``` - Support Preview parameters for Previews in common source sets in IJ and AS. Note: IDEs also need to implement support on their end. Please check the respective IDE release notes to confirm this is supported [#5323](#5323) Example usage: \\\ import androidx.compose.runtime.Composable import org.jetbrains.compose.ui.tooling.preview.Preview import org.jetbrains.compose.ui.tooling.preview.PreviewParameter import org.jetbrains.compose.ui.tooling.preview.PreviewParameterProvider class MyPreviewParameterProvider : PreviewParameterProvider<String> { override val values = sequenceOf("Hello, Compose!", "Hello, World!") } /** * This function will generate two preview images with different texts. */ @Preview @composable fun MyPreview(@PreviewParameter(MyPreviewParameterProvider::class) text: String) { Text(text) } \\\ ``` To fix this issue, the parsing is changed. Previously `ChangelogEntry` represented a single line, even if it is part of a single change. Now it represents the change as a whole. ## Testing These commands give the same result, with the exception that multiline release notes are handled correctly now: ``` kotlin changelog.main.kts v1.8.1..v1.9.0-alpha02 kotlin changelog.main.kts v1.8.1..v1.8.2 kotlin changelog.main.kts v1.8.0..v1.8.1 kotlin changelog.main.kts v1.8.0-beta02..v1.8.0-rc01 ``` ## Release Notes N/A
terrakok
pushed a commit
that referenced
this pull request
Jul 2, 2025
When the 1.8.2 release was prepared, the release notes from #5323 were malformed by stripping empty lines: ``` - Support Preview parameters for Previews in common source sets in IJ and AS. Note: IDEs also need to implement support on their end. Please check the respective IDE release notes to confirm this is supported [#5323](#5323) Example usage: \\\ import androidx.compose.runtime.Composable import org.jetbrains.compose.ui.tooling.preview.Preview import org.jetbrains.compose.ui.tooling.preview.PreviewParameter import org.jetbrains.compose.ui.tooling.preview.PreviewParameterProvider class MyPreviewParameterProvider : PreviewParameterProvider<String> { override val values = sequenceOf("Hello, Compose!", "Hello, World!") } /** * This function will generate two preview images with different texts */ @Preview @composable fun MyPreview(@PreviewParameter(MyPreviewParameterProvider::class) text: String) { Text(text) } \\\ ``` The correct release notes are: ``` - Support Preview parameters for Previews in common source sets in IJ and AS. Note: IDEs also need to implement support on their end. Please check the respective IDE release notes to confirm this is supported [#5323](#5323) Example usage: \\\ import androidx.compose.runtime.Composable import org.jetbrains.compose.ui.tooling.preview.Preview import org.jetbrains.compose.ui.tooling.preview.PreviewParameter import org.jetbrains.compose.ui.tooling.preview.PreviewParameterProvider class MyPreviewParameterProvider : PreviewParameterProvider<String> { override val values = sequenceOf("Hello, Compose!", "Hello, World!") } /** * This function will generate two preview images with different texts. */ @Preview @composable fun MyPreview(@PreviewParameter(MyPreviewParameterProvider::class) text: String) { Text(text) } \\\ ``` To fix this issue, the parsing is changed. Previously `ChangelogEntry` represented a single line, even if it is part of a single change. Now it represents the change as a whole. ## Testing These commands give the same result, with the exception that multiline release notes are handled correctly now: ``` kotlin changelog.main.kts v1.8.1..v1.9.0-alpha02 kotlin changelog.main.kts v1.8.1..v1.8.2 kotlin changelog.main.kts v1.8.0..v1.8.1 kotlin changelog.main.kts v1.8.0-beta02..v1.8.0-rc01 ``` ## Release Notes N/A
henryqwe
pushed a commit
to henryqwe/compose-multiplatform
that referenced
this pull request
Oct 1, 2025
When the 1.8.2 release was prepared, the release notes from JetBrains#5323 were malformed by stripping empty lines: ``` - Support Preview parameters for Previews in common source sets in IJ and AS. Note: IDEs also need to implement support on their end. Please check the respective IDE release notes to confirm this is supported [JetBrains#5323](JetBrains#5323) Example usage: \\\ import androidx.compose.runtime.Composable import org.jetbrains.compose.ui.tooling.preview.Preview import org.jetbrains.compose.ui.tooling.preview.PreviewParameter import org.jetbrains.compose.ui.tooling.preview.PreviewParameterProvider class MyPreviewParameterProvider : PreviewParameterProvider<String> { override val values = sequenceOf("Hello, Compose!", "Hello, World!") } /** * This function will generate two preview images with different texts */ @Preview @composable fun MyPreview(@PreviewParameter(MyPreviewParameterProvider::class) text: String) { Text(text) } \\\ ``` The correct release notes are: ``` - Support Preview parameters for Previews in common source sets in IJ and AS. Note: IDEs also need to implement support on their end. Please check the respective IDE release notes to confirm this is supported [JetBrains#5323](JetBrains#5323) Example usage: \\\ import androidx.compose.runtime.Composable import org.jetbrains.compose.ui.tooling.preview.Preview import org.jetbrains.compose.ui.tooling.preview.PreviewParameter import org.jetbrains.compose.ui.tooling.preview.PreviewParameterProvider class MyPreviewParameterProvider : PreviewParameterProvider<String> { override val values = sequenceOf("Hello, Compose!", "Hello, World!") } /** * This function will generate two preview images with different texts. */ @Preview @composable fun MyPreview(@PreviewParameter(MyPreviewParameterProvider::class) text: String) { Text(text) } \\\ ``` To fix this issue, the parsing is changed. Previously `ChangelogEntry` represented a single line, even if it is part of a single change. Now it represents the change as a whole. ## Testing These commands give the same result, with the exception that multiline release notes are handled correctly now: ``` kotlin changelog.main.kts v1.8.1..v1.9.0-alpha02 kotlin changelog.main.kts v1.8.1..v1.8.2 kotlin changelog.main.kts v1.8.0..v1.8.1 kotlin changelog.main.kts v1.8.0-beta02..v1.8.0-rc01 ``` ## Release Notes N/A
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is required for the preview parameters to be correctly picked up by the preview adapter in IDE, which expects the provider to be a subclass of AndroidX's interface, and fails with the
ClassCastExceptionotherwise.Fixes https://youtrack.jetbrains.com/issue/CMP-8220
Release Notes
Fixes - Multiple Platforms
Example usage:
Testing
Once https://youtrack.jetbrains.com/issue/KMT-879 is merged in IJ, this change can be tested on Nightly Builds (ETA tomorrow)