Skip to content

Commit

Permalink
page.rtl to control text directionality (#37)
Browse files Browse the repository at this point in the history
* Added page.rtl to control text directionality

* Fix page.padding setting to 0

* Fix margin prop set to 0
  • Loading branch information
FeodorFitsner authored Jun 26, 2022
1 parent 5abe464 commit c30be7a
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 43 deletions.
77 changes: 41 additions & 36 deletions client/lib/controls/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class PageControl extends StatelessWidget {
orElse: () => ScrollMode.none);

final autoScroll = control.attrBool("autoScroll", false)!;
final textDirection =
control.attrBool("rtl", false)! ? TextDirection.rtl : TextDirection.ltr;

Control? offstage;
Control? appBar;
Expand Down Expand Up @@ -176,43 +178,46 @@ class PageControl extends StatelessWidget {
theme: lightTheme,
darkTheme: darkTheme,
themeMode: themeMode,
home: Scaffold(
appBar: appBarView != null
? AppBarControl(
parent: control,
control: appBarView.control,
children: appBarView.children,
parentDisabled: disabled,
height: appBarView.control.attrDouble(
"toolbarHeight", kToolbarHeight)!,
theme: theme)
: null,
body: Stack(children: [
SizedBox.expand(
child: Container(
padding:
parseEdgeInsets(control, "padding") ??
home: Directionality(
textDirection: textDirection,
child: Scaffold(
appBar: appBarView != null
? AppBarControl(
parent: control,
control: appBarView.control,
children: appBarView.children,
parentDisabled: disabled,
height: appBarView.control.attrDouble(
"toolbarHeight", kToolbarHeight)!,
theme: theme)
: null,
body: Stack(children: [
SizedBox.expand(
child: Container(
padding: parseEdgeInsets(
control, "padding") ??
const EdgeInsets.all(10),
decoration: BoxDecoration(
color: HexColor.fromString(
theme,
control.attrString(
"bgcolor", "")!)),
child: scrollMode != ScrollMode.none
? ScrollableControl(
child: column,
scrollDirection: Axis.vertical,
scrollMode: scrollMode,
autoScroll: autoScroll,
)
: column)),
...offstageWidgets,
const PageMedia()
]),
floatingActionButton: fab.isNotEmpty
? createControl(offstage, fab.first.id, disabled)
: null,
),
decoration: BoxDecoration(
color: HexColor.fromString(
theme,
control.attrString(
"bgcolor", "")!)),
child: scrollMode != ScrollMode.none
? ScrollableControl(
child: column,
scrollDirection: Axis.vertical,
scrollMode: scrollMode,
autoScroll: autoScroll,
)
: column)),
...offstageWidgets,
const PageMedia()
]),
floatingActionButton: fab.isNotEmpty
? createControl(
offstage, fab.first.id, disabled)
: null,
)),
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/flet/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def margin(self):
@beartype
def margin(self, value: MarginValue):
self.__margin = value
if value and isinstance(value, (int, float)):
if value != None and isinstance(value, (int, float)):
value = margin.all(value)
self._set_attr_json("margin", value)

Expand Down
4 changes: 2 additions & 2 deletions sdk/python/flet/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def padding(self):
@beartype
def padding(self, value: PaddingValue):
self.__padding = value
if value and isinstance(value, (int, float)):
if value != None and isinstance(value, (int, float)):
value = padding.all(value)
self._set_attr_json("padding", value)

Expand All @@ -109,7 +109,7 @@ def margin(self):
@beartype
def margin(self, value: MarginValue):
self.__margin = value
if value and isinstance(value, (int, float)):
if value != None and isinstance(value, (int, float)):
value = margin.all(value)
self._set_attr_json("margin", value)

Expand Down
2 changes: 1 addition & 1 deletion sdk/python/flet/grid_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def padding(self):
@beartype
def padding(self, value: PaddingValue):
self.__padding = value
if value and isinstance(value, (int, float)):
if value != None and isinstance(value, (int, float)):
value = padding.all(value)
self._set_attr_json("padding", value)

Expand Down
2 changes: 1 addition & 1 deletion sdk/python/flet/list_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def padding(self):
@beartype
def padding(self, value: PaddingValue):
self.__padding = value
if value and isinstance(value, (int, float)):
if value != None and isinstance(value, (int, float)):
value = padding.all(value)
self._set_attr_json("padding", value)

Expand Down
2 changes: 1 addition & 1 deletion sdk/python/flet/navigation_rail.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def padding(self):
@beartype
def padding(self, value: PaddingValue):
self.__padding = value
if value and isinstance(value, (int, float)):
if value != None and isinstance(value, (int, float)):
value = padding.all(value)
self._set_attr_json("padding", value)

Expand Down
12 changes: 11 additions & 1 deletion sdk/python/flet/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def padding(self):
@beartype
def padding(self, value: PaddingValue):
self.__padding = value
if value and isinstance(value, (int, float)):
if value != None and isinstance(value, (int, float)):
value = padding.all(value)
self._set_attr_json("padding", value)

Expand Down Expand Up @@ -476,6 +476,16 @@ def auto_scroll(self):
def auto_scroll(self, value: Optional[bool]):
self._set_attr("autoScroll", value)

# rtl
@property
def rtl(self):
return self._get_attr("rtl")

@rtl.setter
@beartype
def rtl(self, value: Optional[bool]):
self._set_attr("rtl", value)

# window_width
@property
def window_width(self):
Expand Down

0 comments on commit c30be7a

Please sign in to comment.