Skip to content

Commit

Permalink
Merge pull request #76 from ruth-lim/branch-enhance-ui
Browse files Browse the repository at this point in the history
Update Ui
  • Loading branch information
ruth-lim authored Oct 17, 2023
2 parents 40ef99c + 55ec0f4 commit 93573ae
Show file tree
Hide file tree
Showing 10 changed files with 288 additions and 82 deletions.
7 changes: 4 additions & 3 deletions src/main/java/seedu/address/ui/DentistCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class DentistCard extends UiPart<Region> {
@FXML
private Label yoe;
@FXML
private Label dentistId;
private FlowPane dentistId;
@FXML
private FlowPane tags;

Expand All @@ -53,15 +53,16 @@ public class DentistCard extends UiPart<Region> {
public DentistCard(Dentist dentist, int displayedIndex) {
super(FXML);
this.dentist = dentist;
id.setText(displayedIndex + ". ");
name.setText(dentist.getName().fullName);
Label idLabel = new Label("ID: " + String.valueOf(dentist.getId()));
dentistId.getChildren().add(idLabel);
phone.setText("Phone: " + dentist.getPhone().value);
address.setText("Address: " + dentist.getAddress().value);
email.setText("Email: " + dentist.getEmail().value);
specialization.setText("Specialization: " + dentist.getSpecialization().getValue());
String experience = dentist.getYoe().getValue();
yoe.setText("Experience: " + experience + ((experience == "0" || experience == "1") ? " Year" : " Years"));
dentistId.setText("Dentist ID: " + String.valueOf(dentist.getId()));

dentist.getTags().stream()
.sorted(Comparator.comparing(tag -> tag.tagName))
.forEach(tag -> tags.getChildren().add(new Label(tag.tagName)));
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public class MainWindow extends UiPart<Stage> {
@FXML
private StackPane resultDisplayPlaceholder;

@FXML
private StackPane quickNotesPlaceholder;

@FXML
private StackPane statusbarPlaceholder;

Expand Down Expand Up @@ -138,6 +141,10 @@ void fillInnerParts() {

CommandBox commandBox = new CommandBox(this::executeCommand);
commandBoxPlaceholder.getChildren().add(commandBox.getRoot());

QuickNotes quickNotes = new QuickNotes();
quickNotesPlaceholder.getChildren().add(quickNotes.getRoot());

}

/**
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/seedu/address/ui/PatientCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ public class PatientCard extends UiPart<Region> {
private Label appointment;
@FXML
private Label service;

@FXML
private Label patientid;
private FlowPane patientId;
@FXML
private FlowPane tags;

Expand All @@ -61,16 +60,16 @@ public class PatientCard extends UiPart<Region> {
public PatientCard(Patient patient, int displayedIndex) {
super(FXML);
this.patient = patient;
id.setText(displayedIndex + ". ");
name.setText(patient.getName().fullName);
Label idLabel = new Label("ID: " + String.valueOf(patient.getId()));
patientId.getChildren().add(idLabel);
phone.setText("Phone: " + patient.getPhone().value);
address.setText("Address: " + patient.getAddress().value);
email.setText("Email: " + patient.getEmail().value);
gender.setText("Gender: " + patient.getGender().value);
birthdate.setText("Birthday: " + patient.getBirthdate().value);
appointment.setText("Appointment: " + patient.getAppointmentdate().value);
service.setText("Service: " + patient.getService().value);
patientid.setText("ID: " + String.valueOf(patient.getId()));

patient.getTags().stream()
.sorted(Comparator.comparing(tag -> tag.tagName))
Expand Down
94 changes: 94 additions & 0 deletions src/main/java/seedu/address/ui/QuickNotes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package seedu.address.ui;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.layout.Region;

/**
* A ui for the status bar that is displayed at the header of the application.
*/
public class QuickNotes extends UiPart<Region> {

private static final String QUICK_NOTES_PATH = "./data/quicknotes.txt";

private static final String FXML = "QuickNotes.fxml";

@FXML
private TextArea quickNotes;

@FXML
private Button saveButton;

@FXML
private Button clearButton;

/**
* Creates a {@code QuickNotes}.
*/
public QuickNotes() {
super(FXML);
initialize();
}

private void initialize() {
saveButton.setOnAction(this::handleSaveNotes);
clearButton.setOnAction(this::handleClearNotes);
loadNotesOnStartup();

quickNotes.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
if (!oldValue.equals(newValue)) {
getRoot().getStyleClass().remove("saved-notes");
}
}
});
}


@FXML
private void handleSaveNotes(ActionEvent event) {
File dir = new File("./data");
if (!dir.exists()) {
dir.mkdirs(); // Create the directory if it doesn't exist
}

try (FileWriter writer = new FileWriter(QUICK_NOTES_PATH)) {
writer.write(quickNotes.getText());
} catch (IOException e) {
e.printStackTrace();
// Insert error message
}

// Change the style of the TextArea after saving
getRoot().getStyleClass().add("saved-notes");
}

@FXML
private void handleClearNotes(ActionEvent event) {
quickNotes.clear();
}

private void loadNotesOnStartup() {
if (new File(QUICK_NOTES_PATH).exists()) {
try {
String content = new String(Files.readAllBytes(Paths.get(QUICK_NOTES_PATH)));
quickNotes.setText(content);
} catch (IOException e) {
e.printStackTrace();
// Insert error message
}
}
}

}
6 changes: 3 additions & 3 deletions src/main/resources/view/DentistListCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@
<Insets top="5" right="5" bottom="5" left="5" />
</padding>
<HBox spacing="5" alignment="CENTER_LEFT">
<Label fx:id="id" styleClass="details-title">
<FlowPane fx:id="dentistId" alignment="CENTER_LEFT" prefWrapLength="0.0" />
<Label fx:id="name" text="\$first" styleClass="details-title" >
<minWidth>
<!-- Ensures that the label text is never truncated -->
<Region fx:constant="USE_PREF_SIZE" />
</minWidth>
</Label>
<Label fx:id="name" text="\$first" styleClass="details-title" />

</HBox>
<FlowPane fx:id="tags" />
<Label fx:id="phone" styleClass="details-text" text="\$phone" />
<Label fx:id="address" styleClass="details-text" text="\$address" />
<Label fx:id="email" styleClass="details-text" text="\$email" />
<Label fx:id="specialization" styleClass="details-text" text="\$specialization" />
<Label fx:id="yoe" styleClass="details-text" text="\$years of experience" />
<Label fx:id="dentistId" styleClass="details-text" text="\$dentistId" />
</VBox>
</GridPane>
</HBox>
80 changes: 78 additions & 2 deletions src/main/resources/view/LightTheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@

.split-pane:horizontal .split-pane-divider {
-fx-background-color: #F4F4F4;
-fx-border-color: transparent transparent transparent #4d4d4d;
-fx-border-color: transparent #4d4d4d transparent transparent;
-fx-padding: 0 3 0 0;
}

.split-pane {
Expand Down Expand Up @@ -115,6 +116,7 @@

.stack-pane {
-fx-background-color: #F4F4F4;
-fx-border-color: transparent;
}

.pane-with-border {
Expand All @@ -127,13 +129,17 @@

.result-display {
-fx-background-color: #FFFFFF;
-fx-background-insets: 0;
-fx-border-color: #D6D6D6;
-fx-border-insets: 0;
-fx-border-width: 1;
-fx-font-family: "Segoe UI Light";
-fx-font-size: 13pt;
-fx-text-fill: black;
}

.result-display .label {
-fx-background-color: #FFFFFF
-fx-background-color: #FFFFFF;
-fx-text-fill: black !important;
}

Expand Down Expand Up @@ -329,6 +335,7 @@
#tags {
-fx-hgap: 7;
-fx-vgap: 3;
-fx-padding: 2 0 0 0;
}

#tags .label {
Expand All @@ -347,6 +354,46 @@
-fx-text-style: bold;
}

.saved-notes {
-fx-background-color: #FFFFFF;
-fx-background-insets: 0;
-fx-border-color: green;
-fx-border-insets: 0;
-fx-border-width: 1;
}

#quickNotes {
-fx-background-color: #FFFFFF;
-fx-background-insets: 0;
-fx-border-color: #D6D6D6;
-fx-border-insets: 0;
-fx-border-width: 1;
-fx-font-family: "Segoe UI Light";
-fx-text-fill: black;
}

