mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 19:32:16 +00:00
Fix: Showing download progress (not real-time-synced though)
This commit is contained in:
parent
0e6affa96d
commit
934f0bd8cc
@ -121,8 +121,9 @@ fun TopBarHeader(
|
|||||||
AnimatedVisibility(visible = state is Cancelable) {
|
AnimatedVisibility(visible = state is Cancelable) {
|
||||||
DownloadProgress(
|
DownloadProgress(
|
||||||
modifier = Modifier.padding(horizontal = 12.dp),
|
modifier = Modifier.padding(horizontal = 12.dp),
|
||||||
totalSize = 69420,
|
totalSize = if (state is Downloading) state.total ?: 1L else 1L,
|
||||||
isIndeterminate = state !is Downloading,
|
isIndeterminate = state !is Downloading,
|
||||||
|
downloaded = if (state is Downloading) state.downloaded else 0L,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,8 +195,8 @@ fun HeaderExtrasCard(
|
|||||||
@Composable
|
@Composable
|
||||||
fun DownloadProgress(
|
fun DownloadProgress(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
downloading: Float = 0f,
|
|
||||||
totalSize: Long,
|
totalSize: Long,
|
||||||
|
downloaded: Long?,
|
||||||
isIndeterminate: Boolean
|
isIndeterminate: Boolean
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
@ -210,15 +211,14 @@ fun DownloadProgress(
|
|||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Text(
|
Text(
|
||||||
text = totalSize.times(downloading).toLong()
|
text = "${downloaded?.formatSize()}/${totalSize.formatSize()}"
|
||||||
.formatSize() + "/" + totalSize.formatSize()
|
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
LinearProgressIndicator(
|
LinearProgressIndicator(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clip(Shapes.Full),
|
.clip(Shapes.Full),
|
||||||
progress = downloading
|
progress = downloaded?.toFloat()?.div(totalSize) ?: 1f
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user