Skip to content

Commit

Permalink
Dividers example
Browse files Browse the repository at this point in the history
  • Loading branch information
FeodorFitsner committed May 13, 2022
1 parent 38c5482 commit 8c11922
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 14 deletions.
9 changes: 3 additions & 6 deletions client/lib/controls/container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import '../utils/borders.dart';
import '../utils/colors.dart';
import '../utils/edge_insets.dart';
import 'create_control.dart';
import 'error.dart';

class ContainerControl extends StatelessWidget {
final Control? parent;
Expand All @@ -32,10 +31,6 @@ class ContainerControl extends StatelessWidget {
var contentCtrls = children.where((c) => c.name == "content");
bool disabled = control.isDisabled || parentDisabled;

if (contentCtrls.isEmpty) {
return const ErrorControl("Container does not contain any content.");
}

return constrainedControl(
Container(
padding: parseEdgeInsets(control, "padding"),
Expand All @@ -45,7 +40,9 @@ class ContainerControl extends StatelessWidget {
color: bgColor,
border: parseBorder(context, control, "border"),
borderRadius: parseBorderRadius(control, "borderRadius")),
child: createControl(control, contentCtrls.first.id, disabled)),
child: contentCtrls.isNotEmpty
? createControl(control, contentCtrls.first.id, disabled)
: null),
parent,
control);
}
Expand Down
4 changes: 2 additions & 2 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* [x] Stack
* [x] ListView
* [x] GridView
* [ ] Divider
* [ ] VerticalDivider
* [x] Divider
* [x] VerticalDivider
* App structure and navigation
* [x] Tabs
* [ ] AppBar
Expand Down
9 changes: 5 additions & 4 deletions sdk/python/flet/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ def _get_control_name(self):
return "container"

def _get_children(self):
if self.__content == None:
raise Exception("Container does not have any content set.")
self.__content._set_attr_internal("n", "content")
return [self.__content]
children = []
if self.__content != None:
self.__content._set_attr_internal("n", "content")
children.append(self.__content)
return children

# alignment
@property
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/flet/divider.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Union

import beartype
from beartype import beartype

from flet.control import Control, OptionalNumber
from flet.ref import Ref
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/flet/vertical_divider.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Union

import beartype
from beartype import beartype

from flet.control import Control, OptionalNumber
from flet.ref import Ref
Expand Down
84 changes: 84 additions & 0 deletions sdk/python/playground/dividers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
from doctest import Example

import flet
from flet import (
Column,
Container,
Divider,
Page,
Row,
Text,
VerticalDivider,
alignment,
colors,
)


def main(page: Page):

page.add(
Row(
[
Column(
[
Container(
bgcolor=colors.AMBER,
alignment=alignment.center,
expand=True,
),
Divider(),
Container(
bgcolor=colors.PINK, alignment=alignment.center, expand=True
),
Divider(height=1, color="white"),
Container(
bgcolor=colors.BLUE_300,
alignment=alignment.center,
expand=True,
),
Divider(height=9, thickness=3),
Container(
bgcolor=colors.DEEP_PURPLE_200,
alignment=alignment.center,
expand=True,
),
],
spacing=0,
expand=True,
),
Row(
[
Container(
bgcolor=colors.ORANGE_300,
alignment=alignment.center,
expand=True,
),
VerticalDivider(),
Container(
bgcolor=colors.BROWN_400,
alignment=alignment.center,
expand=True,
),
VerticalDivider(width=1, color="white"),
Container(
bgcolor=colors.BLUE_300,
alignment=alignment.center,
expand=True,
),
VerticalDivider(width=9, thickness=3),
Container(
bgcolor=colors.GREEN_300,
alignment=alignment.center,
expand=True,
),
],
spacing=0,
expand=True,
),
],
expand=True,
)
)


flet.app(target=main, view=flet.WEB_BROWSER)

0 comments on commit 8c11922

Please sign in to comment.