prat
12/28/2020, 4:24 PMmillis
value doesn't change when I add a log at A - before Canvas. Without the log or when I add log at B instead, millis
gets updated. Is this an expected behavior?
@Composable
fun DrawSomething(
modifier: Modifier,
strokeWidth: Float = 8f
) {
val millis = animationTimeMillis()
// A: when adding a Log here, millis.value will stop at 0 and won't draw arc
// Log.d("DrawSomething", "millis : ${millis.value}")
Canvas(modifier = modifier) {
// B
// Log.d("DrawSomething", "millis : ${millis.value}")
drawArc(
color = Color.Green,
startAngle = 0f,
sweepAngle = 0f + (millis.value / 360),
useCenter = false,
size = Size(100f, 100f),
style = Stroke(width = strokeWidth)
)
}
}
@Composable
fun animationTimeMillis(): State<Long> {
val millisState = mutableStateOf(0L)
val lifecycleOwner = AmbientLifecycleOwner.current
LaunchedEffect(Unit) {
val startTime = withFrameMillis { it }
lifecycleOwner.whenStarted {
while (true) {
withFrameMillis { frameTime ->
millisState.value = frameTime - startTime
}
}
}
}
return millisState
}
robnik
12/28/2020, 8:31 PMBrady Aiello
12/29/2020, 2:52 AMTextField
? I can resolve it with singleLine = true
, but it still chops off the bottom of the sub-baseline letters. This is in a TopAppBar
in a Scaffold. Thought this might be due to a size constraint on TopAppBar
? Or maybe just the topAppBar
content parameter in Scaffold
? Not sure if there's any weird trickiness with TextField
itself.Marcin Środa
12/29/2020, 8:24 AMlewis
12/29/2020, 10:05 AMBottomAppBar
to hide when I scroll down in my ScrollableColumn
?tseisel
12/29/2020, 5:46 PM@Preview
?
It takes almost a minute to render each change, and I'm using a decent laptop. Also, is it required to rebuild project to update preview ?Lilly
12/30/2020, 2:08 AMViewModel
...Nana Vong
12/30/2020, 6:04 AMSe7eN
12/30/2020, 1:49 PMval colors = remember {
mutableStateListOf(
mutableStateListOf(Color.Magenta, Color.Blue, Color.Yellow)
)
}
val activeRowIndex = remember { mutableStateOf(0) }
val activeColumnIndex = remember { mutableStateOf(0) }
...
Sliders(
colors[activeRowIndex.value][activeColumnIndex.value],
onColorChange = { colors[activeRowIndex.value][activeColumnIndex.value] = it }
)
@Composable
fun Sliders(color: Color, onColorChange: (Color) -> Unit) {
Column {
Row(verticalAlignment = Alignment.CenterVertically) {
Text(text = "R - ${color.red * 255}")
Slider(
value = color.red,
onValueChange = { onColorChange(color.copy(red = it)) }
)
}
Row(verticalAlignment = Alignment.CenterVertically) {
Text(text = "G - ${color.green * 255}")
Slider(
value = color.green,
onValueChange = { onColorChange(color.copy(green = it)) }
)
}
Row(verticalAlignment = Alignment.CenterVertically) {
Text(text = "B - ${color.blue * 255}")
Slider(
value = color.blue,
onValueChange = { onColorChange(color.copy(blue = it)) }
)
}
}
}
Colton Idle
12/30/2020, 6:58 PMSam
12/30/2020, 8:10 PMBasicTextField
often doesn’t bring up the keyboard when focused! When it malfunctions, the cursor is literally blinking, yet somehow the keyboard is not open. This happens on physical Pixel 4a in a release build that is deployed to the play store!
Since we are chat-based communities, this is critical. How is it even possible to get into this state, and are there any workarounds/hacks that can fix this reliability bug?Denis
12/30/2020, 10:47 PMpointerInteropFilter
?Qracle
12/31/2020, 1:52 AMbirdsofparadise
12/31/2020, 2:14 AMPiotr
12/31/2020, 10:01 AMDominaezzz
12/31/2020, 2:54 PMAnnotatedString
? Like BulletSpan
, QuoteSpan
, etc. (Unless this can be achieved already?)Christian Maier
12/31/2020, 4:20 PMVsevolod Ganin
12/31/2020, 7:41 PMpointerInput
? My goal is combine zooming (1), scrolling (2) and drag-n-drop (3) on the same composable. 1 and 2 are available with detectMultitouchGestures
. 3 could be done using detectTapGestures
+ detectDragGestures
I guess. The idea is to listen to gesture trigger first and then give full control to corresponding gesture routine. Honestly I don’t how to approach this, the examples don’t cover this it seemsMichael Prenez-Isbell
01/01/2021, 1:22 PMAyomide
01/01/2021, 4:21 PMnavController.navigate()
methodahulyk
01/01/2021, 7:08 PMLazyColumn
?ahulyk
01/01/2021, 9:09 PMBradleycorn
01/01/2021, 11:47 PMsealed class Screen(val route: String, val title: String, val isTopLevel: Boolean = false) {
object Category: Screen("category/{postType}", "Category") {
// here I define a NavType.EnumType for my enum that is used for an argument.
val postTypeArgType = NavType.EnumType(PostType::class.java)
fun buildRoute(postType: PostType): String {
return "category/${postType.name}"
}
}
// ... more screen routes defined here..
}
Then I use the Category to build the composable() in the NavGraph Builder. And I use the postTypeArgType
which is a NavType.EnumType
from the Category object above to get the postType argument. Is this the right approach?
composable(Screen.Category.route,
arguments = listOf(
navArgument("postType") { type = Screen.Category.postTypeArgType },
navArgument("title") { type = NavType.StringType }
)
) { backStackEntry ->
val vm: CategoryScreenViewModel = navViewModel()
// Is this the right way to get the `postType` argument from the backstack entry?
val postType = Screen.Category.postTypeArgType.get(backStackEntry.arguments?: Bundle(), "postType") ?: PostType.OTHER
CategoryScreen(vm, postType)
}
birdsofparadise
01/02/2021, 12:56 AMremember
with an inlined Compose function?
@Composable
inline fun test() {
val i by remember { mutableStateOf(3) }
}
This method produces a nasty compiler error
Part of the error message:
Caused by: java.lang.RuntimeException: Exception while generating code for:
FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit [inline]
annotations:
Composable
BLOCK_BODY
VAR name:$i$f$test type:<http://kotlin.Int|kotlin.Int> [val]
CONST Int type=<http://kotlin.Int|kotlin.Int> value=0
VAR name:i type:<http://kotlin.Int|kotlin.Int> [val]
CALL 'public final fun remember <T> (calculation: @[ComposableContract(restartable = <null>, readonly = <null>, tracked = <null>, preventCapture = 'true')] kotlin.Function0<T of androidx.compose.runtime.RememberKt.remember>): T of androidx.compose.runtime.RememberKt.remember [inline] declared in androidx.compose.runtime.RememberKt' type=<http://kotlin.Int|kotlin.Int> origin=null
<T>: <http://kotlin.Int|kotlin.Int>
calculation: BLOCK type=kotlin.Function0<kotlin.Int> origin=LAMBDA
COMPOSITE type=kotlin.Unit origin=null
FUNCTION_REFERENCE 'private final fun test$lambda-0 (): <http://kotlin.Int|kotlin.Int> declared in dev.birdsofparadise.mua.lifecycle.ComposeActivityKt' type=kotlin.Function0<kotlin.Int> origin=LAMBDA reflectionTarget=null
Marcello Galhardo
01/02/2021, 9:46 AMSavedStateRegistry
. I notice I have an Ambient
for UiSavedStateRegistry
but there's no for SavedStateRegistry
. - and look like they are totally different types so I can't create a custom AbstractSavedStateViewModelProviderFactory
without a SavedStateRegistryOwner
. What is the correct way to get a SavedStateRegistryOwner
in a composable? 🤔Shakil Karim
01/02/2021, 12:10 PMChristian Maier
01/02/2021, 2:17 PMrsktash
01/02/2021, 4:44 PMKarthick
01/03/2021, 3:30 AMPrashant Priyadarshi
01/03/2021, 3:49 AMPrashant Priyadarshi
01/03/2021, 3:49 AMColton Idle
01/03/2021, 4:28 AMPrashant Priyadarshi
01/03/2021, 5:31 AMzoha131
01/03/2021, 6:36 AMPrashant Priyadarshi
01/03/2021, 7:55 AMzoha131
01/03/2021, 4:07 PMPrashant Priyadarshi
01/04/2021, 3:26 AM<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:windowSoftInputMode="adjustResize"
android:theme="@style/Theme.LearnCompose.NoActionBar">
below is the sample code and I have also attached the screen shot
@Composable
fun scaffoldWithTwoInputs(){
val topText = remember { mutableStateOf("") }
val bottomText = remember { mutableStateOf("") }
val modifier = Modifier.fillMaxWidth()
Scaffold(modifier = Modifier.fillMaxSize(),
topBar = {
OutlinedTextField(value = topText.value,
onValueChange = {s-> topText.value = s }, modifier = modifier)
},
bodyContent = {
Column(modifier = modifier.padding(50.dp), verticalArrangement = Arrangement.Center) {
Text(text = topText.value, style = typography.h6, color = Color.Black)
Text(text = bottomText.value, style = typography.h6, color = Color.Black)
}
},
bottomBar = {
OutlinedTextField(value = bottomText.value, onValueChange = {s-> bottomText.value = s },
modifier = modifier)
}
)
}
zoha131
01/04/2021, 8:05 AMbottomBar
. But from you first message I thought You want to hide the bottom nav when keyboard is visible in the screen. Can you please clear what do want to achieve?
You can use this library to detect if keyboard is visible or not.