Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
package com.plainstudio.stackcasino.feature.lobby

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.plainstudio.stackcasino.ui.components.BalancePill
import com.plainstudio.stackcasino.ui.components.CurrencyDropdown
import com.plainstudio.stackcasino.ui.theme.SemanticOk
import com.plainstudio.stackcasino.ui.theme.TextLow
import com.plainstudio.stackcasino.ui.theme.TextMedium

/**
* Balance hero: the left column stacks the AVAILABLE label, the today
* P&L chip, session stats, the masked balance pill and the currency
* dropdown; the right column shows the LOCKED stack.
*/
@Composable
internal fun BalanceHero(
balance: BalanceSummary,
session: SessionStats,
isHidden: Boolean,
onToggleHidden: () -> Unit,
) {
Row(
modifier =
Modifier
.fillMaxWidth()
.padding(horizontal = ScreenHorizontalPadding, vertical = SectionVerticalPadding),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.Bottom,
) {
Column(modifier = Modifier.weight(1f)) {
// Top meta row: AVAILABLE label + PnL chip (chip fades when
// balance is hidden but keeps its slot to avoid layout shift).
BalanceMetaRow(
pnLLabel = balance.todayPnLLabel,
isHidden = isHidden,
)
Spacer(modifier = Modifier.height(2.dp))
// Session stats live on their own row below the chip
// (mockup line 52: tracked text-[9px] tabnum following the
// AVAILABLE/chip line via flex-wrap).
Text(
text = "· ${session.rounds} rounds · ${session.wins}W / ${session.losses}L".uppercase(),
color = TextLow,
fontSize = SessionStatsFontSize,
letterSpacing = TrackedLetterSpacing,
style = TextStyle(fontFeatureSettings = "tnum"),
)
Spacer(modifier = Modifier.height(4.dp))
BalancePill(
label = "Available",
amount = balance.amountLabel,
isHidden = isHidden,
onToggleVisibility = onToggleHidden,
)
Spacer(modifier = Modifier.height(8.dp))
CurrencyDropdown(
initialCurrency = balance.currencyCode,
networkLabel = balance.networkLabel,
)
}
LockedColumn(subtitle = balance.lockedSubtitle)
}
}

@Composable
private fun BalanceMetaRow(
pnLLabel: String?,
isHidden: Boolean,
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(6.dp),
) {
Text(
text = "AVAILABLE",
color = TextMedium,
fontSize = MetaFontSize,
letterSpacing = TrackedLetterSpacing,
)
// The PnL chip fades to alpha 0 when balance is hidden (mockup
// line 46: data-bal-fade) so the row width never shifts.
if (pnLLabel != null) {
PnLChip(
label = pnLLabel,
modifier = Modifier.alpha(if (isHidden) 0f else 1f),
)
}
}
}

@Composable
private fun PnLChip(
label: String,
modifier: Modifier = Modifier,
) {
Row(
modifier =
modifier
.background(SemanticOk.copy(alpha = PNL_CHIP_BACKGROUND_ALPHA))
.border(width = 1.dp, color = SemanticOk.copy(alpha = PNL_CHIP_BORDER_ALPHA))
.padding(horizontal = 6.dp, vertical = 2.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(2.dp),
) {
Text(
text = label.uppercase(),
color = SemanticOk,
fontSize = PnlChipFontSize,
fontWeight = FontWeight.SemiBold,
letterSpacing = TrackedLetterSpacing,
style = TextStyle(fontFeatureSettings = "tnum"),
)
}
}

@Composable
private fun LockedColumn(subtitle: String) {
Column(horizontalAlignment = Alignment.End) {
Text(
text = "LOCKED",
color = TextMedium,
fontSize = MetaFontSize,
letterSpacing = TrackedLetterSpacing,
)
Spacer(modifier = Modifier.height(6.dp))
Text(
text = subtitle.uppercase(),
color = TextLow,
fontSize = MetaFontSize,
letterSpacing = TrackedLetterSpacing,
)
}
}

private val SessionStatsFontSize = 9.sp
private val PnlChipFontSize = 9.sp
private const val PNL_CHIP_BACKGROUND_ALPHA = 0.15f
private const val PNL_CHIP_BORDER_ALPHA = 0.40f
Loading
Loading