Ahmet Delibaş
03/04/2021, 8:15 PMMarko Novakovic
03/04/2021, 9:25 PMOwl
on my own to practice Compose
. I have problem with BottomNavigation
and navigation component. code in thread.Bradleycorn
03/04/2021, 9:39 PMCompositionLocal
and when/how to use it. Does this seem like a valid use case:
Using a Material theme, the designer provided direction for Outlined Buttons ...
When a button is displayed on the surface or background color, it should use the Theme's Secondary
color.
When a button is displayed on another color, it should use that color's "on" Color.
To achieve this, I wrote an AppSurface
Composable that wraps a regular surface, and sets the value of a LocalButtonColor
composition local, and then wrote a AppOutlinedButton
Composable that wraps a regular OutlinedButton, and sets it's color using the LocalButtonColor
...
Does this seem like the right approach? (Code is posted in the thread)Piotr Prus
03/04/2021, 9:41 PMColumn(modifier.verticalScroll)
, additionally I got a .pointeInput
on it to detect when the dragGesture (scroll) actually happens.
In alpha12, the dragGesture was detected on that column, but on Beta01, the detectVerticalDrag
is never called. However , if the .pointerInput
is called on child composable of that column, everything works fine.
Is that a bug or intended behavior for scrollable columns? (Tested also for LazyColumns, which works exactly the same.Arkadii Ivanov
03/04/2021, 9:48 PMBox
vertically, if the height of the Box
is smaller than the height of the content? Currently it sticks to the top and is clipped at the bottom. But I want the content to be centered and clipped from top and bottom.julioromano
03/04/2021, 10:30 PMBox {
One()
Two()
}
I have 2 composables inside a Box()
. I’d like the Box to set its size to the size of One()
and I’d also like that Two()
adapts its size to the size of One()
. Is this possible?Tristan
03/04/2021, 10:36 PMSergey Y.
03/04/2021, 11:36 PMCompositionContext
class, but I don't know how to use it. Can anyone please help?
Thanks 🙂sen kumar
03/05/2021, 1:18 AMColton Idle
03/05/2021, 2:13 AMtad
03/05/2021, 2:38 AMpaddingFromBaseline(top = fontSize, bottom = lineHeight - fontSize)
be the default for Text? It's tough to match Figma/Sketch mocks without something that wraps Text to provide that modifier.Vinay Gaba
03/05/2021, 3:30 AMLayoutInflater.Factory2
gave some of this functionality in classic Android. Just curious if something like this already exists or is planned for in Compose.Jason Inbody
03/05/2021, 4:32 AMLanderl Young
03/05/2021, 9:22 AMvar baseSize by remember { mutableStateOf(0f) }
Column(
modifier = modifier.onSizeChanged { (width, height) ->
baseSize = min(width * 1.7f, height.toFloat())
}
) {
val firstLevelSize = baseSize * 5 / 10
Text(
fontSize = LocalDensity.current.run {
firstLevelSize.toSp()
},
...
)
}
Full code here: https://github.com/LanderlYoung/FlashAppSearch/blob/16a1fc9ac6c67e184f801e125f79ef[…]o/github/landerlyoung/flashappsearch/search/ui/piece/KeyIcon.kt
But this code has a issue: during the initial composition the fontSize is 0, so the Text is not shown. when onSizeChanged got called, baseSize would update, and causing a second pass re-composition, at that time the Text is actually shown.
Is there any better solutions?
BTW, there is a StackOverFlow thread // https://stackoverflow.com/questions/63971569/androidautosizetexttype-in-jetpack-composeSyex
03/05/2021, 9:31 AMTextField
and a Button
. Upon a click on the button I want to clear the focus from the TextField
so the keyboard disappears. I'm currently trying
Button(
onClick = {
FocusRequester.Default.freeFocus()
}
)
This crashes the app with
java.lang.IllegalStateException: FocusRequester is not initialized. One reason for this is that you requesting focus changes during composition. Focus requesters should not be made during composition, but should be made in response to some event.Is there any other way to achieve this?
Simone Summo
03/05/2021, 9:50 AMescodro
03/05/2021, 12:18 PMModalBottomSheetLayout
that I want to appear on top of my Scaffold
. The Scaffold
has 4 tabs and I want each one to have a different content for this Modal.
The solution I made is:
val (sheetContent, setSheetContent) = remember { mutableStateOf<@Composable () -> Unit>({}) }
AlkaaBottomSheetLayout(bottomSheetContent = currentSection) {
Scaffold {
when (tab) {
HomeSection.Tasks -> TaskListSection(bottomSheetContent = setCurrentSection)
HomeSection.Search -> SearchSection(bottomSheetContent = setCurrentSection)
HomeSection.Categories -> CategoriesSection(bottomSheetContent = setCurrentSection)
HomeSection.Settings -> SettingSection(bottomSheetContent = setCurrentSection)
Is it the correct way to delegate the composable function?
Thanks a lot in advance! ❤️FunkyMuse
03/05/2021, 12:22 PM@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun SearchInput(onInputText: (inputText: String) -> Unit = {}) {
val keyboardController = LocalSoftwareKeyboardController.current
var inputText by rememberSaveable { mutableStateOf("") }
val invalidInput = inputText.isBlank()
OutlinedTextField(
modifier = Modifier
.fillMaxWidth()
.padding(start = 24.dp, end = 24.dp),
isError = invalidInput,
label = { Text(text = stringResource(id = R.string.search)) },
value = inputText,
onValueChange = { inputText = it },
keyboardOptions = KeyboardOptions(
KeyboardCapitalization.Words, autoCorrect = false,
keyboardType = KeyboardType.Text, imeAction = ImeAction.Search
),
keyboardActions = KeyboardActions(onSearch = {
keyboardController?.hideSoftwareKeyboard()
onInputText(inputText)
})
)
}
Hey guys, the code above crashes when the app goes into onPause/onStop
the error is
java.lang.RuntimeException: Parcel: unable to marshal value androidx.compose.runtime.SnapshotMutableStateImpl@f5abce7
at android.os.Parcel.writeValue(Parcel.java:1926)
at android.os.Parcel.writeList(Parcel.java:1133)
at android.os.Parcel.writeValue(Parcel.java:1873)
at android.os.Parcel.writeMapInternal(Parcel.java:984)
at android.os.Parcel.writeMap(Parcel.java:966)
at android.os.Parcel.writeValue(Parcel.java:1838)
at android.os.Parcel.writeMapInternal(Parcel.java:984)
at android.os.Parcel.writeMap(Parcel.java:966)
at android.os.Parcel.writeValue(Parcel.java:1838)
at android.os.Parcel.writeList(Parcel.java:1133)
at android.os.Parcel.writeValue(Parcel.java:1873)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:1016)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1620)
at android.os.Bundle.writeToParcel(Bundle.java:1303)
at android.os.Parcel.writeBundle(Parcel.java:1085)
at android.os.Parcel.writeValue(Parcel.java:1842)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:1016)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1620)
at android.os.Bundle.writeToParcel(Bundle.java:1303)
at android.os.Parcel.writeBundle(Parcel.java:1085)
at android.os.Parcel.writeValue(Parcel.java:1842)
at android.os.BaseBundle.dumpStats(BaseBundle.java:1690)
at android.os.BaseBundle.dumpStats(BaseBundle.java:1727)
at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:150)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7729)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:974)
if i use
var inputText by remember { mutableStateOf("") }
the issue goes away
i've made the code by the Unidirectional data flow in Jetpack Compose documentationPedro Gomez
03/05/2021, 12:37 PMDominaezzz
03/05/2021, 12:45 PMModifier.selectable(...)
and when the composable is clicked, the animation plays and UI is updated, but the composable doesn't stay selected (graphically speaking). Do I have to change the background colour myself?Lilly
03/05/2021, 1:10 PMJorkoh
03/05/2021, 1:14 PMmyanmarking
03/05/2021, 3:24 PMLukas K-G
03/05/2021, 3:27 PMRajashekar
03/05/2021, 3:40 PMmyanmarking
03/05/2021, 3:53 PM@Composable
private fun PeopleScreen() {
val viewModel: PeopleViewModel2 = viewModel()
val viewState = viewModel.peopleList.collectAsState(initial = emptyList())
val listItems: List<PeopleItem> by viewState
LazyColumn(
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 16.dp),
modifier = Modifier.padding(bottom = 56.dp)
.fillMaxWidth()
) {
for (item in listItem) {
item(key = item.id) {
PeopleItem(
item = item,
onFavouriteClicked = { viewModel.onFavouriteClicked(item) }
)
Spacer(modifier = Modifier.padding(bottom = 8.dp))
}
}
}
}
zoha131
03/05/2021, 4:10 PMalorma
03/05/2021, 4:54 PMIconButton
with elevation shadow?alorma
03/05/2021, 5:10 PMProvider
is... provided? Ex:
WindowInsets from accompanist, in a library, check if is provided by the main app and apply the Modifier.statusBarPadding()
or else do nothing in the libFilip Wiesner
03/05/2021, 5:56 PMIllegalArgumentException: Failed requirement
. The stacktrace points to MeasureAndLayoutDelegate.kt:194
which is require(!duringMeasureLayout)
.
So my question is if I should look for some problem on my side or if it's likely a bug and I should create minimial repro and file an issue.
Thanks for reply 🙏Filip Wiesner
03/05/2021, 5:56 PMIllegalArgumentException: Failed requirement
. The stacktrace points to MeasureAndLayoutDelegate.kt:194
which is require(!duringMeasureLayout)
.
So my question is if I should look for some problem on my side or if it's likely a bug and I should create minimial repro and file an issue.
Thanks for reply 🙏Dominaezzz
03/05/2021, 6:16 PMAndrey Kulikov
03/05/2021, 6:31 PMFilip Wiesner
03/05/2021, 8:58 PM