oday
12/16/2022, 2:33 PMModalBottomSheetLayout
before? I have another Composable placed inside its sheetContent
, to show as its content, and a primary Composable that will be shown as the rest of the page
when I come to test the main page, the Composable sitting inside the ModalBottomSheetLayout
as the primary thing to be shown in the page, and I check for the existence of some string (which also exists in the sheet WHEN it opens), Im getting that there’s 2 instances of that string, it’s reading the contents of the sheet without it having been opened yetOmkar Amberkar
12/16/2022, 6:12 PMPablo
12/16/2022, 7:55 PMzt
12/17/2022, 3:11 AMkotlinCompilerExtensionVersion
? Is there a way I can set it throughout my entire project?Ashish Gautam
12/17/2022, 7:33 AMCLOVIS
12/17/2022, 12:34 PMandroidx.compose.material3
doesn't have date/time pickers yet?abu naser
12/17/2022, 1:54 PMDavide Giuseppe Farella
12/17/2022, 4:43 PMstatusBarPadding
to the yellow box, but on the top bar, thus if the yellow box got removed, the top bar will be drawn behind the status barGioele Dev
12/18/2022, 9:29 AMv79
12/18/2022, 10:19 AMval
rather than var
! Compose developers: great, now let's wrap everything in mutableStateOf
to make everything mutable again...KotlinLeaner
12/18/2022, 12:00 PMdef composeBom = platform "androidx.compose:compose-bom:$compose_bom"
implementation composeBom
androidTestImplementation composeBom
I see in the gradle doc. Use of platform
is used in transitive version. So what the connection of platform
with BOM? Any guidance will be great..zt
12/18/2022, 9:04 PMxxfast
12/19/2022, 12:43 AMLargeTopAppBar
collapse when you scroll on the list view - but it doesn't seem to work. full code in the 🧵
val scrollState = rememberTopAppBarScrollState()
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(state = scrollState)
LargeTopAppBar(
modifier = Modifier.windowInsetsPadding(WindowInsets.statusBars),
..
scrollBehavior = scrollBehavior
)
chanjungskim
12/19/2022, 3:17 AMjava.lang.IllegalStateException: Vertically scrollable component was measured with an infinity maximum height constraints, which is disallowed. One of the common reasons is nesting layouts like LazyColumn and Column(Modifier.verticalScroll()). If you want to add a header before the list of items please add a header as a separate item() before the main items() inside the LazyColumn scope. There are could be other reasons for this to happen: your ComposeView was added into a LinearLayout with some weight, you applied Modifier.wrapContentSize(unbounded = true) or wrote a custom layout. Please try to remove the source of infinite constraints in the hierarchy above the scrolling container.
errorchanjungskim
12/19/2022, 3:18 AM@Composable
fun SupplementSearchScreen(
onSearch: (String) -> List<Vitamin>,
updateRecentAddedSupplementList: List<Vitamin>
) {
LazyColumn(
modifier = Modifier
.fillMaxSize()
) {
item{
SupplementSearchResultCard(someList)
}
}
}
@Composable
fun SupplementSearchScreen(list:List<SomeList>){
ContentCard(
modifier = Modifier.fillMaxWidth()
) {
Text(
text = "Hello World",
fontSize = 16.sp,
color = Color.Black
)
LazyColumn(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
) {
items(list){ resultItem ->
SearchResultItem(resultItem)
}
}
}
}
Zaki Shaikh
12/19/2022, 6:52 AMSharedFlow
or StateFlow
? cuurently I am using SharedFlow
.Hasan Nagizade
12/19/2022, 8:42 AMMathew xu
12/19/2022, 2:57 PMczuckie
12/19/2022, 4:00 PMOmkar Amberkar
12/19/2022, 5:01 PMSlackbot
12/19/2022, 9:09 PMmattinger
12/19/2022, 9:19 PMstart_onboarding
which reads the view model to get the device info.
2. Pass the selection in the route like start_onboarding/111111
which can get the device info from the view model, but the selected device is in the path.
I see option 2 as a little more flexible in that it keeps the viewModel quite a bit lighter and has some possibilities for proper deep linking. But option 1 is more uniform in that all state is stored in the view model instead of being split in two places.xxfast
12/19/2022, 10:02 PMmaterial3.Slider
?Travis Griggs
12/19/2022, 10:54 PMErlan Amanatov
12/20/2022, 6:53 AMmutableInteractionSource's
pressed state.
So simplified version of my composable looks like this
@Composable
fun Sbn(
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }
) {
val pressed by interactionSource.collectIsPressedAsState()
val target by rememberUpdatedState(newValue = if (pressed) Color.Red else Color.Green)
Box(
modifier = Modifier
.padding(24.dp)
.size(64.dp)
.background(color = target)
.clickable(
interactionSource = interactionSource,
indication = null,
onClick = {}
),
)
}
It works fine, but if I put it in a scrollable column, the pressed state works with some kind of delay. Any workarounds?
Video in threadTanuj Soni
12/20/2022, 8:01 AMElio Maroun
12/20/2022, 8:05 AM@Composable
fun DynamicSchedule(
viewModel: CalenderViewModel,
modifier: Modifier = Modifier,
appointmentContent: @Composable (appointment: Appointment) -> Unit = {
ScheduleCard(
appointment = it
)
},
minDate: LocalDate,
maxDate: LocalDate,
dayWidth: Dp,
hourHeight: Dp
) {
val numDays = ChronoUnit.DAYS.between(minDate, maxDate).toInt() + 1
val dividerColor = if (MaterialTheme.colors.isLight) Color.LightGray else Color.DarkGray
var offsetY by remember { mutableStateOf(0f) }
Layout(
content = {
viewModel.state.value.appointmentList.sortedBy { it.startDate }
.forEach { appointment ->
Box(modifier = Modifier.appointmentData(appointment)) {
appointmentContent(appointment)
}
}
},
modifier = modifier
.drawBehind {
repeat(23) {
drawLine(
dividerColor,
start = Offset(0f, (it + 1) * hourHeight.toPx()),
end = Offset(size.width, (it + 1) * hourHeight.toPx()),
strokeWidth = 1.dp.toPx()
)
}
repeat(numDays - 1) {
drawLine(
dividerColor,
start = Offset((it + 1) * dayWidth.toPx(), 0f),
end = Offset((it + 1) * dayWidth.toPx(), size.height),
strokeWidth = 1.dp.toPx()
)
}
}
.pointerInput(Unit) {
detectTapGestures {
val x = it.x.toDp()
val y = it.y.toDp()
val time = y.value.toInt() / hourHeight.value
val date = (x.value.toInt() / dayWidth.value)
println("X: $x, Y: $y")
println("Day: $date, Time: $time")
}
}
.draggable(
orientation = Orientation.Vertical,
state = rememberDraggableState { delta ->
offsetY += delta
println("Delta: $offsetY")
}
),
) { measurables, constraints ->
println("i got recomposed ======== ")
val height = hourHeight.roundToPx() * 24
val width = dayWidth.roundToPx() * numDays
val placeablesWithAppointment = measurables.map { measurable ->
val appointment = measurable.parentData as Appointment
val appointmentDurationInMinutes =
ChronoUnit.MINUTES.between(
appointment.startDate.time.toJavaLocalTime(),
appointment.endDate.time.toJavaLocalTime()
)
val appointmentHeight =
((appointmentDurationInMinutes / 60f) * hourHeight.toPx()).roundToInt()
val placeable = measurable.measure(
constraints.copy(
minWidth = dayWidth.roundToPx(),
maxWidth = dayWidth.roundToPx(),
minHeight = appointmentHeight,
maxHeight = appointmentHeight
)
)
Pair(placeable, appointment)
}
layout(width, height) {
placeablesWithAppointment.forEach { (placeable, appointment) ->
//appointment time - midnight
val appointmentOffsetMinutes =
ChronoUnit.MINUTES.between(
LocalTime.MIN,
appointment.startDate.time.toJavaLocalTime()
)
val appointmentY =
((appointmentOffsetMinutes / 60f) * hourHeight.toPx()).roundToInt()
val appointmentOffsetDays =
ChronoUnit.DAYS.between(
minDate,
appointment.startDate.date.toJavaLocalDate()
).toInt()
val appointmentX = appointmentOffsetDays * dayWidth.roundToPx()
placeable.place(appointmentX, appointmentY)
}
}
}
}
I have a custom schedule representing a weekview, how may I listen to drag events to change background color of that surface.v79
12/20/2022, 8:13 AMJasmin Fajkic
12/20/2022, 9:10 AMdazza5000
12/20/2022, 2:59 PMrequestFocus()
only works the first time it is called. Does anyone know how to work around this issue? https://stackoverflow.com/questions/74391260/jetpack-compose-requestfocus-works-only-oncedazza5000
12/20/2022, 2:59 PMrequestFocus()
only works the first time it is called. Does anyone know how to work around this issue? https://stackoverflow.com/questions/74391260/jetpack-compose-requestfocus-works-only-onceZach Klippenstein (he/him) [MOD]
12/22/2022, 12:37 AMdazza5000
12/22/2022, 4:57 PM'1.3.2'
Zach Klippenstein (he/him) [MOD]
12/22/2022, 6:47 PMdazza5000
12/22/2022, 7:36 PMclass MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
var error = remember { mutableStateOf("") }
var isError = remember { mutableStateOf(false) }
var value = remember { mutableStateOf(TextFieldValue("")) }
var focusRequester = remember { FocusRequester() }
MyApplicationTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
Column() {
OutlinedTextField(
value.value,
modifier = Modifier.semantics {
if (isError.value) liveRegion = LiveRegionMode.Polite
}.focusRequester(focusRequester),
onValueChange = {
value.value = it
},
isError = isError.value,
supportingText = {
if (isError.value) Text(text = error.value) else null
})
Button({
isError.value = !isError.value
error.value = if (isError.value) "we got errorz" else ""
}) {
Text("Button")
}
}
}
if (isError.value) focusRequester.requestFocus()
}
}
}
}
Zach Klippenstein (he/him) [MOD]
12/23/2022, 2:56 AM