Amrutha04 commited on
Commit
5ebeec7
ยท
verified ยท
1 Parent(s): c174e39

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -28
app.py CHANGED
@@ -4,23 +4,40 @@ from model_api import query_model
4
 
5
  st.set_page_config(page_title="FitPlan AI", layout="wide")
6
 
7
- # Enhanced CSS for the Icon-Table Grid UI
8
  st.markdown("""
9
  <style>
10
  .stApp { background: linear-gradient(135deg, #f6d365 0%, #fda085 100%); background-attachment: fixed; }
11
  section[data-testid="stSidebar"] { background-color: #000000 !important; }
12
  section[data-testid="stSidebar"] h1, section[data-testid="stSidebar"] p { color: #FFFFFF !important; }
13
 
14
- .result-card { background-color: white !important; padding: 25px; border-radius: 15px; border-left: 10px solid #004d57; color: #000000 !important; margin-bottom: 20px; }
 
 
 
 
 
 
 
 
15
 
16
- .day-container { background-color: #f8f9fa; border-radius: 20px; padding: 25px; margin-bottom: 30px; border: 1px solid #e0e0e0; }
17
- .day-header { color: #004d57; font-size: 24px; font-weight: bold; margin-bottom: 20px; display: flex; align-items: center; }
18
-
19
- .exercise-row { background: white; border-radius: 12px; padding: 15px; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
20
- .ex-name { flex: 2; font-weight: 600; color: #2d3436; font-size: 16px; }
21
- .stat-box { flex: 1; text-align: center; display: flex; flex-direction: column; align-items: center; }
22
- .stat-val { background: #e0f2f1; color: #004d57; padding: 5px 15px; border-radius: 20px; font-weight: bold; font-size: 14px; min-width: 60px; }
23
- .stat-label { font-size: 11px; color: #636e72; text-transform: uppercase; margin-top: 4px; }
 
 
 
 
 
 
 
 
 
24
  </style>
25
  """, unsafe_allow_html=True)
26
 
@@ -35,7 +52,7 @@ with st.sidebar:
35
  st.session_state.page = 'input'
36
  st.rerun()
37
 
38
- # --- INPUT PAGE ---
39
  if st.session_state.page == 'input':
40
  st.title("๐Ÿ‹๏ธ Create Your Fitness Profile")
41
  col1, col2, col3 = st.columns([2, 1, 1])
@@ -43,9 +60,9 @@ if st.session_state.page == 'input':
43
  with col2: gender = st.selectbox("Gender", ["Male", "Female", "Other"])
44
  with col3: age = st.number_input("Age", min_value=1, value=19)
45
 
46
- col_h, col_w = st.columns(2)
47
- with col_h: height = st.number_input("Height (cm)", min_value=1.0)
48
- with col_w: weight = st.number_input("Weight (kg)", min_value=1.0)
49
 
50
  goal = st.selectbox("Goal", ["Build Muscle", "Weight Loss", "Strength", "Flexibility"])
51
  level = st.selectbox("Fitness Level", ["Beginner", "Intermediate", "Advanced"])
@@ -53,17 +70,17 @@ if st.session_state.page == 'input':
53
 
54
  if st.button("Submit Profile"):
55
  prompt, bmi, bmi_status, status_color = build_prompt(name, gender, age, height, weight, goal, level, equip)
56
- with st.spinner("Generating Professional UI..."):
57
  raw_workout = query_model(prompt)
58
  st.session_state.workout_plan = raw_workout
59
  st.session_state.assessment_data = {"name": name, "bmi": bmi, "status": bmi_status, "color": status_color, "age": age, "gender": gender}
60
  st.session_state.page = 'result'
61
  st.rerun()
62
 
63
- # --- RESULT PAGE ---
64
  elif st.session_state.page == 'result':
65
  d = st.session_state.assessment_data
