Skip to content

Commit 4751be9

Browse files
committed
AppBar, NavigationRail - Python
1 parent 8110110 commit 4751be9

File tree

5 files changed

+469
-3
lines changed

5 files changed

+469
-3
lines changed

client/lib/controls/page.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ class PageControl extends StatelessWidget {
133133
darkTheme: darkTheme,
134134
themeMode: themeMode,
135135
home: Scaffold(
136+
appBar: null,
136137
body: Stack(children: [
137138
SizedBox.expand(
138139
child: Container(

docs/roadmap.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
* [x] Tabs
2020
* [ ] AppBar
2121
* [ ] NavigationRail
22-
* [ ] NavigationBar
2322
* Basic controls
2423
* [x] Text
2524
* [x] Icon
@@ -56,12 +55,19 @@
5655
* Flet Daemon
5756
* [x] "assets" directory with static content
5857

58+
* Samples apps
59+
* [x] Counter
60+
* [x] To-Do
61+
* [x] Icon browser
62+
* [ ] Chat
63+
5964
* Website
6065
* [ ] Controls S1 reference
6166
* [x] Introduction
67+
* [ ] Home page
6268
* [ ] Blog post
6369
* [ ] Python Guide
64-
* [ ] Deployment (+how to change favicon.ico)
70+
* Deployment (+how to change favicon.ico)
6571
* [x] Deployment to Replit
6672
* [x] Deployment to Fly.io
6773

@@ -70,7 +76,8 @@
7076
* Authentication
7177
* Controls
7278
* Navigation
73-
* NavigationDrawer
79+
* NavigationDrawer
80+
* NavigationBar
7481
* Layout
7582
* Row (responsive)
7683
* Column (responsive)

sdk/python/flet/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from flet.alert_dialog import AlertDialog
2+
from flet.app_bar import AppBar
23
from flet.banner import Banner
34
from flet.checkbox import Checkbox
45
from flet.circle_avatar import CircleAvatar
@@ -17,6 +18,7 @@
1718
from flet.icon_button import IconButton
1819
from flet.image import Image
1920
from flet.list_view import ListView
21+
from flet.navigation_rail import NavigationRail, NavigationRailDestination
2022
from flet.outlined_button import OutlinedButton
2123
from flet.page import Page
2224
from flet.popup_menu_button import PopupMenuButton, PopupMenuItem

sdk/python/flet/app_bar.py

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
import json
2+
from typing import Literal, Optional, Union
3+
4+
from beartype import beartype
5+
from beartype.typing import List
6+
7+
from flet import padding
8+
from flet.constrained_control import ConstrainedControl
9+
from flet.control import Control, OptionalNumber, PaddingValue
10+
from flet.embed_json_encoder import EmbedJsonEncoder
11+
from flet.ref import Ref
12+
13+
14+
class AppBar(Control):
15+
def __init__(
16+
self,
17+
ref: Ref = None,
18+
leading: Control = None,
19+
leading_width: OptionalNumber = None,
20+
title: Control = None,
21+
center_title: bool = None,
22+
toolbar_height: OptionalNumber = None,
23+
color: str = None,
24+
bgcolor: str = None,
25+
actions: List[Control] = None,
26+
):
27+
Control.__init__(self, ref=ref)
28+
29+
self.__leading: Control = None
30+
self.__title: Control = None
31+
self.__actions: List[Control] = []
32+
33+
self.leading = leading
34+
self.leading_width = leading_width
35+
self.title = title
36+
self.center_title = center_title
37+
self.toolbar_height = toolbar_height
38+
self.color = color
39+
self.bgcolor = bgcolor
40+
self.actions = actions
41+
42+
def _get_control_name(self):
43+
return "appbar"
44+
45+
def _get_children(self):
46+
children = []
47+
if self.__leading:
48+
self.__leading._set_attr_internal("n", "leading")
49+
children.append(self.__leading)
50+
if self.__title:
51+
self.__title._set_attr_internal("n", "title")
52+
children.append(self.__title)
53+
for action in self.__actions:
54+
action._set_attr_internal("n", "action")
55+
children.append(action)
56+
return children
57+
58+
# leading
59+
@property
60+
def leading(self):
61+
return self.__leading
62+
63+
@leading.setter
64+
@beartype
65+
def leading(self, value: Optional[Control]):
66+
self.__leading = value
67+
68+
# leading_width
69+
@property
70+
def leading_width(self):
71+
return self._get_attr("leadingWidth")
72+
73+
@leading_width.setter
74+
@beartype
75+
def leading_width(self, value: OptionalNumber):
76+
self._set_attr("leadingWidth", value)
77+
78+
# title
79+
@property
80+
def title(self):
81+
return self.__title
82+
83+
@title.setter
84+
@beartype
85+
def title(self, value: Optional[Control]):
86+
self.__title = value
87+
88+
# center_title
89+
@property
90+
def center_title(self):
91+
return self._get_attr("centerTitle", data_type="bool", def_value=False)
92+
93+
@center_title.setter
94+
@beartype
95+
def center_title(self, value: Optional[bool]):
96+
self._set_attr("centerTitle", value)
97+
98+
# toolbar_height
99+
@property
100+
def toolbar_height(self):
101+
return self._get_attr("toolbarHeight")
102+
103+
@toolbar_height.setter
104+
@beartype
105+
def toolbar_height(self, value: OptionalNumber):
106+
self._set_attr("toolbarHeight", value)
107+
108+
# color
109+
@property
110+
def color(self):
111+
return self._get_attr("color")
112+
113+
@color.setter
114+
def color(self, value):
115+
self._set_attr("color", value)
116+
117+
# bgcolor
118+
@property
119+
def bgcolor(self):
120+
return self._get_attr("bgcolor")
121+
122+
@bgcolor.setter
123+
def bgcolor(self, value):
124+
self._set_attr("bgcolor", value)
125+
126+
# actions
127+
@property
128+
def actions(self):
129+
return self.__actions
130+
131+
@actions.setter
132+
def actions(self, value):
133+
self.__actions = value or []

0 commit comments

Comments
 (0)