|
|
@ -5,6 +5,7 @@ import app.data.entity.Player; |
|
|
|
import app.gameimage.GameImageUtils; |
|
|
|
import app.utils.ChessComUtils; |
|
|
|
import app.utils.EntityComponentUtils; |
|
|
|
import app.utils.TimeControl; |
|
|
|
import com.vaadin.flow.component.button.Button; |
|
|
|
import com.vaadin.flow.component.button.ButtonVariant; |
|
|
|
import com.vaadin.flow.component.html.Div; |
|
|
@ -85,26 +86,21 @@ public class GameCardUtils { |
|
|
|
|
|
|
|
|
|
|
|
public static Div getTimeControlDiv(Game game) { |
|
|
|
String timeControl = game.getGameInfo().getTimeControl(); |
|
|
|
TimeControl timeControl = TimeControl.fromSecondsString(game.getGameInfo().getTimeControl()); |
|
|
|
|
|
|
|
Icon icon; |
|
|
|
String string; |
|
|
|
switch (timeControl) { |
|
|
|
case "600": |
|
|
|
case TEN_MINUTES: |
|
|
|
icon = new Icon(VaadinIcon.STOPWATCH); |
|
|
|
string = "10 min"; |
|
|
|
break; |
|
|
|
case "300": |
|
|
|
case FIVE_MINUTES: |
|
|
|
icon = new Icon(VaadinIcon.BOLT); |
|
|
|
string = "5 min"; |
|
|
|
break; |
|
|
|
case "180": |
|
|
|
case THREE_MINUTES: |
|
|
|
icon = new Icon(VaadinIcon.BOMB); |
|
|
|
string = "3 min"; |
|
|
|
break; |
|
|
|
default: |
|
|
|
icon = new Icon(VaadinIcon.QUESTION); |
|
|
|
string = String.format("Unknown Time Control: %s", timeControl); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
@ -114,7 +110,7 @@ public class GameCardUtils { |
|
|
|
HorizontalLayout horizontalLayout = new HorizontalLayout(); |
|
|
|
horizontalLayout.setWidthFull(); |
|
|
|
horizontalLayout.setJustifyContentMode(FlexComponent.JustifyContentMode.CENTER); |
|
|
|
horizontalLayout.add(icon, new Label(string)); |
|
|
|
horizontalLayout.add(icon, new Label(timeControl.toPresentationString())); |
|
|
|
|
|
|
|
div.add(horizontalLayout); |
|
|
|
|
|
|
|