Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix popover parameter name #275

Merged
merged 4 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/pages/docs/overlay/popover-menu.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const FPopoverMenu(
controller: FPopoverController(),
menuAnchor: Alignment.topCenter,
childAnchor: Alignment.bottomCenter,
ignoreDirectionalPadding: true,
directionPadding: false,
hideOnTapOutside: true,
shift: FPortalFollowerShift.flip,
menu: [
Expand All @@ -111,7 +111,7 @@ const FPopoverMenu.tappable(
controller: FPopoverController(),
menuAnchor: Alignment.topCenter,
childAnchor: Alignment.bottomCenter,
ignoreDirectionalPadding: true,
directionPadding: false,
hideOnTapOutside: true,
shift: FPortalFollowerShift.flip,
menu: [
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/docs/overlay/popover.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const FPopover(
controller: FPopoverController(),
followerAnchor: Alignment.topCenter,
targetAnchor: Alignment.bottomCenter,
ignoreDirectionalPadding: true,
directionPadding: false,
hideOnTapOutside: true,
shift: FPortalFollowerShift.flip,
follower: (context) => const Placeholder(),
Expand All @@ -112,7 +112,7 @@ const FPopover.tappable(
controller: FPopoverController(),
followerAnchor: Alignment.topCenter,
targetAnchor: Alignment.bottomCenter,
ignoreDirectionalPadding: true,
directionPadding: false,
hideOnTapOutside: true,
shift: FPortalFollowerShift.flip,
follower: (context) => const Placeholder(),
Expand Down
13 changes: 12 additions & 1 deletion forui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
## 0.7.0 (Next)
## 0.8.0 (Next)

### Changes

* **Breaking** Change `Popover.ignoreDirectionalPadding` to `Popover.directionPadding` - the value should be inverted.

* **Breaking** Change `PopoverMenu.ignoreDirectionalPadding` to `PopoverMenu.directionPadding` - the value should be inverted.

* **Breaking** Change `SelectMenuTile.ignoreDirectionalPadding` to `SelectMenuTile.directionPadding` - the value should be inverted.


## 0.7.0

This update adds responsive breakpoints, focused outlines & localization! It also introduces several new tile widgets.

Expand Down
2 changes: 1 addition & 1 deletion forui/lib/src/foundation/rendering.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extension RenderBoxes on RenderBox {

@internal
extension Alignments on Alignment {
static Offset ignoreDirectionalPadding(EdgeInsets padding, Alignment follower, Alignment target) {
static Offset removeDirectionalPadding(EdgeInsets padding, Alignment follower, Alignment target) {
final Alignment(:x, :y) = follower;
// ignore corners that are diagonal.
if (x != 0 && y != 0 && x == -target.x && y == -target.y) {
Expand Down
21 changes: 7 additions & 14 deletions forui/lib/src/widgets/popover.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ class FPopover extends StatefulWidget {
/// True if the popover is hidden when tapped outside of it. Defaults to true.
final bool hideOnTapOutside;

/// True if the follower should ignore the cross-axis padding of the anchor when aligning to it. Defaults to true.
/// True if the follower should include the cross-axis padding of the anchor when aligning to it. Defaults to false.
///
/// Diagonal corners are ignored.
final bool ignoreDirectionalPadding;
final bool directionPadding;

/// The follower's semantic label used by accessibility frameworks.
final String? semanticLabel;
Expand Down Expand Up @@ -148,7 +148,7 @@ class FPopover extends StatefulWidget {
this.style,
this.shift = FPortalFollowerShift.flip,
this.hideOnTapOutside = true,
this.ignoreDirectionalPadding = true,
this.directionPadding = false,
this.semanticLabel,
this.autofocus = false,
this.focusNode,
Expand All @@ -171,7 +171,7 @@ class FPopover extends StatefulWidget {
this.style,
this.shift = FPortalFollowerShift.flip,
this.hideOnTapOutside = true,
this.ignoreDirectionalPadding = true,
this.directionPadding = false,
this.semanticLabel,
this.autofocus = false,
this.focusNode,
Expand All @@ -196,13 +196,7 @@ class FPopover extends StatefulWidget {
..add(DiagnosticsProperty('targetAnchor', targetAnchor))
..add(DiagnosticsProperty('shift', shift))
..add(FlagProperty('hideOnTapOutside', value: hideOnTapOutside, ifTrue: 'hideOnTapOutside'))
..add(
FlagProperty(
'ignoreDirectionalPadding',
value: ignoreDirectionalPadding,
ifTrue: 'ignoreDirectionalPadding',
),
)
..add(FlagProperty('directionPadding', value: directionPadding, ifTrue: 'directionPadding'))
..add(StringProperty('semanticLabel', semanticLabel))
..add(FlagProperty('autofocus', value: autofocus, ifTrue: 'autofocus'))
..add(DiagnosticsProperty('focusNode', focusNode))
Expand Down Expand Up @@ -245,9 +239,8 @@ class _State extends State<FPopover> with SingleTickerProviderStateMixin {
followerAnchor: widget.followerAnchor,
targetAnchor: widget.targetAnchor,
shift: widget.shift,
offset: widget.ignoreDirectionalPadding
? Alignments.ignoreDirectionalPadding(style.padding, follower, target)
: Offset.zero,
offset:
widget.directionPadding ? Offset.zero : Alignments.removeDirectionalPadding(style.padding, follower, target),
followerBuilder: (context) => CallbackShortcuts(
bindings: {
const SingleActivator(LogicalKeyboardKey.escape): _controller.hide,
Expand Down
18 changes: 6 additions & 12 deletions forui/lib/src/widgets/popover_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class FPopoverMenu extends StatefulWidget {
/// True if the popover is hidden when tapped outside of it. Defaults to true.
final bool hideOnTapOutside;

/// True if the menu should ignore the cross-axis padding of the anchor when aligning to it. Defaults to true.
/// True if the follower should include the cross-axis padding of the anchor when aligning to it. Defaults to false.
///
/// Diagonal corners are ignored.
final bool ignoreDirectionalPadding;
final bool directionPadding;

/// The menu's semantic label used by accessibility frameworks.
final String? semanticLabel;
Expand Down Expand Up @@ -90,7 +90,7 @@ class FPopoverMenu extends StatefulWidget {
this.childAnchor = Alignment.bottomCenter,
this.shift = FPortalFollowerShift.flip,
this.hideOnTapOutside = true,
this.ignoreDirectionalPadding = true,
this.directionPadding = false,
this.semanticLabel,
this.autofocus = false,
this.focusNode,
Expand All @@ -112,7 +112,7 @@ class FPopoverMenu extends StatefulWidget {
this.childAnchor = Alignment.bottomCenter,
this.shift = FPortalFollowerShift.flip,
this.hideOnTapOutside = true,
this.ignoreDirectionalPadding = true,
this.directionPadding = false,
this.semanticLabel,
this.autofocus = false,
this.focusNode,
Expand All @@ -134,13 +134,7 @@ class FPopoverMenu extends StatefulWidget {
..add(DiagnosticsProperty('childAnchor', childAnchor))
..add(DiagnosticsProperty('shift', shift))
..add(FlagProperty('hideOnTapOutside', value: hideOnTapOutside, ifTrue: 'hideOnTapOutside'))
..add(
FlagProperty(
'ignoreDirectionalPadding',
value: ignoreDirectionalPadding,
ifTrue: 'ignoreDirectionalPadding',
),
)
..add(FlagProperty('directionPadding', value: directionPadding, ifTrue: 'directionPadding'))
..add(StringProperty('semanticLabel', semanticLabel))
..add(FlagProperty('autofocus', value: autofocus, ifTrue: 'autofocus'))
..add(DiagnosticsProperty('focusNode', focusNode))
Expand Down Expand Up @@ -180,7 +174,7 @@ class _FPopoverMenuState extends State<FPopoverMenu> with SingleTickerProviderSt
targetAnchor: widget.childAnchor,
shift: widget.shift,
hideOnTapOutside: widget.hideOnTapOutside,
ignoreDirectionalPadding: widget.ignoreDirectionalPadding,
directionPadding: widget.directionPadding,
autofocus: widget.autofocus,
focusNode: widget.focusNode,
onFocusChange: widget.onFocusChange,
Expand Down
16 changes: 5 additions & 11 deletions forui/lib/src/widgets/select_menu_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ class FSelectMenuTile<T> extends FormField<Set<T>> with FTileMixin {
/// True if the popover is hidden when tapped outside of it. Defaults to true.
final bool hideOnTapOutside;

/// True if the menu should ignore the cross-axis padding of the anchor when aligning to it. Defaults to true.
/// True if the follower should include the cross-axis padding of the anchor when aligning to it. Defaults to false.
///
/// Diagonal corners are ignored.
final bool ignoreDirectionalPadding;
final bool directionPadding;

/// True if the menu should be automatically hidden after a menu option is selected. Defaults to false.
final bool autoHide;
Expand Down Expand Up @@ -126,7 +126,7 @@ class FSelectMenuTile<T> extends FormField<Set<T>> with FTileMixin {
this.tileAnchor = Alignment.bottomRight,
this.shift = FPortalFollowerShift.flip,
this.hideOnTapOutside = true,
this.ignoreDirectionalPadding = true,
this.directionPadding = false,
this.autoHide = false,
this.label,
this.description,
Expand Down Expand Up @@ -180,7 +180,7 @@ class FSelectMenuTile<T> extends FormField<Set<T>> with FTileMixin {
targetAnchor: tileAnchor,
shift: shift,
hideOnTapOutside: hideOnTapOutside,
ignoreDirectionalPadding: ignoreDirectionalPadding,
directionPadding: directionPadding,
autofocus: autofocus,
focusNode: focusNode,
onFocusChange: onFocusChange,
Expand Down Expand Up @@ -237,13 +237,7 @@ class FSelectMenuTile<T> extends FormField<Set<T>> with FTileMixin {
..add(DiagnosticsProperty('tileAnchor', tileAnchor))
..add(DiagnosticsProperty('shift', shift))
..add(FlagProperty('hideOnTapOutside', value: hideOnTapOutside, ifTrue: 'hideOnTapOutside'))
..add(
FlagProperty(
'ignoreDirectionalPadding',
value: ignoreDirectionalPadding,
ifTrue: 'ignoreDirectionalPadding',
),
)
..add(FlagProperty('directionPadding', value: directionPadding, ifTrue: 'directionPadding'))
..add(FlagProperty('autoHide', value: autoHide, ifTrue: 'autoHide'))
..add(ObjectFlagProperty.has('errorBuilder', errorBuilder))
..add(StringProperty('semanticLabel', semanticLabel))
Expand Down
Binary file modified forui/test/golden/focused-outline/zinc-dark/focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified forui/test/golden/focused-outline/zinc-light/focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion forui/test/src/foundation/focused_outline_golden_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:forui/forui.dart';
import '../test_scaffold.dart';

void main() {
group('FAccordion', () {
group('FFocusedOutline', () {
testWidgets('blue screen', (tester) async {
await tester.pumpWidget(
TestScaffold.blue(
Expand Down
4 changes: 2 additions & 2 deletions forui/test/src/foundation/rendering_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ void main() {
(Alignment.bottomRight, Alignment.bottomRight, const Offset(3, 4)),
]) {
test(
'ignoreDirectionalPadding - $follower - $target',
() => expect(Alignments.ignoreDirectionalPadding(insets, follower, target), expected),
'removeDirectionalPadding - $follower - $target',
() => expect(Alignments.removeDirectionalPadding(insets, follower, target), expected),
);
}

Expand Down
6 changes: 3 additions & 3 deletions forui/test/src/widgets/popover/popover_golden_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void main() {
child: FPopover(
followerAnchor: Alignment.topRight,
targetAnchor: Alignment.bottomRight,
ignoreDirectionalPadding: false,
directionPadding: true,
style: theme.data.popoverStyle.copyWith(padding: const EdgeInsets.all(50)),
controller: controller,
followerBuilder: (context, style, _) => const SizedBox.square(dimension: 100),
Expand All @@ -121,7 +121,7 @@ void main() {
);
});

testWidgets('${theme.name} ignore directional padding', (tester) async {
testWidgets('${theme.name} no directional padding', (tester) async {
await tester.pumpWidget(
TestScaffold.app(
theme: theme.data,
Expand All @@ -146,7 +146,7 @@ void main() {

await expectLater(
find.byType(TestScaffold),
matchesGoldenFile('popover/ignore-directional-padding-${theme.name}.png'),
matchesGoldenFile('popover/no-directional-padding-${theme.name}.png'),
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void main() {
child: FPopoverMenu(
menuAnchor: Alignment.topRight,
childAnchor: Alignment.bottomRight,
ignoreDirectionalPadding: false,
directionPadding: true,
style: theme.data.popoverMenuStyle.copyWith(padding: const EdgeInsets.all(50)),
controller: controller,
menu: [
Expand Down Expand Up @@ -141,7 +141,7 @@ void main() {
);
});

testWidgets('${theme.name} ignore directional padding', (tester) async {
testWidgets('${theme.name} without no directional padding', (tester) async {
await tester.pumpWidget(
TestScaffold.app(
theme: theme.data,
Expand Down Expand Up @@ -183,7 +183,7 @@ void main() {

await expectLater(
find.byType(TestScaffold),
matchesGoldenFile('popover-menu/ignore-directional-padding-${theme.name}.png'),
matchesGoldenFile('popover-menu/no-directional-padding-${theme.name}.png'),
);
});
});
Expand Down
Loading