From c3273c11feceac57427b4030cab529ba1d641d07 Mon Sep 17 00:00:00 2001 From: Feodor Fitsner Date: Tue, 2 Aug 2022 12:35:27 -0700 Subject: [PATCH] Switch Flutter to dev channel --- .appveyor.yml | 10 +++++----- client/lib/controls/alert_dialog.dart | 3 +-- client/lib/controls/page.dart | 4 ++-- client/lib/utils/theme.dart | 22 +++++++++++++++++++++- client/pubspec.lock | 2 +- sdk/python/flet/control.py | 14 +++++++------- sdk/python/flet/theme.py | 7 ++++++- sdk/python/tests/test_image.py | 2 +- 8 files changed, 44 insertions(+), 20 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 26c735198..345e10e14 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -95,7 +95,7 @@ for: install: - ps: .\ci\install_flutter.ps1 - set PATH=C:\flutter\bin;%PATH% - - flutter channel master + - flutter channel dev - flutter upgrade build_script: @@ -139,7 +139,7 @@ for: - curl https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_3.0.3-stable.zip -o flutter_macos_stable.zip - unzip -qq flutter_macos_stable.zip - export PATH="$PATH:`pwd`/flutter/bin" - - flutter channel master + - flutter channel dev - flutter upgrade - flutter config --enable-macos-desktop - flutter doctor @@ -174,7 +174,7 @@ for: install: # Flutter SDK - sudo snap install flutter --classic - - flutter channel master + - flutter channel dev - flutter upgrade - flutter sdk-path @@ -210,7 +210,7 @@ for: - curl https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_3.0.3-stable.zip -o flutter_macos_stable.zip - unzip -qq flutter_macos_stable.zip - export PATH="$PATH:`pwd`/flutter/bin" - - flutter channel master + - flutter channel dev - flutter upgrade - flutter doctor @@ -253,7 +253,7 @@ for: install: # Flutter SDK - sudo snap install flutter --classic - - flutter channel master + - flutter channel dev - flutter upgrade - flutter sdk-path diff --git a/client/lib/controls/alert_dialog.dart b/client/lib/controls/alert_dialog.dart index 53a7b1134..ec2a5cf99 100644 --- a/client/lib/controls/alert_dialog.dart +++ b/client/lib/controls/alert_dialog.dart @@ -69,8 +69,7 @@ class _AlertDialogControlState extends State { actions: actionCtrls .map((c) => createControl(widget.control, c.id, disabled)) .toList(), - actionsPadding: - parseEdgeInsets(widget.control, "actionsPadding") ?? EdgeInsets.zero, + actionsPadding: parseEdgeInsets(widget.control, "actionsPadding"), actionsAlignment: actionsAlignment, ); } diff --git a/client/lib/controls/page.dart b/client/lib/controls/page.dart index aee25c268..ac5affaf9 100644 --- a/client/lib/controls/page.dart +++ b/client/lib/controls/page.dart @@ -97,14 +97,14 @@ class _PageControlState extends State { // fontFamily: kIsWeb && window.navigator.userAgent.contains('OS 15_') // ? '-apple-system' // : null, - visualDensity: VisualDensity.adaptivePlatformDensity); + visualDensity: VisualDensity.standard); var darkTheme = parseTheme(widget.control, "darkTheme") ?? ThemeData( colorSchemeSeed: Colors.blue, brightness: Brightness.dark, useMaterial3: true, - visualDensity: VisualDensity.adaptivePlatformDensity); + visualDensity: VisualDensity.standard); var themeMode = ThemeMode.values.firstWhere( (t) => diff --git a/client/lib/utils/theme.dart b/client/lib/utils/theme.dart index bfefa0735..100c0af18 100644 --- a/client/lib/utils/theme.dart +++ b/client/lib/utils/theme.dart @@ -23,5 +23,25 @@ ThemeData themeFromJson(Map json) { colorSchemeSeed: HexColor.fromString(null, json["color_scheme_seed"] ?? ""), fontFamily: json["font_family"], - useMaterial3: json["use_material3"]); + useMaterial3: json["use_material3"], + visualDensity: parseVisualDensity(json["visual_density"])); +} + +VisualDensity? parseVisualDensity(String? vd) { + if (vd == null) { + return null; + } + + switch (vd.toLowerCase()) { + case "adaptiveplatformdensity": + return VisualDensity.adaptivePlatformDensity; + case "comfortable": + return VisualDensity.comfortable; + case "compact": + return VisualDensity.compact; + case "standard": + return VisualDensity.standard; + default: + return null; + } } diff --git a/client/pubspec.lock b/client/pubspec.lock index 941063225..74c073155 100644 --- a/client/pubspec.lock +++ b/client/pubspec.lock @@ -209,7 +209,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.9.1" + version: "1.9.0" stack_trace: dependency: transitive description: diff --git a/sdk/python/flet/control.py b/sdk/python/flet/control.py index 5111b6a92..9532e6374 100644 --- a/sdk/python/flet/control.py +++ b/sdk/python/flet/control.py @@ -274,7 +274,7 @@ def clean(self): return self.__page._send_command("clean", [self.uid]) def build_update_commands(self, index, added_controls, commands, isolated=False): - update_cmd = self._get_cmd_attrs(update=True) + update_cmd = self._build_command(update=True) if len(update_cmd.attrs) > 0: update_cmd.name = "set" @@ -333,7 +333,7 @@ def build_update_commands(self, index, added_controls, commands, isolated=False) for h in current_ints[b1:b2]: # add ctrl = hashes[h] - innerCmds = ctrl.get_cmd_str( + innerCmds = ctrl._build_add_commands( index=index, added_controls=added_controls ) commands.append( @@ -350,7 +350,7 @@ def build_update_commands(self, index, added_controls, commands, isolated=False) # add for h in current_ints[b1:b2]: ctrl = hashes[h] - innerCmds = ctrl.get_cmd_str( + innerCmds = ctrl._build_add_commands( index=index, added_controls=added_controls ) commands.append( @@ -376,7 +376,7 @@ def _remove_control_recursively(self, index, control): del index[control.__uid] # private methods - def get_cmd_str(self, indent=0, index=None, added_controls=None): + def _build_add_commands(self, indent=0, index=None, added_controls=None): self._build() @@ -387,7 +387,7 @@ def get_cmd_str(self, indent=0, index=None, added_controls=None): commands = [] # main command - command = self._get_cmd_attrs(False) + command = self._build_command(False) command.indent = indent command.values.append(self._get_control_name()) commands.append(command) @@ -398,7 +398,7 @@ def get_cmd_str(self, indent=0, index=None, added_controls=None): # controls children = self._get_children() for control in children: - childCmd = control.get_cmd_str( + childCmd = control._build_add_commands( indent=indent + 2, index=index, added_controls=added_controls ) commands.extend(childCmd) @@ -408,7 +408,7 @@ def get_cmd_str(self, indent=0, index=None, added_controls=None): return commands - def _get_cmd_attrs(self, update=False): + def _build_command(self, update=False): command = Command(0, None, [], {}, []) if update and not self.__uid: diff --git a/sdk/python/flet/theme.py b/sdk/python/flet/theme.py index f90605844..1f6b0d83e 100644 --- a/sdk/python/flet/theme.py +++ b/sdk/python/flet/theme.py @@ -6,10 +6,15 @@ except: from typing_extensions import Literal +VisualDensity = Literal[ + None, "standard", "compact", "comfortable", "adaptivePlatformDensity" +] + @dataclasses.dataclass class Theme: color_scheme_seed: str = field(default=None) brightness: Literal[None, "dark", "light"] = field(default="light") font_family: str = field(default=None) - use_material3: bool = field(default=False) + use_material3: bool = field(default=True) + visual_density: VisualDensity = field(default="standard") diff --git a/sdk/python/tests/test_image.py b/sdk/python/tests/test_image.py index 4f023abac..4bead3f15 100644 --- a/sdk/python/tests/test_image.py +++ b/sdk/python/tests/test_image.py @@ -9,7 +9,7 @@ def test_image_add(): ) assert isinstance(i, flet.Control) assert isinstance(i, flet.Image) - assert i.get_cmd_str() == [ + assert i._build_add_command() == [ Command( indent=0, name=None,