Skip to content

Commit

Permalink
feature: use colorful chips for post tags
Browse files Browse the repository at this point in the history
  • Loading branch information
uragiristereo committed May 19, 2022
1 parent 56bdfa2 commit dd53829
Show file tree
Hide file tree
Showing 6 changed files with 393 additions and 138 deletions.
1 change: 1 addition & 0 deletions app-alpha/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ dependencies {
// Accompanist
def accompanist_version = "0.24.7-alpha"
implementation "com.google.accompanist:accompanist-systemuicontroller:$accompanist_version"
implementation "com.google.accompanist:accompanist-flowlayout:0.24.7-alpha"
// DataStore
implementation "androidx.datastore:datastore:1.0.0"
// ExoPlayer
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.github.uragiristereo.mejiboard.common.helper

import kotlin.math.floor
import kotlin.math.ln
import kotlin.math.pow
import kotlin.math.roundToInt

object NumberHelper {
fun convertToReadable(number: Int): String {
if (number < 1000)
return "$number"

val units = listOf(' ', 'K', 'M', 'G')

val i = floor(ln(number.toDouble()) / ln(1000.0))
val p = 1000.0.pow(i)
val s = (number / p * 100).roundToInt() / 100.0

return if (s > 10) {
"%d%s".format(s.roundToInt(), units[i.toInt()])
} else {
"%.1f%s".format(s, units[i.toInt()])
.replace(oldValue = ".0", newValue = "")
}
}
}
Loading

0 comments on commit dd53829

Please sign in to comment.