-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew_setup.py
More file actions
246 lines (198 loc) · 7.74 KB
/
Copy pathnew_setup.py
File metadata and controls
246 lines (198 loc) · 7.74 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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
from kivy.lang import Builder
from kivy.properties import ObjectProperty
from kivy.uix.spinner import Spinner
from kivymd.uix.button import MDRoundFlatButton, MDFillRoundFlatButton
from kivymd.uix.screen import MDScreen
from user import UserManager
from sign_up import SignUpScreen
Builder.load_string("""
<NewSetupScreen>:
MDBoxLayout:
orientation: 'vertical'
padding: 0,0,0,30
spacing: 10
MDBoxLayout:
size_hint_y: 0.2
orientation: "vertical"
padding: 30
# canvas.before:
# Color:
# rgba: 99/255, 210/255, 218/255, 1
# Rectangle:
# size: self.size
# pos: self.pos
MDLabel:
text: "Set Up"
font_style: "H5"
# theme_text_color: "Custom"
# text_color: 1,1,1,1
ScrollView:
size_hint_y: 0.90
GridLayout:
cols: 1
# size_hint_y: 0.9
size_hint_y: None
height: self.minimum_height
spacing: 20
padding: 30
MDBoxLayout:
orientation: 'vertical'
size_hint_y: None
height: 100
spacing: 15
padding: 5, 5, 5, 10
MDLabel:
text: "Age"
valign: 'top'
# font_style: "Subtitle2"
# font_size: "15sp"
Spinner:
id: age_spinner
values: [str(i) for i in range(18, 100)]
text: 'Select Age'
background_color: (99 / 255, 210 / 255, 218 / 255, 0.8)
MDBoxLayout:
id: gender_box
orientation: 'vertical'
size_hint_y: None
height: 100
spacing: 15
padding: 5, 5, 5, 10
MDLabel:
text: "Gender"
valign: 'top'
Spinner:
id: gender_spinner
values: ["Male", "Female"]
text: 'Select Gender'
background_color: (99 / 255, 210 / 255, 218 / 255, 0.8)
MDBoxLayout:
id: height_box
orientation: 'vertical'
size_hint_y: None
height: 100
spacing: 15
padding: 5, 5, 5, 10
MDLabel:
text: "Height"
valign: 'top'
Spinner:
id: height_spinner
values: ['{}\\'{}\\" ({}cm)'.format(ft, inch, \
round(ft * 30.48 + inch * 2.54)) for ft in range(4, 8) \
for inch in range(0, 12)]
text: 'Select Height'
background_color: (99 / 255, 210 / 255, 218 / 255, 0.8)
MDBoxLayout:
id: name_box
orientation: 'vertical'
size_hint_y: None
height: 100
spacing: 15
padding: 5, 5, 5, 10
MDLabel:
text: "Weight"
valign: 'top'
MDBoxLayout:
MDTextField:
id: weight_input
input_filter: 'float'
input_type: 'number'
hint_text: "Enter your weight in pounds"
pos_hint: {"center_x": 0.5, "center_y": 0.3}
line_color_focus: [99/255, 210/255, 218/255, 1]
# MDBoxLayout:
# orientation: 'vertical'
# size_hint_y: None
# height: 100
# spacing: 30
# MDLabel:
# text: "Where do you workout?"
# valign: 'top'
#
# MDBoxLayout:
# id: location_box
# orientation: 'horizontal'
# padding: 0, 5, 0, 0
# spacing: 30
MDBoxLayout:
orientation: 'vertical'
size_hint_y: None
height: 140
# spacing: 30
# adaptive_height: True
MDLabel:
text: "Level"
valign: 'top'
ScrollView:
do_scroll_x: True
do_scroll_y: False
# cols:2
# adaptive_height: True
# size_hint_y: 0.3
MDBoxLayout
id: level_box
# orientation: 'horizontal'
# padding: 0, 5, 0, 0
spacing: 30
adaptive_width: True
MDRectangleFlatButton:
text: "Done"
size_hint: 0.5, None
md_bg_color: 99/255, 210/255, 218/255, 1
text_color: 1,1,1,1
theme_text_color: "Custom"
line_color: 99/255, 210/255, 218/255, 1
pos_hint: {"center_x": 0.5, "center_y": 0.5}
# pos_hint: {"x": 0.5, "y": 0.5}
on_release: root.save_profile()
# root.manager.current = "setup"
""")
class NewSetupScreen(MDScreen):
user_manager = ObjectProperty(None)
def __init__(self, **kwargs):
super(NewSetupScreen, self).__init__(**kwargs)
self.add_level_buttons()
self.selected_level = []
def add_level_buttons(self):
level = ["Beginner", "Intermediate"]
for text in level:
button = MDRoundFlatButton(
text=text,
pos_hint={'center_y': 0.5},
line_color=(99 / 255, 210 / 255, 218 / 255, 1),
text_color=(99 / 255, 210 / 255, 218 / 255, 1)
)
button.bind(on_press=self.select_level)
self.ids.level_box.add_widget(button)
def select_level(self, button):
if button.text in self.selected_level:
self.selected_level.remove(button.text)
button.text_color = (99 / 255, 210 / 255, 218 / 255, 1)
button.md_bg_color = (0, 0, 0, 0)
else:
self.selected_level.append(button.text)
button.text_color = (1, 1, 1, 1)
button.md_bg_color = (99 / 255, 210 / 255, 218 / 255, 1)
def save_profile(self):
age = self.ids.age_spinner.text
gender = self.ids.gender_spinner.text
height = self.ids.height_spinner.text
weight = self.ids.weight_input.text
level = ', '.join(self.selected_level)
profile_data = {
"Age": int(age),
"Gender": gender,
"Height (cm)": height,
"Weight (lbs)": int(weight),
"Experience Level": level
}
self.user_manager.set_user_profile(profile_data)
self.user_manager.process_height()
self.user_manager.add_user_groups()
self.user_manager.save_user_profile()
user_id = self.user_manager.get_user_id()
if user_id:
self.user_manager.save_profile_to_db(user_id, age, gender, height, int(weight), level)
self.manager.current = "setupgoals"
pass