-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: live time elapsed display on install steps
- Loading branch information
1 parent
bd5bc39
commit 4b820e5
Showing
7 changed files
with
105 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
app/src/main/kotlin/com/aliucord/manager/ui/screens/install/components/TimeElapsed.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.aliucord.manager.ui.screens.install.components | ||
|
||
import androidx.compose.animation.* | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
|
||
@Composable | ||
fun TimeElapsed( | ||
seconds: Float, | ||
enabled: Boolean = true, | ||
modifier: Modifier = Modifier, | ||
) { | ||
AnimatedVisibility( | ||
visible = enabled, | ||
enter = fadeIn(), | ||
exit = ExitTransition.None, | ||
label = "TimeElapsed Visibility" | ||
) { | ||
Text( | ||
text = "%.2fs".format(seconds), | ||
style = MaterialTheme.typography.labelMedium, | ||
maxLines = 1, | ||
modifier = modifier, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.aliucord.manager.util | ||
|
||
import kotlin.math.pow | ||
import kotlin.math.truncate | ||
|
||
/** | ||
* Truncates this value to a specific number of [decimals] digits. | ||
*/ | ||
fun Double.toPrecision(decimals: Int): Double { | ||
val multiplier = 10.0.pow(decimals) | ||
return truncate(this * multiplier) / multiplier | ||
} |