Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WR-381: Show warning for demo events #32

Merged
merged 3 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ data class GetEventDto(
val streetNumber: String,
val postalCode: String,
val city: String,
val organisationId: ID
val organisationId: ID,
val isDemo: Boolean
) {
@Transient
val date: LocalDate? = dateString?.let { LocalDate.parse(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ fun Navigation() {
LoginScreen(viewModel)
}

Screen.MainScreen -> {
val viewModel = getViewModel { MainScreenViewModel(navigator) }
is Screen.MainScreen -> {
val viewModel = getViewModel { MainScreenViewModel(navigator, screenState.isDemoEvent) }
MainScreen(viewModel)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ sealed class Screen {
object StartUpScreen : Screen()
object LoginScreen : Screen()
object ConfigurePrintersScreen : Screen()
object MainScreen : Screen()
class MainScreen(val isDemoEvent: Boolean) : Screen()
object AppVersionTooOld : Screen()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.datepollsystems.waiterrobot.mediator.ui.common

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp

@Composable
fun DemoEventInfo(isDemoEvent: Boolean?) {
if (isDemoEvent != true) return

Surface(
modifier = Modifier.fillMaxWidth(),
color = Color.Red.copy(alpha = 0.9f),
contentColor = Color.Black
) {
Text(
text = "The selected Event is a Demo-Event. Orders will not be printed completely.",
dev-Fabi marked this conversation as resolved.
Show resolved Hide resolved
modifier = Modifier.padding(5.dp).fillMaxWidth(),
textAlign = TextAlign.Center
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ import androidx.compose.ui.unit.dp
import org.datepollsystems.waiterrobot.mediator.App
import org.datepollsystems.waiterrobot.mediator.data.api.dto.GetPrinterDto
import org.datepollsystems.waiterrobot.mediator.printer.LocalPrinterInfo
import org.datepollsystems.waiterrobot.mediator.ui.common.CenteredText
import org.datepollsystems.waiterrobot.mediator.ui.common.DropDownInput
import org.datepollsystems.waiterrobot.mediator.ui.common.LoadableScreen
import org.datepollsystems.waiterrobot.mediator.ui.common.SelectedEnvironmentInfo
import org.datepollsystems.waiterrobot.mediator.ui.common.*

@Composable
fun ConfigurePrintersScreen(vm: ConfigurePrintersViewModel) {
Expand All @@ -27,6 +24,7 @@ fun ConfigurePrintersScreen(vm: ConfigurePrintersViewModel) {
LoadableScreen(state.screenState) {
Column {
SelectedEnvironmentInfo()
DemoEventInfo(state.selectedEvent?.isDemo)
Row(
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class ConfigurePrintersViewModel(
PrinterService.pair(pairing.bePrinter, localPrinter)
}

navigator.navigate(Screen.MainScreen)
navigator.navigate(Screen.MainScreen(state.selectedEvent.isDemo))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import org.datepollsystems.waiterrobot.mediator.App
import org.datepollsystems.waiterrobot.mediator.ui.common.DemoEventInfo
import org.datepollsystems.waiterrobot.mediator.ui.common.SelectedEnvironmentInfo
import java.time.format.DateTimeFormatter

Expand All @@ -26,6 +27,7 @@ fun MainScreen(vm: MainScreenViewModel) {

Column {
SelectedEnvironmentInfo()
DemoEventInfo(vm.isDemoEvent)
Row(
modifier = Modifier.padding(vertical = 20.dp),
verticalAlignment = Alignment.CenterVertically
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.datepollsystems.waiterrobot.mediator.ws.messages.PrintTestPdfMessage

class MainScreenViewModel(
navigator: Navigator,
val isDemoEvent: Boolean,
) : AbstractViewModel<MainScreenState>(navigator, MainScreenState()) {

override suspend fun onCreate() {
Expand Down