Skip to content
Snippets Groups Projects
Verified Commit a3594f5d authored by Réthelyi Bálint's avatar Réthelyi Bálint :no_mouth:
Browse files

add lost in space functionality

parent 14773467
No related branches found
No related tags found
No related merge requests found
Pipeline #18309 passed
...@@ -4,6 +4,7 @@ import androidx.compose.foundation.layout.Arrangement ...@@ -4,6 +4,7 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material.DropdownMenu
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.SmallTopAppBar import androidx.compose.material3.SmallTopAppBar
...@@ -37,6 +38,10 @@ fun AppBar(internet: Boolean) { ...@@ -37,6 +38,10 @@ fun AppBar(internet: Boolean) {
contentDescription = stringResource(R.string.no_internet) contentDescription = stringResource(R.string.no_internet)
) )
} }
// DropdownMenu()
// {
//
// }
}, },
) )
} }
\ No newline at end of file
...@@ -26,6 +26,7 @@ fun MachineOnFloorView(machine: Machine, modifier: Modifier, lastRequestTime: Da ...@@ -26,6 +26,7 @@ fun MachineOnFloorView(machine: Machine, modifier: Modifier, lastRequestTime: Da
onClick = { onClick = {
val intent = Intent(context, MachineViewActivity::class.java) val intent = Intent(context, MachineViewActivity::class.java)
intent.putExtra("machine", machine) intent.putExtra("machine", machine)
intent.putExtra("last_request_time", lastRequestTime)
context.startActivity(intent) context.startActivity(intent)
}), }),
color = when { color = when {
......
...@@ -21,12 +21,13 @@ import com.google.firebase.messaging.ktx.messaging ...@@ -21,12 +21,13 @@ import com.google.firebase.messaging.ktx.messaging
import space.rethelyi.mosogepsch.R import space.rethelyi.mosogepsch.R
import space.rethelyi.mosogepsch.model.Machine import space.rethelyi.mosogepsch.model.Machine
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.*
val format = SimpleDateFormat.getDateTimeInstance() val format = SimpleDateFormat.getDateTimeInstance()
@Composable @Composable
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
fun MachineScreen(machine: Machine, onUpdate: (Boolean) -> Unit) { fun MachineScreen(machine: Machine, lastRequestTime: Date?, onUpdate: (Boolean) -> Unit) {
val modifier = Modifier.fillMaxWidth() val modifier = Modifier.fillMaxWidth()
val ctx = LocalContext.current val ctx = LocalContext.current
Scaffold( Scaffold(
...@@ -61,10 +62,25 @@ fun MachineScreen(machine: Machine, onUpdate: (Boolean) -> Unit) { ...@@ -61,10 +62,25 @@ fun MachineScreen(machine: Machine, onUpdate: (Boolean) -> Unit) {
) { ) {
Card( Card(
modifier = modifier, modifier = modifier,
color = if (machine.status == 1) { MaterialTheme.colorScheme.error } else { MaterialTheme.colorScheme.primary } color = when {
machine.last_query_time.isLostInSpace(lastRequestTime) -> {
MaterialTheme.colorScheme.surfaceVariant
}
machine.status == 1 -> {
MaterialTheme.colorScheme.error
}
else -> MaterialTheme.colorScheme.primary
},
) { ) {
val status = if (machine.status == 1) { stringResource(R.string.not_available) } else { stringResource( val status = when {
R.string.available) } machine.last_query_time.isLostInSpace(lastRequestTime) -> {
stringResource(R.string.lost_in_space)
}
machine.status == 1 -> {
stringResource(R.string.not_available)
}
else -> stringResource(R.string.available)
}
Text( Text(
modifier = modifier modifier = modifier
.padding(16.dp), .padding(16.dp),
......
...@@ -7,12 +7,14 @@ import androidx.compose.material3.MaterialTheme ...@@ -7,12 +7,14 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface import androidx.compose.material3.Surface
import space.rethelyi.mosogepsch.model.Machine import space.rethelyi.mosogepsch.model.Machine
import space.rethelyi.mosogepsch.ui.theme.MosogepSCHTheme import space.rethelyi.mosogepsch.ui.theme.MosogepSCHTheme
import java.util.*
class MachineViewActivity : ComponentActivity() { class MachineViewActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
val machine = intent.getSerializableExtra("machine") as? Machine ?: throw IllegalArgumentException("machine must be machine") val machine = intent.getSerializableExtra("machine") as? Machine ?: throw IllegalArgumentException("machine must be machine")
val lastRequestTime = intent.getSerializableExtra("last_request_time") as? Date ?: throw IllegalArgumentException("date must be date")
setContent { setContent {
MosogepSCHTheme { MosogepSCHTheme {
...@@ -20,6 +22,7 @@ class MachineViewActivity : ComponentActivity() { ...@@ -20,6 +22,7 @@ class MachineViewActivity : ComponentActivity() {
Surface(color = MaterialTheme.colorScheme.background) { Surface(color = MaterialTheme.colorScheme.background) {
MachineScreen( MachineScreen(
machine = machine, machine = machine,
lastRequestTime = lastRequestTime
) { false } ) { false }
} }
} }
......
...@@ -17,4 +17,5 @@ ...@@ -17,4 +17,5 @@
<string name="title">%1$s. emeleti %2$s</string> <string name="title">%1$s. emeleti %2$s</string>
<string name="notification_msg">A %1$s. emeleti %2$s %3$s lett.</string> <string name="notification_msg">A %1$s. emeleti %2$s %3$s lett.</string>
<string name="no_internet">nincs internet kapcsolat</string> <string name="no_internet">nincs internet kapcsolat</string>
<string name="lost_in_space">elveszett (az űrben)</string>
</resources> </resources>
\ No newline at end of file
...@@ -19,4 +19,5 @@ ...@@ -19,4 +19,5 @@
<string name="title">%2$s on floor %1$s</string> <string name="title">%2$s on floor %1$s</string>
<string name="notification_msg">The %2$s on floor %1$s became %3$s</string> <string name="notification_msg">The %2$s on floor %1$s became %3$s</string>
<string name="no_internet">no internet connection</string> <string name="no_internet">no internet connection</string>
<string name="lost_in_space">lost in space</string>
</resources> </resources>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment