macosui / macos_ui

Flutter widgets and themes implementing the current macOS design language.
https://macosui.github.io/macos_ui/#/
MIT License
1.88k stars 183 forks source link

MacosPulldownMenuItem onTap doesnt call showMacosAlertDialog #516

Closed xalikoutis closed 1 month ago

xalikoutis commented 2 months ago

Description

When i call showMacosAlertDialog from ToolBarIconButton onPressed works as expected, i see the dialog poping up

When i call showMacosAlertDialog from MacosPulldownMenuItem onTap does not call the function

Steps To Reproduce

Run the sample app below

Code sample ``` import 'package:flutter/cupertino.dart'; import 'package:flutter/material.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 MacosApp( title: 'macos_ui example', theme: MacosThemeData.light(), darkTheme: MacosThemeData.dark(), themeMode: ThemeMode.system, ); } } class Demo extends StatefulWidget { const Demo({super.key}); @override _DemoState createState() => _DemoState(); } class _DemoState extends State { double ratingValue = 0; double sliderValue = 0; bool value = false; int pageIndex = 0; @override Widget build(BuildContext context) { return const MacosWindow( child: AppsScreen(), ); } } class AppsScreen extends StatelessWidget { const AppsScreen({super.key}); @override Widget build(BuildContext context) { return MacosScaffold( toolBar: ToolBar( title: Text('Apps'), actions: [ ToolBarIconButton( label: 'Release for all', icon: const MacosIcon( CupertinoIcons.wand_stars, ), showLabel: true, onPressed: () => showMacosAlertDialog( context: context, builder: (BuildContext context) { return MacosAlertDialog( title: const Text('Release for all'), message: const Text('Are you sure you want to release this app for all?'), primaryButton: PushButton( onPressed: () => Navigator.of(context).pop(), controlSize: ControlSize.large, child: const Text('Cancel'), ), secondaryButton: PushButton( controlSize: ControlSize.large, onPressed: () => Navigator.of(context).pop(), child: const Text('Release'), ), appIcon: const FlutterLogo(size: 56), ); }, ), ), ToolBarPullDownButton( label: 'Actions', tooltipMessage: 'actions about apps', icon: CupertinoIcons.gear_alt, items: [ MacosPulldownMenuItem( label: 'Reset IAP cache', title: Text('Reset IAP cache'), onTap: () => showMacosAlertDialog( context: context, builder: (BuildContext context) { return MacosAlertDialog( title: const Text('Release for all'), message: const Text('Are you sure you want to release this app for all?'), primaryButton: PushButton( onPressed: () => Navigator.of(context).pop(), controlSize: ControlSize.large, child: const Text('Cancel'), ), secondaryButton: PushButton( controlSize: ControlSize.large, onPressed: () => Navigator.of(context).pop(), child: const Text('Release'), ), appIcon: const FlutterLogo(size: 56), ); }, ), ), ]), ], ), children: [ ContentArea(builder: (BuildContext context, ScrollController scrollController) { return ListView.builder( controller: scrollController, itemCount: 10, itemBuilder: (BuildContext context, int index) { return MacosListTile( title: Text('App $index'), subtitle: Text('Subtitle $index'), ); }, ); }), ], ); } } ```

Expected behavior

MacosPulldownMenuItem onTap should call the showMacosAlertDialog

Screenshots

TahaTesser commented 1 month ago

Fixed in https://github.com/macosui/macos_ui/pull/520