tweak cards on dashboard
to allow very short and very long text looks fine too
This commit is contained in:
parent
99b7229628
commit
37475c83d5
1 changed files with 8 additions and 15 deletions
|
@ -37,7 +37,6 @@ import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import eu.m724.vastapp.R
|
import eu.m724.vastapp.R
|
||||||
import eu.m724.vastapp.activity.dashboard.DashboardViewModel
|
import eu.m724.vastapp.activity.dashboard.DashboardViewModel
|
||||||
import kotlin.math.min
|
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class) // for pullRefresh
|
@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class) // for pullRefresh
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -45,7 +44,7 @@ fun DashboardScreen(dashboardViewModel: DashboardViewModel) {
|
||||||
val uiState by dashboardViewModel.uiState.collectAsState()
|
val uiState by dashboardViewModel.uiState.collectAsState()
|
||||||
|
|
||||||
val user by remember(uiState) { derivedStateOf { uiState.user } }
|
val user by remember(uiState) { derivedStateOf { uiState.user } }
|
||||||
val remainingTime by rememberSaveable { mutableIntStateOf(0) }
|
val remainingTime by rememberSaveable { mutableIntStateOf(6000000) }
|
||||||
|
|
||||||
val scrollState = rememberScrollState()
|
val scrollState = rememberScrollState()
|
||||||
|
|
||||||
|
@ -70,11 +69,12 @@ fun DashboardScreen(dashboardViewModel: DashboardViewModel) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
FlowRow {
|
FlowRow(
|
||||||
|
horizontalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
// balance card
|
// balance card
|
||||||
Card(
|
Card(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(160.dp)
|
|
||||||
.padding(16.dp),
|
.padding(16.dp),
|
||||||
colors = CardDefaults.cardColors(
|
colors = CardDefaults.cardColors(
|
||||||
containerColor = balanceCardColor(user.credit)
|
containerColor = balanceCardColor(user.credit)
|
||||||
|
@ -90,9 +90,7 @@ fun DashboardScreen(dashboardViewModel: DashboardViewModel) {
|
||||||
contentDescription = stringResource(id = R.string.balance)
|
contentDescription = stringResource(id = R.string.balance)
|
||||||
)
|
)
|
||||||
Spacer(
|
Spacer(
|
||||||
modifier = Modifier
|
modifier = Modifier.width(12.dp)
|
||||||
.fillMaxWidth()
|
|
||||||
.weight(1f)
|
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = "$%.2f".format(user.credit),
|
text = "$%.2f".format(user.credit),
|
||||||
|
@ -105,7 +103,6 @@ fun DashboardScreen(dashboardViewModel: DashboardViewModel) {
|
||||||
// time card
|
// time card
|
||||||
Card(
|
Card(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(160.dp)
|
|
||||||
.padding(16.dp)
|
.padding(16.dp)
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
|
@ -118,9 +115,7 @@ fun DashboardScreen(dashboardViewModel: DashboardViewModel) {
|
||||||
contentDescription = stringResource(id = R.string.time_left)
|
contentDescription = stringResource(id = R.string.time_left)
|
||||||
)
|
)
|
||||||
Spacer(
|
Spacer(
|
||||||
modifier = Modifier
|
modifier = Modifier.width(12.dp)
|
||||||
.fillMaxWidth()
|
|
||||||
.weight(1f)
|
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = formatTime(remainingTime),
|
text = formatTime(remainingTime),
|
||||||
|
@ -132,7 +127,6 @@ fun DashboardScreen(dashboardViewModel: DashboardViewModel) {
|
||||||
// instances
|
// instances
|
||||||
Card(
|
Card(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(160.dp)
|
|
||||||
.padding(16.dp)
|
.padding(16.dp)
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
|
@ -144,9 +138,8 @@ fun DashboardScreen(dashboardViewModel: DashboardViewModel) {
|
||||||
painter = painterResource(id = R.drawable.server_solid),
|
painter = painterResource(id = R.drawable.server_solid),
|
||||||
contentDescription = stringResource(id = R.string.rented_instances)
|
contentDescription = stringResource(id = R.string.rented_instances)
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier
|
Spacer(
|
||||||
.fillMaxWidth()
|
modifier = Modifier.width(12.dp)
|
||||||
.weight(1f)
|
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = "4",
|
text = "4",
|
||||||
|
|
Loading…
Reference in a new issue