@@ -210,11 +210,11 @@ def __str__(self):
210
210
211
211
def tooltip (self ):
212
212
"""returns the tooltip for the filter button"""
213
- if self is ProjectStates .ACTIVE . value :
213
+ if self is ProjectStates .ACTIVE :
214
214
return "Not completed and not due."
215
- elif self is ProjectStates .UPCOMING . value :
215
+ elif self is ProjectStates .UPCOMING :
216
216
return "Scheduled for the future."
217
- elif self is ProjectStates .COMPLETED . value :
217
+ elif self is ProjectStates .COMPLETED :
218
218
return "Marked as completed."
219
219
else :
220
220
return "All projects."
@@ -225,56 +225,28 @@ class ProjectFiltersView(UserControl):
225
225
226
226
def __init__ (self , onStateChanged : Callable [[ProjectStates ], None ]):
227
227
super ().__init__ ()
228
- self .currentState = ProjectStates .ALL
228
+ self .current_state = ProjectStates .ALL
229
229
self .stateTofilterButtonsMap = {}
230
230
self .onStateChangedCallback = onStateChanged
231
231
232
- def filter_button (
233
- self ,
234
- state : ProjectStates ,
235
- label : str ,
236
- onClick : Callable [[ProjectStates ], None ],
237
- tooltip : str ,
238
- ):
239
- """creates a filter button for project status"""
240
- button = ElevatedButton (
241
- text = label ,
242
- col = {"xs" : 6 , "sm" : 3 , "lg" : 2 },
243
- on_click = lambda e : onClick (state ),
244
- height = dimens .CLICKABLE_PILL_HEIGHT ,
245
- color = colors .PRIMARY_COLOR
246
- if state == self .currentState
247
- else colors .GRAY_COLOR ,
248
- tooltip = tooltip ,
249
- style = ButtonStyle (
250
- elevation = {
251
- utils .PRESSED : 3 ,
252
- utils .SELECTED : 3 ,
253
- utils .HOVERED : 4 ,
254
- utils .OTHER_CONTROL_STATES : 2 ,
255
- },
256
- ),
257
- )
258
- return button
259
-
260
232
def on_filter_button_clicked (self , state : ProjectStates ):
261
233
"""sets the new state and updates selected button"""
262
- self .stateTofilterButtonsMap [self .currentState ].color = colors .GRAY_COLOR
263
- self .currentState = state
264
- self .stateTofilterButtonsMap [self .currentState ].color = colors .PRIMARY_COLOR
234
+ self .stateTofilterButtonsMap [self .current_state ].color = colors .GRAY_COLOR
235
+ self .current_state = state
236
+ self .stateTofilterButtonsMap [self .current_state ].color = colors .PRIMARY_COLOR
265
237
self .update ()
266
238
self .onStateChangedCallback (state )
267
239
268
240
def set_filter_buttons (self ):
269
241
"""sets the filter buttons for each project state"""
270
242
for state in ProjectStates :
271
- button = self . filter_button (
243
+ self . stateTofilterButtonsMap [ state ] = views . TStatusFilterBtn (
272
244
label = state .__str__ (),
273
- state = state ,
274
- onClick = self .on_filter_button_clicked ,
245
+ is_current_state = state .value == self .current_state .value ,
246
+ on_click = self .on_filter_button_clicked ,
247
+ on_click_params = state ,
275
248
tooltip = state .tooltip (),
276
249
)
277
- self .stateTofilterButtonsMap [state ] = button
278
250
279
251
def build (self ):
280
252
"""builds the filter buttons"""
0 commit comments