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 MacosPulldownMenuItem.onTap doesn't open alert dialog #520

Merged
merged 2 commits into from
Oct 5, 2024

Conversation

TahaTesser
Copy link
Contributor

fixes MacosPulldownMenuItem onTap doesnt call showMacosAlertDialog

Code sample

expand to view the code sample
import 'package:flutter/cupertino.dart';
import 'package:macos_ui/macos_ui.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MacosApp(
      debugShowCheckedModeBanner: false,
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return MacosScaffold(
      toolBar: ToolBar(
        title: const Text('macos_ui'),
        actions: [
          ToolBarPullDownButton(
            label: 'Actions',
            icon: CupertinoIcons.ellipsis_circle,
            tooltipMessage: 'Perform tasks with the selected items',
            items: [
              MacosPulldownMenuItem(
                label: 'New Folder',
                title: const Text('New Folder'),
                onTap: () => showMacosAlertDialog(
                  context: context,
                  builder: (context) => MacosAlertDialog(
                    appIcon: const FlutterLogo(size: 64),
                    title: const Text('Title'),
                    message: const Text('Message'),
                    //horizontalActions: false,
                    primaryButton: PushButton(
                      controlSize: ControlSize.large,
                      onPressed: Navigator.of(context).pop,
                      child: const Text('Label'),
                    ),
                  ),
                ),
              ),
              MacosPulldownMenuItem(
                label: 'Open',
                title: const Text('Open'),
                onTap: () => debugPrint('Opening...'),
              ),
            ],
          ),
        ],
      ),
    );
  }
}

Preview

Screenshot 2024-10-04 at 00 40 39

Pre-launch Checklist

  • I have incremented the package version as appropriate and updated CHANGELOG.md with my changes
  • I have added/updated relevant documentation
  • I have run "optimize/organize imports" on all changed files
  • I have addressed all analyzer warnings as best I could

Copy link
Collaborator

@GroovinChip GroovinChip left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @TahaTesser !!! Just one small change request and then we are good to go

@@ -65,8 +65,8 @@ class _MacosPulldownMenuItemButtonState
final MacosPulldownMenuEntry menuEntity =
widget.route.items[widget.itemIndex].item!;
if (menuEntity is MacosPulldownMenuItem) {
menuEntity.onTap?.call();
Navigator.pop(context);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we make this .of(context).pop() please?

@TahaTesser TahaTesser requested a review from GroovinChip October 3, 2024 22:10
Copy link
Collaborator

@GroovinChip GroovinChip left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

@GroovinChip
Copy link
Collaborator

Just gonna run the checks manually since you're a first time contributor

@GroovinChip
Copy link
Collaborator

Looks like we've got some failing tests

@TahaTesser TahaTesser force-pushed the fix_MacosPulldownMenuItem_onTap branch from 4a44177 to 1b0dd59 Compare October 4, 2024 15:37
@TahaTesser
Copy link
Contributor Author

Looks like we've got some failing tests

For some reason test passes locally with FlutterLogo but not in the CI so i just replaced it.

@GroovinChip GroovinChip merged commit 0c1a14e into macosui:dev Oct 5, 2024
3 of 4 checks passed
@TahaTesser TahaTesser deleted the fix_MacosPulldownMenuItem_onTap branch October 5, 2024 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MacosPulldownMenuItem onTap doesnt call showMacosAlertDialog
2 participants