Skip to content

Fix MacosPulldownMenuItem.onTap doesn't open alert dialog#520

Merged
GroovinChip merged 2 commits intomacosui:devfrom
TahaTesser:fix_MacosPulldownMenuItem_onTap
Oct 5, 2024
Merged

Fix MacosPulldownMenuItem.onTap doesn't open alert dialog#520
GroovinChip merged 2 commits intomacosui:devfrom
TahaTesser:fix_MacosPulldownMenuItem_onTap

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

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
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
@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