Skip to content

Flyout rework#690

Merged
bdlukaa merged 24 commits into
masterfrom
flyout-rework
Jan 26, 2023
Merged

Flyout rework#690
bdlukaa merged 24 commits into
masterfrom
flyout-rework

Conversation

@bdlukaa
Copy link
Copy Markdown
Owner

@bdlukaa bdlukaa commented Jan 21, 2023

Fixes #27


Flyouts were reworked to match the design and behavior of native WinUI 3

BREAKING Removed Flyout widget.
To replace it, FlyoutTarget and FlyoutController were created. FlyoutTarget works like a target, which the given controller will use to display the flyout


Migration guide:

Before:

final controller = FlyoutController();

Flyout(
  controller: controller,
  placement: ...,
  position: ...,
  verticalOffset: ...,
  onOpen: ...,
  onClose: ...,
  child: Button(
    onPressed: controller,
    child: Text('Tap me'),
  ),
),

Now:

final controller = FlyoutController();

FlyoutTarget(
  controller: controller,
  child: Button(
    onPressed: _showFlyout,
    child: Text('Tap me'),
  ),
),

void _showFlyout() async {
  await controller.showFlyout(
    barrierDismissible: ...,
    dismissWithEsc: ..., // NEW
    dismissOnPointerMoveAway: ..., // NEW
    placementMode: ...,
    autoModeConfiguration: ..., // NEW
    forceAvailableSpace: ..., // NEW
    shouldConstrainToRootBounds: ..., // NEW
    additionalOffset: ...,
    margin: ..., // NEW
    barrierColor: ...,
    navigatorKey: ..., // NEW
    transitionBuilder: ..., // NEW
    transitionDuration: ..., // NEW
    builder: (context) => FlyoutContent(...),
  ); 
}

Now, it's possible to dismiss the flyout by tapping the barrier (barrierDismissible), pressing the ESC keyboard key (dismissWithEsc) and by moving the cursor (pointer) away from the flyout (dismissOnPointerMoveAway - defaults to false);

Automatic mode is finally implemented, and it's the default mode. By setting autoModeConfiguration, it's possible to customize the preferred flyout placement. If flyout doesn't meet the placement conditions, it decides where it fits the best.

forceAvailableSpace determines whether the flyout size should be forced the available space according to the attached target. It's useful when the flyout is large but can not be on top of the target. NavigationView's top navigation mode now uses it by default on pane items overflow.

shouldConstrainToRootBounds determines whether the flyout should fit the root bounds - usually the window bounds. If false, the flyout will be able to overflow the screen on all sides. Defaults to true

margin determines the margin of the flyout to the root. additionalOffset determines the margin of the flyout to the target.

It's now possible to assign a custom transition to the flyout by providing transitionBuilder and transitionDuration. By default, a light slide-fade transition is used, but it can be highly customizable to fit your needs. It provides the current placement mode - since automatic mode may change it at layout time. DropdownButton uses it to create its slidethrough transition.

position and placement were replaced by placementMode, which gives horizontal and vertical options of placement, at all screen alignments. It's also possible to use it in a right-to-left context by using placementMode.resolve(Directionality.of(context))

Pre-launch Checklist

  • I have updated CHANGELOG.md with my changes
  • I have run "dart format ." on the project
  • I have added/updated relevant documentation

@bdlukaa
Copy link
Copy Markdown
Owner Author

bdlukaa commented Jan 24, 2023

Some updates to FlyoutContent and FlyoutListTile are still necessary until this becomes ready. Some tests would be nice as well

@bdlukaa bdlukaa linked an issue Jan 24, 2023 that may be closed by this pull request
@bdlukaa
Copy link
Copy Markdown
Owner Author

bdlukaa commented Jan 24, 2023

There should be an option to position the flyout anywhere in the screen (#622)

@bdlukaa bdlukaa marked this pull request as ready for review January 25, 2023 15:34
Copy link
Copy Markdown
Contributor

@dvd-bnc dvd-bnc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's most of the stuff i found, some things could be expanded and explained better if needed, you know where to find me in case :)

Comment thread lib/src/controls/flyouts/flyout.dart Outdated
Comment thread lib/src/controls/flyouts/flyout.dart Outdated
Comment thread lib/src/controls/flyouts/content.dart Outdated
@@ -0,0 +1,124 @@
import 'package:fluent_ui/fluent_ui.dart';

class ContentManager extends StatefulWidget {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this documented anywhere?

Comment thread lib/src/controls/flyouts/content_manager.dart
Comment thread lib/src/controls/navigation/navigation_view/pane_items.dart Outdated
Comment thread lib/src/controls/navigation/navigation_view/pane_items.dart
return MenuFlyout(
items: widget.items.map<MenuFlyoutItemBase>((item) {
if (item is PaneItem) {
return _PaneItemExpanderMenuItem(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a method like getMenuItem to PaneItem so you can remove this whole switch/case statement

Comment thread example/lib/screens/popups/flyout.dart
Comment thread example/lib/screens/popups/flyout.dart Outdated
@bdlukaa bdlukaa merged commit ad4a054 into master Jan 26, 2023
@bdlukaa bdlukaa deleted the flyout-rework branch January 26, 2023 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants