Skip to content

Commit

Permalink
Revamped Card Detail UI (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
r0adkll authored Aug 17, 2023
1 parent 809d1af commit 1ac55f4
Show file tree
Hide file tree
Showing 72 changed files with 1,352 additions and 529 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
jobs:
danger-pr:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
name: "danger-pr"
steps:
- uses: actions/checkout@v1
Expand Down Expand Up @@ -100,6 +101,7 @@ jobs:
-x :androidApp:bundle
- name: Danger Lint
if: ${{ github.event_name == 'pull_request' }}
uses: docker://ghcr.io/danger/danger-kotlin:1.2.0
with:
args: --failOnErrors --no-publish-check
Expand Down
1 change: 0 additions & 1 deletion .idea/kotlinScripting.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,6 @@ val DeckBoxIcons.Types.Colorless: ImageVector
curveTo(10.8635f, 7.1708f, 11.5584f, 5.1805f, 12.138f, 1.8127f)
close()
}
path(
fill = SolidColor(Color(0xFF000000)),
fillAlpha = 1.0f,
stroke = null,
strokeAlpha = 1.0f,
strokeLineWidth = 1.0f,
strokeLineCap = StrokeCap.Butt,
strokeLineJoin = StrokeJoin.Miter,
strokeLineMiter = 1.0f,
pathFillType = PathFillType.NonZero,
) {
moveTo(24f, 0f)
horizontalLineTo(-9.53674e-7f)
verticalLineTo(24f)
horizontalLineTo(24f)
verticalLineTo(0f)
close()
}
}
}.build()
return _colorless!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,6 @@ val DeckBoxIcons.Types.Dark: ImageVector
curveTo(2.4f, 8.599f, 5.3505f, 5.3568f, 9.3631f, 4.3922f)
close()
}
path(
fill = SolidColor(Color(0xFF000000)),
fillAlpha = 1.0f,
stroke = null,
strokeAlpha = 1.0f,
strokeLineWidth = 1.0f,
strokeLineCap = StrokeCap.Butt,
strokeLineJoin = StrokeJoin.Miter,
strokeLineMiter = 1.0f,
pathFillType = PathFillType.NonZero,
) {
moveTo(24f, 0f)
horizontalLineTo(0f)
verticalLineTo(24f)
horizontalLineTo(24f)
verticalLineTo(0f)
close()
}
}
}.build()
return _dark!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,6 @@ val DeckBoxIcons.Types.Dragon: ImageVector
lineTo(13.2331f, 13.2976f)
close()
}
path(
fill = SolidColor(Color(0xFF000000)),
fillAlpha = 1.0f,
stroke = null,
strokeAlpha = 1.0f,
strokeLineWidth = 1.0f,
strokeLineCap = StrokeCap.Butt,
strokeLineJoin = StrokeJoin.Miter,
strokeLineMiter = 1.0f,
pathFillType = PathFillType.NonZero,
) {
moveTo(24f, 0f)
horizontalLineTo(0f)
verticalLineTo(24f)
horizontalLineTo(24f)
verticalLineTo(0f)
close()
}
}
}.build()
return _dragon!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,6 @@ val DeckBoxIcons.Types.Fairy: ImageVector
curveTo(10.8213f, 5.373f, 11.4493f, 4.2893f, 12.0798f, 2.5199f)
close()
}
path(
fill = SolidColor(Color(0xFF000000)),
fillAlpha = 1.0f,
stroke = null,
strokeAlpha = 1.0f,
strokeLineWidth = 1.0f,
strokeLineCap = StrokeCap.Butt,
strokeLineJoin = StrokeJoin.Miter,
strokeLineMiter = 1.0f,
pathFillType = PathFillType.NonZero,
) {
moveTo(24f, 0f)
horizontalLineTo(0f)
verticalLineTo(24f)
horizontalLineTo(24f)
verticalLineTo(0f)
close()
}
}
}.build()
return _fairy!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,24 +111,6 @@ val DeckBoxIcons.Types.Fighting: ImageVector
lineTo(14.1943f, 12.2197f)
close()
}
path(
fill = SolidColor(Color(0xFF000000)),
fillAlpha = 1.0f,
stroke = null,
strokeAlpha = 1.0f,
strokeLineWidth = 1.0f,
strokeLineCap = StrokeCap.Butt,
strokeLineJoin = StrokeJoin.Miter,
strokeLineMiter = 1.0f,
pathFillType = PathFillType.NonZero,
) {
moveTo(24f, 0f)
horizontalLineTo(0f)
verticalLineTo(24f)
horizontalLineTo(24f)
verticalLineTo(0f)
close()
}
}
}.build()
return _fighting!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,6 @@ val DeckBoxIcons.Types.Fire: ImageVector
curveTo(11.6283f, 13.6253f, 11.9254f, 13.1299f, 12.5197f, 12.5f)
close()
}
path(
fill = SolidColor(Color(0xFF000000)),
fillAlpha = 1.0f,
stroke = null,
strokeAlpha = 1.0f,
strokeLineWidth = 1.0f,
strokeLineCap = StrokeCap.Butt,
strokeLineJoin = StrokeJoin.Miter,
strokeLineMiter = 1.0f,
pathFillType = PathFillType.NonZero,
) {
moveTo(24f, 0f)
horizontalLineTo(0f)
verticalLineTo(24f)
horizontalLineTo(24f)
verticalLineTo(0f)
close()
}
}
}.build()
return _fire!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,6 @@ val DeckBoxIcons.Types.Grass: ImageVector
curveTo(13.177f, 6.1881f, 13.4991f, 5.3691f, 13.939f, 4.2752f)
close()
}
path(
fill = SolidColor(Color(0xFF000000)),
fillAlpha = 1.0f,
stroke = null,
strokeAlpha = 1.0f,
strokeLineWidth = 1.0f,
strokeLineCap = StrokeCap.Butt,
strokeLineJoin = StrokeJoin.Miter,
strokeLineMiter = 1.0f,
pathFillType = PathFillType.NonZero,
) {
moveTo(24f, 0f)
horizontalLineTo(0f)
verticalLineTo(24f)
horizontalLineTo(24f)
verticalLineTo(0f)
close()
}
}
}.build()
return _grass!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,6 @@ val DeckBoxIcons.Types.Lightning: ImageVector
lineTo(13.826f, 1.51495f)
close()
}
path(
fill = SolidColor(Color(0xFF000000)),
fillAlpha = 1.0f,
stroke = null,
strokeAlpha = 1.0f,
strokeLineWidth = 1.0f,
strokeLineCap = StrokeCap.Butt,
strokeLineJoin = StrokeJoin.Miter,
strokeLineMiter = 1.0f,
pathFillType = PathFillType.NonZero,
) {
moveTo(24f, 0f)
horizontalLineTo(0f)
verticalLineTo(24f)
horizontalLineTo(24f)
verticalLineTo(0f)
close()
}
}
}.build()
return _lightning!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,6 @@ val DeckBoxIcons.Types.Psychic: ImageVector
curveTo(9.9498f, 12.65f, 9.6672f, 12.5744f, 9.4203f, 12.4412f)
close()
}
path(
fill = SolidColor(Color(0xFF000000)),
fillAlpha = 1.0f,
stroke = null,
strokeAlpha = 1.0f,
strokeLineWidth = 1.0f,
strokeLineCap = StrokeCap.Butt,
strokeLineJoin = StrokeJoin.Miter,
strokeLineMiter = 1.0f,
pathFillType = PathFillType.NonZero,
) {
moveTo(24f, 0f)
horizontalLineTo(0f)
verticalLineTo(24f)
horizontalLineTo(24f)
verticalLineTo(0f)
close()
}
}
}.build()
return _psychic!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,6 @@ val DeckBoxIcons.Types.Steel: ImageVector
lineTo(8.60269f, 17.1435f)
close()
}
path(
fill = SolidColor(Color(0xFF000000)),
fillAlpha = 1.0f,
stroke = null,
strokeAlpha = 1.0f,
strokeLineWidth = 1.0f,
strokeLineCap = StrokeCap.Butt,
strokeLineJoin = StrokeJoin.Miter,
strokeLineMiter = 1.0f,
pathFillType = PathFillType.NonZero,
) {
moveTo(24f, 0f)
horizontalLineTo(0f)
verticalLineTo(24f)
horizontalLineTo(24f)
verticalLineTo(0f)
close()
}
}
}.build()
return _steel!!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
package app.deckbox.common.compose.icons.types

