Skip to content

Commit

Permalink
Page.design replaced with Page.adaptive
Browse files Browse the repository at this point in the history
Close #2650
  • Loading branch information
FeodorFitsner committed Feb 16, 2024
1 parent 840ef3f commit 7bfd86f
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 83 deletions.
2 changes: 1 addition & 1 deletion client/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion client/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
6 changes: 3 additions & 3 deletions client/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ SPEC CHECKSUMS:
DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac
DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
file_picker: 15fd9539e4eb735dc54bae8c0534a7a9511a03de
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
integration_test: 13825b8a9334a850581300559b8839134b124670
media_kit_libs_ios_video: a5fe24bc7875ccd6378a0978c13185e1344651c1
media_kit_native_event_loop: e6b2ab20cf0746eb1c33be961fcf79667304fa2a
Expand All @@ -155,8 +155,8 @@ SPEC CHECKSUMS:
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812
volume_controller: 531ddf792994285c9b17f9d8a7e4dcdd29b3eae9
wakelock_plus: 8b09852c8876491e4b6d179e17dfe2a0b5f60d47
webview_flutter_wkwebview: 4f3e50f7273d31e5500066ed267e3ae4309c5ae4
webview_flutter_wkwebview: be0f0d33777f1bfd0c9fdcb594786704dbf65f36

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011

COCOAPODS: 1.14.3
8 changes: 4 additions & 4 deletions client/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -342,7 +342,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -423,7 +423,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -472,7 +472,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
25 changes: 9 additions & 16 deletions packages/flet/lib/src/controls/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import 'navigation_drawer.dart';
import 'scroll_notification_control.dart';
import 'scrollable_control.dart';

enum PageDesign { adaptive, material, cupertino }
enum PageDesign { material, cupertino }

