From 3a5ca3bb9728486d8b625b65528eb5d13a8ed654 Mon Sep 17 00:00:00 2001 From: Amir Ali Amiri Date: Mon, 22 Jun 2026 20:25:09 +0330 Subject: [PATCH] complete core pricing plans UI and theme toggling --- src/main/java/workshop/Controller.java | 49 +++++++++++++++++++------- src/main/java/workshop/Launcher.java | 3 +- src/main/java/workshop/Main.java | 21 ++++++++--- 3 files changed, 56 insertions(+), 17 deletions(-) diff --git a/src/main/java/workshop/Controller.java b/src/main/java/workshop/Controller.java index 070b56f..607f7ce 100644 --- a/src/main/java/workshop/Controller.java +++ b/src/main/java/workshop/Controller.java @@ -1,41 +1,66 @@ package workshop; import javafx.fxml.FXML; -import javafx.scene.control.Label; +import javafx.scene.Scene; +import javafx.scene.control.Alert; +import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Button; public class Controller { - @FXML private Label titleLabel; @FXML private Button themeToggle; + // فلگ ردیابی وضعیت تم private boolean isDark = true; - // TODO: (Optional:For Practice) Create initialize function and use it to set prices during runtime. - - - // TODO: (Optional:For Practice) Make the plan price go 1 dollar up each time user clicks on the shop button. @FXML private void buyBasic() { - // TODO: Call showAlert() with a message indicating the user entered the payment gateway + // باز کردن پاپ‌آپ ورود به درگاه پرداخت برای پلن بیسیک + showAlert("You are entering the payment gateway for the Basic Plan."); } @FXML private void buyPro() { - // TODO: Call showAlert() with a message indicating the user entered the payment gateway + // باز کردن پاپ‌آپ ورود به درگاه پرداخت برای پلن پرو + showAlert("You are entering the payment gateway for the Pro Plan."); } @FXML private void buyEnterprise() { - // TODO: Call showAlert() with a message indicating the user entered the payment gateway + // باز کردن پاپ‌آپ ورود به درگاه پرداخت برای پلن اینترپرایز + showAlert("You are entering the payment gateway for the Enterprise Plan."); } @FXML private void toggleTheme() { - // TODO: Toggle the isDark flag. If dark, switch to style.css and set button text to "Switch to Light Mode" - // TODO: If light, switch to light.css and set button text to "Switch to Dark Mode" + // دسترسی به آبجکت Scene برای تغییر پویا استایل‌شیت‌ها + Scene scene = themeToggle.getScene(); + if (scene == null) return; + + // پاک کردن استایل‌شیت قبلی برای اعمال استایل جدید بدون تداخل + scene.getStylesheets().clear(); + + // تغییر وضعیت فلگ تم + isDark = !isDark; + + if (isDark) { + // لود کردن تم تاریک و تغییر متن دکمه راهنما + scene.getStylesheets().add(getClass().getResource("/workshop/style.css").toExternalForm()); + themeToggle.setText("Switch to Light Mode"); + } else { + // لود کردن تم روشن و تغییر متن دکمه راهنما + scene.getStylesheets().add(getClass().getResource("/workshop/light.css").toExternalForm()); + themeToggle.setText("Switch to Dark Mode"); + } } private void showAlert(String message) { - // TODO: Create a new Alert of type INFORMATION with the given message and display it + // ساخت دایالوگ پاپ‌آپ از نوع INFORMATION برای نمایش پیغام‌ها + Alert alert = new Alert(AlertType.INFORMATION); + alert.setTitle("Payment Gateway"); + alert.setHeaderText(null); // حذف هدر برای سادگی و زیبایی بیشتر دایالوگ + alert.setContentText(message); + + // نمایش دایالوگ و منتظر ماندن برای واکشی اکشن کاربر (بستن دایالوگ) + alert.showAndWait(); } } diff --git a/src/main/java/workshop/Launcher.java b/src/main/java/workshop/Launcher.java index 0f82aeb..f213c89 100644 --- a/src/main/java/workshop/Launcher.java +++ b/src/main/java/workshop/Launcher.java @@ -4,6 +4,7 @@ import javafx.application.Application; public class Launcher { public static void main(String[] args) { - // TODO: Launch the JavaFX application by calling Application.launch(Main.class) + // اجرای اپلیکیشن جاوااف‌ایکس + Application.launch(Main.class, args); } } diff --git a/src/main/java/workshop/Main.java b/src/main/java/workshop/Main.java index d6cd3fd..cc1ee8e 100644 --- a/src/main/java/workshop/Main.java +++ b/src/main/java/workshop/Main.java @@ -1,13 +1,26 @@ package workshop; import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage stage) throws Exception { - // TODO: Load the FXML file using FXMLLoader.load() and get the Parent root - // TODO: Create a Scene with the root (width=750, height=450) and add the stylesheet "style.css" - // TODO: Set the stage title to "Pricing Plans", set the scene, and call stage.show() + // بارگذاری فایل FXML رابط کاربری از مسیر پکیج پروژه + Parent root = FXMLLoader.load(getClass().getResource("/workshop/pricing.fxml")); + + // ساختن صحنه با ابعاد مشخص شده (طول ۷۵۰ و عرض ۴۵۰) + Scene scene = new Scene(root, 750, 450); + + // اضافه کردن استایل‌شیت پیش‌فرض (تم تاریک) به صحنه + scene.getStylesheets().add(getClass().getResource("/workshop/style.css").toExternalForm()); + + // تنظیم عنوان پنجره، قرار دادن صحنه روی استیج و در نهایت نمایش آن + stage.setTitle("Pricing Plans"); + stage.setScene(scene); + stage.show(); } -} +} \ No newline at end of file