1
1
from board import Board
2
2
from data_store import DataStore
3
- from flet import (
4
- ButtonStyle ,
5
- Column ,
6
- Container ,
7
- Control ,
8
- IconButton ,
9
- Page ,
10
- PopupMenuButton ,
11
- PopupMenuItem ,
12
- RoundedRectangleBorder ,
13
- Row ,
14
- Text ,
15
- TextButton ,
16
- TextField ,
17
- border ,
18
- border_radius ,
19
- colors ,
20
- icons ,
21
- padding ,
22
- )
3
+ import flet as ft
23
4
from sidebar import Sidebar
24
5
25
- class AppLayout (Row ):
26
- def __init__ (self , app , page : Page , store : DataStore , * args , ** kwargs ):
6
+
7
+ class AppLayout (ft .Row ):
8
+ def __init__ (self , app , page : ft .Page , store : DataStore , * args , ** kwargs ):
27
9
super ().__init__ (* args , ** kwargs )
28
10
self .app = app
29
- self .page = page
30
- self .page .on_resize = self .page_resize
11
+ self .page : ft . Page = page
12
+ self .page .on_resized = self .page_resize
31
13
self .store : DataStore = store
32
- self .toggle_nav_rail_button = IconButton (
33
- icon = icons .ARROW_CIRCLE_LEFT ,
34
- icon_color = colors .BLUE_GREY_400 ,
14
+ self .toggle_nav_rail_button = ft . IconButton (
15
+ icon = ft . Icons .ARROW_CIRCLE_LEFT ,
16
+ icon_color = ft . Colors .BLUE_GREY_400 ,
35
17
selected = False ,
36
- selected_icon = icons .ARROW_CIRCLE_RIGHT ,
18
+ selected_icon = ft . Icons .ARROW_CIRCLE_RIGHT ,
37
19
on_click = self .toggle_nav_rail ,
38
20
)
39
- self .sidebar = Sidebar (self , self .store , page )
40
- self .members_view = Text ("members view" )
41
- self .all_boards_view = Column (
21
+ self .sidebar = Sidebar (self , self .store )
22
+ self .members_view = ft . Text ("members view" )
23
+ self .all_boards_view = ft . Column (
42
24
[
43
- Row (
25
+ ft . Row (
44
26
[
45
- Container (
46
- Text (value = "Your Boards" , style = "headlineMedium" ),
27
+ ft .Container (
28
+ ft .Text (
29
+ value = "Your Boards" ,
30
+ theme_style = ft .TextThemeStyle .HEADLINE_MEDIUM ,
31
+ ),
47
32
expand = True ,
48
- padding = padding .only (top = 15 ),
33
+ padding = ft . padding .only (top = 15 ),
49
34
),
50
- Container (
51
- TextButton (
35
+ ft . Container (
36
+ ft . TextButton (
52
37
"Add new board" ,
53
- icon = icons .ADD ,
38
+ icon = ft . Icons .ADD ,
54
39
on_click = self .app .add_board ,
55
- style = ButtonStyle (
40
+ style = ft . ButtonStyle (
56
41
bgcolor = {
57
- "" : colors .BLUE_200 ,
58
- "hovered" : colors .BLUE_400 ,
42
+ ft .ControlState .DEFAULT : ft .Colors .BLUE_200 ,
43
+ ft .ControlState .HOVERED : ft .Colors .BLUE_400 ,
44
+ },
45
+ shape = {
46
+ ft .ControlState .DEFAULT : ft .RoundedRectangleBorder (
47
+ radius = 3
48
+ )
59
49
},
60
- shape = {"" : RoundedRectangleBorder (radius = 3 )},
61
50
),
62
51
),
63
- padding = padding .only (right = 50 , top = 15 ),
52
+ padding = ft . padding .only (right = 50 , top = 15 ),
64
53
),
65
54
]
66
55
),
67
- Row (
56
+ ft . Row (
68
57
[
69
- TextField (
58
+ ft . TextField (
70
59
hint_text = "Search all boards" ,
71
60
autofocus = False ,
72
- content_padding = padding .only (left = 10 ),
61
+ content_padding = ft . padding .only (left = 10 ),
73
62
width = 200 ,
74
63
height = 40 ,
75
64
text_size = 12 ,
76
- border_color = colors .BLACK26 ,
77
- focused_border_color = colors .BLUE_ACCENT ,
78
- suffix_icon = icons .SEARCH ,
65
+ border_color = ft . Colors .BLACK26 ,
66
+ focused_border_color = ft . Colors .BLUE_ACCENT ,
67
+ suffix_icon = ft . Icons .SEARCH ,
79
68
)
80
69
]
81
70
),
82
- Row ([Text ("No Boards to Display" )]),
71
+ ft . Row ([ft . Text ("No Boards to Display" )]),
83
72
],
84
73
expand = True ,
85
74
)
86
- self ._active_view : Control = self .all_boards_view
75
+ self ._active_view : ft . Control = self .all_boards_view
87
76
88
77
self .controls = [self .sidebar , self .toggle_nav_rail_button , self .active_view ]
89
78
@@ -96,29 +85,26 @@ def active_view(self, view):
96
85
self ._active_view = view
97
86
self .controls [- 1 ] = self ._active_view
98
87
self .sidebar .sync_board_destinations ()
99
- self .update ()
88
+ self .page . update ()
100
89
101
90
def set_board_view (self , i ):
102
91
self .active_view = self .store .get_boards ()[i ]
103
92
self .sidebar .bottom_nav_rail .selected_index = i
104
93
self .sidebar .top_nav_rail .selected_index = None
105
- self .sidebar .update ()
106
- self .page .update ()
107
94
self .page_resize ()
95
+ self .page .update ()
108
96
109
97
def set_all_boards_view (self ):
110
98
self .active_view = self .all_boards_view
111
99
self .hydrate_all_boards_view ()
112
100
self .sidebar .top_nav_rail .selected_index = 0
113
101
self .sidebar .bottom_nav_rail .selected_index = None
114
- self .sidebar .update ()
115
102
self .page .update ()
116
103
117
104
def set_members_view (self ):
118
105
self .active_view = self .members_view
119
106
self .sidebar .top_nav_rail .selected_index = 1
120
107
self .sidebar .bottom_nav_rail .selected_index = None
121
- self .sidebar .update ()
122
108
self .page .update ()
123
109
124
110
def page_resize (self , e = None ):
@@ -129,49 +115,49 @@ def page_resize(self, e=None):
129
115
self .page .update ()
130
116
131
117
def hydrate_all_boards_view (self ):
132
- self .all_boards_view .controls [- 1 ] = Row (
118
+ self .all_boards_view .controls [- 1 ] = ft . Row (
133
119
[
134
- Container (
135
- content = Row (
120
+ ft . Container (
121
+ content = ft . Row (
136
122
[
137
- Container (
138
- content = Text (value = b .name ),
123
+ ft . Container (
124
+ content = ft . Text (value = b .name ),
139
125
data = b ,
140
126
expand = True ,
141
127
on_click = self .board_click ,
142
128
),
143
- Container (
144
- content = PopupMenuButton (
129
+ ft . Container (
130
+ content = ft . PopupMenuButton (
145
131
items = [
146
- PopupMenuItem (
147
- content = Text (
132
+ ft . PopupMenuItem (
133
+ content = ft . Text (
148
134
value = "Delete" ,
149
- style = "labelMedium" ,
150
- text_align = "center" ,
135
+ theme_style = ft . TextThemeStyle . LABEL_MEDIUM ,
136
+ text_align = ft . TextAlign . CENTER ,
151
137
),
152
138
on_click = self .app .delete_board ,
153
139
data = b ,
154
140
),
155
- PopupMenuItem (),
156
- PopupMenuItem (
157
- content = Text (
141
+ ft . PopupMenuItem (),
142
+ ft . PopupMenuItem (
143
+ content = ft . Text (
158
144
value = "Archive" ,
159
- style = "labelMedium" ,
160
- text_align = "center" ,
145
+ theme_style = ft . TextThemeStyle . LABEL_MEDIUM ,
146
+ text_align = ft . TextAlign . CENTER ,
161
147
),
162
148
),
163
149
]
164
150
),
165
- padding = padding .only (right = - 10 ),
166
- border_radius = border_radius .all (3 ),
151
+ padding = ft . padding .only (right = - 10 ),
152
+ border_radius = ft . border_radius .all (3 ),
167
153
),
168
154
],
169
- alignment = "spaceBetween" ,
155
+ alignment = ft . MainAxisAlignment . SPACE_BETWEEN ,
170
156
),
171
- border = border .all (1 , colors .BLACK38 ),
172
- border_radius = border_radius .all (5 ),
173
- bgcolor = colors .WHITE60 ,
174
- padding = padding .all (10 ),
157
+ border = ft . border .all (1 , ft . Colors .BLACK38 ),
158
+ border_radius = ft . border_radius .all (5 ),
159
+ bgcolor = ft . Colors .WHITE60 ,
160
+ padding = ft . padding .all (10 ),
175
161
width = 250 ,
176
162
data = b ,
177
163
)
0 commit comments