import Dragon
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.dp
import app.deckbox.common.compose.icons.DeckBoxIcons
import app.deckbox.common.compose.theme.PokemonTypeColor.toColor
import app.deckbox.common.compose.theme.PokemonTypeColor.toContentColor
import app.deckbox.core.model.Type

fun Type.asImageVector(): ImageVector = when (this) {
Expand All @@ -19,3 +29,21 @@ fun Type.asImageVector(): ImageVector = when (this) {
Type.WATER -> DeckBoxIcons.Types.Water
Type.UNKNOWN -> DeckBoxIcons.Types.Colorless
}

@Composable
fun TypeIcon(
type: Type,
modifier: Modifier = Modifier,
) {
Image(
type.asImageVector(),
contentDescription = type.displayName,
modifier = modifier
.background(
color = type.toColor(),
shape = CircleShape,
)
.padding(4.dp),
colorFilter = ColorFilter.tint(type.toContentColor(true)),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,6 @@ val DeckBoxIcons.Types.Water: ImageVector
curveTo(6.7511f, 18.6564f, 8.3174f, 19.5975f, 9.1685f, 19.8892f)
close()
}
path(
fill = SolidColor(Color(0xFF000000)),
fillAlpha = 1.0f,
stroke = null,
strokeAlpha = 1.0f,
strokeLineWidth = 1.0f,
strokeLineCap = StrokeCap.Butt,
strokeLineJoin = StrokeJoin.Miter,
strokeLineMiter = 1.0f,
pathFillType = PathFillType.NonZero,
) {
moveTo(24f, 0f)
horizontalLineTo(0f)
verticalLineTo(24f)
horizontalLineTo(24f)
verticalLineTo(0f)
close()
}
}
}.build()
return _water!!
Expand Down
2 changes: 1 addition & 1 deletion common/resources/strings/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {

kotlin {
sourceSets {
val commonMain by getting {
commonMain {
dependencies {
api(libs.lyricist)
api(compose.foundation)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package app.deckbox.common.resources.strings

import android.icu.number.Notation
import android.icu.number.NumberFormatter
import android.icu.number.Precision
import android.icu.text.NumberFormat
import android.icu.util.Currency
import android.os.Build
import androidx.annotation.RequiresApi
import java.util.Locale

actual object CurrencyFormatter {

actual fun format(value: Double, type: CurrencyType): String {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
formatAndroid30(value, type)
} else {
formatLegacy(value, type)
}
}

@RequiresApi(Build.VERSION_CODES.R)
private fun formatAndroid30(value: Double, type: CurrencyType): String {
return NumberFormatter.withLocale(Locale.getDefault())
.notation(Notation.compactLong())
.unit(type.asCurrency())
.precision(Precision.maxSignificantDigits(2))
.format(value)
.toString()
}

private fun formatLegacy(value: Double, type: CurrencyType): String {
return NumberFormat.getInstance(Locale.getDefault())
.apply {
currency = type.asCurrency()
maximumFractionDigits = 2
}
.format(value)
}

private fun CurrencyType.asCurrency(): Currency {
return when (this) {
CurrencyType.USD -> Currency.getInstance(Locale.US)
CurrencyType.EUR -> Currency.getInstance("EUR")
}
}
}
Loading

0 comments on commit 1ac55f4

Please sign in to comment.