Skip to content

Commit b6a77b2

Browse files
committedAug 10, 2024
gota loading screen and the boxes on the home screen can be clicked now
1 parent 08070f7 commit b6a77b2

File tree

3 files changed

+114
-85
lines changed

3 files changed

+114
-85
lines changed
 

‎movie_streaming_site/components/moviecard.py

+25-19
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
11
import reflex as rx
2-
def movie_card(title: str, year: str, duration: str, img:str = "https://via.placeholder.com/316x421", description:str = ""):
2+
def movie_card(title: str, year: str, duration: str, link:str, img:str = "https://via.placeholder.com/316x421", description:str = ""):
33
return rx.hover_card.root(
44
rx.hover_card.trigger(
5-
rx.box(
6-
rx.image(src=img, width="17vw", height="47vh"),
7-
rx.vstack(
8-
rx.hstack(
9-
rx.text(year, color="#C0C0C0", font_size="2vh", font_style="italic"),
10-
rx.text(duration, color="#C0C0C0", font_size="2vh", font_style="italic", text_align="right", width="100%"),
11-
width="100%"
5+
rx.link(
6+
7+
rx.box(
8+
rx.image(src=img, width="17vw", height="47vh"),
9+
rx.vstack(
10+
rx.hstack(
11+
rx.text(year, color="#C0C0C0", font_size="2vh", font_style="italic"),
12+
rx.text(duration, color="#C0C0C0", font_size="2vh", font_style="italic", text_align="right", width="100%"),
13+
width="100%"
14+
),
15+
rx.heading(title, color="#F2F2F2", font_size="4vh", font_weight="800"),
16+
spacing="0.5vh",
17+
align_items="flex-start",
18+
padding="1.7vh",
1219
),
13-
rx.heading(title, color="#F2F2F2", font_size="4vh", font_weight="800"),
14-
spacing="0.5vh",
15-
align_items="flex-start",
16-
padding="1.7vh",
20+
padding="1vw",
21+
width="19vw",
22+
#height="60.4vh",
23+
bg="#1A1A1A",
24+
border_radius="1vh",
25+
#border="0.1vh solid #D9D9D9",
1726
),
18-
padding="1vw",
19-
width="19vw",
20-
#height="60.4vh",
21-
bg="#1A1A1A",
22-
border_radius="1vh",
23-
#border="0.1vh solid #D9D9D9",
24-
),
27+
href=link,
28+
is_external=True
29+
)
30+
2531
),
2632
rx.hover_card.content(
2733
rx.hstack(

‎movie_streaming_site/movie_streaming_site.py

+79-64
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from movie_streaming_site.state import State
44
from movie_streaming_site.components.search import search
55
from movie_streaming_site.components.footer import footer
6-
6+
from reflex_lottiefiles import LottieFiles
77

88
@rx.page(on_load=State.on_load)
99
def index():
@@ -58,17 +58,9 @@ def index():
5858
rx.grid(
5959
rx.foreach(
6060
State.now_playing,
61-
lambda info, index: movie_card(info["title"], info["year"], f"{info['runtime']} mins", info["poster"], description=info["description"])
61+
lambda info, index: movie_card(info["title"], info["year"], f"{info['runtime']} mins", info["link"], info["poster"], description=info["description"])
6262

6363
),
64-
# movie_card("Borderlands", "2024", "1 hr 31 min", "https://cloud-6t0bvxvfn-hack-club-bot.vercel.app/7borders.jpg"),
65-
# movie_card("Dealpool & Wolverine", "2024", "1 hr 21 min", "https://cloud-6t0bvxvfn-hack-club-bot.vercel.app/3dead_and_wolv.jpg"),
66-
# movie_card("Despicable Me 4", "2024", "1 hr 35 min", "https://cloud-6t0bvxvfn-hack-club-bot.vercel.app/4minions_wer_despicible.jpg"),
67-
# movie_card("Joe Rogan", "2024", "1 hr 23 min", "https://cloud-6t0bvxvfn-hack-club-bot.vercel.app/6joe.jpg"),
68-
# movie_card("Trap", "2024", "2 hr 41 min", "https://cloud-6t0bvxvfn-hack-club-bot.vercel.app/5trap.jpg"),
69-
# movie_card("The Garfield Move", "2024", "101 min", "https://cloud-6t0bvxvfn-hack-club-bot.vercel.app/2garlf.jpg"),
70-
# movie_card("Inside Out 2", "2024", "1 hr 31 min", "https://cloud-6t0bvxvfn-hack-club-bot.vercel.app/1inside_out_2.jpg"),
71-
# movie_card("The Super Mario Bros Movie", "2023", "93 min", "https://cloud-6t0bvxvfn-hack-club-bot.vercel.app/0maro.jpg"),
7264
footer(),
7365
spacing="1.5vh",
7466
columns="4",
@@ -87,76 +79,99 @@ def index():
8779

8880

8981

90-
@rx.page(route="/movieplayer/[movieid]")
82+
@rx.page(route="/movieplayer/[movieid]", on_load=State.on_load)
9183
def movieplayer():
9284
return rx.box(
9385
search(),
94-
rx.text(State.current_movie["title"], font_size="10.5vh", font_weight="800"),
95-
rx.hstack(
96-
rx.html(
97-
State.movie_iframe,
98-
width="50vw",
99-
height="60vw"
100-
),
101-
#rx.box(width="960px", height="540px", bg="#D9D9D9"),
102-
rx.vstack(
103-
rx.text(
104-
"Description",
105-
color="white",
106-
font_size="4vh",
107-
font_weight="800"
108-
),
109-
rx.text(
110-
State.current_movie["description"],
111-
color="white",
112-
font_size="3vh",
113-
max_width="28vw"
86+
87+
88+
rx.cond(
89+
State.loading,
90+
rx.center(
91+
rx.vstack(
92+
rx.heading("Loading, please wait"),
93+
LottieFiles(
94+
src="https://lottie.host/5ff06a80-3f45-4dd3-8737-f4cf62ba3d48/X5hdVEjbNK.lottie",
95+
autoplay=True,
96+
loop=True,
97+
width="20vw",
98+
height="20vw",
99+
)
114100
),
115-
align_items="flex-start",
101+
102+
width="100%",
103+
height="90vh"
116104
),
117-
rx.desktop_only(
118-
rx.vstack(
119-
movie_info_item(State.current_movie["date"], "calendar"),
120-
movie_info_item(State.current_movie["revenue"], "dollar-sign"),
121-
movie_info_item(State.current_movie["runtime"], "clock"),
122-
123-
rx.cond(
124-
State.current_movie["site"],
125-
rx.link(
126-
movie_info_item("Site", "globe"),
127-
href=State.current_movie["site"],
128-
is_external=True
105+
106+
rx.box(
107+
rx.text(State.current_movie["title"], font_size="10.5vh", font_weight="800"),
108+
rx.hstack(
109+
rx.html(
110+
State.movie_iframe,
111+
width="50vw",
112+
height="60vw"
113+
),
114+
#rx.box(width="960px", height="540px", bg="#D9D9D9"),
115+
rx.vstack(
116+
rx.text(
117+
"Description",
118+
color="white",
119+
font_size="4vh",
120+
font_weight="800"
121+
),
122+
rx.text(
123+
State.current_movie["description"],
124+
color="white",
125+
font_size="3vh",
126+
max_width="28vw"
129127
),
128+
align_items="flex-start",
130129
),
131-
rx.cond(
132-
State.current_movie["tmdb_link"],
133-
rx.link(
134-
movie_info_item("TMDB", "clock"),
135-
href=State.current_movie["tmdb_link"],
136-
is_external=True
130+
rx.desktop_only(
131+
rx.vstack(
132+
movie_info_item(State.current_movie["date"], "calendar"),
133+
movie_info_item(State.current_movie["revenue"], "dollar-sign"),
134+
movie_info_item(State.current_movie["runtime"], "clock"),
135+
136+
rx.cond(
137+
State.current_movie["site"],
138+
rx.link(
139+
movie_info_item("Site", "globe"),
140+
href=State.current_movie["site"],
141+
is_external=True
142+
),
143+
),
144+
rx.cond(
145+
State.current_movie["tmdb_link"],
146+
rx.link(
147+
movie_info_item("TMDB", "clock"),
148+
href=State.current_movie["tmdb_link"],
149+
is_external=True
150+
),
151+
),
152+
rx.cond(
153+
State.current_movie["imdb_link"],
154+
rx.link(
155+
movie_info_item("IMDB", "clock"),
156+
href=State.current_movie["imdb_link"],
157+
is_external=True
158+
)
159+
)
160+
161+
162+
137163
),
138164
),
139-
rx.cond(
140-
State.current_movie["imdb_link"],
141-
rx.link(
142-
movie_info_item("IMDB", "clock"),
143-
href=State.current_movie["imdb_link"],
144-
is_external=True
145-
)
146-
)
147-
148-
149165

166+
spacing="2vw",
150167
),
151-
),
152-
153-
spacing="2vw",
168+
)
154169
),
170+
155171

156172

157173
width = "100%",
158174
padding="5.5vh",
159-
on_mount=State.on_load
160175
)
161176

162177
def movie_info_item(text, icon):

‎movie_streaming_site/state.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ class State(rx.State):
99
now_playing:list[dict[str, str]]
1010
movie_iframe:str
1111
current_movie:dict[str, str]
12+
loading:bool = True
13+
1214

1315
@rx.var
1416
def movie_id(self) -> str:
@@ -29,7 +31,6 @@ def get_current_movie(self):
2931
"title":data["title"],
3032
"date":data["release_date"]
3133
}
32-
print(result)
3334
return result
3435

3536

@@ -69,13 +70,20 @@ def get_now_playing_movies(self):
6970
"title": result["title"],
7071
"year":result["release_date"][:4],
7172
"description":result["overview"],
72-
"runtime":self.get_movie_data(result["id"])["runtime"]
73+
"runtime":self.get_movie_data(result["id"])["runtime"],
74+
"link":f"/movieplayer/{result["id"]}"
7375
}
7476
)
7577
return result_list
7678
def on_load(self):
79+
self.loading = True
80+
print("start load")
7781
self.movie_iframe = f" <iframe src=\"https://moviesapi.club/movie/" + self.router.page.params.get("movieid", "519182") + "\" style=\"width:50vw;height:60vh;\"></iframe> " #style="height:60vh; width:50vw"
82+
print("load iframe")
7883
self.now_playing = self.get_now_playing_movies()
84+
print("load now playing")
7985
self.current_movie = self.get_current_movie()
86+
print("load current")
87+
self.loading=False
8088

8189

0 commit comments

Comments
 (0)
Please sign in to comment.