use these helper methods and tweak instance card
This commit is contained in:
parent
0b4bc2e524
commit
2fc83c4d5b
2 changed files with 20 additions and 8 deletions
|
@ -115,10 +115,10 @@ class DashboardViewModel(
|
|||
|
||||
fun toggleInstance(instance: RentedInstance) {
|
||||
val deferred =
|
||||
if (instance.status == "running") {
|
||||
vastApi.startInstance(instance.rentalId)
|
||||
} else {
|
||||
if (instance.isRunning()) {
|
||||
vastApi.stopInstance(instance.rentalId)
|
||||
} else {
|
||||
vastApi.startInstance(instance.rentalId)
|
||||
}
|
||||
|
||||
viewModelScope.launch {
|
||||
|
@ -144,5 +144,4 @@ class DashboardViewModel(
|
|||
}
|
||||
} // TODO once again these methods share some code and more probably will so why not move the shared stuff
|
||||
// OR not refresh but refresh only instances or even better don't refresh instances but delete or edit that one
|
||||
|
||||
}
|
|
@ -6,9 +6,11 @@ import androidx.compose.foundation.layout.Box
|
|||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ContextualFlowRow
|
||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||
import androidx.compose.foundation.layout.IntrinsicSize
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
|
@ -104,8 +106,19 @@ fun RentedInstanceCard(
|
|||
} }
|
||||
|
||||
Card(modifier = modifier) {
|
||||
Row(modifier = Modifier.padding(8.dp)) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.height(IntrinsicSize.Min)
|
||||
.padding(8.dp)
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxHeight(),
|
||||
verticalArrangement = Arrangement.SpaceEvenly // TODO I think the label is too low
|
||||
) {
|
||||
Text(label, fontSize = 22.sp)
|
||||
Text(rentedInstance.status, fontSize = 14.sp)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
|
||||
Column(
|
||||
|
@ -130,9 +143,9 @@ fun RentedInstanceCard(
|
|||
modifier = Modifier.size(24.dp),
|
||||
contentPadding = PaddingValues(0.dp),
|
||||
onClick = { actionButtonClick(rentedInstance) },
|
||||
enabled = rentedInstance.status == rentedInstance.targetStatus
|
||||
enabled = !rentedInstance.isChangingState()
|
||||
) {
|
||||
if (rentedInstance.status == "running") {
|
||||
if (rentedInstance.isRunning()) {
|
||||
Icon(
|
||||
modifier = Modifier.size(16.dp),
|
||||
painter = painterResource(id = R.drawable.baseline_stop_24),
|
||||
|
|
Loading…
Reference in a new issue