Skip to content

Commit

Permalink
Icon browser done
Browse files Browse the repository at this point in the history
  • Loading branch information
FeodorFitsner committed Apr 30, 2022
1 parent 9827890 commit 4de9377
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 16 deletions.
2 changes: 2 additions & 0 deletions client/lib/controls/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class TextControl extends StatelessWidget {
debugPrint("Text build: ${control.id}");

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

TextStyle? style;
var styleName = control.attrString("style", null);
Expand Down Expand Up @@ -53,6 +54,7 @@ class TextControl extends StatelessWidget {
)
: Text(
text,
softWrap: !noWrap,
style: style,
textAlign: textAlign,
overflow: overflow,
Expand Down
10 changes: 8 additions & 2 deletions client/lib/controls/textfield.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class _TextFieldControlState extends State<TextFieldControl> {
String _value = "";
bool _revealPassword = false;
late TextEditingController _controller;
final FocusNode _focusNode = FocusNode();
late final FocusNode _focusNode = FocusNode();

late final _shiftEnterfocusNode = FocusNode(
onKey: (FocusNode node, RawKeyEvent evt) {
Expand Down Expand Up @@ -138,6 +138,12 @@ class _TextFieldControlState extends State<TextFieldControl> {
var textField = TextFormField(
autofocus: autofocus,
enabled: !disabled,
onFieldSubmitted: (_) {
ws.pageEventFromWeb(
eventTarget: widget.control.id,
eventName: "submit",
eventData: "");
},
decoration: buildInputDecoration(
widget.control,
prefixControls.isNotEmpty ? prefixControls.first : null,
Expand All @@ -154,7 +160,7 @@ class _TextFieldControlState extends State<TextFieldControl> {
? _shiftEnterfocusNode
: _focusNode,
onChanged: (String value) {
debugPrint(value);
//debugPrint(value);
setState(() {
_value = value;
});
Expand Down
1 change: 1 addition & 0 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ TextTheme: https://api.flutter.dev/flutter/material/TextTheme-class.html
- overflow - (TextOverflow) `clip`, `ellipsis`, `fade`, `visible`
- selectable
- tooltip
- noWrap

## Icon

Expand Down
3 changes: 2 additions & 1 deletion sdk/python/flet/tabs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import List, Optional
from typing import Optional

from beartype import beartype
from beartype.typing import List

from flet.constrained_control import ConstrainedControl
from flet.control import Control, OptionalNumber
Expand Down
12 changes: 12 additions & 0 deletions sdk/python/flet/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(
style: str = None,
overflow: TextOverflow = None,
selectable: bool = None,
no_wrap: bool = None,
color: str = None,
bgcolor: str = None,
):
Expand All @@ -76,6 +77,7 @@ def __init__(
self.size = size
self.weight = weight
self.italic = italic
self.no_wrap = no_wrap
self.style = style
self.overflow = overflow
self.selectable = selectable
Expand Down Expand Up @@ -144,6 +146,16 @@ def italic(self):
def italic(self, value: Optional[bool]):
self._set_attr("italic", value)

# no_wrap
@property
def no_wrap(self):
return self._get_attr("italic", data_type="noWrap", def_value=False)

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

# selectable
@property
def selectable(self):
Expand Down
23 changes: 10 additions & 13 deletions sdk/python/playground/icons-browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
Row,
SnackBar,
Text,
TextButton,
TextField,
alignment,
border_radius,
Expand Down Expand Up @@ -43,15 +44,18 @@ def main(page: Page):
page.theme_mode = "light"

search_txt = TextField(
expand=1, hint_text="Enter keyword and press search button", autofocus=True
expand=1,
hint_text="Enter keyword and press search button",
autofocus=True,
on_submit=lambda e: display_icons(e.control.value),
)
search_results = GridView(
expand=1,
runs_count=10,
max_extent=150,
spacing=5,
run_spacing=5,
child_aspect_ratio=2,
child_aspect_ratio=1,
)
status_bar = Text()

Expand All @@ -73,20 +77,17 @@ def display_icons(search_term: str):
icon_name = icons_list[i]
icon_key = f"icons.{icon_name.upper()}"
search_results.controls.append(
OutlinedButton(
TextButton(
content=Container(
content=Column(
[
Icon(
name=icon_name,
),
Icon(name=icon_name, size=30),
Text(
value=icon_name,
size=10,
size=12,
width=100,
# selectable=True,
no_wrap=True,
text_align="center",
overflow="fade",
color=colors.ON_SURFACE_VARIANT,
),
],
Expand All @@ -95,10 +96,6 @@ def display_icons(search_term: str):
horizontal_alignment="center",
),
alignment=alignment.center,
padding=padding.only(left=5, right=5),
# border=border.all(1, colors.BLACK26),
# bgcolor="#f0f0f0",
border_radius=border_radius.all(3),
),
tooltip=f"{icon_key}\nClick to copy to a clipboard",
on_click=copy_to_clipboard,
Expand Down

0 comments on commit 4de9377

Please sign in to comment.