Skip to content

Commit 4de9377

Browse files
committed
Icon browser done
1 parent 9827890 commit 4de9377

File tree

6 files changed

+35
-16
lines changed

6 files changed

+35
-16
lines changed

client/lib/controls/text.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class TextControl extends StatelessWidget {
1717
debugPrint("Text build: ${control.id}");
1818

1919
String text = control.attrString("value", "")!;
20+
bool noWrap = control.attrBool("noWrap", false)!;
2021

2122
TextStyle? style;
2223
var styleName = control.attrString("style", null);
@@ -53,6 +54,7 @@ class TextControl extends StatelessWidget {
5354
)
5455
: Text(
5556
text,
57+
softWrap: !noWrap,
5658
style: style,
5759
textAlign: textAlign,
5860
overflow: overflow,

client/lib/controls/textfield.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class _TextFieldControlState extends State<TextFieldControl> {
3232
String _value = "";
3333
bool _revealPassword = false;
3434
late TextEditingController _controller;
35-
final FocusNode _focusNode = FocusNode();
35+
late final FocusNode _focusNode = FocusNode();
3636

3737
late final _shiftEnterfocusNode = FocusNode(
3838
onKey: (FocusNode node, RawKeyEvent evt) {
@@ -138,6 +138,12 @@ class _TextFieldControlState extends State<TextFieldControl> {
138138
var textField = TextFormField(
139139
autofocus: autofocus,
140140
enabled: !disabled,
141+
onFieldSubmitted: (_) {
142+
ws.pageEventFromWeb(
143+
eventTarget: widget.control.id,
144+
eventName: "submit",
145+
eventData: "");
146+
},
141147
decoration: buildInputDecoration(
142148
widget.control,
143149
prefixControls.isNotEmpty ? prefixControls.first : null,
@@ -154,7 +160,7 @@ class _TextFieldControlState extends State<TextFieldControl> {
154160
? _shiftEnterfocusNode
155161
: _focusNode,
156162
onChanged: (String value) {
157-
debugPrint(value);
163+
//debugPrint(value);
158164
setState(() {
159165
_value = value;
160166
});

docs/roadmap.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ TextTheme: https://api.flutter.dev/flutter/material/TextTheme-class.html
599599
- overflow - (TextOverflow) `clip`, `ellipsis`, `fade`, `visible`
600600
- selectable
601601
- tooltip
602+
- noWrap
602603

603604
## Icon
604605

sdk/python/flet/tabs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from typing import List, Optional
1+
from typing import Optional
22

33
from beartype import beartype
4+
from beartype.typing import List
45

56
from flet.constrained_control import ConstrainedControl
67
from flet.control import Control, OptionalNumber

sdk/python/flet/text.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __init__(
5454
style: str = None,
5555
overflow: TextOverflow = None,
5656
selectable: bool = None,
57+
no_wrap: bool = None,
5758
color: str = None,
5859
bgcolor: str = None,
5960
):
@@ -76,6 +77,7 @@ def __init__(
7677
self.size = size
7778
self.weight = weight
7879
self.italic = italic
80+
self.no_wrap = no_wrap
7981
self.style = style
8082
self.overflow = overflow
8183
self.selectable = selectable
@@ -144,6 +146,16 @@ def italic(self):
144146
def italic(self, value: Optional[bool]):
145147
self._set_attr("italic", value)
146148

149+
# no_wrap
150+
@property
151+
def no_wrap(self):
152+
return self._get_attr("italic", data_type="noWrap", def_value=False)
153+
154+
@no_wrap.setter
155+
@beartype
156+
def no_wrap(self, value: Optional[bool]):
157+
self._set_attr("noWrap", value)
158+
147159
# selectable
148160
@property
149161
def selectable(self):

sdk/python/playground/icons-browser.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
Row,
1717
SnackBar,
1818
Text,
19+
TextButton,
1920
TextField,
2021
alignment,
2122
border_radius,
@@ -43,15 +44,18 @@ def main(page: Page):
4344
page.theme_mode = "light"
4445

4546
search_txt = TextField(
46-
expand=1, hint_text="Enter keyword and press search button", autofocus=True
47+
expand=1,
48+
hint_text="Enter keyword and press search button",
49+
autofocus=True,
50+
on_submit=lambda e: display_icons(e.control.value),
4751
)
4852
search_results = GridView(
4953
expand=1,
5054
runs_count=10,
5155
max_extent=150,
5256
spacing=5,
5357
run_spacing=5,
54-
child_aspect_ratio=2,
58+
child_aspect_ratio=1,
5559
)
5660
status_bar = Text()
5761

@@ -73,20 +77,17 @@ def display_icons(search_term: str):
7377
icon_name = icons_list[i]
7478
icon_key = f"icons.{icon_name.upper()}"
7579
search_results.controls.append(
76-
OutlinedButton(
80+
TextButton(
7781
content=Container(
7882
content=Column(
7983
[
80-
Icon(
81-
name=icon_name,
82-
),
84+
Icon(name=icon_name, size=30),
8385
Text(
8486
value=icon_name,
85-
size=10,
87+
size=12,
8688
width=100,
87-
# selectable=True,
89+
no_wrap=True,
8890
text_align="center",
89-
overflow="fade",
9091
color=colors.ON_SURFACE_VARIANT,
9192
),
9293
],
@@ -95,10 +96,6 @@ def display_icons(search_term: str):
9596
horizontal_alignment="center",
9697
),
9798
alignment=alignment.center,
98-
padding=padding.only(left=5, right=5),
99-
# border=border.all(1, colors.BLACK26),
100-
# bgcolor="#f0f0f0",
101-
border_radius=border_radius.all(3),
10299
),
103100
tooltip=f"{icon_key}\nClick to copy to a clipboard",
104101
on_click=copy_to_clipboard,

0 commit comments

Comments
 (0)