#quickNotes.text-area {
-fx-background-insets: 0;
-fx-background-color: transparent, white, transparent, white;
}

#quickNotes.text-area .content {
-fx-background-color: transparent, white, transparent, white;
}

#quickNotes.text-area:focused .content {
-fx-background-color: transparent, white, transparent, white;
}

#quickNotes.text-area:focused {
-fx-highlight-fill: #FFFFFF;
}

#quickNotes.text-area .content {
-fx-text-fill: gray;
-fx-highlight-fill: #FFFFFF;
}

/** Patient and Dentist Cards */
.details-title {
-fx-font-size: 24px;
Expand All @@ -359,4 +406,33 @@
-fx-font-size: 13px;
-fx-font-weight: bold;
-fx-text-fill: black;
-fx-padding: 1 0 1 0;
}

#patientId {
-fx-hgap: 7;
-fx-vgap: 3;
}

#patientId .label {
-fx-text-fill: white;
-fx-background-color: #6563FF;
-fx-padding: 1 3 1 3;
-fx-border-radius: 2;
-fx-background-radius: 2;
-fx-font-size: 20;
}

#dentistId {
-fx-hgap: 7;
-fx-vgap: 3;
}

#dentistId .label {
-fx-text-fill: white;
-fx-background-color: #818D97;
-fx-padding: 1 3 1 3;
-fx-border-radius: 2;
-fx-background-radius: 2;
-fx-font-size: 20;
}
Loading

0 comments on commit 93573ae

Please sign in to comment.