From 934f0bd8ccfdaf675a70e457ffe66a75fe232fd2 Mon Sep 17 00:00:00 2001 From: machiav3lli Date: Tue, 31 May 2022 03:03:47 +0200 Subject: [PATCH] Fix: Showing download progress (not real-time-synced though) --- .../ui/compose/pages/app_detail/components/Header.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/com/looker/droidify/ui/compose/pages/app_detail/components/Header.kt b/src/main/kotlin/com/looker/droidify/ui/compose/pages/app_detail/components/Header.kt index 3b905d4e..22b29c03 100644 --- a/src/main/kotlin/com/looker/droidify/ui/compose/pages/app_detail/components/Header.kt +++ b/src/main/kotlin/com/looker/droidify/ui/compose/pages/app_detail/components/Header.kt @@ -121,8 +121,9 @@ fun TopBarHeader( AnimatedVisibility(visible = state is Cancelable) { DownloadProgress( modifier = Modifier.padding(horizontal = 12.dp), - totalSize = 69420, + totalSize = if (state is Downloading) state.total ?: 1L else 1L, isIndeterminate = state !is Downloading, + downloaded = if (state is Downloading) state.downloaded else 0L, ) } } @@ -194,8 +195,8 @@ fun HeaderExtrasCard( @Composable fun DownloadProgress( modifier: Modifier = Modifier, - downloading: Float = 0f, totalSize: Long, + downloaded: Long?, isIndeterminate: Boolean ) { Column( @@ -210,15 +211,14 @@ fun DownloadProgress( ) } else { Text( - text = totalSize.times(downloading).toLong() - .formatSize() + "/" + totalSize.formatSize() + text = "${downloaded?.formatSize()}/${totalSize.formatSize()}" ) Spacer(modifier = Modifier.height(8.dp)) LinearProgressIndicator( modifier = Modifier .fillMaxWidth() .clip(Shapes.Full), - progress = downloading + progress = downloaded?.toFloat()?.div(totalSize) ?: 1f ) } }