Oussama Haff.
10/14/2020, 7:26 AMonRoot().printToLog()
for tests, but I can’t find the equivalent for a running app.Christian
10/14/2020, 8:02 AMend
? basically, cursor starts from the right using BaseTextField
Denis Sakhapov
10/14/2020, 8:07 AMBox
?Philip Blandford
10/14/2020, 9:46 AMConstraintLayout(Modifier.fillMaxSize()) {
val (box1, box2) = createRefs()
Box(Modifier.constrainAs(box1){
top.linkTo(parent.top); bottom.linkTo(box2.top)
}.background(Color.Red).fillMaxSize())
Box(Modifier.constrainAs(box2){
bottom.linkTo(parent.bottom); centerHorizontallyTo(parent)
}.size(200.dp,50.dp).background(Color.Green))
}
Hitanshu Dhawan
10/14/2020, 12:42 PMMaterialTheme.sizes.medium
And we can specify sizes like small, medium, large (similar to shapes).Rodri Represa
10/14/2020, 1:46 PMConstraintLayout
in base of a mutableStateOf<Boolean>
?
If the mutable value change, my component will have others constrains..Adriano Celentano
10/14/2020, 2:33 PM@Composable
fun TodoItemInput(onItemComplete: (TodoItem) -> Unit) {
// onItemComplete is an event will fire when an item is completed by the user
Column {
Row(Modifier
.padding(horizontal = 16.dp)
.padding(top = 16.dp)
) {
TodoInputTextField(Modifier
.weight(1f)
.padding(end = 8.dp)
)
TodoEditButton(
onClick = { /* todo */ },
text = "Add",
modifier = Modifier.align(Alignment.CenterVertically)
)
}
}
}
my app does not compile anymore
w: ATTENTION!
This build uses unsafe internal compiler arguments:
-XXLanguage:+NonParenthesizedAnnotationsOnFunctionalTypes
This mode is not recommended for production use,
as no stability/compatibility guarantees are given on
compiler or generated code. Use it at your own risk!
e: warnings found and -Werror specified
w: /Users/adrian/Workspace/Android/android-compose-codelabs-main/StateCodelab/start/src/main/java/com/codelabs/state/todo/TodoScreen.kt: (84, 19): Parameter 'onItemComplete' is never used
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':start:compileDebugKotlin'.
> Compilation error. See log for more details
tcracknell
10/14/2020, 5:12 PMGavin
10/14/2020, 10:56 PMTextField
and related components.
I couldn't find a way to filter between an onFocus/blur event vs actual typing/keyboard actions. The onValueChange
handler is firing when I click in and out of the TextField and causes some un-wanted side effects. Am I missing something or is there currently a way (or a way around) to only account for keyboard actions and ignore focus/blur actions?Chethan
10/15/2020, 3:46 AMManuel Vivo
10/15/2020, 9:49 AMalpha05
😄 Happy Composing!
For the lazy:
https://goo.gle/compose-samples
https://goo.gle/compose-pathwaydarkmoon_uk
10/15/2020, 10:11 AMCiprian Grigor
10/15/2020, 3:25 PMVinay Gaba
10/15/2020, 3:49 PMlaunchInComposition
got renamed to LaunchedTask
. Eerily close to AsyncTask
in name and functionally (not entirely true) 😆Apoorv Patel
10/15/2020, 4:40 PMConstraintLayout
but i am not able to get the constraints to work properly.
ConstraintLayout(modifier = Modifier.padding(top = 16.dp, bottom = 16.dp)) {
val (profileImage, progressText1) = createRefs()
Image(
modifier = Modifier
.constrainAs(profileImage){
start.linkTo(parent.start, 16.dp)
}.preferredWidth(72.dp)
.preferredHeight(72.dp)
.background(Color.Green),
asset = imageResource(R.drawable.unknown_profile_empty)
)
val half = createGuidelineFromTop(0.5f)
Text(text = "Sample text", modifier = Modifier.background(Color.Red).constrainAs(progressText1) {
bottom.linkTo(half, 0.dp)
start.linkTo(profileImage.end, 0.dp)
end.linkTo(parent.end, 16.dp)
})
}
I am expecting that the text will align itself to the image end but it is not aligned to thatallan.conda
10/15/2020, 5:15 PMColumn(
Modifier.wrapContentHeight().aspectRatio(1f)
) {
Icon(asset, Modifier.size(24.dp))
Text("Action")
}
We expected this to be a square component; Why is Column expanding to the size of its parent?
We figured to just use a fixed size to simplify things, I’m just curious why this wasn’t working. And I’m looking to know a solution for this in case we really need more dynamic sizing.Devesh Sanghvi
10/15/2020, 11:27 PMFabio
10/15/2020, 11:29 PMFabio
10/16/2020, 2:25 AMMahdi
10/16/2020, 2:53 AMobserveAsState
It is very odd that after update liveData compose ui update is not happening, but on some events ( click on items) I can see that model is updated! Is it better way to have handle items state outside compose? Thanksallan.conda
10/16/2020, 2:57 AM@Immutable
and read this bit:
And then looked at compose-samplesclasses that only containdata
properties that do not have custom getters can safely be marked as Immutable if the types of properties are either primitive types or also Immutable:val
@Immutable
data class Episode(
@PrimaryKey @ColumnInfo(name = "uri") val uri: String,
@ColumnInfo(name = "podcast_uri") val podcastUri: String,
@ColumnInfo(name = "title") val title: String,
@ColumnInfo(name = "subtitle") val subtitle: String? = null,
@ColumnInfo(name = "summary") val summary: String? = null,
@ColumnInfo(name = "author") val author: String? = null,
@ColumnInfo(name = "published") val published: OffsetDateTime,
@ColumnInfo(name = "duration") val duration: Duration? = null
)
I have data classes with Date
. Anyway it should still be safe to annotate as long as I’m sure it doesn’t get changed right?
Also, I have states with single-time events:
data class Event<out T>(val content: T) {
var consumed: Boolean = false
private set
fun consume(): T? =
if (consumed) {
null
} else {
consumed = true
content
}
}
I guess I can’t use `@Immutable`for such state classes…popalay
10/16/2020, 5:25 AMfabio.carballo
10/16/2020, 8:29 AMComponent
to use to just represent the background
?
I understand the in MaterialTheme the Surface
has a similar goal, but it takes by default the surfaceColor
. In my case where I want the same practical use but so that the background color is always backgroundColor
. From looking at usages, it seems only Scaffold
actually uses this color, but internally still uses a Surface
and changes the background color.Javier
10/16/2020, 9:20 AMMikael Alfredsson
10/16/2020, 1:05 PM@Composable
fun versionText(){
val versionName = packageManager.getPackageInfo(packageName, 0).versionName
Text(text = versionName)
}
either this is the completely wrong way to do something like this, or I need some way to know if this composable is currently running in a preview, since the preview engine will not really show anything here (I think it even crashes silently somewhere)alexandrepiveteau
10/16/2020, 1:20 PMLinearGradient
to a Text()
composable ? I’ve looked a bit into the docs, but can only find usages of solid colors for text.Ian Lake
10/16/2020, 3:18 PM/ui/
part of your snapshot build URL should be removed and the URL should be in the format:
maven { url '<https://androidx.dev/snapshots/builds/[buildId]/artifacts/repository>' }
Ian Lake
10/16/2020, 3:23 PMandroidx.navigation:navigation-compose:1.0.0-SNAPSHOT
(using build IDs of 6910220 or higher - make sure to switch to the new snapshot URL format ^). Working towards the first alpha 🙂bryansills
10/16/2020, 4:02 PM@Composable
fun BasicNav() {
var isLoggedIn by remember { mutableStateOf(false) }
NavHost(startDestination = "Profile") {
composable("Profile") { Profile(isLoggedIn) { isLoggedIn = !isLoggedIn } }
composable("Dashboard") { Dashboard() }
if (isLoggedIn) {
composable("Scrollable") { Scrollable() }
}
}
}
(the lambda passed into Profile()
) is just connected to a Button
to toggle the logged in statedmnk_89
10/16/2020, 4:30 PMOutlinedTextField
non editable? So that it like gray and doesn't show keyboard when focused.dmnk_89
10/16/2020, 4:30 PMOutlinedTextField
non editable? So that it like gray and doesn't show keyboard when focused.Siyamed
10/16/2020, 4:39 PMZach Klippenstein (he/him) [MOD]
10/16/2020, 4:50 PMdmnk_89
10/16/2020, 5:04 PM