Zach Klippenstein (he/him) [MOD]
10/01/2021, 5:32 PMyschimke
10/04/2021, 8:50 AMAsh
10/08/2021, 9:24 PMyschimke
10/13/2021, 7:03 AMJohn Nichol
10/14/2021, 4:28 PMJohn O'Reilly
10/15/2021, 9:16 AMNoop
10/16/2021, 6:31 AMyschimke
10/19/2021, 8:52 AMGaran Jenkin
10/21/2021, 5:46 PMLazyListState
supports scrollToItem()
but ScalingLazyListState
does not. Is this something that might come in the future, or consciously omitted?Alex Bravo
10/21/2021, 10:07 PMyschimke
10/22/2021, 8:53 AMyschimke
10/26/2021, 12:05 PM@Composable
fun MyAppThemePreview(
round: Boolean = true,
content: @Composable () -> Unit,
) {
MyAppTheme {
if (round) {
Box(Modifier.fillMaxSize().background(Color.White)) {
}
Box(modifier = Modifier.fillMaxSize().clip(CircleShape).background(Color.DarkGray)) {
content()
}
} else {
Box(modifier = Modifier.fillMaxSize().background(Color.DarkGray)) {
content()
}
}
}
}
John Nichol
11/03/2021, 6:35 PMyschimke
11/04/2021, 8:55 AMGabriel Gircenko
11/04/2021, 11:21 AM@Composable
private fun ListOfHomePages(rows: List<PageItemUIData>) {
val listState = rememberLazyListState()
val listScope = rememberCoroutineScope()
val scrollState = rememberScrollState()
var index by remember { mutableStateOf(0) }
LazyRow(
modifier = Modifier
.fillMaxSize()
.background(color = colorResource(id = R.color.black)),
state = listState
) {
items(rows) { item: PageItemUIData ->
if (!listState.isScrollInProgress) {
listScope.launch {
listState.animateScrollToItem(index)
}
/*if (listState.isScrollingUp()) {
listScope.launch {
listState.animateScrollToItem(listState.firstVisibleItemIndex + 1)
}
} else if (listState.isScrollingDown()) {
listScope.launch {
listState.animateScrollToItem(listState.firstVisibleItemIndex - 1)
}
}*/
}
PageItem(
painter = item.painter,
iconContentDescription = item.iconContentDescription,
title = item.title,
backgroundGradientStart = item.backgroundGradientStart,
backgroundGradientEnd = item.backgroundGradientEnd,
backgroundGradientOffset = item.backgroundGradientOffset,
modifier = Modifier.onGloballyPositioned { coordinates ->
index = coordinates.positionInParent().x.roundToInt()
}
)
}
}
}
I'm pretty new to Compose too and don't understand how to run a coroutine just once instead of every composition...yschimke
11/04/2021, 2:23 PMbarat
11/07/2021, 9:58 AMBoxWithConstraints() {
val absoluteValue = (maxWidth - (maxWidth / sqrt(2f)))/2
ConstraintLayout(modifier = Modifier.fillMaxSize()) {
val absoluteStartGuideline = createGuidelineFromAbsoluteLeft(absoluteValue)
Austin Nelson
11/07/2021, 1:06 PM@Composable
fun TextField() {
var value by remember { mutableStateOf(TextFieldValue("")) }
val keyboardController = LocalSoftwareKeyboardController.current
BasicTextField(
value = value,
onValueChange = { value = it },
keyboardOptions = KeyboardOptions(
imeAction = ImeAction.Done,
keyboardType = KeyboardType.Number
),
keyboardActions = KeyboardActions(
onDone = { keyboardController?.hide() }),
decorationBox = { innerTextField ->
Row(
Modifier
.background(Color.DarkGray, RoundedCornerShape(percent = 50))
.padding(12.dp)
) {
if (value.text.isEmpty()) {
Text("Manual IP Address")
}
innerTextField()
}
},
)
}
Garan Jenkin
11/08/2021, 2:43 PMLaunchedEffect
that sits outside of the NavHost
. You can see this here: https://github.com/garanj/wearwind/blob/main/app/src/main/java/com/garan/wearwind/FanActivity.kt#L115 So when the watch successfully connects to the fan, the screen transitions to the Connected screen, but it avoids the situation where when the user swipes back from the Connected screen they may hit the Connect screen but bounce back to the Connected screen as the fan hasn't disconnected yet... but is this a bad idea to have this navigation logic here? I've been trying to have it within each screen but with no success yet.Garan Jenkin
11/08/2021, 2:47 PMSteve Bower [G]
11/09/2021, 9:24 AMGaran Jenkin
11/11/2021, 11:22 AMGaran Jenkin
11/14/2021, 11:39 AMText(
text = speed,
color = Colors.primary,
style = LocalTextStyle.current.copy(fontSize = 108.sp),
fontStyle = FontStyle.Italic,
fontWeight = FontWeight.ExtraBold
)
But as per @yschimke’s comment it would be great to know how to best make use of Theming to support this cleanly? (I like Yuri's suggestion of WearWindTheme.typography.majorItem
) ? Any thoughts?yschimke
11/19/2021, 12:44 PMAndrew Leung
11/24/2021, 9:30 PMGaran Jenkin
12/06/2021, 12:45 PMStepper(
value = curr.value,
onValueChange = { value ->
curr.value = value
Log.i(TAG, "New value: $value")
},
valueRange = 100.0f .. 220.0f,
steps = (220 - 100) / 5 - 1
) {
Aim was to be able to have a range of 100 to 220 and be able to step values by 5.
The part that confused me was the steps
value. Docs say "Step value is calculated as the difference between min and max values divided by steps+1". So, to get the correct step size, I have to subtract one from what I initially thought as the intuitive number of steps ((220 - 100) / 5
). It's no big deal, reading the documentation solved it, just wasn't sure why "steps+1", though I've likely just misunderstood something.Garan Jenkin
12/07/2021, 10:33 AMyschimke
12/08/2021, 10:40 AMyschimke
12/13/2021, 8:07 AMcomposable(
Screens.LoginDialog.route
) {
AlertDialog(
title = {
then
positiveButton = {
Button(onClick = {
viewModel.continueLogin()
navController.popBackStack()
Austin Nelson
12/14/2021, 1:58 AMandroidx.hilt:hilt-navigation-compose
to 1.0.0-beta01
I am now getting this error:
You cannot access the NavBackStackEntry's ViewModels until it is added to the NavController's back stack (i.e., the Lifecycle of the NavBackStackEntry reaches the CREATED state).
But I commented out all of my ViewModel stuff and it's still erroring out. Can anyone explain what changed?
This is basically all I have:
SwipeDismissableNavHost(
navController = navController,
startDestination = "start",
modifier = Modifier.background(MaterialTheme.colors.background)
) {
composable("start") {
// val mainViewModel = hiltViewModel<MainViewModel>()
// val uiState = mainViewModel.uiState.collectAsState()
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Text("uiState.value")
}
}
}
Austin Nelson
12/14/2021, 1:58 AMandroidx.hilt:hilt-navigation-compose
to 1.0.0-beta01
I am now getting this error:
You cannot access the NavBackStackEntry's ViewModels until it is added to the NavController's back stack (i.e., the Lifecycle of the NavBackStackEntry reaches the CREATED state).
But I commented out all of my ViewModel stuff and it's still erroring out. Can anyone explain what changed?
This is basically all I have:
SwipeDismissableNavHost(
navController = navController,
startDestination = "start",
modifier = Modifier.background(MaterialTheme.colors.background)
) {
composable("start") {
// val mainViewModel = hiltViewModel<MainViewModel>()
// val uiState = mainViewModel.uiState.collectAsState()
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Text("uiState.value")
}
}
}
Ian Lake
12/14/2021, 2:09 AMAustin Nelson
12/14/2021, 2:11 AM