Skip to content

Commit c30be7a

Browse files
page.rtl to control text directionality (#37)
* Added page.rtl to control text directionality * Fix page.padding setting to 0 * Fix margin prop set to 0
1 parent 5abe464 commit c30be7a

File tree

7 files changed

+58
-43
lines changed

7 files changed

+58
-43
lines changed

client/lib/controls/page.dart

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class PageControl extends StatelessWidget {
4646
orElse: () => ScrollMode.none);
4747

4848
final autoScroll = control.attrBool("autoScroll", false)!;
49+
final textDirection =
50+
control.attrBool("rtl", false)! ? TextDirection.rtl : TextDirection.ltr;
4951

5052
Control? offstage;
5153
Control? appBar;
@@ -176,43 +178,46 @@ class PageControl extends StatelessWidget {
176178
theme: lightTheme,
177179
darkTheme: darkTheme,
178180
themeMode: themeMode,
179-
home: Scaffold(
180-
appBar: appBarView != null
181-
? AppBarControl(
182-
parent: control,
183-
control: appBarView.control,
184-
children: appBarView.children,
185-
parentDisabled: disabled,
186-
height: appBarView.control.attrDouble(
187-
"toolbarHeight", kToolbarHeight)!,
188-
theme: theme)
189-
: null,
190-
body: Stack(children: [
191-
SizedBox.expand(
192-
child: Container(
193-
padding:
194-
parseEdgeInsets(control, "padding") ??
181+
home: Directionality(
182+
textDirection: textDirection,
183+
child: Scaffold(
184+
appBar: appBarView != null
185+
? AppBarControl(
186+
parent: control,
187+
control: appBarView.control,
188+
children: appBarView.children,
189+
parentDisabled: disabled,
190+
height: appBarView.control.attrDouble(
191+
"toolbarHeight", kToolbarHeight)!,
192+
theme: theme)
193+
: null,
194+
body: Stack(children: [
195+
SizedBox.expand(
196+
child: Container(
197+
padding: parseEdgeInsets(
198+
control, "padding") ??
195199
const EdgeInsets.all(10),
196-
decoration: BoxDecoration(
197-
color: HexColor.fromString(
198-
theme,
199-
control.attrString(
200-
"bgcolor", "")!)),
201-
child: scrollMode != ScrollMode.none
202-
? ScrollableControl(
203-
child: column,
204-
scrollDirection: Axis.vertical,
205-
scrollMode: scrollMode,
206-
autoScroll: autoScroll,
207-
)
208-
: column)),
209-
...offstageWidgets,
210-
const PageMedia()
211-
]),
212-
floatingActionButton: fab.isNotEmpty
213-
? createControl(offstage, fab.first.id, disabled)
214-
: null,
215-
),
200+
decoration: BoxDecoration(
201+
color: HexColor.fromString(
202+
theme,
203+
control.attrString(
204+
"bgcolor", "")!)),
205+
child: scrollMode != ScrollMode.none
206+
? ScrollableControl(
207+
child: column,
208+
scrollDirection: Axis.vertical,
209+
scrollMode: scrollMode,
210+
autoScroll: autoScroll,
211+
)
212+
: column)),
213+
...offstageWidgets,
214+
const PageMedia()
215+
]),
216+
floatingActionButton: fab.isNotEmpty
217+
? createControl(
218+
offstage, fab.first.id, disabled)
219+
: null,
220+
)),
216221
);
217222
});
218223
});

sdk/python/flet/card.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def margin(self):
6363
@beartype
6464
def margin(self, value: MarginValue):
6565
self.__margin = value
66-
if value and isinstance(value, (int, float)):
66+
if value != None and isinstance(value, (int, float)):
6767
value = margin.all(value)
6868
self._set_attr_json("margin", value)
6969

sdk/python/flet/container.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def padding(self):
9696
@beartype
9797
def padding(self, value: PaddingValue):
9898
self.__padding = value
99-
if value and isinstance(value, (int, float)):
99+
if value != None and isinstance(value, (int, float)):
100100
value = padding.all(value)
101101
self._set_attr_json("padding", value)
102102

@@ -109,7 +109,7 @@ def margin(self):
109109
@beartype
110110
def margin(self, value: MarginValue):
111111
self.__margin = value
112-
if value and isinstance(value, (int, float)):
112+
if value != None and isinstance(value, (int, float)):
113113
value = margin.all(value)
114114
self._set_attr_json("margin", value)
115115

sdk/python/flet/grid_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def padding(self):
132132
@beartype
133133
def padding(self, value: PaddingValue):
134134
self.__padding = value
135-
if value and isinstance(value, (int, float)):
135+
if value != None and isinstance(value, (int, float)):
136136
value = padding.all(value)
137137
self._set_attr_json("padding", value)
138138

sdk/python/flet/list_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def padding(self):
122122
@beartype
123123
def padding(self, value: PaddingValue):
124124
self.__padding = value
125-
if value and isinstance(value, (int, float)):
125+
if value != None and isinstance(value, (int, float)):
126126
value = padding.all(value)
127127
self._set_attr_json("padding", value)
128128

sdk/python/flet/navigation_rail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def padding(self):
124124
@beartype
125125
def padding(self, value: PaddingValue):
126126
self.__padding = value
127-
if value and isinstance(value, (int, float)):
127+
if value != None and isinstance(value, (int, float)):
128128
value = padding.all(value)
129129
self._set_attr_json("padding", value)
130130

sdk/python/flet/page.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def padding(self):
321321
@beartype
322322
def padding(self, value: PaddingValue):
323323
self.__padding = value
324-
if value and isinstance(value, (int, float)):
324+
if value != None and isinstance(value, (int, float)):
325325
value = padding.all(value)
326326
self._set_attr_json("padding", value)
327327

@@ -476,6 +476,16 @@ def auto_scroll(self):
476476
def auto_scroll(self, value: Optional[bool]):
477477
self._set_attr("autoScroll", value)
478478

479+
# rtl
480+
@property
481+
def rtl(self):
482+
return self._get_attr("rtl")
483+
484+
@rtl.setter
485+
@beartype
486+
def rtl(self, value: Optional[bool]):
487+
self._set_attr("rtl", value)
488+
479489
# window_width
480490
@property
481491
def window_width(self):

0 commit comments

Comments
 (0)