Skip to content

Commit

Permalink
designed a colouful UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Hasib-39 committed May 4, 2024
1 parent 9eb9de7 commit 87fb414
Show file tree
Hide file tree
Showing 6 changed files with 1,798 additions and 13 deletions.
1,721 changes: 1,721 additions & 0 deletions hs_err_pid7368.log

Large diffs are not rendered by default.

33 changes: 29 additions & 4 deletions src/main/java/org/example/pokedex/AppData.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
import java.util.*;

public class AppData implements Initializable {

Expand All @@ -42,6 +40,7 @@ public class AppData implements Initializable {
@FXML
private Button details;
private List<PokemonModel> pokemons = new ArrayList<>();
private Map<String, String> color_map = new HashMap<>();

public List<PokemonModel> getPokemon(String sql, int value) {
List<PokemonModel> pokemons = new ArrayList<>();
Expand Down Expand Up @@ -92,6 +91,7 @@ public List<PokemonModel> getPokemon(String sql, int value) {

public void Search() {
String keyword = searchBar.getText();
if (Objects.equals(keyword, "")) return;
List<PokemonModel> pokemons_search = new ArrayList<>(getPokemon("SELECT * FROM POKEMON WHERE NAME LIKE ? OR TYPE1 LIKE ? OR TYPE2 LIKE ?", 2));
gridpane.getChildren().clear();
int column = 0;
Expand All @@ -107,6 +107,7 @@ public void Search() {
column = 0;
row++;
}
anchorpane.setStyle("-fx-background-color: " + color_map.get(pokemons.get(i).type1) + ";");
gridpane.add(anchorpane, column++, row);
GridPane.setMargin(anchorpane, new Insets(10));

Expand All @@ -132,6 +133,7 @@ public void FavPokemons() {
column = 0;
row++;
}
anchorpane.setStyle("-fx-background-color: " + color_map.get(pokemons.get(i).type1) + ";");
gridpane.add(anchorpane, column++, row);
GridPane.setMargin(anchorpane, new Insets(10));

Expand Down Expand Up @@ -165,6 +167,7 @@ public void home() {
column = 0;
row++;
}
anchorpane.setStyle("-fx-background-color: " + color_map.get(pokemons.get(i).type1) + ";");
gridpane.add(anchorpane, column++, row);
GridPane.setMargin(anchorpane, new Insets(10));

Expand All @@ -174,10 +177,32 @@ public void home() {
}
}

public void initColor() {
color_map.put("Normal", "#A8A77A");
color_map.put("Fire", "#EE8130");
color_map.put("Water", "#6390F0");
color_map.put("Electric", "#F7D02C");
color_map.put("Grass", "#7AC74C");
color_map.put("Ice", "#96D9D6");
color_map.put("Fighting", "#C22E28");
color_map.put("Poison", "#A33EA1");
color_map.put("Ground", "#E2BF65");
color_map.put("Flying", "#A98FF3");
color_map.put("Psychic", "#F95587");
color_map.put("Bug", "#A6B91A");
color_map.put("Rock", "#B6A136");
color_map.put("Ghost", "#735797");
color_map.put("Dragon", "#6F35FC");
color_map.put("Dark", "#705746");
color_map.put("Steel", "#B7B7CE");
color_map.put("Fairy", "#D685AD");
}

@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
pokemons.addAll(getPokemon("SELECT * FROM POKEMON", 1));
// print(pokemons.get(5));
initColor();
int column = 0;
int row = 1;
try {
Expand All @@ -191,9 +216,9 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
column = 0;
row++;
}
anchorpane.setStyle("-fx-background-color: " + color_map.get(pokemons.get(i).type1) + ";");
gridpane.add(anchorpane, column++, row);
GridPane.setMargin(anchorpane, new Insets(10));

}
} catch (Exception e) {
e.printStackTrace();
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/org/example/pokedex/home-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions src/main/resources/org/example/pokedex/main.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</ImageView>
</children>
</HBox>
<Button fx:id="favBtn" mnemonicParsing="false" onAction="#FavPokemons" text="Favourites">
<Button fx:id="favBtn" mnemonicParsing="false" onAction="#FavPokemons" styleClass="dashBtns" stylesheets="@styles.css" text="FAVOURITES">
<VBox.margin>
<Insets top="30.0" />
</VBox.margin>
Expand All @@ -52,17 +52,17 @@
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0" />
</VBox.margin>
<children>
<Button fx:id="homeBtn" mnemonicParsing="false" onAction="#home" text="Home">
<Button fx:id="homeBtn" mnemonicParsing="false" onAction="#home" prefHeight="33.0" prefWidth="101.0" styleClass="dashBtns" stylesheets="@styles.css" text="HOME">
<HBox.margin>
<Insets left="15.0" top="15.0" />
</HBox.margin>
</Button>
<TextField fx:id="searchBar" prefHeight="31.0" prefWidth="481.0">
<TextField fx:id="searchBar" prefHeight="33.0" prefWidth="481.0">
<HBox.margin>
<Insets left="15.0" top="15.0" />
</HBox.margin>
</TextField>
<Button fx:id="searchBtn" mnemonicParsing="false" onAction="#Search" text="Search">
<Button fx:id="searchBtn" mnemonicParsing="false" onAction="#Search" styleClass="dashBtns" stylesheets="@styles.css" text="SEARCH">
<HBox.margin>
<Insets left="15.0" top="15.0" />
</HBox.margin>
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/org/example/pokedex/pokemonCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
<children>
<HBox alignment="CENTER_LEFT" prefHeight="20.0" prefWidth="266.0">
<children>
<Label fx:id="nameLabel" prefHeight="77.0" prefWidth="225.0" text="Pikachu">
<Label fx:id="nameLabel" prefHeight="77.0" prefWidth="225.0" styleClass="info" stylesheets="@styles.css" text="Pikachu">
<font>
<Font name="Cambria Bold" size="24.0" />
</font>
</Label>
<Label fx:id="idLabel" prefHeight="30.0" prefWidth="90.0" text="#001">
<Label fx:id="idLabel" prefHeight="30.0" prefWidth="90.0" styleClass="info" stylesheets="@styles.css" text="#001">
<font>
<Font name="Cambria Bold" size="24.0" />
</font>
Expand All @@ -34,8 +34,8 @@
</ImageView>
</children>
</VBox>
<Button fx:id="details" layoutX="25.0" layoutY="166.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="56.0" text="Details" />
<Button fx:id="favBtn" layoutX="100.0" layoutY="166.0" mnemonicParsing="false" text="Favourite" />
<Button fx:id="UnfavBtn" layoutX="187.0" layoutY="166.0" mnemonicParsing="false" text="Unfavourite" />
<Button fx:id="details" layoutX="12.0" layoutY="166.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="70.0" styleClass="cardBtns" stylesheets="@styles.css" text="DETAILS" />
<Button fx:id="favBtn" layoutX="93.0" layoutY="166.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="85.0" styleClass="cardBtns" stylesheets="@styles.css" text="FAVOURITE" />
<Button fx:id="UnfavBtn" layoutX="185.0" layoutY="166.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="90.0" styleClass="cardBtns" stylesheets="@styles.css" text="UNFAVOURITE" />
</children>
</AnchorPane>
38 changes: 38 additions & 0 deletions src/main/resources/org/example/pokedex/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,42 @@
-fx-text-fill: black;
}

.dashBtns {
-fx-background-color: #2a75bb;
-fx-text-fill: #ffcb05;
-fx-font-weight: bold;
-fx-font-size: 18px;
-fx-font-family: Arial;
}
.dashBtns:hover {
-fx-background-color: #3c5aa6;
-fx-text-fill: #c7a008;
-fx-font-weight: bold;
-fx-font-size: 18px;
-fx-font-family: Arial;
}

#anchor {
-fx-background-color: #ffeda3;
-fx-background-radius: 10px;
-fx-text-fill: #3c5aa6;
}

.cardBtns {
-fx-background-color: #2a75bb;
-fx-text-fill: #ffcb05;
-fx-font-weight: bold;
-fx-font-size: 10px;
-fx-font-family: Arial;
}
.cardBtns:hover {
-fx-background-color: #3c5aa6;
-fx-text-fill: #c7a008;
-fx-font-weight: bold;
-fx-font-size: 10px;
-fx-font-family: Arial;
}

.info {
-fx-text-fill: #3c5aa6;
}

0 comments on commit 87fb414

Please sign in to comment.