-
Notifications
You must be signed in to change notification settings - Fork 315
Update AndroidStudioComposeSnippets.kt #752
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
base: main
Are you sure you want to change the base?
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello @ksdmyanmar-lighter, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request comments out the entirety of the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request comments out the entire content of AndroidStudioComposeSnippets.kt. If this code is no longer necessary, it would be better for maintainability to delete the file or its contents entirely, rather than leaving it as commented-out code. Version control can be used to retrieve the code if it's needed again in the future. If this is a temporary change, it would be helpful to add a comment explaining the reason.
| //package com.example.compose.snippets.tooling | ||
|
|
||
| //import androidx.compose.foundation.background | ||
| //import androidx.compose.foundation.layout.Box | ||
| //import androidx.compose.material3.MaterialTheme | ||
| //import androidx.compose.material3.Surface | ||
| //import androidx.compose.material3.Text | ||
| //import androidx.compose.runtime.Composable | ||
| //import androidx.compose.ui.Modifier | ||
| //import androidx.compose.ui.graphics.Color | ||
| //import androidx.compose.ui.platform.LocalInspectionMode | ||
| //import androidx.compose.ui.res.stringResource | ||
| //import androidx.compose.ui.tooling.preview.Preview | ||
| //import androidx.compose.ui.tooling.preview.PreviewParameter | ||
| //import androidx.compose.ui.tooling.preview.PreviewParameterProvider | ||
| //import com.example.compose.snippets.R | ||
|
|
||
| // [START android_compose_tooling_simple_composable] | ||
| @Composable | ||
| fun SimpleComposable() { | ||
| Text("Hello World") | ||
| //@Composable | ||
| //fun SimpleComposable() { | ||
| // Text("Hello World") | ||
| } | ||
| // [END android_compose_tooling_simple_composable] | ||
|
|
||
| // [START android_compose_tooling_simple_composable_preview] | ||
| @Preview | ||
| @Composable | ||
| fun SimpleComposablePreview() { | ||
| SimpleComposable() | ||
| //@Preview | ||
| //@Composable | ||
| //fun SimpleComposablePreview() { | ||
| // SimpleComposable() | ||
| } | ||
| // [END android_compose_tooling_simple_composable_preview] | ||
|
|
||
| // [START android_compose_tooling_local_inspection_mode] | ||
| @Composable | ||
| fun GreetingScreen(name: String) { | ||
| if (LocalInspectionMode.current) { | ||
| //@Composable | ||
| //fun GreetingScreen(name: String) { | ||
| // if (LocalInspectionMode.current) { | ||
| // Show this text in a preview window: | ||
| Text("Hello preview user!") | ||
| // Text("Hello preview user!") | ||
| } else { | ||
| // Show this text in the app: | ||
| Text("Hello $name!") | ||
| // Text("Hello $name!") | ||
| } | ||
| } | ||
| // [END android_compose_tooling_local_inspection_mode] | ||
|
|
||
| // [START android_compose_tooling_multipreview_annotations] | ||
| @Preview( | ||
| name = "small font", | ||
| group = "font scales", | ||
| fontScale = 0.5f | ||
| //@Preview( | ||
| // name = "small font", | ||
| // group = "font scales", | ||
| //fontScale = 0.5f | ||
| ) | ||
| @Preview( | ||
| name = "large font", | ||
| group = "font scales", | ||
| fontScale = 1.5f | ||
| //@Preview( | ||
| //name = "large font", | ||
| //group = "font scales", | ||
| //fontScale = 1.5f | ||
| ) | ||
| annotation class FontScalePreviews | ||
| //annotation class FontScalePreviews | ||
| // [END android_compose_tooling_multipreview_annotations] | ||
|
|
||
| // [START android_compose_tooling_multipreview_usage] | ||
| @FontScalePreviews | ||
| @Composable | ||
| fun HelloWorldPreview() { | ||
| Text("Hello World") | ||
| //@FontScalePreviews | ||
| //@Composable | ||
| //fun HelloWorldPreview() { | ||
| // Text("Hello World") | ||
| } | ||
| // [END android_compose_tooling_multipreview_usage] | ||
|
|
||
| // [START android_compose_tooling_multipreview_combine] | ||
| @Preview( | ||
| name = "Spanish", | ||
| group = "locale", | ||
| locale = "es" | ||
| //@Preview( | ||
| // name = "Spanish", | ||
| // group = "locale", | ||
| //locale = "es" | ||
| ) | ||
| @FontScalePreviews | ||
| annotation class CombinedPreviews | ||
| //@FontScalePreviews | ||
| //annotation class CombinedPreviews | ||
|
|
||
| @CombinedPreviews | ||
| @Composable | ||
| fun HelloWorldPreview2() { | ||
| MaterialTheme { Surface { Text(stringResource(R.string.hello_world)) } } | ||
| //@CombinedPreviews | ||
| //@Composable | ||
| //fun HelloWorldPreview2() { | ||
| // MaterialTheme { Surface { Text(stringResource(R.string.hello_world)) } } | ||
| } | ||
| // [END android_compose_tooling_multipreview_combine] | ||
|
|
||
| // [START android_compose_tooling_preview_bg_color] | ||
| @Preview(showBackground = true, backgroundColor = 0xFF00FF00) | ||
| @Composable | ||
| fun WithGreenBackground() { | ||
| Text("Hello World") | ||
| //@Preview(showBackground = true, backgroundColor = 0xFF00FF00) | ||
| //@Composable | ||
| //fun WithGreenBackground() { | ||
| // Text("Hello World") | ||
| } | ||
| // [END android_compose_tooling_preview_bg_color] | ||
|
|
||
| // [START android_compose_tooling_preview_dimens] | ||
| @Preview(widthDp = 50, heightDp = 50) | ||
| @Composable | ||
| fun SquareComposablePreview() { | ||
| Box(Modifier.background(Color.Yellow)) { | ||
| Text("Hello World") | ||
| //@Preview(widthDp = 50, heightDp = 50) | ||
| //@Composable | ||
| //fun SquareComposablePreview() { | ||
| // Box(Modifier.background(Color.Yellow)) { | ||
| // Text("Hello World") | ||
| } | ||
| } | ||
| // [END android_compose_tooling_preview_dimens] | ||
|
|
||
| // [START android_compose_tooling_preview_locale] | ||
| @Preview(locale = "fr-rFR") | ||
| @Composable | ||
| fun DifferentLocaleComposablePreview() { | ||
| Text(text = stringResource(R.string.greeting)) | ||
| //@Preview(locale = "fr-rFR") | ||
| //@Composable | ||
| //fun DifferentLocaleComposablePreview() { | ||
| // Text(text = stringResource(R.string.greeting)) | ||
| } | ||
| // [END android_compose_tooling_preview_locale] | ||
|
|
||
| // [START android_compose_tooling_preview_system_ui] | ||
| @Preview(showSystemUi = true) | ||
| @Composable | ||
| fun DecoratedComposablePreview() { | ||
| Text("Hello World") | ||
| //@Preview(showSystemUi = true)/ | ||
| //@Composable | ||
| //fun DecoratedComposablePreview() { | ||
| // Text("Hello World") | ||
| } | ||
| // [END android_compose_tooling_preview_system_ui] | ||
|
|
||
| // [START android_compose_tooling_preview_parameter_provider_composable] | ||
| @Preview | ||
| @Composable | ||
| fun UserProfilePreview( | ||
| @PreviewParameter(UserPreviewParameterProvider::class) user: User | ||
| ) { | ||
| UserProfile(user) | ||
| //@Preview | ||
| //@Composable | ||
| //fun UserProfilePreview( | ||
| // @PreviewParameter(UserPreviewParameterProvider::class) user: User | ||
| ) //{ | ||
| //UserProfile(user) | ||
| } | ||
|
|
||
| // [START_EXCLUDE silent] | ||
| @Composable | ||
| fun UserProfile(user: User) { | ||
| //@Composable | ||
| //fun UserProfile(user: User) { | ||
| } | ||
| // [END_EXCLUDE] | ||
| // [END android_compose_tooling_preview_parameter_provider_composable] | ||
|
|
||
| // [START android_compose_tooling_preview_parameter_provider] | ||
| class UserPreviewParameterProvider : PreviewParameterProvider<User> { | ||
| override val values = sequenceOf( | ||
| User("Elise"), | ||
| User("Frank"), | ||
| User("Julia") | ||
| //class UserPreviewParameterProvider : PreviewParameterProvider<User> { | ||
| // override val values = sequenceOf( | ||
| // User("Elise"), | ||
| // User("Frank"), | ||
| //User("Julia") | ||
| ) | ||
| } | ||
| // [END android_compose_tooling_preview_parameter_provider] | ||
|
|
||
| // [START android_compose_tooling_preview_parameter_provider_composable2] | ||
| @Preview | ||
| @Composable | ||
| fun UserProfilePreview2( | ||
| @PreviewParameter(UserPreviewParameterProvider::class, limit = 2) user: User | ||
| //@Preview | ||
| //@Composable | ||
| //fun UserProfilePreview2( | ||
| // @PreviewParameter(UserPreviewParameterProvider::class, limit = 2) user: User | ||
| ) { | ||
| UserProfile(user) | ||
| //UserProfile(user) | ||
| } | ||
| // [END android_compose_tooling_preview_parameter_provider_composable2] | ||
|
|
||
|
|
||
| // [START android_compose_tooling_preview_parameter_provider_composable3] | ||
| class UserAgePreviewParameterProvider : PreviewParameterProvider<User> { | ||
| //class UserAgePreviewParameterProvider : PreviewParameterProvider<User> { | ||
| // Using a List internally for efficient index-based access | ||
| private val userList = listOf( | ||
| User(name = "Elise", age = 30), | ||
| User(name = "Frank", age = 31), | ||
| User(name = "Julia", age = 40) | ||
| // private val userList = listOf( | ||
| // User(name = "Elise", age = 30), | ||
| // User(name = "Frank", age = 31), | ||
| //User(name = "Julia", age = 40) | ||
| ) | ||
|
|
||
| override val values = userList.asSequence() | ||
| // override val values = userList.asSequence() | ||
|
|
||
| override fun getDisplayName(index: Int): String? { | ||
| //override fun getDisplayName(index: Int): String? { | ||
| // Return null or an empty string to use the default index-based name | ||
| val user = userList.getOrNull(index) ?: return null | ||
| return "${user.name} - ${user.age}" | ||
| // val user = userList.getOrNull(index) ?: return null | ||
| //return "${user.name} - ${user.age}" | ||
| } | ||
| } | ||
| // [END android_compose_tooling_preview_parameter_provider_composable3] | ||
|
|
||
| // [START_EXCLUDE silent] | ||
| data class User(val name: String, val age: Int = 0) | ||
| //data class User(val name: String, val age: Int = 0) | ||
| // [END_EXCLUDE] |
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.
The entire content of this file has been commented out. If this code is no longer needed, it is best practice to delete it rather than commenting it out. This helps to keep the codebase clean and avoids confusion for other developers. Code history is preserved in version control, so it can be retrieved if necessary.
If there is a specific reason to temporarily disable this code, please add a comment explaining the context or document it in the pull request description.
No description provided.