class RoutesViewModel extends Equatable {
final Control page;
Expand Down Expand Up @@ -124,7 +124,7 @@ class PageControl extends StatefulWidget {
}

class _PageControlState extends State<PageControl> with FletStoreMixin {
PageDesign _pageDesign = PageDesign.material;
bool? _adaptive;
PageDesign _widgetsDesign = PageDesign.material;
TargetPlatform _platform = defaultTargetPlatform;
Brightness? _brightness;
Expand Down Expand Up @@ -247,20 +247,13 @@ class _PageControlState extends State<PageControl> with FletStoreMixin {
widget.control.attrString("platform", "")!.toLowerCase(),
orElse: () => defaultTargetPlatform);

_pageDesign = PageDesign.values.firstWhere(
(a) =>
a.name.toLowerCase() ==
widget.control.attrString("design", "")!.toLowerCase(),
orElse: () => PageDesign.material);
_adaptive = widget.control.attrBool("adaptive");

if ((_pageDesign == PageDesign.adaptive &&
_widgetsDesign = _adaptive == true &&
(_platform == TargetPlatform.iOS ||
_platform == TargetPlatform.macOS)) ||
_pageDesign == PageDesign.cupertino) {
_widgetsDesign = PageDesign.cupertino;
} else {
_widgetsDesign = PageDesign.material;
}
_platform == TargetPlatform.macOS)
? PageDesign.cupertino
: PageDesign.material;

// theme
_themeMode = ThemeMode.values.firstWhereOrNull((t) =>
Expand Down Expand Up @@ -648,7 +641,7 @@ class _PageControlState extends State<PageControl> with FletStoreMixin {
overlayWidgets: overlayWidgets(view.id),
loadingPage: loadingPage,
backend: widget.backend,
parentAdaptive: _pageDesign == PageDesign.adaptive,
parentAdaptive: _adaptive,
widgetsDesign: _widgetsDesign,
brightness: _brightness,
themeMode: _themeMode,
Expand Down Expand Up @@ -701,7 +694,7 @@ class ViewControl extends StatefulWidget {
final List<Widget> overlayWidgets;
final Widget? loadingPage;
final FletControlBackend backend;
final bool parentAdaptive;
final bool? parentAdaptive;
final PageDesign widgetsDesign;
final Brightness? brightness;
final ThemeMode? themeMode;
Expand Down
27 changes: 7 additions & 20 deletions packages/flet/lib/src/controls/pagelet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,28 +67,15 @@ class _PageletControlState extends State<PageletControl> with FletStoreMixin {
}

return withPagePlatform((context, platform) {
PageDesign widgetsDesign = PageDesign.material;

var pageDesign = PageDesign.values.firstWhereOrNull((a) =>
a.name.toLowerCase() ==
widget.control.attrString("design", "")!.toLowerCase());

if ((pageDesign == PageDesign.adaptive &&
(platform == TargetPlatform.iOS ||
platform == TargetPlatform.macOS)) ||
pageDesign == PageDesign.cupertino) {
widgetsDesign = PageDesign.cupertino;
} else {
widgetsDesign = PageDesign.material;
}

bool disabled = widget.control.isDisabled || widget.parentDisabled;
bool? adaptive = pageDesign != null
? pageDesign == PageDesign.adaptive
: widget.parentAdaptive;
bool? adaptive =
widget.control.attrBool("adaptive") ?? widget.parentAdaptive;

var bgcolor = HexColor.fromString(
Theme.of(context), widget.control.attrString("bgcolor", "")!);
var widgetsDesign = adaptive == true &&
(platform == TargetPlatform.iOS ||
platform == TargetPlatform.macOS)
? PageDesign.cupertino
: PageDesign.material;

List<String> childIds = [
appBarCtrls.firstOrNull?.id,
Expand Down
1 change: 0 additions & 1 deletion sdk/python/packages/flet-core/src/flet_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@
MaterialState,
NotchShape,
PaddingValue,
PageDesign,
PagePlatform,
ScrollMode,
TabAlignment,
Expand Down
16 changes: 2 additions & 14 deletions sdk/python/packages/flet-core/src/flet_core/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from urllib.parse import urlparse

import flet_core
from flet_core.adaptive_control import AdaptiveControl
from flet_core.alert_dialog import AlertDialog
from flet_core.animation import AnimationCurve
from flet_core.app_bar import AppBar
Expand Down Expand Up @@ -42,7 +43,6 @@
MainAxisAlignment,
OffsetValue,
PaddingValue,
PageDesign,
PagePlatform,
ScrollMode,
ThemeMode,
Expand Down Expand Up @@ -72,7 +72,7 @@ def __init__(self, pubsubhub, session_id) -> None:
pass


class Page(Control):
class Page(AdaptiveControl):
"""
Page is a container for `View` (https://flet.dev/docs/controls/view) controls.
Expand Down Expand Up @@ -1242,18 +1242,6 @@ def platform(self, value: PagePlatform):
"platform", value.value if isinstance(value, PagePlatform) else value
)

# design
@property
def design(self):
av = self._get_attr("design")
return PageDesign(av) if av else PageDesign.MATERIAL

@design.setter
def design(self, value: PageDesign):
self._set_attr(
"design", value.value if isinstance(value, PageDesign) else value
)

# platform_brightness
@property
def platform_brightness(self) -> ThemeMode:
Expand Down
23 changes: 7 additions & 16 deletions sdk/python/packages/flet-core/src/flet_core/pagelet.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
AnimationValue,
FloatingActionButtonLocation,
OffsetValue,
PageDesign,
ResponsiveNumber,
RotateValue,
ScaleValue,
)


class Pagelet(ConstrainedControl):
class Pagelet(ConstrainedControl, AdaptiveControl):
"""
Pagelet implements the basic Material Design visual layout structure.
Expand Down Expand Up @@ -94,7 +93,10 @@ def __init__(
FloatingActionButtonLocation, OffsetValue
] = None,
bgcolor: Optional[str] = None,
design: Optional[PageDesign] = None,
#
# Adaptive
#
adaptive: Optional[bool] = None,
):
ConstrainedControl.__init__(
self,
Expand Down Expand Up @@ -127,6 +129,8 @@ def __init__(
data=data,
)

AdaptiveControl.__init__(self, adaptive=adaptive)

self.content = content
self.appbar = appbar
self.bgcolor = bgcolor
Expand All @@ -137,7 +141,6 @@ def __init__(
self.end_drawer = end_drawer
self.floating_action_button = floating_action_button
self.floating_action_button_location = floating_action_button_location
self.design = design

def _get_control_name(self):
return "pagelet"
Expand Down Expand Up @@ -319,15 +322,3 @@ def floating_action_button_location(
"floatingActionButtonLocation",
value.value if isinstance(value, FloatingActionButtonLocation) else value,
)

# design
@property
def design(self):
av = self._get_attr("design")
return PageDesign(av) if av else PageDesign.MATERIAL

@design.setter
def design(self, value: Optional[PageDesign]):
self._set_attr(
"design", value.value if isinstance(value, PageDesign) else value
)
6 changes: 0 additions & 6 deletions sdk/python/packages/flet-core/src/flet_core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,6 @@ class PagePlatform(Enum):
LINUX = "linux"


class PageDesign(Enum):
MATERIAL = "material"
CUPERTINO = "cupertino"
ADAPTIVE = "adaptive"


ThemeModeString = Literal[None, "system", "light", "dark"]


Expand Down

0 comments on commit 7bfd86f

Please sign in to comment.