66
- st.markdown(f'<div class="result-card"><h2>Hello {d["name"]}</h2><p>{d["gender"]} | {d["age"]} Years Old</p><p>BMI: <strong>{d["bmi"]:.2f}</strong> | <span style="color:{d["color"]}">{d["status"]}</span></p></div>', unsafe_allow_html=True)
67
 
68
  raw_content = st.session_state.workout_plan
69
  days = ["Day 1:", "Day 2:", "Day 3:", "Day 4:", "Day 5:"]
@@ -74,25 +91,30 @@ elif st.session_state.page == 'result':
74
  end = raw_content.find(days[i+1]) if i+1 < len(days) else len(raw_content)
75
  day_block = raw_content[start:end].strip()
76
 
77
- st.markdown(f'<div class="day-container"><div class="day-header">๐Ÿ”น {days[i][:-1]}</div>', unsafe_allow_html=True)
 
78
 
79
- # Parse individual exercises
80
  lines = day_block.split("\n")
81
  for line in lines:
82
  if "|" in line:
83
  parts = [p.strip() for p in line.replace("- ", "").split("|")]
84
  if len(parts) == 4:
85
- name, sets, reps, rest = parts
86
  st.markdown(f"""
87
  <div class="exercise-row">
88
- <div class="ex-name">๐Ÿ‹๏ธ {name}</div>
89
- <div class="stat-box"><span class="stat-val">{sets}</span><span class="stat-label">Sets</span></div>
90
- <div class="stat-box"><span class="stat-val">{reps}</span><span class="stat-label">Reps</span></div>
91
- <div class="stat-box"><span class="stat-val" style="background:#fff3e0; color:#e65100;">{rest}</span><span class="stat-label">Rest</span></div>
 
 
92
  </div>
93
  """, unsafe_allow_html=True)
94
- elif "Rest" in line:
95
- st.info("๐Ÿง˜ Enjoy your Rest Day! Recovery is part of progress.")
96
- st.markdown('</div>', unsafe_allow_html=True)
 
 
97
 
98
- st.download_button("๐Ÿ“ฅ Download Plan", data=raw_content, file_name="Workout.txt")
 
 
4
 
5
  st.set_page_config(page_title="FitPlan AI", layout="wide")
6
 
7
+ # Updated CSS for Single Box Per Day
8
  st.markdown("""
9
  <style>
10
  .stApp { background: linear-gradient(135deg, #f6d365 0%, #fda085 100%); background-attachment: fixed; }
11
  section[data-testid="stSidebar"] { background-color: #000000 !important; }
12
  section[data-testid="stSidebar"] h1, section[data-testid="stSidebar"] p { color: #FFFFFF !important; }
13
 
14
+ /* Main Card for the Day */
15
+ .day-card {
16
+ background-color: white !important;
17
+ padding: 30px;
18
+ border-radius: 20px;
19
+ margin-bottom: 40px;
20
+ box-shadow: 0 8px 24px rgba(0,0,0,0.1);
21
+ border-left: 12px solid #004d57;
22
+ }
23
 
24
+ .day-title { color: #004d57; font-size: 28px; font-weight: bold; margin-bottom: 25px; border-bottom: 2px solid #f0f0f0; padding-bottom: 10px; }
25
+
26
+ /* Exercise Row - No border/shadow to keep it inside the single box */
27
+ .exercise-row {
28
+ display: flex;
29
+ align-items: center;
30
+ justify-content: space-between;
31
+ padding: 15px 0;
32
+ border-bottom: 1px solid #eee;
33
+ }
34
+ .exercise-row:last-child { border-bottom: none; }
35
+
36
+ .ex-name { flex: 2; font-weight: 600; color: #2d3436; font-size: 18px; }
37
+ .stat-container { display: flex; gap: 20px; flex: 1.5; justify-content: flex-end; }
38
+ .stat-box { text-align: center; min-width: 70px; }
39
+ .stat-val { background: #e0f2f1; color: #004d57; padding: 4px 12px; border-radius: 12px; font-weight: bold; display: block; }
40
+ .stat-label { font-size: 10px; color: #636e72; text-transform: uppercase; margin-top: 4px; display: block; }
41
  </style>
42
  """, unsafe_allow_html=True)
