Added offline mode warning and note

This commit is contained in:
Maximilian P. Käfer 2020-08-24 21:54:25 +02:00
parent 1983cebde1
commit da309098b7
2 changed files with 34 additions and 12 deletions

View File

@ -22,15 +22,15 @@ import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.*;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.FileChooser;
@ -183,12 +183,20 @@ public final class ChatScene implements Restorable {
clip.setArcWidth(43);
clientProfilePic.setClip(clip);
Platform.runLater(() -> {
if(client.isOnline()) {
try {
contactSearchTab.setContent(FXMLLoader.load(new File("src/main/resources/fxml/ContactSearchTab.fxml").toURI().toURL()));
groupCreationTab.setContent(FXMLLoader.load(new File("src/main/resources/fxml/GroupCreationTab.fxml").toURI().toURL()));
} catch (Exception e2) {
e2.printStackTrace();
}
} else {
contactSearchTab.setContent(createOfflineNote());
groupCreationTab.setContent(createOfflineNote());
}
});
//Listen to backEvents
eventBus.register(BackEvent.class, e -> tabPane.getSelectionModel().select(0));
@ -264,6 +272,22 @@ public final class ChatScene implements Restorable {
});
}
private AnchorPane createOfflineNote() {
AnchorPane anc = new AnchorPane();
VBox vBox = new VBox();
vBox.setAlignment(Pos.TOP_CENTER);
vBox.setPrefWidth(316);
Label label = new Label("You have to be online!");
label.setPadding(new Insets(50, 0, 5, 0));
Button button = new Button("OK");
button.setOnAction(e -> eventBus.dispatch(new BackEvent()));
vBox.getChildren().add(label);
vBox.getChildren().add(button);
anc.getChildren().add(vBox);
anc.setId("note-background");
return anc;
}
/**
* Initializes all {@code SystemCommands} used in {@code ChatScene}.
*
@ -398,8 +422,6 @@ public final class ChatScene implements Restorable {
*/
@FXML
private void addContactButtonClicked() {
// sceneContext.load(SceneContext.SceneInfo.CONTACT_SEARCH_SCENE);
// sceneContext.<ContactSearchScene>getController().initializeData(sceneContext, localDB);
tabPane.getSelectionModel().select(1);
}

View File

@ -46,7 +46,7 @@
-fx-background-color: rgb(25, 25, 25);
}
#chatList, #topBar, #search-panel {
#chatList, #topBar, #search-panel, #note-background {
-fx-background-color: #303030;
}