Files changed (1) hide show
  1. app.py +57 -81
app.py CHANGED
@@ -1,84 +1,60 @@
1
- # app.py
2
-
3
  import streamlit as st
4
- import pandas as pd
5
- import matplotlib.pyplot as plt
6
- import datetime
7
  import time
8
 
9
- # App Title
10
- st.title("Time Management App")
11
- st.subheader("Developed by Anupam+918847374914")
12
-
13
- # Sidebar for navigation
14
- st.sidebar.title("Navigation")
15
- selection = st.sidebar.radio("Go to", ["Today's Tasks", "Calendar", "Analytics", "Goals"])
16
-
17
- # Placeholder Data for Task List
18
- tasks_data = pd.DataFrame({
19
- "Task": ["Meeting", "Coding Session", "Review Project"],
20
- "Time": ["10:00 AM", "1:00 PM", "3:00 PM"]
21
- })
22
-
23
- # Today's Tasks Section
24
- if selection == "Today's Tasks":
25
- st.header("Today's Tasks")
26
-
27
- # Input form for new tasks
28
- with st.form("task_form"):
29
- task_name = st.text_input("Task Name")
30
- task_time = st.time_input("Time")
31
- submit_task = st.form_submit_button("Add Task")
32
-
33
- # Append new tasks
34
- if submit_task:
35
- new_task = pd.DataFrame({"Task": [task_name], "Time": [task_time.strftime("%I:%M %p")]})
36
- tasks_data = pd.concat([tasks_data, new_task], ignore_index=True)
37
- st.success(f"Task '{task_name}' added for {task_time.strftime('%I:%M %p')}")
38
-
39
- st.table(tasks_data)
40
-
41
- # Focus Timer Section
42
- st.subheader("Focus Timer")
43
- focus_duration = st.slider("Set Focus Duration (minutes)", min_value=5, max_value=60, step=5)
44
- if st.button("Start Focus Session"):
45
- st.write(f"Focus session started for {focus_duration} minutes...")
46
- with st.spinner("Focusing..."):
47
- time.sleep(focus_duration * 60) # Replace with actual countdown timer functionality
48
- st.success("Focus session completed!")
49
-
50
- # Analytics Section
51
- elif selection == "Analytics":
52
- st.header("Productivity Insights")
53
-
54
- # Sample data for productivity breakdown
55
- productivity_data = {"Category": ["Work", "Study", "Exercise", "Leisure"], "Hours": [20, 15, 5, 10]}
56
- df_productivity = pd.DataFrame(productivity_data)
57
-
58
- # Bar chart for productivity
59
- fig, ax = plt.subplots()
60
- ax.bar(df_productivity["Category"], df_productivity["Hours"], color='skyblue')
61
- ax.set_title("Weekly Productivity Breakdown")
62
- st.pyplot(fig)
63
-
64
- # AI-Based Suggestions (Simplified Example)
65
- def get_suggestions():
66
- return "Try focusing on high-priority tasks in the morning when you're most productive."
67
-
68
- st.subheader("AI Suggestions")
69
- st.write(get_suggestions())
70
-
71
- # Peak Productivity Hours
72
- st.subheader("Peak Productivity Hours")
73
- peak_hours = [9, 10, 11, 14, 15]
74
- st.write(f"Your peak productivity hours: {', '.join([str(hour) + ':00' for hour in peak_hours])}")
75
-
76
- # Goals Section
77
- elif selection == "Goals":
78
- st.header("Goals")
79
- st.write("Set and track your productivity goals here!")
80
-
81
- # Calendar Section
82
- elif selection == "Calendar":
83
- st.header("Calendar View")
84
- st.write("Calendar integration coming soon!")
 
 
 
1
  import streamlit as st
 
 
 
2
  import time
3
 
4
+ st.set_page_config(page_title="8-8-8 Timer", page_icon="⏱️", layout="centered")
5
+
6
+ # --- Session State Setup ---
7
+ if "start_times" not in st.session_state:
8
+ st.session_state.start_times = {"Work": None, "Personal": None, "Rest": None}
9
+ if "elapsed" not in st.session_state:
10
+ st.session_state.elapsed = {"Work": 0, "Personal": 0, "Rest": 0}
11
+ if "running" not in st.session_state:
12
+ st.session_state.running = {"Work": False, "Personal": False, "Rest": False}
13
+
14
+ # --- Functions ---
15
+ def toggle_timer(activity):
16
+ if st.session_state.running[activity]:
17
+ # Pause
18
+ st.session_state.elapsed[activity] += time.time() - st.session_state.start_times[activity]
19
+ st.session_state.running[activity] = False
20
+ else:
21
+ # Start
22
+ st.session_state.start_times[activity] = time.time()
23
+ st.session_state.running[activity] = True
24
+
25
+ def reset_timer(activity):
26
+ st.session_state.elapsed[activity] = 0
27
+ st.session_state.start_times[activity] = None
28
+ st.session_state.running[activity] = False
29
+
30
+ def get_display_time(activity):
31
+ elapsed = st.session_state.elapsed[activity]
32
+ if st.session_state.running[activity]:
33
+ elapsed += time.time() - st.session_state.start_times[activity]
34
+ h, m = divmod(int(elapsed), 3600)
35
+ m, s = divmod(m, 60)
36
+ return f"{h:02d}:{m:02d}:{s:02d}"
37
+
38
+ # --- UI ---
39
+ st.title("⏱️ 8-8-8 Life Balance Timer")
40
+ st.caption("Track Work, Personal, and Rest time following the 8-8-8 rule.")
41
+
42
+ cols = st.columns(3)
43
+ activities = ["Work", "Personal", "Rest"]
44
+
45
+ for i, activity in enumerate(activities):
46
+ with cols[i]:
47
+ st.subheader(activity)
48
+ st.metric("Elapsed", get_display_time(activity))
49
+ if st.button("Start/Pause", key=f"start_{activity}"):
50
+ toggle_timer(activity)
51
+ if st.button("Reset", key=f"reset_{activity}"):
52
+ reset_timer(activity)
53
+
54
+ # --- Progress bars ---
55
+ st.markdown("### 📊 Daily Progress (out of 8 hours each)")
56
+ for activity in activities:
57
+ elapsed = st.session_state.elapsed[activity]
58
+ if st.session_state.running[activity]:
59
+ elapsed += time.time() - st.session_state.start_times[activity]
60
+ st.progress(min(elapsed / (8 * 3600), 1.0), text=f"{activity}: {get_display_time(activity)} / 08:00:00")