Oussama Haff.
10/28/2020, 12:19 PMLazyColumn
with lots of items, the assertion of onChildren().assertCountEquals()
counts only the displayed nodes.
How can I test that the composable will actually show all items
passed to the LazyColumn
?Chethan
10/28/2020, 12:25 PM@Composable
fun UploadPhotos(
viewModel: YourViewModel,
imageAdapterClickLister: ImageAdapterClickLister
) {
val userSelectedMediaList = viewModel.listOfSelectedImages.collectAsState()
if (userSelectedMediaList.value.isEmpty())
DefaultPlaceHolder(
onClickOfUpload = {
imageAdapterClickLister.onUploadMoreButtonClick()
}
)
else
SetUserSelectedMedia()
}
class YourViewModel @ViewModelInject constructor(
private val repository: YourReviewRepository
) : ViewModel() {
private val _uploadItems = MutableStateFlow(mutableListOf<UploadedItem>())
val listOfSelectedImages: StateFlow<List<UploadedItem>> get() = _uploadItems
fun addSelectedMediaToList(userSelectedUploadItem: UploadedItem) {
val listWithNewlyAddedItem = _uploadItems.value.also {
it.add(userSelectedUploadItem)
}
_uploadItems.value = listWithNewlyAddedItem
}
}
William Barbosa
10/28/2020, 1:04 PMKshitij Patil
10/28/2020, 1:07 PM@Preview
for these configurations?dagomni
10/28/2020, 1:15 PMval backStackEntry = navHostController.currentBackStackEntryAsState()
and then accessing
backStackEntry.value
causes constant recompositionKshitij Patil
10/28/2020, 2:03 PMstringResource(resId)
in its get()
methodzoha131
10/28/2020, 5:03 PMBottomNavigation
bottomBar = {
BottomNavigation(
elevation = 16.dp,
backgroundColor = MaterialTheme.colors.surface,
contentColor = MaterialTheme.colors.onSurface
) {
BottomNavigationItem(icon = {Icon(asset = Icons.Outlined.Home)}, selected = true, onClick = {})
BottomNavigationItem(icon = {Icon(asset = Icons.Outlined.Search)}, selected = false, onClick = {})
BottomNavigationItem(icon = {Icon(asset = Icons.Outlined.Person)}, selected = false, onClick = {})
}
}
nickbutcher
10/28/2020, 5:06 PMAfzal Najam
10/28/2020, 7:18 PMEric Ampire [MOD]
10/28/2020, 7:56 PMSergey Y.
10/28/2020, 8:04 PMNavigation Compose Alpha 1
.
I wanted to ask what is the state or plans of the graphical representation of the navigation graph?
I know the preview of the graph works only with xml, but will it extend for composable functions?
I mostly like to use Navigation Component because of the graph preview. But the android community received it underestimated and coldly. Let's say, there are some contradictory things.tylerwilson
10/28/2020, 11:05 PMVal Salamakha
10/28/2020, 11:42 PM@Composable
fun Profile(navController: NavHostController) {
Column(Modifier.fillMaxSize().then(Modifier.padding(8.dp))) {
Text(text = stringResource(Screen.Profile.resourceId))
NavigateButton(stringResource(Screen.Dashboard.resourceId)) {
navController.navigate(Screen.Dashboard.route)
}
Divider(color = Color.Black)
NavigateButton(stringResource(Screen.Scrollable.resourceId)) {
//it should be navController.navigate(Screen.Scrollable.route)
// instead of //navController.navigate(Screen.Dashboard.route)
}
Spacer(Modifier.weight(1f))
NavigateBackButton(navController)
}
}
alorma
10/29/2020, 7:21 AMRatingBar
on Compose?József Szilvási
10/29/2020, 9:05 AMImeAction
on TextFields stopped working. I guess it is related to this fix: Added single line keyboard option to CoreTextField (<https://android-review.googlesource.com/#/q/I72e6d9f84abbf4ff6a9ede5355de4c30d37c3d8c|I72e6d>)
harry248
10/29/2020, 9:16 AMmanueldidonna
10/29/2020, 10:24 AMKshitij Patil
10/29/2020, 11:54 AMnavigation-compose
with bottom nav bar (basically same as the example from documentation) and the app runs fine on my device. But the @Preview
is not working and shows this errorChethan
10/29/2020, 12:10 PMviewModel.uploadImage(ContextAmbient.current, job, uri).observeAsState()
@Composable
fun SetImageUpdateProgressBar(
job: Job,
uri: Uri,
viewModel: UploadViewModel = viewModel()
) {
var result = viewModel.uploadImage(ContextAmbient.current, job, uri).observeAsState()
result?.value?.let { data ->
when (data.response.status) {
Status.ERROR -> {
// setRetryButton()
}
Status.SUCCESS -> {
ShowProgressBar(value = 0, visibility = false)
}
Status.LOADING -> {
ShowProgressBar(data.uploadProgressValue)
}
}
}
}
Grigorii Yurkov
10/29/2020, 1:08 PM@Preview
@Composable
fun Test() {
Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally
) {
ButtonText(
text = "Super very large button"
modifier = Modifier.wrapContentWidth(Alignment.CenterHorizontally)
)
ButtonText(
text = "small"
modifier = Modifier.wrapContentWidth(Alignment.CenterHorizontally)
)
}
}
@Composable
fun ButtonText(text: String, modifier: Modifier = Modifier) {
Button(onClick = {}, modifier = modifier) {
Text(text)
}
}
zoha131
10/29/2020, 4:25 PMGrigorii Yurkov
10/29/2020, 6:44 PM@Composable
val composableScope: CoroutineScope
get() {
val context = SupervisorJob() + Dispatchers.Main.immediate
onDispose {
context.cancel()
}
return CoroutineScope(context)
}
Or maybe there is out-of-the-box solution?sjthn
10/29/2020, 6:55 PMval image = imageResource(id = R.drawable.img_123)
val imageModifier = Modifier
.preferredHeight(180.dp)
.fillMaxWidth()
Image(image, modifier = imageModifier,
contentScale = ContentScale.Crop)
Oussama Haff.
10/29/2020, 7:40 PM@Preview(group = "Themed Screens", showBackground = true, heightDp = 600, widthDp = 300)
@Composable
fun HomeScreenThemedPreview() {
AppTheme {
HomeScreen(viewModel = viewModel())
}
}
Bryan Herbst
10/29/2020, 7:46 PMButton
to Button-bpaW8jA
) it is a little tricker to find the right ComposablesSam
10/29/2020, 10:29 PM1.4.20-RC
works with Jetpack Compose alpha06
?Kshitij Patil
10/30/2020, 7:11 AMTlaster
10/30/2020, 7:30 AMRuntimeException: Cannot create an instance of class MyViewModel
. Does anyone have the same issue?jannis
10/30/2020, 9:20 AMAlberto
10/30/2020, 10:03 AMAlberto
10/30/2020, 10:03 AMJavier
10/30/2020, 10:05 AMIrving
10/30/2020, 10:09 AMAlberto
10/30/2020, 10:41 AMnavController.navigate(DETAIL_SCREEN+"/${StateScreen.READ}?${note}")
Ian Lake
10/30/2020, 3:37 PMpost/{postId}/comment/{commentId}
is a perfectly fine routeAlberto
10/30/2020, 3:55 PMpost?postId={postId}/comment/{commentId}
Ian Lake
10/30/2020, 4:34 PM?
, optional ones after?
is the path, after is the query parameters