43
 
 
52
  st.session_state.page = 'input'
53
  st.rerun()
54
 
55
+ # --- PAGE 1: INPUT ---
56
  if st.session_state.page == 'input':
57
  st.title("๐Ÿ‹๏ธ Create Your Fitness Profile")
58
  col1, col2, col3 = st.columns([2, 1, 1])
 
60
  with col2: gender = st.selectbox("Gender", ["Male", "Female", "Other"])
61
  with col3: age = st.number_input("Age", min_value=1, value=19)
62
 
63
+ h, w = st.columns(2)
64
+ with h: height = st.number_input("Height (cm)", min_value=1.0)
65
+ with w: weight = st.number_input("Weight (kg)", min_value=1.0)
66
 
67
  goal = st.selectbox("Goal", ["Build Muscle", "Weight Loss", "Strength", "Flexibility"])
68
  level = st.selectbox("Fitness Level", ["Beginner", "Intermediate", "Advanced"])
 
70
 
71
  if st.button("Submit Profile"):
72
  prompt, bmi, bmi_status, status_color = build_prompt(name, gender, age, height, weight, goal, level, equip)
73
+ with st.spinner("Building your single-box workout plan..."):
74
  raw_workout = query_model(prompt)
75
  st.session_state.workout_plan = raw_workout
76
  st.session_state.assessment_data = {"name": name, "bmi": bmi, "status": bmi_status, "color": status_color, "age": age, "gender": gender}
77
  st.session_state.page = 'result'
78
  st.rerun()
79
 
80
+ # --- PAGE 2: RESULTS ---
81
  elif st.session_state.page == 'result':
82
  d = st.session_state.assessment_data
83
+ st.markdown(f'<div class="result-card"><h2>Assessment for {d["name"]}</h2><p>{d["gender"]} | {d["age"]} Years Old</p><p>BMI: <strong>{d["bmi"]:.2f}</strong> | <span style="color:{d["color"]}">{d["status"]}</span></p></div>', unsafe_allow_html=True)
84
 
85
  raw_content = st.session_state.workout_plan
86
  days = ["Day 1:", "Day 2:", "Day 3:", "Day 4:", "Day 5:"]
 
91
  end = raw_content.find(days[i+1]) if i+1 < len(days) else len(raw_content)
92
  day_block = raw_content[start:end].strip()
93
 
94
+ # Start of Single White Box for the Day
95
+ st.markdown(f'<div class="day-card"><div class="day-title">๐Ÿ’  {days[i][:-1]}</div>', unsafe_allow_html=True)
96
 
 
97
  lines = day_block.split("\n")
98
  for line in lines:
99
  if "|" in line:
100
  parts = [p.strip() for p in line.replace("- ", "").split("|")]
101
  if len(parts) == 4:
102
+ ex_name, sets, reps, rest = parts
103
  st.markdown(f"""
104
  <div class="exercise-row">
105
+ <div class="ex-name">๐Ÿ”ฅ {ex_name}</div>
106
+ <div class="stat-container">
107
+ <div class="stat-box"><span class="stat-val">{sets}</span><span class="stat-label">Sets</span></div>
108
+ <div class="stat-box"><span class="stat-val">{reps}</span><span class="stat-label">Reps</span></div>
109
+ <div class="stat-box"><span class="stat-val" style="background:#fff3e0;">{rest}</span><span class="stat-label">Rest</span></div>
110
+ </div>
111
  </div>
112
  """, unsafe_allow_html=True)
113
+
114
+ if "Rest Day" in day_block or "Recovery" in day_block:
115
+ st.info("๐Ÿง˜ Day 3: Active recovery and stretching.")
116
+
117
+ st.markdown('</div>', unsafe_allow_html=True) # End of Day Card
118
 
119
+ st.download_button("๐Ÿ“ฅ Download Full Plan", data=raw_content, file_name=f"{d['name']}_Plan.txt")
120
+