-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
103 lines (78 loc) · 3.38 KB
/
Copy pathapp.py
File metadata and controls
103 lines (78 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#############################################################################
# app.py
#
# This file contains the entrypoint for the app.
#
#############################################################################
import streamlit as sl
from modules import display_my_custom_component, display_post, display_genai_advice, display_activity_summary, display_recent_workouts
from data_fetcher import get_user_posts, get_genai_advice, get_user_profile, get_user_sensor_data, get_user_workouts,get_user_friends
from streamlit_option_menu import option_menu
from activity_page import display_activity_page
from community_page import display_community
from auth_page import display_auth, logout
from sidebar import display_sidebar
from modules import post_creation_box, manual_workout_box, add_friend_box
from leaderboard_page import render_leaderboards
def display_app_page():
"""Displays the home page of the app."""
sl.set_page_config(layout="wide")
if 'userId' not in sl.session_state:
# sl.session_state.userId = 'user1'
display_auth()
sl.markdown('Testers: Log in using username \'alicej\' and password \'AliceR0ckss\'')
return
userId = sl.session_state.userId
user_profile = get_user_profile(userId)
user_name = user_profile['username']
friends = get_user_friends(userId)
friend_profiles = [get_user_profile(fid) for fid in friends]
friend_names = [p['full_name'] for p in friend_profiles]
friend_usernames = [p['username'] for p in friend_profiles]
selected = option_menu(
menu_title=None, # Appears at top of sidebar
options=["Home", "Activities", "Community","LeaderBoards"],
icons=["house", "bar-chart", "heart","trophy"], # Choose icons from https://icons.getbootstrap.com/
default_index=0,
menu_icon="cast",
orientation="horizontal",
)
if selected == "Home":
sl.title("🏠 Home Page")
sl.subheader(f"Welcome {user_profile['full_name']} to Commit To Fit!")
# Profile Card
col1, col2 = sl.columns([1, 3])
with col1:
if user_profile['profile_image']:
sl.image(user_profile['profile_image'], width=150)
with col2:
sl.markdown(f"**Username:** {user_profile['username']}")
sl.markdown(f"**Date of Birth:** {user_profile['date_of_birth']}")
# Friends section
sl.markdown("---")
sl.markdown("### Your Friends")
if friends:
with sl.container():
for i, j in zip(friend_names, friend_usernames):
sl.markdown(f"**{i}** \n`@{j}`")
else:
sl.info("You don't have any friends yet!")
elif selected == "Activities":
display_activity_page(user_id=userId)
elif selected == "Community":
display_community(userId)
elif selected == "LeaderBoards":
render_leaderboards(userId)
selected_action = display_sidebar(userId)
if selected_action == "Create Post":
post_creation_box(userId)
elif selected_action == "Add Workout":
manual_workout_box()
elif selected_action == "Add Friend":
add_friend_box(userId)
sl.markdown("---")
if sl.button("🚪 Log Out"):
logout()
# This is the starting point for your app. You do not need to change these lines
if __name__ == '__main__':
display_app_page()