File size: 7,055 Bytes
896dedd 207970a 896dedd 317d573 896dedd ac6742a 896dedd 0f774c1 ac6742a 317d573 896dedd 207970a 896dedd 0f774c1 207970a 896dedd 0f774c1 896dedd 0f774c1 207970a 0f774c1 c432943 ac6742a c432943 ac6742a c432943 ac6742a c432943 ac6742a 317d573 | 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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | import streamlit as st
import random
# Sample data for users
users = [
{"name": "John", "age": 23, "bio": "Loves weightlifting and HIIT workouts.", "interests": ["Weightlifting", "HIIT"], "preferences": ["Dumbbells", "Squat Rack"], "picture": "https://i0.wp.com/www.muscleandfitness.com/wp-content/uploads/2019/08/John-Cena-Sitting-Down-Resting.jpg?quality=86&strip=all"},
{"name": "Emma", "age": 21, "bio": "Yoga enthusiast and casual runner.", "interests": ["Yoga", "Running"], "preferences": ["Yoga Mat", "Treadmill"], "picture": "https://static01.nyt.com/images/2020/02/20/arts/20emma-1/20emma-1-mediumSquareAt3X-v2.jpg"},
{"name": "Mike", "age": 25, "bio": "Powerlifter looking for a sparring partner.", "interests": ["Powerlifting", "Sparring"], "preferences": ["Barbell", "Bench Press"], "picture": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTU_PQKNX063OJE_cg6OOPKKicS6PTQXYx8Cg&s"},
{"name": "Sophia", "age": 22, "bio": "Pilates and bodyweight exercises are my thing!", "interests": ["Pilates", "Bodyweight"], "preferences": ["Resistance Bands", "Pull-Up Bar"], "picture": "https://alldus.com/wp-content/uploads/2022/10/shutterstock_754222927-min-scaled.jpg"},
{"name": "Chris", "age": 24, "bio": "Big on calisthenics and cardio challenges.", "interests": ["Calisthenics", "Cardio"], "preferences": ["Parallel Bars", "Elliptical"], "picture": "https://hips.hearstapps.com/hmg-prod/images/chris-64a6d63b7263d.png"},
{"name": "Liam", "age": 26, "bio": "Always up for CrossFit and obstacle races!", "interests": ["CrossFit", "Obstacle Races"], "preferences": ["Kettlebells", "Climbing Rope"], "picture": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR9KN-NzG_YmTGbXUEjgKfUWgX2vnZQXKhx1A&s"},
{"name": "Olivia", "age": 23, "bio": "Focused on strength and mobility training.", "interests": ["Strength Training", "Mobility"], "preferences": ["Foam Roller", "Deadlift Platform"], "picture": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRbNHL7m4G1omr3rsA3-l3kGwA0iK_YIym9-w&s"},
]
# Function to get a random user
def get_random_user(excluded_users):
available_users = [user for user in users if user["name"] not in excluded_users]
return random.choice(available_users) if available_users else None
# App interface
st.title("GrinderGang Gym V3")
st.write("Find your perfect gym buddy! Swipe through potential partners and see who matches your vibe.")
# Session state to keep track of seen profiles, matches, chat logs, and events
if "seen_users" not in st.session_state:
st.session_state["seen_users"] = []
if "liked_users" not in st.session_state:
st.session_state["liked_users"] = []
if "chat_logs" not in st.session_state:
st.session_state["chat_logs"] = {}
if "events" not in st.session_state:
st.session_state["events"] = []
if "posts" not in st.session_state:
st.session_state["posts"] = []
current_user = get_random_user(st.session_state["seen_users"])
if current_user:
st.image(current_user["picture"], width=150)
st.write(f"### {current_user['name']}, {current_user['age']} years old")
st.write(f"*{current_user['bio']}*")
st.write("**Interests:** " + ", ".join(current_user['interests']))
st.write("**Equipment Preferences:** " + ", ".join(current_user['preferences']))
col1, col2 = st.columns(2)
with col1:
if st.button("👍 Like"):
st.session_state["seen_users"].append(current_user["name"])
st.session_state["liked_users"].append(current_user)
st.session_state["chat_logs"][current_user["name"]] = [] # Initialize chat log
st.success(f"You liked {current_user['name']}!")
with col2:
if st.button("👎 Pass"):
st.session_state["seen_users"].append(current_user["name"])
st.info(f"You passed on {current_user['name']}.")
else:
st.write("No more gym buddies to show. Come back later!")
# Display liked users with chat feature
if st.session_state["liked_users"]:
st.write("### Your Matches")
for user in st.session_state["liked_users"]:
st.image(user["picture"], width=100)
st.write(f"**{user['name']}**, {user['age']} years old")
st.write(f"*{user['bio']}*")
st.write("**Interests:** " + ", ".join(user['interests']))
st.write("**Equipment Preferences:** " + ", ".join(user['preferences']))
with st.expander(f"Chat with {user['name']}"):
chat_log = st.session_state["chat_logs"][user["name"]]
for message in chat_log:
st.write(message)
new_message = st.text_input(f"Send a message to {user['name']}", key=f"chat_{user['name']}")
if st.button(f"Send to {user['name']}", key=f"send_{user['name']}"):
if new_message:
chat_log.append(f"You: {new_message}")
st.session_state["chat_logs"][user["name"]] = chat_log
st.success("Message sent!")
# Event creation feature - Post your workout
st.write("### Post Your Workout")
workout_name = st.text_input("Workout Name", key="workout_name")
workout_description = st.text_area("Workout Description", key="workout_description")
workout_date = st.date_input("Workout Date", key="workout_date")
workout_time = st.time_input("Workout Time", key="workout_time")
if st.button("Post Workout"):
if workout_name and workout_description:
workout = {
"name": workout_name,
"description": workout_description,
"date": workout_date,
"time": workout_time
}
st.session_state["events"].append(workout)
st.success(f"Workout '{workout_name}' posted successfully!")
else:
st.error("Please provide both a workout name and description.")
if st.session_state["events"]:
st.write("### Upcoming Workouts")
for event in st.session_state["events"]:
st.write(f"**{event['name']}** - {event['date']} at {event['time']}")
st.write(f"*{event['description']}*")
# Post Feature - Videos, Meals, and Music
st.write("### Share Your Gym Journey")
post_type = st.selectbox("What do you want to share?", ["Workout Video", "Dance Celebration", "Meal Prep Recipe", "Workout Music"])
post_description = st.text_area("Describe your post", key="post_description")
post_link = st.text_input("Link to video, recipe, or music (optional)", key="post_link")
if st.button("Share Post"):
if post_description:
post = {
"type": post_type,
"description": post_description,
"link": post_link
}
st.session_state["posts"].append(post)
st.success(f"Your {post_type.lower()} has been shared!")
else:
st.error("Please provide a description for your post.")
if st.session_state["posts"]:
st.write("### Community Posts")
for post in st.session_state["posts"]:
st.write(f"**{post['type']}**")
st.write(f"*{post['description']}*")
if post['link']:
st.write(f"[View More]({post['link']})")
|