I am trying to achieve something like this but with Jetpack Compose. In other words swipe to delete like we could do in RecyclerView with ItemTouchHelper and class DiffCallBack : DiffUtil.ItemCallback<RvModel>() where we could see enter - exit animations and then the list moving gracefully up or down where the item has been inserted or removed.
This is what I have tried:
LazyColumn(state = listState) {
items(products, {listItem:InventoryEntity -> listItem.inventoryId}) { item ->
var unread by remember { mutableStateOf(false) } …Run Code Online (Sandbox Code Playgroud) lightweight从可组合项的 viewModel 观察当前时间的最有效方法是什么。
在我的可组合项看来,我希望看到当前时间的格式为HH:mm并始终根据当前时间进行更新。
我正在使用最新版本的线圈:
implementation("io.coil-kt:coil-compose:2.0.0-rc01")
我想将条形码标签图像加载到我的 Jetpack Compose 文件中,例如如下所示:
Box(modifier = Modifier.background(Color.DarkGray).fillMaxSize()) {
AsyncImage(
model = ImageRequest.Builder(LocalContext.current)
.data("https://www.researchgate.net/profile/Adnan-Ghaffar/publication/313103370/figure/fig3/AS:456489858015234@1485847071322/An-example-of-barcode.png")
.crossfade(true)
.build(),
contentDescription = "barcode image",
contentScale = ContentScale.Crop,
modifier = Modifier
)
}
Run Code Online (Sandbox Code Playgroud)
这工作正常,当我尝试从如下所示的 URI 加载图像时,就会出现问题:
http://api.labelary.com/v1/printers/8dpmm/labels/4x6/0/^xa^cfa,50^fo100,100^fdHello World^fs^xz
但它不起作用,例如我尝试过的代码:
Box(modifier = Modifier.background(Color.DarkGray).fillMaxSize()) {
AsyncImage(
model = ImageRequest.Builder(LocalContext.current)
.data("http://api.labelary.com/v1/printers/8dpmm/labels/4x6/0/^xa^cfa,50^fo100,100^fdHello World^fs^xz")
.crossfade(true)
.build(),
contentDescription = "barcode image",
contentScale = ContentScale.Crop,
modifier = Modifier
)
}
Run Code Online (Sandbox Code Playgroud)