Skip to content

Commit 38c5482

Browse files
committed
Filled buttons, dividers
1 parent 20ab93c commit 38c5482

File tree

14 files changed

+413
-91
lines changed

14 files changed

+413
-91
lines changed

client/lib/controls/create_control.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'circle_avatar.dart';
1212
import 'clipboard.dart';
1313
import 'column.dart';
1414
import 'container.dart';
15+
import 'divider.dart';
1516
import 'dropdown.dart';
1617
import 'elevated_button.dart';
1718
import 'floating_action_button.dart';
@@ -35,6 +36,7 @@ import 'tabs.dart';
3536
import 'text.dart';
3637
import 'text_button.dart';
3738
import 'textfield.dart';
39+
import 'vertical_divider.dart';
3840

3941
// abstract class ControlWidget extends Widget {
4042
// const ControlWidget(
@@ -75,6 +77,10 @@ Widget createControl(Control? parent, String id, bool parentDisabled) {
7577
return ClipboardControl(control: controlView.control);
7678
case ControlType.image:
7779
return ImageControl(parent: parent, control: controlView.control);
80+
case ControlType.divider:
81+
return DividerControl(control: controlView.control);
82+
case ControlType.verticalDivider:
83+
return VerticalDividerControl(control: controlView.control);
7884
case ControlType.circleAvatar:
7985
return CircleAvatarControl(
8086
parent: parent,

client/lib/controls/divider.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import 'package:flutter/material.dart';
2+
3+
import '../models/control.dart';
4+
import '../utils/colors.dart';
5+
import 'create_control.dart';
6+
7+
class DividerControl extends StatelessWidget {
8+
final Control? parent;
9+
final Control control;
10+
11+
const DividerControl({Key? key, this.parent, required this.control})
12+
: super(key: key);
13+
14+
@override
15+
Widget build(BuildContext context) {
16+
debugPrint("Divider build: ${control.id}");
17+
18+
var height = control.attrDouble("height");
19+
var thickness = control.attrDouble("thickness");
20+
var color = HexColor.fromString(context, control.attrString("color", "")!);
21+
22+
return baseControl(
23+
Divider(
24+
height: height,
25+
thickness: thickness,
26+
color: color,
27+
),
28+
parent,
29+
control);
30+
}
31+
}

client/lib/controls/elevated_button.dart

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ class ElevatedButtonControl extends StatelessWidget {
2828
IconData? icon = getMaterialIcon(control.attrString("icon", "")!);
2929
Color? iconColor =
3030
HexColor.fromString(context, control.attrString("iconColor", "")!);
31+
Color? color =
32+
HexColor.fromString(context, control.attrString("color", "")!);
33+
Color? bgcolor =
34+
HexColor.fromString(context, control.attrString("bgcolor", "")!);
35+
var elevation = control.attrDouble("elevation");
3136
var contentCtrls = children.where((c) => c.name == "content");
3237
bool autofocus = control.attrBool("autofocus", false)!;
33-
bool filled = control.attrBool("filled", false)!;
34-
bool filledTonal = control.attrBool("filledTonal", false)!;
3538
bool disabled = control.isDisabled || parentDisabled;
3639

3740
Function()? onPressed = disabled
@@ -47,20 +50,13 @@ class ElevatedButtonControl extends StatelessWidget {
4750
ElevatedButton? button;
4851
ButtonStyle? style;
4952

50-
if (filled) {
53+
if (color != null || bgcolor != null || elevation != null) {
5154
style = ElevatedButton.styleFrom(
5255
// Foreground color
53-
onPrimary: Theme.of(context).colorScheme.onPrimary,
56+
onPrimary: color,
5457
// Background color
55-
primary: Theme.of(context).colorScheme.primary,
56-
).copyWith(elevation: ButtonStyleButton.allOrNull(0.0));
57-
} else if (filledTonal) {
58-
style = ElevatedButton.styleFrom(
59-
// Foreground color
60-
onPrimary: Theme.of(context).colorScheme.onSecondaryContainer,
61-
// Background color
62-
primary: Theme.of(context).colorScheme.secondaryContainer,
63-
).copyWith(elevation: ButtonStyleButton.allOrNull(0.0));
58+
primary: bgcolor,
59+
).copyWith(elevation: ButtonStyleButton.allOrNull(elevation));
6460
}
6561

6662
if (icon != null) {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import 'package:flutter/material.dart';
2+
3+
import '../models/control.dart';
4+
import '../utils/colors.dart';
5+
import 'create_control.dart';
6+
7+
class VerticalDividerControl extends StatelessWidget {
8+
final Control? parent;
9+
final Control control;
10+
11+
const VerticalDividerControl({Key? key, this.parent, required this.control})
12+
: super(key: key);
13+
14+
@override
15+
Widget build(BuildContext context) {
16+
debugPrint("VerticalDivider build: ${control.id}");
17+
18+
var width = control.attrDouble("width");
19+
var thickness = control.attrDouble("thickness");
20+
var color = HexColor.fromString(context, control.attrString("color", "")!);
21+
22+
return baseControl(
23+
VerticalDivider(
24+
width: width,
25+
thickness: thickness,
26+
color: color,
27+
),
28+
parent,
29+
control);
30+
}
31+
}

client/lib/models/control_type.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ enum ControlType {
66
clipboard,
77
column,
88
container,
9+
divider,
910
dropdown,
1011
dropdownOption,
1112
elevatedButton,
@@ -32,5 +33,6 @@ enum ControlType {
3233
tab,
3334
text,
3435
textButton,
35-
textField
36+
textField,
37+
verticalDivider
3638
}

docs/roadmap.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@
1313
* [x] Stack
1414
* [x] ListView
1515
* [x] GridView
16+
* [ ] Divider
17+
* [ ] VerticalDivider
1618
* App structure and navigation
1719
* [x] Tabs
20+
* [ ] AppBar
21+
* [ ] NavigationRail
22+
* [ ] NavigationBar
1823
* Basic controls
1924
* [x] Text
2025
* [x] Icon
@@ -24,10 +29,13 @@
2429
* [x] ProgressRing
2530
* Buttons
2631
* [x] ElevatedButton
32+
* [x] FilledButton
33+
* [x] FilledTonalButton
2734
* [x] OutlinedButton
2835
* [x] TextButton
2936
* [x] IconButton
3037
* [x] FloatingActionButton
38+
* [ ] PopupMenuButton
3139
* Input and selections
3240
* [x] TextField
3341
* [x] Dropdown
@@ -59,12 +67,14 @@
5967

6068
## Sprint 2
6169

70+
* Authentication
6271
* Controls
72+
* Navigation
73+
* NavigationDrawer
6374
* Layout
6475
* Row (responsive)
6576
* Column (responsive)
6677
* Behavior
67-
* Complex embeddable values for `padding`, `marging`, etc, e.g. `.padding = { 'left': 10, 'right': 20 }`
6878
* Visual Density ([more](https://api.flutter.dev/flutter/material/VisualDensity-class.html))
6979
* Early detection of layout issues (like enabling scrolling in unbounded controls) with [Layout Builder](https://api.flutter.dev/flutter/widgets/LayoutBuilder-class.html).
7080
* Scroll speed on Windows Desktop [The issue](https://github.com/flutter/flutter/issues/67985)
@@ -75,6 +85,17 @@
7585
* [ ] Windows ("host" mode with hot reload)
7686
* [ ] macOS ("host" mode with hot reload)
7787

88+
## Year 2022
89+
90+
* Grids
91+
* Charts
92+
* Navigation controls and Routing
93+
* Responsive layout
94+
* Adaptive controls
95+
* Animations
96+
* PubSub
97+
* DB
98+
7899
## Controls
79100

80101
<table>

sdk/python/flet/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
from flet.column import Column
66
from flet.container import Container
77
from flet.control import Control
8+
from flet.divider import Divider
89
from flet.dropdown import Dropdown
910
from flet.elevated_button import ElevatedButton
11+
from flet.filled_button import FilledButton
12+
from flet.filled_tonal_button import FilledTonalButton
1013
from flet.flet import *
1114
from flet.floating_action_button import FloatingActionButton
1215
from flet.grid_view import GridView
@@ -31,3 +34,4 @@
3134
from flet.text_button import TextButton
3235
from flet.textfield import TextField
3336
from flet.theme import Theme
37+
from flet.vertical_divider import VerticalDivider

sdk/python/flet/divider.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
from typing import Union
2+
3+
import beartype
4+
5+
from flet.control import Control, OptionalNumber
6+
from flet.ref import Ref
7+
8+
9+
class Divider(Control):
10+
def __init__(
11+
self,
12+
ref: Ref = None,
13+
opacity: OptionalNumber = None,
14+
visible: bool = None,
15+
data: any = None,
16+
#
17+
# Specific
18+
#
19+
height: OptionalNumber = None,
20+
thickness: OptionalNumber = None,
21+
color: str = None,
22+
):
23+
24+
Control.__init__(
25+
self,
26+
ref=ref,
27+
opacity=opacity,
28+
visible=visible,
29+
data=data,
30+
)
31+
32+
self.height = height
33+
self.thickness = thickness
34+
self.color = color
35+
36+
def _get_control_name(self):
37+
return "divider"
38+
39+
# height
40+
@property
41+
def height(self):
42+
return self._get_attr("height")
43+
44+
@height.setter
45+
@beartype
46+
def height(self, value: OptionalNumber):
47+
self._set_attr("height", value)
48+
49+
# thickness
50+
@property
51+
def thickness(self):
52+
return self._get_attr("thickness")
53+
54+
@thickness.setter
55+
@beartype
56+
def thickness(self, value: OptionalNumber):
57+
self._set_attr("thickness", value)
58+
59+
# color
60+
@property
61+
def color(self):
62+
return self._get_attr("color")
63+
64+
@color.setter
65+
def color(self, value):
66+
self._set_attr("color", value)

sdk/python/flet/elevated_button.py

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ def __init__(
2323
#
2424
# Specific
2525
#
26-
filled: bool = None,
27-
filled_tonal: bool = None,
26+
color: str = None,
27+
bgcolor: str = None,
28+
elevation: OptionalNumber = None,
2829
icon: str = None,
2930
icon_color: str = None,
3031
content: Control = None,
@@ -45,8 +46,9 @@ def __init__(
4546
)
4647

4748
self.text = text
48-
self.filled = filled
49-
self.filled_tonal = filled_tonal
49+
self.color = color
50+
self.bgcolor = bgcolor
51+
self.elevation = elevation
5052
self.icon = icon
5153
self.icon_color = icon_color
5254
self.content = content
@@ -71,25 +73,33 @@ def text(self):
7173
def text(self, value):
7274
self._set_attr("text", value)
7375

74-
# filled
76+
# color
7577
@property
76-
def filled(self):
77-
return self._get_attr("filled", data_type="bool", def_value=False)
78+
def color(self):
79+
return self._get_attr("color")
7880

79-
@filled.setter
80-
@beartype
81-
def filled(self, value: Optional[bool]):
82-
self._set_attr("filled", value)
81+
@color.setter
82+
def color(self, value):
83+
self._set_attr("color", value)
84+
85+
# bgcolor
86+
@property
87+
def bgcolor(self):
88+
return self._get_attr("bgcolor")
89+
90+
@bgcolor.setter
91+
def bgcolor(self, value):
92+
self._set_attr("bgcolor", value)
8393

84-
# filled_tonal
94+
# elevation
8595
@property
86-
def filled_tonal(self):
87-
return self._get_attr("filledTonal", data_type="bool", def_value=False)
96+
def elevation(self) -> OptionalNumber:
97+
return self._get_attr("elevation")
8898

89-
@filled_tonal.setter
99+
@elevation.setter
90100
@beartype
91-
def filled_tonal(self, value: Optional[bool]):
92-
self._set_attr("filledTonal", value)
101+
def elevation(self, value: OptionalNumber):
102+
self._set_attr("elevation", value)
93103

94104
# icon
95105
@property

0 commit comments

Comments
 (0)