from PySide6.QtGui import Qt
from Movie import Movie, createImage
from PySide6.QtWidgets import QHBoxLayout, QPushButton, QWidget, QGridLayout, QLabel

class MovieView(QWidget):
    """
    A QWidget which shows details about a given movie.
    Shows cover image, title, price, description.
    Also provided a button for buying tickets to the movie.
    """
    def __init__(self, movie: Movie):
        super().__init__()

        self.setMaximumWidth(800)
        self.setMaximumHeight(600)
        self.setWindowTitle("Movie Information")

        # Create layouts
        bodylayout = QHBoxLayout()
        contentlayout = QGridLayout()

        # Create labels and buttons
        label1 = QLabel(f"Buying a ticket for {movie.name}\nFor cost ${movie.price}\n\n{movie.description}")
        label1.setWordWrap(True)
        label2 = createImage(movie.image_path)

        button1 = QPushButton("Add to cart")
        button1.setMaximumWidth(100)

        contentlayout.addWidget(label1, 0, 0, alignment=Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignLeft)
        contentlayout.addWidget(button1, 1, 0, alignment=Qt.AlignmentFlag.AlignBottom | Qt.AlignmentFlag.AlignLeft)

        bodylayout.addWidget(label2)
        bodylayout.addLayout(contentlayout)

        self.setLayout(bodylayout)


