[WIP] Created a snackbar for notification. Currently used for keybinding success/fail. Need to show red if fails.

#story[1278]
This commit is contained in:
Zhi You Tan
2017-09-23 01:39:26 +12:00
parent 094eb4c1cf
commit 957821f1f2
4 changed files with 71 additions and 17 deletions
@@ -4,6 +4,7 @@ import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXDecorator;
import com.jfoenix.controls.JFXDialog;
import com.jfoenix.controls.JFXDialog.DialogTransition;
import com.jfoenix.controls.JFXSnackbar;
import com.jfoenix.svg.SVGGlyph;
import java.io.IOException;
import java.util.HashMap;
@@ -37,6 +38,7 @@ public class ViewManager {
private ObservableList<String> playerList;
private Logger logger = LoggerFactory.getLogger(ViewManager.class);
private Stage stage;
private JFXSnackbar jfxSnackbar;
private ViewManager() {
properties = new HashMap<>();
@@ -98,6 +100,10 @@ public class ViewManager {
gameClient.stopGame();
System.exit(0);
});
jfxSnackbar = new JFXSnackbar();
decorator.getChildren().add(jfxSnackbar);
jfxSnackbar.registerSnackbarContainer(decorator);
}
/**
@@ -210,13 +216,22 @@ public class ViewManager {
DialogTransition.CENTER);
KeyBindingDialogController keyBindingDialogController = dialogContent
.getController();
keyBindingDialogController.init(gameClient.getKeyBind());
keyBindingDialogController.init(gameClient.getKeyBind(), this);
dialog.show();
Sounds.playButtonClick();
}
}
}
/**
* Show a snackbar at the bottom of the app for 1 second.
*
* @param snackbarText text to be displayed.
*/
public void showSnackbar(String snackbarText) {
jfxSnackbar.show(snackbarText, 1000);
}
/**
* Determines if a PC has compatibility with the bonjour protocol for server detection.
*/
@@ -362,4 +377,13 @@ public class ViewManager {
public Stage getStage() {
return stage;
}
/**
* Getter to return snackbar object.
*
* @return snackbar object.
*/
public JFXSnackbar getJfxSnackbar() {
return jfxSnackbar;
}
}