diff --git a/app/src/main/java/eu/m724/vastapp/activity/dashboard/DashboardViewModel.kt b/app/src/main/java/eu/m724/vastapp/activity/dashboard/DashboardViewModel.kt index 612a2e4..5be130b 100644 --- a/app/src/main/java/eu/m724/vastapp/activity/dashboard/DashboardViewModel.kt +++ b/app/src/main/java/eu/m724/vastapp/activity/dashboard/DashboardViewModel.kt @@ -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 - } \ No newline at end of file diff --git a/app/src/main/java/eu/m724/vastapp/activity/dashboard/screen/Instances.kt b/app/src/main/java/eu/m724/vastapp/activity/dashboard/screen/Instances.kt index 921c78f..b730e48 100644 --- a/app/src/main/java/eu/m724/vastapp/activity/dashboard/screen/Instances.kt +++ b/app/src/main/java/eu/m724/vastapp/activity/dashboard/screen/Instances.kt @@ -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)) { - Text(label, fontSize = 22.sp) + 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),