Compare commits
No commits in common. "8d95c3271cd62213171c29e4085787f2093c2234" and "5f1787d6ff6e9609a4570f60267b4709eab5676a" have entirely different histories.
8d95c3271c
...
5f1787d6ff
2 changed files with 33 additions and 46 deletions
1
app/.gitignore
vendored
1
app/.gitignore
vendored
|
@ -1,2 +1 @@
|
||||||
/build
|
/build
|
||||||
/release
|
|
|
@ -2,14 +2,11 @@ package eu.m724.vastapp.activity.dashboard.screen
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
|
||||||
import androidx.compose.foundation.layout.FlowRow
|
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
@ -36,8 +33,9 @@ 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 org.json.JSONObject
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class) // for pullRefresh
|
@OptIn(ExperimentalMaterial3Api::class) // for pullRefresh
|
||||||
@Composable
|
@Composable
|
||||||
fun DashboardScreen(dashboardViewModel: DashboardViewModel) {
|
fun DashboardScreen(dashboardViewModel: DashboardViewModel) {
|
||||||
val uiState by dashboardViewModel.uiState.collectAsState()
|
val uiState by dashboardViewModel.uiState.collectAsState()
|
||||||
|
@ -65,27 +63,27 @@ fun DashboardScreen(dashboardViewModel: DashboardViewModel) {
|
||||||
Text("Hello ${user.username}!", fontSize = 28.sp)
|
Text("Hello ${user.username}!", fontSize = 28.sp)
|
||||||
}
|
}
|
||||||
|
|
||||||
FlowRow {
|
Row(
|
||||||
// balance card
|
modifier = Modifier.width(340.dp)
|
||||||
|
) {
|
||||||
Card(
|
Card(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(160.dp)
|
.fillMaxWidth()
|
||||||
.padding(16.dp),
|
.padding(16.dp)
|
||||||
|
.weight(1f),
|
||||||
colors = CardDefaults.cardColors(
|
colors = CardDefaults.cardColors(
|
||||||
containerColor = balanceCardColor(user.credit)
|
containerColor = balanceCardColor(user.credit)
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.padding(16.dp, 8.dp),
|
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
modifier = Modifier.size(24.dp),
|
|
||||||
painter = painterResource(id = R.drawable.baseline_monetization_on_24),
|
painter = painterResource(id = R.drawable.baseline_monetization_on_24),
|
||||||
contentDescription = "Balance"
|
contentDescription = "Balance"
|
||||||
)
|
)
|
||||||
Spacer(
|
Spacer(modifier = Modifier
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.weight(1f)
|
.weight(1f)
|
||||||
)
|
)
|
||||||
|
@ -96,19 +94,17 @@ fun DashboardScreen(dashboardViewModel: DashboardViewModel) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// time card
|
|
||||||
Card(
|
Card(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(160.dp)
|
.fillMaxWidth()
|
||||||
.padding(16.dp)
|
.padding(16.dp)
|
||||||
|
.weight(1f),
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.padding(16.dp, 8.dp),
|
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
modifier = Modifier.size(24.dp),
|
|
||||||
painter = painterResource(id = R.drawable.baseline_access_time_filled_24),
|
painter = painterResource(id = R.drawable.baseline_access_time_filled_24),
|
||||||
contentDescription = "Remaining time"
|
contentDescription = "Remaining time"
|
||||||
)
|
)
|
||||||
|
@ -123,32 +119,24 @@ fun DashboardScreen(dashboardViewModel: DashboardViewModel) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// instances
|
// TODO maybe reuse that from Instances?
|
||||||
Card(
|
|
||||||
modifier = Modifier
|
val instance = JSONObject()
|
||||||
.width(160.dp)
|
instance.put("id", 234523)
|
||||||
.padding(16.dp)
|
instance.put("machine_id", 1121323)
|
||||||
|
instance.put("host_id", 5924)
|
||||||
|
instance.put("gpu_name", "RTX 4090")
|
||||||
|
instance.put("num_gpus", 2)
|
||||||
|
instance.put("gpu_util", 70)
|
||||||
|
instance.put("gpu_ram", 24564)
|
||||||
|
instance.put("vmem_usage", 0.339843)
|
||||||
|
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.width(340.dp)
|
||||||
) {
|
) {
|
||||||
Row(
|
InstanceCard(instance = instance, modifier = Modifier.padding(16.dp))
|
||||||
modifier = Modifier.padding(16.dp, 8.dp),
|
|
||||||
verticalAlignment = Alignment.CenterVertically
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
modifier = Modifier.size(24.dp),
|
|
||||||
painter = painterResource(id = R.drawable.server_solid),
|
|
||||||
contentDescription = "Rented"
|
|
||||||
)
|
|
||||||
Spacer(modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.weight(1f)
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
text = "4",
|
|
||||||
fontSize = 22.sp
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue