diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ca49845..6f53ee30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,89 +1,10 @@ -## [2.2.0] -### โœจ New โœจ -* Add support for Swift package manager. - -## [2.1.10] -### ๐Ÿ”„ Updated ๐Ÿ”„ -* Make text field cursor color follow the userโ€™s accent color if not explicitly set (thanks, [@driftwoodstudio](https://github.com/driftwoodstudio)). -* Expose the `AccentColorListener` class to macos_ui users. - -## [2.1.9] -### ๐Ÿ› ๏ธ Fixed ๐Ÿ› ๏ธ -* Fix incorrect highlighting and focusing behavior of `_MacosPopupMenuItemButton`. -* Remove scrolling animation from dropdown menus when manipulating the focus with the keyboard to mimic native macOS behavior. - -## [2.1.8] -### ๐Ÿ› ๏ธ Fixed ๐Ÿ› ๏ธ -* Fixed `shownByDefault` not being respected for the left sidebar of the `MacosWindow` (thanks, [@ShayperCool](https://github.com/ShayperCool)). - -## [2.1.7] -### ๐Ÿ”„ Updated ๐Ÿ”„ -* Expose `WindowMainStateListener` and implement `overrideIsMainWindow` method to allow for the windowโ€™s main state to be overridden. - -## [2.1.6] -### ๐Ÿ”„ Updated ๐Ÿ”„ -* add `section` parameter to `SidebarItem` to display an unclickable widget in the sidebar as a section header (thanks, [@whirlun](https://github.com/whirlun)). -* Fix incorrect barrier color when calling `showMacosSheet` when dark mode is enabled. - -## [2.1.5] -### ๐Ÿ›ป Migrated ๐Ÿ›ป -* Migrate to Flutterโ€™s new Color API. - -## [2.1.4] -### ๐Ÿ› ๏ธ Fixed ๐Ÿ› ๏ธ -* Fix incorrect barrier color when calling `showMacosAlertDialog` when dark mode is enabled. - -## [2.1.3] -### ๐Ÿ› ๏ธ Fixed ๐Ÿ› ๏ธ -* Fix `ToolbarOverflowButton` only reacting to every second click. - -## [2.1.2] -### ๐Ÿ› ๏ธ Updated ๐Ÿ› ๏ธ -* Add โ€œOlder macOS versionsโ€ section to README -* Add Flutter version constraints to prevent the following error: - ``` - Package validation found the following error: - * pubspec.yaml allows Flutter SDK version 1.9.x, which does not support the flutter.plugin.platforms key. - Please consider increasing the Flutter SDK requirement to ^1.10.0 (environment.sdk.flutter) - ``` -## [2.1.1] -* Fixed a bug where `MacosPulldownMenuItem` would not show an alert dialog when tapped. - -## [2.1.0] -* Updated dependencies -* Support macOS 15 - -## [2.0.9] -### ๐Ÿ› ๏ธ Updated ๐Ÿ› ๏ธ -* Add `expandDisclosureItems` flag to `SidebarItem` to optionally (default not changed) expand disclosure items initially - -## [2.0.8] -### ๐Ÿ› ๏ธ Updated ๐Ÿ› ๏ธ -* Fixed `SidebarItem` text overflowing. - -## [2.0.7] -### ๐Ÿ› ๏ธ Updated ๐Ÿ› ๏ธ -* Made most widgets aware of the userโ€™s accent color and window state by adding respective fields to `MacosThemeData`. -* `MacosCheckbox` has received a facelift to mimic the look and feel of native macOS checkboxes better. - -## [2.0.6] -### ๐Ÿ› ๏ธ Updated ๐Ÿ› ๏ธ -* Implemented value equality for `MacosThemeData`. - -## [2.0.5] -### ๐Ÿ› ๏ธ Fixed ๐Ÿ› ๏ธ -* Fixed `MacosRadioButton` check null value issue. - ## [2.0.4] -### ๐Ÿ”„ Updated ๐Ÿ”„ -* Added `initialTime` parameter to `MacosTimePicker`, allowing to set an initial time for the picker.This provides more customization options for selecting time. - -## [2.0.3] ### ๐Ÿ› ๏ธ Fixed ๐Ÿ› ๏ธ -* Fixed a bug that caused the sidebar to appear darker than intended. +- Fixed setState called after dispose issue in MacosPulldownButton. +## [2.0.3] ### ๐Ÿ”„ Updated ๐Ÿ”„ -* `SidebarItems` has now respects the userโ€™s selected accent color and mimics the look of macOSโ€™ sidebar items more closely. +* Added `initialTime` parameter to `MacosTimePicker`, allowing to set an initial time for the picker.This provides more customization options for selecting time. ## [2.0.2] ### ๐Ÿ› ๏ธ Fixed ๐Ÿ› ๏ธ @@ -97,16 +18,16 @@ ## [2.0.0] ### ๐Ÿšจ Breaking Changes ๐Ÿšจ * `macos_ui` has been migrated to utilize [macos_window_utils](https://pub.dev/packages/macos_window_utils) under the hood, which provides the following benefits: - * Window animation smoothness is drastically improved, particularly when miniaturizing and deminiaturizing the application window. - * Some visual artifacts that occurred while the window was being (de)miniaturized (such as the application's shadow going missing) no longer occur. - * The sidebar remains transparent when the app's brightness setting mismatches the OS setting. - * Wallpaper tinting is now supported. - * To migrate an existing application, please refer to the โ€œModern window lookโ€ section in the README. + * Window animation smoothness is drastically improved, particularly when miniaturizing and deminiaturizing the application window. + * Some visual artifacts that occurred while the window was being (de)miniaturized (such as the application's shadow going missing) no longer occur. + * The sidebar remains transparent when the app's brightness setting mismatches the OS setting. + * Wallpaper tinting is now supported. + * To migrate an existing application, please refer to the โ€œModern window lookโ€ section in the README. * Support for Flutter 3.10 and Dart 3 * `PushButton` has been updated to support the `ControlSize` enum. - * The `buttonSize` property has been changed to `controlSize`. - * Buttons can now be any of the following sizes: mini, small, regular, or large. + * The `buttonSize` property has been changed to `controlSize`. + * Buttons can now be any of the following sizes: mini, small, regular, or large. * `PushButton.isSecondary` is now `PushButton.secondary`. * `MacosAlertDialog`: `primaryButton` and `secondaryButton` are now declared to be of type `PushButton`. * `RelevanceIndicator` has been deprecated @@ -117,22 +38,22 @@ * `MacosSwitch` has been completely rewritten and now matches the native macOS switch in appearance and behavior. * A `ControlSize` enum has been introduced, which will allow widgets to more closely match their native counterparts. * `MacosTypography` - * You can now call `MacosTypography.of(context)` as a shorthand for retrieving the typography used in your `MacosTheme`. - * `MacosFontWeight` allows using Apple-specific font weights like `w510`, `w590`, and `w860`. + * You can now call `MacosTypography.of(context)` as a shorthand for retrieving the typography used in your `MacosTheme`. + * `MacosFontWeight` allows using Apple-specific font weights like `w510`, `w590`, and `w860`. * Localization - * Added support for `weekdayAbbreviations` and `monthAbbreviations` to `MacosDatePicker`. - * Added support for `dateFormat` to `MacosDatePicker`. - * Added support for `startWeekOnMonday` to `MacosDatePicker`. + * Added support for `weekdayAbbreviations` and `monthAbbreviations` to `MacosDatePicker`. + * Added support for `dateFormat` to `MacosDatePicker`. + * Added support for `startWeekOnMonday` to `MacosDatePicker`. ### ๐Ÿ”„ Updated ๐Ÿ”„ * `MacosColor` has been updated with some previously missing elements. * `PushButton` - * Now uses the correct `body` text style instead of the incorrect `headline` + * Now uses the correct `body` text style instead of the incorrect `headline` * `PushButton`'s secondary and disabled colors more closely match their native counterparts. * `MacosCheckbox` appearance more closely matches its native counterpart. * `MacosAlertDialog` - * `primaryButton` and `secondaryButton` are now required to have `controlSize`s of `ControlSize.large`. - * Docs now suggest that `appIcon` should be of size 64x64. + * `primaryButton` and `secondaryButton` are now required to have `controlSize`s of `ControlSize.large`. + * Docs now suggest that `appIcon` should be of size 64x64. * `Toolbar` now uses the correct `title3` text style instead of the incorrect `headline` * `MacosTheme` sets the global typography more efficiently * `HelpButton` now sizes itself according to specification @@ -172,9 +93,9 @@ ## [1.11.0] * ๐Ÿšจ Breaking Changes ๐Ÿšจ * `ResizablePane` can now be vertically resized - * `ResizablePane.startWidth` has been changed to `ResizablePane.startSize` - * `ResizablePane.minWidth` has been changed to `ResizablePane.minSize` - * `ResizablePane.maxWidth` has been changed to `ResizablePane.maxSize` + * `ResizablePane.startWidth` has been changed to `ResizablePane.startSize` + * `ResizablePane.minWidth` has been changed to `ResizablePane.minSize` + * `ResizablePane.maxWidth` has been changed to `ResizablePane.maxSize` ## [1.10.0] ๐Ÿšจ Breaking Changes ๐Ÿšจ @@ -197,8 +118,8 @@ Other changes: ## [1.8.0] ๐Ÿšจ Breaking Changes ๐Ÿšจ * `ContentArea.builder` has been changed from a `ScrollableWidgetBuilder` to a `WidgetBuilder` due to - changes in Flutter 3.7. The `MacosScrollbar` widget needs to undergo radical changes in order to achieve the - native macOS scrollbar look and feel in the future, so this will be revisited at that time. +changes in Flutter 3.7. The `MacosScrollbar` widget needs to undergo radical changes in order to achieve the +native macOS scrollbar look and feel in the future, so this will be revisited at that time. Other changes: * Per Flutter 3.7.0: Replace deprecated `MacosTextField.toolbarOptions` with `MacosTextField.contextMenuBuilder` @@ -227,21 +148,21 @@ Other changes: ## [1.7.0] * โœจ New - * `MacosImageIcon` widget. Identical to the `ImageIcon` from `flutter/widgets.dart` except it will obey a - `MacosIconThemeData` instead of an `IconThemeData` - * `SidebarItemSize` enum, which determines the height of sidebar items and the maximum size their `leading` widgets. - * `SidebarItem` now accepts an optional `trailing` widget. + * `MacosImageIcon` widget. Identical to the `ImageIcon` from `flutter/widgets.dart` except it will obey a +`MacosIconThemeData` instead of an `IconThemeData` + * `SidebarItemSize` enum, which determines the height of sidebar items and the maximum size their `leading` widgets. + * `SidebarItem` now accepts an optional `trailing` widget. * ๐Ÿ”„ Updated - * `SidebarItems` now supports `SidebarItemSize` via the `itemSize` property, which defaults to - `SidebarItemSize.medium`. The widget has been updated to manage the item's height, the maximum size of the item's - leading widget, and the font size of the item's label widget according to the given `SidebarItemSize`. - * The example app has been tweaked to use some icons from the SF Symbols 4 Beta via the new `MacosImageIcon` widget. + * `SidebarItems` now supports `SidebarItemSize` via the `itemSize` property, which defaults to +`SidebarItemSize.medium`. The widget has been updated to manage the item's height, the maximum size of the item's +leading widget, and the font size of the item's label widget according to the given `SidebarItemSize`. + * The example app has been tweaked to use some icons from the SF Symbols 4 Beta via the new `MacosImageIcon` widget. ## [1.6.0] * New widgets: `MacosTabView` and `MacosTabView` * BREAKING CHANGE: `Label.yAxis` has been renamed to `Label.crossAxisAlignment` * BREAKING CHANGE: `TooltipTheme` and `TooltipThemeData` have been renamed to `MacosTooltipTheme` and - `MacosTooltipThemeData` +`MacosTooltipThemeData` ## [1.5.1] * Correct the placement of the leading widget in disclosure sidebar items [#268](https://github.com/GroovinChip/macos_ui/issues/268) @@ -261,15 +182,15 @@ Other changes: ## [1.4.0] * Migration to Flutter 3.0 - * Minimum dart sdk version is now 2.17.0 - * Use new super parameters feature - * Update to `flutter_lints: ^2.0.1` with subsequent fixes - * `MacosScrollbar` API more closely matches its material counterpart + * Minimum dart sdk version is now 2.17.0 + * Use new super parameters feature + * Update to `flutter_lints: ^2.0.1` with subsequent fixes + * `MacosScrollbar` API more closely matches its material counterpart * Update `MacosColor` to more closely match the `Color` class - * Adds `MacosColor.fromARGB` constructor - * Adds `MacosColor.fromRGBO` constructor - * Adds `alphaBlend` function - * Adds `getAlphaFromOpacity` function + * Adds `MacosColor.fromARGB` constructor + * Adds `MacosColor.fromRGBO` constructor + * Adds `alphaBlend` function + * Adds `getAlphaFromOpacity` function ## [1.3.0] * Add a `top` property to `Sidebar` @@ -283,8 +204,8 @@ Other changes: ## [1.2.0] * Improved styling for `MacosTooltip`: - * Better color and shadows. - * Displays left-aligned, below the mouse cursor. + * Better color and shadows. + * Displays left-aligned, below the mouse cursor. * New widget: `ToolBarDivider` that can be used as a divider (vertical/horizontal line) in the `ToolBar` [#231](https://github.com/GroovinChip/macos_ui/issues/231). * All toolbar widgets can now receive a `tooltipMessage` property to display a `MacosTooltip` when user hovers over them [#232](https://github.com/GroovinChip/macos_ui/issues/232). @@ -293,17 +214,17 @@ Other changes: ## [1.1.0] * New functionality for `MacosSearchField` - * Shows a list of search results in an overlay below the field - * A result can be selected and customized. + * Shows a list of search results in an overlay below the field + * A result can be selected and customized. * A `MacosOverlayFilter` widget can now be used to apply the blurry "frosted glass" effect on surfaces. * New widget: `CustomToolbarItem` that enables any widget to be used in the `Toolbar`. ## [1.0.1] * Improvements to the graphical `MacosTimePicker` - * Better color gradient on the border - * Better inner shadow - * Minor size adjustments - * API improvements + * Better color gradient on the border + * Better inner shadow + * Minor size adjustments + * API improvements * Throw an exception if `MacosColorWell` is clicked on a non-macOS platform ## [1.0.0+1] @@ -375,9 +296,9 @@ Other changes: ## [0.10.2] * Updates to `MacosIconButton` and `MacosBackButton`: - * Added a hover effect when mouse moves over the buttons ([#168](https://github.com/GroovinChip/macos_ui/issues/168)) - * Added `hoverColor` property. - * Default shape is now `BoxShape.rectangle` with border radius, as it seems to be the most used in macOS design. + * Added a hover effect when mouse moves over the buttons ([#168](https://github.com/GroovinChip/macos_ui/issues/168)) + * Added `hoverColor` property. + * Default shape is now `BoxShape.rectangle` with border radius, as it seems to be the most used in macOS design. ## [0.10.1] * Added support for transparent sidebar. Please note that changes to `MainFlutterWindow.swift` are required for this to work. [(#175)](https://github.com/GroovinChip/macos_ui/pull/175) @@ -391,7 +312,7 @@ Other changes: ## [0.9.3] * Update to `PushButton`: - * Added `isSecondary` property + * Added `isSecondary` property ## [0.9.2] * Nearly all `MouseRegion`s have been updated to use `SystemMouseCursors.basic` in order to more closely adhere to Apple norms @@ -399,7 +320,7 @@ Other changes: ## [0.9.1] * Added top-level theming for `MacosIconButton` - * Introduces the `MacosIconButtonTheme` InheritedTheme and the `MacosIconButtonThemeData` theme class + * Introduces the `MacosIconButtonTheme` InheritedTheme and the `MacosIconButtonThemeData` theme class * Updates `MacosThemeData` and `MacosIconButton` to use the new `MacosIconButtonThemeData` * Removes an unnecessary setting of VisualDensity from `MacosThemeData.dark()` @@ -408,10 +329,10 @@ Other changes: ## [0.8.2] * Updates to `MacosListTile`: - * Added `leadingWhitespace` property - * Added `onClick` callback - * Added `onLongPress` callback - * Added `mouseCursor` property + * Added `leadingWhitespace` property + * Added `onClick` callback + * Added `onLongPress` callback + * Added `mouseCursor` property ## [0.8.1] * Fix the outer border of `MacosSheet` not having a border radius @@ -473,16 +394,16 @@ Other changes: ## [0.3.0] * Add `MacosPrefix` to widgets/classes with names that overlap with the material/cupertino libraries: - * `TextField` -> `MacosTextField` - * `Scaffold` -> `MacosTextField` - * `IconButton` -> `MacosIconButton` - * `BackButton` -> `MacosBackButton` - * `Scrollbar` -> `MacosScrollbar` - * `Checkbox` -> `MacosCheckbox` - * `RadioButton` -> `MacosRadioButton` - * `Tooltip` -> `MacosTooltip` - * `Typography` -> `MacosTypography` - * `Switch` -> `MacosSwitch` + * `TextField` -> `MacosTextField` + * `Scaffold` -> `MacosTextField` + * `IconButton` -> `MacosIconButton` + * `BackButton` -> `MacosBackButton` + * `Scrollbar` -> `MacosScrollbar` + * `Checkbox` -> `MacosCheckbox` + * `RadioButton` -> `MacosRadioButton` + * `Tooltip` -> `MacosTooltip` + * `Typography` -> `MacosTypography` + * `Switch` -> `MacosSwitch` ## [0.2.4] * Fix text field prefix icon alignment @@ -496,9 +417,9 @@ Other changes: ## [0.2.1] * `IconButton` updates: - - The `color` property is now `backgroundColor` - - The widget now takes a `Widget icon` rather than `IconData iconData` for better control over widget properties - - Deprecate and remove internal `foregroundColor` value + - The `color` property is now `backgroundColor` + - The widget now takes a `Widget icon` rather than `IconData iconData` for better control over widget properties + - Deprecate and remove internal `foregroundColor` value ## [0.2.0] * New widget: `BackButton`, `IconButton` @@ -515,9 +436,9 @@ Other changes: ## [0.1.2] * Updated the theme api - * Properties in `MacosThemeData` and in `Typography` can't be null - * Renamed `DynamicColorX` to `MacosDynamicColor` - * Added the method `lerp` on all theme data classes. + * Properties in `MacosThemeData` and in `Typography` can't be null + * Renamed `DynamicColorX` to `MacosDynamicColor` + * Added the method `lerp` on all theme data classes. ## [0.1.1] * Implemented `Label` ([#61](https://github.com/GroovinChip/macos_ui/issues/61)) @@ -564,12 +485,12 @@ Other changes: ## [0.0.4] * Major theme refactor that more closely resembles flutter/material and flutter/cupertino - * The `Style` class is now `MacosThemeData` - * `MacosTheme` is now a `StatelessWidget` that returns a private `_InheritedMacosTheme`. - The static `MacosTheme.of(context)` is now defined here. - * `MacosApp` now takes a `theme` and `darkTheme` rather than `style` and `darkStyle`. - Additionally, there are minor changes to the way `MacosApp` is built that more closely - resemble how `MaterialApp` is built. + * The `Style` class is now `MacosThemeData` + * `MacosTheme` is now a `StatelessWidget` that returns a private `_InheritedMacosTheme`. + The static `MacosTheme.of(context)` is now defined here. + * `MacosApp` now takes a `theme` and `darkTheme` rather than `style` and `darkStyle`. + Additionally, there are minor changes to the way `MacosApp` is built that more closely + resemble how `MaterialApp` is built. ## [0.0.3] @@ -585,6 +506,6 @@ Other changes: ## [0.0.1] * Project creation - * `MacosApp` widget - * Basic `Typography` - * Basic theming via `MacosTheme` and `Style` + * `MacosApp` widget + * Basic `Typography` + * Basic theming via `MacosTheme` and `Style` diff --git a/lib/src/buttons/pulldown_button.dart b/lib/src/buttons/pulldown_button.dart index 174383eb..8efaf523 100644 --- a/lib/src/buttons/pulldown_button.dart +++ b/lib/src/buttons/pulldown_button.dart @@ -852,9 +852,9 @@ class _MacosPulldownButtonState extends State ); navigator.push(_pulldownRoute!).then((_) { + if (!mounted) return; setState(() => _pullDownButtonState = PulldownButtonState.enabled); _removeMacosPulldownRoute(); - if (!mounted) return; }); widget.onTap?.call(); diff --git a/pubspec.yaml b/pubspec.yaml index 2c9badb9..99f6a50b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: macos_ui description: Flutter widgets and themes implementing the current macOS design language. -version: 2.2.0 +version: 2.2.1 homepage: "https://macosui.dev" repository: "https://github.com/GroovinChip/macos_ui" diff --git a/test/buttons/pulldown_button_test.dart b/test/buttons/pulldown_button_test.dart index f1d4428f..bea82b98 100644 --- a/test/buttons/pulldown_button_test.dart +++ b/test/buttons/pulldown_button_test.dart @@ -56,6 +56,48 @@ void main() { }, ); + testWidgets('MacosPulldownButton displays correctly items ', + (WidgetTester tester) async { + await tester.pumpWidget(MacosApp( + home: MacosWindow( + child: MacosScaffold( + children: [ + ContentArea( + builder: (context, _) { + return Center( + child: MacosPulldownButton( + title: "Menu", + items: [ + MacosPulldownMenuItem( + title: const Text('New folder'), + onTap: () {}, + ), + MacosPulldownMenuItem( + title: const Text('Document'), + onTap: () {}, + ), + ], + ), + ); + }, + ), + ], + ), + ), + )); + + // Verify that the title is rendered on the button. + expect(find.text('Menu'), findsOneWidget); + + // tap on the button to open the pulldown menu. + await tester.tap(find.text('Menu')); + await tester.pumpAndSettle(); + + // Verify that the menu items are displayed. + expect(find.text('New folder'), findsOneWidget); + expect(find.text('Document'), findsOneWidget); + }); + testWidgets( 'MacosPulldownButtonItems\' onTap callback is called when defined', (WidgetTester tester) async {