android / snippets Goto Github PK
View Code? Open in Web Editor NEWMain repository for snippets surfaced on developer.android.com.
License: Apache License 2.0
Main repository for snippets surfaced on developer.android.com.
License: Apache License 2.0
When running the SampleListDetailPaneScaffoldFull
sample on a small screen, clicking on a list item, and then pressing back exits the app.
This should instead return back to the list.
In this snippet and the documentation mentioned to use the addOnUserLeaveHintListener
to register a listener for user leave action of the activity but I have not found such a method. I am using the latest version of androidx.activity:activity
which is 1.8.2
.
The latest couple of commits on main
has CLA issues from @compose-devrel-github-bot. Opening this to track addressing this issue
The colour variables in the snippet:
(LightBlue and Purple) should be part of the gradient depicted here:
https://developer.android.com/jetpack/compose/text/style-text#use-brush
Instead, they're both "LightBlue", same hexvalue.
@Preview
@Composable
fun AnimatedVisibilityCookbook() {
var visible1 by remember {
mutableStateOf(true)
}
var visible2 by remember {
mutableStateOf(true)
}
Row(
modifier = Modifier.padding(top = 20.dp).fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(6.dp)
) {
Button(
modifier = Modifier,
onClick = {
visible1 = !visible1
},
shape = RoundedCornerShape(6.dp),
colors = ButtonDefaults.buttonColors(containerColor = Color.White),
contentPadding = PaddingValues(horizontal = 8.dp)
) {
Text(
text = "text",
color = Color.Black,
textAlign = TextAlign.Center
)
}
AnimatedVisibility(
modifier = Modifier.weight(1f),
visible = visible1
) {
Button(
modifier = Modifier,
onClick = { },
shape = RoundedCornerShape(6.dp),
colors = ButtonDefaults.buttonColors(containerColor = Color.White),
contentPadding = PaddingValues(horizontal = 8.dp)
) {
Text(
text = "text1",
color = Color.Black,
textAlign = TextAlign.Center
)
}
}
AnimatedVisibility(
modifier = Modifier.weight(1f),
visible = visible2
) {
Button(
modifier = Modifier,
onClick = { },
shape = RoundedCornerShape(6.dp),
colors = ButtonDefaults.buttonColors(containerColor = Color.White),
contentPadding = PaddingValues(horizontal = 8.dp)
) {
Text(
text = "text2",
color = Color.Black,
textAlign = TextAlign.Center
)
}
}
}
}
File: com.example.compose.snippets.layouts.ConstraintLayoutSnippets.kt
fun DecoupledConstraintLayout() {
BoxWithConstraints {
val constraints = if (minWidth < 600.dp) {
decoupledConstraints(margin = 16.dp) // Portrait constraints
} else {
decoupledConstraints(margin = 32.dp) // Landscape constraints
}
Variable minWidth
should be maxWidth
Would be great to update the Compose samples to use the Compose BOM. See android/user-interface-samples#399 for an example of how to do such a migration.
So that we can run the build
workflow on the entire project.
Context: #18
https://github.com/android/snippets/actions/runs/5320511077/jobs/9634382032
:bluetoothle:lintDebug FAILED
snippet-bot full scan
Life is too short to manually check unmatched region tags.
Here is the result:
Great job! No unmatching region tags found!
Report generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
Running ./gradlew :compose:snippets:lintDebug
and ConstraintLayout
snippets throw the following error:
Github/snippets/compose/snippets/src/main/java/com/example/compose/snippets/layouts/ConstraintLayoutSnippets.kt: Error: Unexpected failure during lint analysis of ConstraintLayoutSnippets.kt (this is a bug in lint or one of the libraries it depends on)
Running with --stacktrace, gives the following error:
java.lang.AbstractMethodError: Method androidx/constraintlayout/compose/lint/ConstraintLayoutDslDetectorKt$findChildIdentifier$1.afterVisitSimpleNameReferenceExpression(Lorg/jetbrains/uast/USimpleNameReferenceExpression;)V is abstract
at androidx.constraintlayout.compose.lint.ConstraintLayoutDslDetectorKt$findChildIdentifier$1.afterVisitSimpleNameReferenceExpression(ConstraintLayoutDslDetector.kt)
at org.jetbrains.uast.kotlin.KotlinUSimpleReferenceExpression.accept(KotlinUSimpleReferenceExpression.kt:47)
at androidx.constraintlayout.compose.lint.ConstraintLayoutDslDetectorKt.findChildIdentifier(ConstraintLayoutDslDetector.kt:732)
at androidx.constraintlayout.compose.lint.ConstraintLayoutDslDetector$createUastHandler$1.detectChainParamsUsage(ConstraintLayoutDslDetector.kt:338)
at androidx.constraintlayout.compose.lint.ConstraintLayoutDslDetector$createUastHandler$1.visitCallExpression(ConstraintLayoutDslDetector.kt:145)
at com.android.tools.lint.client.api.UElementVisitor$DispatchPsiVisitor.visitCallExpression(UElementVisitor.kt:523)
at com.android.tools.lint.client.api.UElementVisitor$DelegatingPsiVisitor.visitCallExpression(UElementVisitor.kt:1071)
at org.jetbrains.uast.kotlin.KotlinUFunctionCallExpression.accept(KotlinUFunctionCallExpression.kt:165)
at org.jetbrains.uast.kotlin.KotlinULocalVariable.accept(KotlinULocalVariable.kt:46)
at org.jetbrains.uast.internal.ImplementationUtilsKt.acceptList(implementationUtils.kt:15)
at org.jetbrains.uast.UDeclarationsExpression$DefaultImpls.accept(UDeclarationsExpression.kt:22)
at org.jetbrains.uast.kotlin.KotlinUDeclarationsExpression.accept(KotlinUDeclarationsExpression.kt:10)
at org.jetbrains.uast.internal.ImplementationUtilsKt.acceptList(implementationUtils.kt:15)
at org.jetbrains.uast.UBlockExpression$DefaultImpls.accept(UBlockExpression.kt:21)
Edit: I get why it's made this way, I just don't think it's ideal for a snippet in the docs
How to Implement a Timer Scheme with GlanceAppWidget
Some GitHub actions fail when PRs are created from a forked repo. This prevents external contributors from making contributions to the repo. I wasn't able to fix the issue after several attempts (see fdc1b8e and 0d296b9) which only partly fixed the issue. I'm filing this to track that we still need to make changes to our GH actions to unblock external contributions.
See #198 as an example.
This is supposed to be an Optimal implementation but the comment says otherwise.
Thanks.
Fellows,
I was trying to follow this example:
https://developer.android.com/develop/ui/compose/components/snackbar
But I cannot find how to enable both options like in the image:
I want to have the X to dismiss and the action. Is it possible? Or is the image wrong? Since I cannot find the way to enable it. Thanks.
snippets/.github/workflows/build.yml
Lines 31 to 34 in 87948ac
The checkout build step uses a secret PAT, which forks don't have access to, so the build step immediately fails for any PRs opened from a fork.
Example PR: #178
Only detectDragGestures was works
Line 1 in 0c7be2b
This causes the color on the bottom to leak out from the edges.
anunenkianka4 sizi CATA CT-4050 SMART HOME CAMERA kullanmaya davet ediyor. https://m-eu.smart321.com/EUpdhNZroneOyzoG
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.