Nat Strangerweather
01/08/2021, 10:23 PM.observeAsState
. In my ViewModel I have this:
val dynamicCallSenderCode = MutableLiveData(0)
fun onSenderChanged (){
dynamicCallSenderCode.value = broadcastReceivers.notifyCallSenderCode(context)
}
What I want to do is observe the broadcast receiver changes from my HomePage but I can't use .observeAsState
with a function. How could I pass these changes live to my Composable?Kshitij Patil
01/09/2021, 9:26 AMArchie
01/09/2021, 10:31 AM@ExperimentalAnimationApi
@Composable
fun FillingIssues() {
val navController = rememberNavController()
val number by sampleFlow.collectAsState(initial = 0)
Scaffold(
topBar = {
// This recomposes just fine
// Gets 0, 1, 2, 3
Text(text = "Top Bar: $number")
}
) { padding ->
val modifier = Modifier.padding(padding)
NavHost(navController, startDestination = FIRST_SCREEN) {
myNavigation(modifier, number)
}
}
}
fun NavGraphBuilder.myNavigation(
modifier: Modifier,
number: Int,
) {
composable(FIRST_SCREEN) {
// This Doesn't recompose
// So it remains displaying
// Number: 0
// Even when 1, 2, 3 are emitted
// This only happens when I make it
// as an extension function
Column(
modifier.fillMaxSize(),
Arrangement.Center,
Alignment.CenterHorizontally
) {
Text("Number: $number")
}
}
}
val sampleFlow = flow {
emit(1)
delay(1000)
emit(2)
delay(3000)
emit(3)
}
private const val FIRST_SCREEN = "FIRST_SCREEN"
buszi0809
01/09/2021, 10:54 AMVsevolod Ganin
01/09/2021, 3:22 PMpointerInput
? It doesn’t react on lambda changes and always use only first served lambda. Below prints only pointerInput 2
and doesn’t print anything on switch toggle.
@Preview
@Composable
fun PointInputTest() {
var toggled: Boolean by remember { mutableStateOf(false) }
Column {
Switch(checked = toggled, onCheckedChange = { toggled = !toggled })
Box(
modifier = Modifier
.size(50.dp)
.background(Color.Red)
.run {
if (toggled) {
pointerInput {
println("pointerInput 1")
}
} else {
pointerInput {
println("pointerInput 2")
}
}
}
)
}
}
Bradleycorn
01/09/2021, 3:49 PMListAdapter
and DiffUtils.ItemCallback
to get automatic cool animations when items in our list change positions and are added/removed ... Is there a way to achieve this with LazyColumn?Bradleycorn
01/09/2021, 4:36 PMenum class Orientation {
HORIZONTAL,
VERTICAL
}
@Composable
fun OrientedContent(
orientation: Orientation,
modifier: Modifier = Modifier,
content: @Composable () -> Unit) = when (orientation) {
Orientation.HORIZONTAL -> Row(modifier = modifier) { content() }
Orientation.VERTICAL -> Column(modifier = modifier) { content () }
}
Nat Strangerweather
01/09/2021, 4:50 PMAyomide
01/09/2021, 8:24 PMmutableStateOf()
a mutable list of strings. I'm just using a forEach inside a column to display the items.
messageList.forEach {Text(it)}
However, I don't seem to see any updates on the screen when the list gets a new item (The list is updated via a coroutine scope fetching data from elsewhere). I put a println()
to debug, and the list definitely changes in size - so I think I must be doing something wrongDenis
01/10/2021, 7:55 AMval vm: MyViewModel = viewModel()
always retrieve the same ViewModel object in different composables but in the same activity?zsperske
01/10/2021, 7:13 PMFunction ColumnScope.weight(Float, Boolean) on Modifier will no longer be accessible after extraction
Is there a way around this?Rick Regan
01/10/2021, 10:23 PM@Composable
fun SliderTest() {
val sliderValue = remember { mutableStateOf(5f) }
Slider(
value = sliderValue.value,
onValueChange = {
Log.d("Slider onValueChange ", "$it")
sliderValue.value = it
},
modifier = Modifier.width(200.dp),
valueRange = 0f..10f,
)
}
The first message is always for the end value in valueRange, 10 in this example.
(I'm using Arctic Fox 2020.3.1 Canary 4, built on Dec 23, 2020.)Nana Vong
01/11/2021, 2:45 AMLilly
01/11/2021, 4:13 AMShakil Karim
01/11/2021, 7:23 AM--------------------- in ViewModel ----------------------------
val newsSelection : MutableStateFlow<HeadlinesPagingKey> = MutableStateFlow(
HeadlinesPagingKey())
@ExperimentalCoroutinesApi
val topHeadlines: Flow<PagingData<Article>> =
newsSelection.flatMapLatest {
newsRepository.topNewsHeadlines(it)
}.shareIn(viewModelScope, SharingStarted.Lazily,1)
---------------------and in Composable----------------------------
val lazyPagingItems: LazyPagingItems<Article> =
headlinesViewModel.topHeadlines.collectAsLazyPagingItems()
Piotr
01/11/2021, 3:43 PMLazyColumn() {
item {
box()
box()
box()
ScrollableTabRow()
}
itemsIndexed {...}
I need to know when the ScrollableTabRow moves past a certain position on y axis (for example lets say 100.dp )
I tried working with .scrollable()
(something like scrollable)
and with scroll gesture filter
(something like gesture)
and with dragGestureFilter
but i cannot get it to work, am i doing something wrong, or is it just not possible?tieskedh
01/11/2021, 3:53 PMalorma
01/11/2021, 4:45 PMalorma
01/11/2021, 4:46 PMDavid Albers
01/11/2021, 5:24 PMandroidx
libraries get bumped to alpha for the whole project. Anyone know what I’m doing wrong?grandstaish
01/11/2021, 5:37 PMKayacan Kaya
01/11/2021, 6:52 PMcodeslubber
01/11/2021, 9:07 PMVipulyaara
01/11/2021, 9:37 PMTextLayoutResult
before the text is actually drawn? I reduce my text size until the text fits the width of the screen using onTextLayout
(never thought it'd be that easy on Android) and it works fine but I'd like to do it in background without the user seeing the text get smaller.dagomni
01/12/2021, 11:19 AMBack-end (JVM) Internal error: Couldn't inline method call '<get-current>' into @androidx.compose.runtime.Composable
Cyril Find
01/12/2021, 11:42 AMcollectAsLazyPagingItems()
before declaring the NavHost
but it seems to me like I should be able to do it right before LazyColumn
Is there something I’m missing ? (I’ll share the code in the thread :thread-please: )Bryan Herbst
01/12/2021, 8:04 PMAmbientAutofillTree
note that Autofill semantics will be replacing some of the existing autofill APIs at some point, but reference an internal issue and the comment itself seems to be over a year old.
Is the plan still to leverage semantics for some of the autofill support?
Ref: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-master-dev:co[…]compose/ui/platform/Ambients.kt;l=58-65?q=AmbientAutofillTreeBradleycorn
01/12/2021, 9:18 PMDaniele B
01/12/2021, 9:19 PMLilly
01/13/2021, 3:01 AMtrailing
slot of a ListItem
but due to its default minWidth of 280 dp I can't make it smaller without side effects. When I set the with of the TextField
it behaves not like expected. The TextField will always fill a width of 280 dp no matter what width I apply. What options do I have here? Should I make an own version of TextField -> what basic composable would I use to build on?Lilly
01/13/2021, 3:01 AMtrailing
slot of a ListItem
but due to its default minWidth of 280 dp I can't make it smaller without side effects. When I set the with of the TextField
it behaves not like expected. The TextField will always fill a width of 280 dp no matter what width I apply. What options do I have here? Should I make an own version of TextField -> what basic composable would I use to build on?Siyamed
01/13/2021, 3:31 AMLilly
01/13/2021, 1:13 PMalorma
01/13/2021, 4:45 PMLilly
01/13/2021, 4:49 PMstring array
for the possible selectionsalorma
01/13/2021, 4:52 PMLilly
01/13/2021, 5:04 PMtrailingIcon
slot out of the slot and remove this slot. Then you make your TextField clickable
via the modifier. And in the clickable block you define the expanding logic. I have currently stress otherwise I would implement it for youSiyamed
01/13/2021, 5:29 PMprivate val TextFieldMinWidth = 280.dp
Anastasia [G]
01/13/2021, 5:37 PMLilly
01/13/2021, 5:37 PMSiyamed
01/13/2021, 5:37 PMLilly
01/13/2021, 5:37 PMSiyamed
01/13/2021, 5:38 PMAnastasia [G]
01/13/2021, 5:38 PMLilly
01/13/2021, 5:38 PMText
and Surface
?Siyamed
01/13/2021, 5:40 PMBasicTextField
Lilly
01/13/2021, 5:48 PM