initial commit
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
from web.custom_widgets.content_card import ContentCard
|
||||
from web.custom_widgets.content_dialog import ContentDialog
|
||||
from web.custom_widgets.header import draw_header
|
||||
@@ -0,0 +1,48 @@
|
||||
from nicegui import ui
|
||||
|
||||
import globals
|
||||
from web.custom_widgets import ContentDialog
|
||||
|
||||
|
||||
class ContentCard:
|
||||
def __init__(self, tmdb_id: int):
|
||||
self.content = globals.MOVIES_DATABASE.by_tmdb_id[tmdb_id]
|
||||
|
||||
self.dialog = ContentDialog(tmdb_id)
|
||||
|
||||
self.card = ui.card()
|
||||
self.card.classes("no-shadow")
|
||||
self.card.style("margin: 0; padding: 6px; border-radius: 20px")
|
||||
|
||||
with self.card:
|
||||
self.poster_image = ui.image(source=self.content.poster_url)
|
||||
self.poster_image.style("width: 200px; height: 100%; border-radius: 15px")
|
||||
|
||||
with self.poster_image:
|
||||
self.poster_column = ui.column()
|
||||
self.poster_column.classes("w-full h-full justify-between")
|
||||
self.poster_column.style(
|
||||
"margin: 0; padding:0; opacity: 0; transition-duration: 0.5s")
|
||||
|
||||
with self.poster_column:
|
||||
with ui.column(wrap=False).classes("w-full").style("gap: 0px; margin: 0; padding: 3px 3px 3px 10px;"):
|
||||
ui.html(f"<b>{self.content.title}</b>").style("font-size: 16px")
|
||||
ui.html(f"<i>{self.content.og_title}</i>").style("font-size: 10px")
|
||||
|
||||
with ui.column(wrap=True).classes("w-full").style("gap: 0px; margin: 0; padding: 3px 3px 10px 10px"):
|
||||
ui.html(f"<b><i>{"<br>".join((self.content.genres))}</i></b>").style("font-size: 8px")
|
||||
|
||||
self.card.on("mouseover", self.on_card_hover)
|
||||
self.card.on("mouseleave", self.on_card_unhover)
|
||||
self.card.on("click", self.on_card_click)
|
||||
|
||||
def on_card_hover(self):
|
||||
self.poster_column.style("opacity: 0.9")
|
||||
self.card.style("transform: scale(1.02)")
|
||||
|
||||
def on_card_unhover(self):
|
||||
self.poster_column.style("opacity: 0")
|
||||
self.card.style("transform: scale(1.0)")
|
||||
|
||||
def on_card_click(self):
|
||||
self.dialog.open()
|
||||
@@ -0,0 +1,66 @@
|
||||
import itertools
|
||||
|
||||
from nicegui import ui
|
||||
|
||||
import globals
|
||||
from web.misc import convert_runtime
|
||||
|
||||
|
||||
class ContentDialog(ui.dialog):
|
||||
def __init__(self, tmdb_id: int, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.content = globals.MOVIES_DATABASE.by_tmdb_id[tmdb_id]
|
||||
|
||||
with self:
|
||||
self.card = ui.card()
|
||||
self.card.classes("h-max no-shadow")
|
||||
self.card.style("min-width: 40%; min-height: 60%; border-radius: 15px")
|
||||
|
||||
with self.card:
|
||||
self.title_column = ui.column(wrap=False)
|
||||
self.title_column.classes("w-full")
|
||||
self.title_column.style("gap: 0; margin: 0; padding: 0;")
|
||||
|
||||
with self.title_column:
|
||||
ui.html(f"<b>{self.content.title}</b>").style("font-size: 22px")
|
||||
ui.html(f"<i>{self.content.og_title}</i>").style("font-size: 14px")
|
||||
ui.html(f"<b><i>{", ".join(self.content.genres)}</i></b>").style("font-size: 12px")
|
||||
|
||||
with self.card:
|
||||
self.main_row = ui.row(wrap=False)
|
||||
self.main_row.classes("w-full h-full")
|
||||
|
||||
with self.main_row:
|
||||
ui.image(source=self.content.poster_url).style("width: 50%; border-radius: 15px")
|
||||
|
||||
self.additional_info_column = ui.column(wrap=False)
|
||||
self.additional_info_column.style("width: 50%")
|
||||
|
||||
with self.additional_info_column:
|
||||
release_date = self.content.release_date.split("-")[::-1]
|
||||
release_date = ".".join(release_date)
|
||||
ui.html(f"<b>Release Date: </b>{release_date}").style("font-size: 12px")
|
||||
ui.html(f"<b>Average Score: </b>{round(self.content.vote_average, 2)}").style("font-size: 12px")
|
||||
|
||||
if self.content.type == "movie":
|
||||
budget = "$" + f"{self.content.budget:_}".replace("_", ".")
|
||||
ui.html(f"<b>Budget: </b>{budget}").style("font-size: 12px")
|
||||
ui.html(f"<b>Runtime: </b>{convert_runtime(self.content.runtime)}").style("font-size: 12px")
|
||||
elif self.content.type == "tv":
|
||||
ui.html(f"<b>Number of Seasons: </b>{self.content.number_of_seasons}").style("font-size: 12px")
|
||||
ui.html(f"<b>Number of Episodes: </b>{self.content.number_of_episodes}").style("font-size: 12px")
|
||||
total_runtime = sum([ep.runtime for ep in
|
||||
itertools.chain.from_iterable([s.episodes for s in self.content.seasons])])
|
||||
ui.html(f"<b>Total Runtime: </b>{convert_runtime(total_runtime)}").style("font-size: 12px")
|
||||
if self.content.in_production:
|
||||
ui.html(f"<b><i>Currently in production</i></b>").style("font-size: 12px")
|
||||
else:
|
||||
ui.html(f"<b><i>Finished</i></b>").style("font-size: 12px")
|
||||
|
||||
with self.card, ui.row(wrap=False).classes("w-full").style("display: flex; justify-content: center;"):
|
||||
ui.button("Create Room").on_click(self.create_room)
|
||||
|
||||
async def create_room(self):
|
||||
room = await globals.ROOMS_DATABASE.create_room(self.content.tmdb_id)
|
||||
ui.navigate.to(f"/room/{room.uid}")
|
||||
@@ -0,0 +1,11 @@
|
||||
from nicegui import ui
|
||||
|
||||
from web.misc import logout
|
||||
|
||||
|
||||
async def draw_header():
|
||||
with ui.header(wrap=False):
|
||||
with ui.row(wrap=False).classes("w-full justify-between") as header_row:
|
||||
ui.button(icon="home", on_click=lambda: ui.navigate.to("/"))
|
||||
ui.button(text="Rooms", icon="movie", on_click=lambda: ui.navigate.to("/rooms"))
|
||||
ui.button(icon="logout", on_click=lambda: logout(redirect=True))
|
||||
Reference in New Issue
Block a user