Pith - stave
stave/app/src/main/kotlin/com/vgmlr/stave/StaveClass.kt [2.2 kb]
Modified: 20:14:53 158 026 (24 Aug 026)
0 Days Ago
package com.vgmlr.stave

import androidx.compose.ui.graphics.Color
import java.util.Locale
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.AirplaneTicket
import androidx.compose.material.icons.automirrored.filled.Help
import androidx.compose.material.icons.filled.Fastfood
import androidx.compose.material.icons.filled.Home
import androidx.compose.material.icons.filled.LocalGasStation
import androidx.compose.material.icons.filled.LocalGroceryStore
import androidx.compose.material.icons.filled.DirectionsBus
import androidx.compose.ui.graphics.vector.ImageVector

data class StaveEntry(
    val id: Int,
    val tripId: Int,
    val cost: Double,
    val category: String,
    val location: String,
    val stavetime: String,
    val lat: Double? = null,
    val lng: Double? = null,
    val note: String = ""
) {
    val label: String get() = note.ifBlank { category }
}

data class StaveTrip(
    val id: Int,
    val name: String,
    val stavetime: String,
    val total: Double = 0.0,
    val startLocation: String = "",
    val lastLocation: String = ""
)

object StaveCategory {
    const val DEFAULT = "Fuel"
    const val MISC = "Miscellaneous"

    val ALL =
        listOf("Fuel", "Food/Beverage", "Room", "Merchandise", "Ticket", "Transportation", MISC)

    private val COLORS = listOf(
        Color(0xFF6E9E8B),
        Color(0xFFB4885B),
        Color(0xFF7A8CA8),
        Color(0xFFA8737B),
        Color(0xFF8E8AA8),
        Color(0xFF98A87A),
        Color(0xFF868D97)
    )

    fun color(name: String): Color {
        val i = ALL.indexOf(name)
        return COLORS[if (i >= 0) i else COLORS.lastIndex]
    }

    fun normalize(name: String): String = if (name in ALL) name else MISC
    
    fun icon(name: String): ImageVector = when (name) {
        "Fuel" -> Icons.Filled.LocalGasStation
        "Food/Beverage" -> Icons.Filled.Fastfood
        "Room" -> Icons.Filled.Home
        "Merchandise" -> Icons.Filled.LocalGroceryStore
        "Ticket" -> Icons.AutoMirrored.Filled.AirplaneTicket
        "Transportation" -> Icons.Filled.DirectionsBus
        else -> Icons.AutoMirrored.Filled.Help
    }
}

fun money(value: Double): String = String.format(Locale.US, "%,.2f", value)
Updates
Stave - Android 158.026
Kerf - Android 157.026
Kiln - Android 157.026
Wedge - Android 156.026
Whittle - Linux 155.026

Menu
Calendar
Project Tin (024/029)
Miter
RSS Feed
User Avatar
@vgmlr
=SUM(parts)
0.00237
257,426 (+36)