diff --git a/.gitignore b/.gitignore index fcfa202c..c8887dcd 100644 --- a/.gitignore +++ b/.gitignore @@ -80,3 +80,4 @@ metrics coverage_report coverage +example/macos/Flutter/GeneratedPluginRegistrant.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index fd70a111..3c9e7321 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ +## [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. + +### 🔄 Updated 🔄 +* `SidebarItems` has now respects the user’s selected accent color and mimics the look of macOS’ sidebar items more closely. + ## [2.0.2] ### 🛠️ Fixed 🛠️ * Fixed images in generated documentation. @@ -10,16 +25,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 @@ -30,22 +45,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 @@ -85,9 +100,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 🚨 @@ -110,8 +125,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` @@ -140,21 +155,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) @@ -174,15 +189,15 @@ leading widget, and the font size of the item's label widget according to the gi ## [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` @@ -196,8 +211,8 @@ leading widget, and the font size of the item's label widget according to the gi ## [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). @@ -206,17 +221,17 @@ leading widget, and the font size of the item's label widget according to the gi ## [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] @@ -288,9 +303,9 @@ leading widget, and the font size of the item's label widget according to the gi ## [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) @@ -304,7 +319,7 @@ leading widget, and the font size of the item's label widget according to the gi ## [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 @@ -312,7 +327,7 @@ leading widget, and the font size of the item's label widget according to the gi ## [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()` @@ -321,10 +336,10 @@ leading widget, and the font size of the item's label widget according to the gi ## [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 @@ -386,16 +401,16 @@ leading widget, and the font size of the item's label widget according to the gi ## [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 @@ -409,9 +424,9 @@ leading widget, and the font size of the item's label widget according to the gi ## [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` @@ -428,9 +443,9 @@ leading widget, and the font size of the item's label widget according to the gi ## [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)) @@ -477,12 +492,12 @@ leading widget, and the font size of the item's label widget according to the gi ## [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] @@ -498,6 +513,6 @@ leading widget, and the font size of the item's label widget according to the gi ## [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/example/macos/Podfile.lock b/example/macos/Podfile.lock index 6aa1d86e..92146f31 100644 --- a/example/macos/Podfile.lock +++ b/example/macos/Podfile.lock @@ -44,4 +44,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: ff0a9a3ce75ee73f200ca7e2f47745698c917ef9 -COCOAPODS: 1.12.1 +COCOAPODS: 1.13.0 diff --git a/example/macos/Runner.xcodeproj/project.pbxproj b/example/macos/Runner.xcodeproj/project.pbxproj index 2c562a4e..428da703 100644 --- a/example/macos/Runner.xcodeproj/project.pbxproj +++ b/example/macos/Runner.xcodeproj/project.pbxproj @@ -202,7 +202,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 33CC10EC2044A3C60003C045 = { diff --git a/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index fb7259e1..83d88728 100644 --- a/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ extends StatelessWidget { final MacosThemeData theme = MacosTheme.of(context); final isLight = !theme.brightness.isDark; return GestureDetector( - onTap: () => onChanged!(value), + onTap: isDisabled ? null : () => onChanged!(value), child: Semantics( checked: selected, label: semanticLabel, diff --git a/lib/src/layout/sidebar/sidebar_item.dart b/lib/src/layout/sidebar/sidebar_item.dart index 1454ccbd..4e5d1318 100644 --- a/lib/src/layout/sidebar/sidebar_item.dart +++ b/lib/src/layout/sidebar/sidebar_item.dart @@ -43,7 +43,7 @@ class SidebarItem with Diagnosticable { final Color? unselectedColor; /// The [shape] property specifies the outline (border) of the - /// decoration. The shape must not be null. It's used alonside + /// decoration. The shape must not be null. It's used alongside /// [selectedColor]. final ShapeBorder? shape; diff --git a/lib/src/layout/sidebar/sidebar_items.dart b/lib/src/layout/sidebar/sidebar_items.dart index 65b3dadb..58a781b7 100644 --- a/lib/src/layout/sidebar/sidebar_items.dart +++ b/lib/src/layout/sidebar/sidebar_items.dart @@ -1,4 +1,5 @@ import 'package:macos_ui/macos_ui.dart'; +import 'package:macos_ui/src/enums/accent_color.dart'; import 'package:macos_ui/src/library.dart'; const Duration _kExpand = Duration(milliseconds: 200); @@ -79,7 +80,8 @@ class SidebarItems extends StatelessWidget { /// The color to paint the item when it's selected. /// - /// If null, [MacosThemeData.primaryColor] is used. + /// If null, the color is chosen automatically based on the user’s selected + /// system accent color and whether the sidebar is in the main window. final Color? selectedColor; /// The color to paint the item when it's unselected. @@ -97,6 +99,21 @@ class SidebarItems extends StatelessWidget { /// Defaults to [SystemMouseCursors.basic]. final MouseCursor? cursor; + /// The user’s selected system accent color. + AccentColor get _accentColor => + AccentColorListener.instance.currentAccentColor ?? AccentColor.blue; + + /// Returns the sidebar item’s selected color. + Color _getColor(BuildContext context) { + final isMainWindow = WindowMainStateListener.instance.isMainWindow; + + return _ColorProvider.getSelectedColor( + accentColor: _accentColor, + isDarkModeEnabled: MacosTheme.of(context).brightness.isDark, + isWindowMain: isMainWindow, + ); + } + List get _allItems { List result = []; for (var element in items) { @@ -117,39 +134,50 @@ class SidebarItems extends StatelessWidget { final theme = MacosTheme.of(context); return MacosIconTheme.merge( data: const MacosIconThemeData(size: 20), - child: _SidebarItemsConfiguration( - selectedColor: selectedColor ?? theme.primaryColor, - unselectedColor: unselectedColor ?? MacosColors.transparent, - shape: shape ?? _defaultShape, - itemSize: itemSize, - child: ListView( - controller: scrollController, - physics: const ClampingScrollPhysics(), - padding: EdgeInsets.all(10.0 - theme.visualDensity.horizontal), - children: List.generate(items.length, (index) { - final item = items[index]; - if (item.disclosureItems != null) { - return MouseRegion( - cursor: cursor!, - child: _DisclosureSidebarItem( - item: item, - selectedItem: _allItems[currentIndex], - onChanged: (item) { - onChanged(_allItems.indexOf(item)); - }, + child: StreamBuilder( + stream: AccentColorListener.instance.onChanged, + builder: (context, _) { + return StreamBuilder( + stream: WindowMainStateListener.instance.onChanged, + builder: (context, _) { + return _SidebarItemsConfiguration( + selectedColor: selectedColor ?? _getColor(context), + unselectedColor: unselectedColor ?? MacosColors.transparent, + shape: shape ?? _defaultShape, + itemSize: itemSize, + child: ListView( + controller: scrollController, + physics: const ClampingScrollPhysics(), + padding: + EdgeInsets.all(10.0 - theme.visualDensity.horizontal), + children: List.generate(items.length, (index) { + final item = items[index]; + if (item.disclosureItems != null) { + return MouseRegion( + cursor: cursor!, + child: _DisclosureSidebarItem( + item: item, + selectedItem: _allItems[currentIndex], + onChanged: (item) { + onChanged(_allItems.indexOf(item)); + }, + ), + ); + } + return MouseRegion( + cursor: cursor!, + child: _SidebarItem( + item: item, + selected: _allItems[currentIndex] == item, + onClick: () => onChanged(_allItems.indexOf(item)), + ), + ); + }), ), ); - } - return MouseRegion( - cursor: cursor!, - child: _SidebarItem( - item: item, - selected: _allItems[currentIndex] == item, - onClick: () => onChanged(_allItems.indexOf(item)), - ), - ); - }), - ), + }, + ); + }, ), ); } @@ -279,18 +307,16 @@ class _SidebarItem extends StatelessWidget { ), child: Row( children: [ - if (hasLeading) - Padding( - padding: EdgeInsets.only(right: spacing), - child: MacosIconTheme.merge( - data: MacosIconThemeData( - color: - selected ? MacosColors.white : theme.primaryColor, - size: itemSize.iconSize, - ), - child: item.leading!, + if (hasLeading) ...[ + MacosIconTheme.merge( + data: MacosIconThemeData( + color: selected ? MacosColors.white : theme.primaryColor, + size: itemSize.iconSize, ), + child: item.leading!, ), + SizedBox(width: spacing), + ], DefaultTextStyle( style: labelStyle.copyWith( color: selected ? textLuminance(selectedColor) : null, @@ -497,3 +523,74 @@ class __DisclosureSidebarItemState extends State<_DisclosureSidebarItem> ); } } + +class _ColorProvider { + /// Returns the selected color based on the provided parameters. + static Color getSelectedColor({ + required AccentColor accentColor, + required bool isDarkModeEnabled, + required bool isWindowMain, + }) { + if (isDarkModeEnabled) { + if (!isWindowMain) { + return const MacosColor.fromRGBO(76, 78, 65, 1.0); + } + + switch (accentColor) { + case AccentColor.blue: + return const MacosColor.fromRGBO(22, 105, 229, 0.749); + + case AccentColor.purple: + return const MacosColor.fromRGBO(204, 45, 202, 0.749); + + case AccentColor.pink: + return const MacosColor.fromRGBO(229, 74, 145, 0.749); + + case AccentColor.red: + return const MacosColor.fromRGBO(238, 64, 68, 0.749); + + case AccentColor.orange: + return const MacosColor.fromRGBO(244, 114, 0, 0.749); + + case AccentColor.yellow: + return const MacosColor.fromRGBO(233, 176, 0, 0.749); + + case AccentColor.green: + return const MacosColor.fromRGBO(76, 177, 45, 0.749); + + case AccentColor.graphite: + return const MacosColor.fromRGBO(129, 129, 122, 0.824); + } + } + + if (!isWindowMain) { + return const MacosColor.fromRGBO(213, 213, 208, 1.0); + } + + switch (accentColor) { + case AccentColor.blue: + return const MacosColor.fromRGBO(9, 129, 255, 0.749); + + case AccentColor.purple: + return const MacosColor.fromRGBO(162, 28, 165, 0.749); + + case AccentColor.pink: + return const MacosColor.fromRGBO(234, 81, 152, 0.749); + + case AccentColor.red: + return const MacosColor.fromRGBO(220, 32, 40, 0.749); + + case AccentColor.orange: + return const MacosColor.fromRGBO(245, 113, 0, 0.749); + + case AccentColor.yellow: + return const MacosColor.fromRGBO(240, 180, 2, 0.749); + + case AccentColor.green: + return const MacosColor.fromRGBO(66, 174, 33, 0.749); + + case AccentColor.graphite: + return const MacosColor.fromRGBO(174, 174, 167, 0.847); + } + } +} diff --git a/lib/src/layout/window.dart b/lib/src/layout/window.dart index b0d6f202..64bf38c8 100644 --- a/lib/src/layout/window.dart +++ b/lib/src/layout/window.dart @@ -275,10 +275,10 @@ class _MacosWindowState extends State { child: Column( children: [ // If an app is running on macOS, apply - // sidebar.topOffset as needed in order to avoid the - // traffic lights. Otherwise, position the sidebar - // by the top of the application's bounds based on - // the presence of sidebar.top. + // sidebar.topOffset as needed in order to avoid + // the traffic lights. Otherwise, position the + // sidebar by the top of the application's bounds + // based on the presence of sidebar.top. if (!kIsWeb && sidebar.topOffset > 0) ...[ SizedBox(height: sidebar.topOffset), ] else if (sidebar.top != null) ...[ @@ -293,7 +293,12 @@ class _MacosWindowState extends State { color: dividerColor), if (sidebar.top != null && constraints.maxHeight > 81) - sidebar.top!, + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 8.0, + ), + child: sidebar.top!, + ), Expanded( child: MacosScrollbar( controller: _sidebarScrollController, @@ -308,7 +313,10 @@ class _MacosWindowState extends State { ), if (sidebar.bottom != null && constraints.maxHeight > 141) - sidebar.bottom!, + Padding( + padding: const EdgeInsets.all(16.0), + child: sidebar.bottom!, + ), ], ), ) @@ -317,10 +325,10 @@ class _MacosWindowState extends State { child: Column( children: [ // If an app is running on macOS, apply - // sidebar.topOffset as needed in order to avoid the - // traffic lights. Otherwise, position the sidebar - // by the top of the application's bounds based on - // the presence of sidebar.top. + // sidebar.topOffset as needed in order to avoid + // the traffic lights. Otherwise, position the + // sidebar by the top of the application's bounds + // based on the presence of sidebar.top. if (!kIsWeb && sidebar.topOffset > 0) ...[ SizedBox(height: sidebar.topOffset), ] else if (sidebar.top != null) ...[ @@ -337,7 +345,8 @@ class _MacosWindowState extends State { constraints.maxHeight > 81) Padding( padding: const EdgeInsets.symmetric( - horizontal: 8.0), + horizontal: 8.0, + ), child: sidebar.top!, ), Expanded( @@ -474,45 +483,40 @@ class _MacosWindowState extends State { minHeight: height, maxHeight: height, ).normalize(), - child: WallpaperTintedArea( - backgroundColor: endSidebarBackgroundColor, - insertRepaintBoundary: true, - child: Column( - children: [ - if (endSidebar.topOffset > 0) - SizedBox(height: endSidebar.topOffset), - if (_endSidebarScrollController.hasClients && - _endSidebarScrollController.offset > 0.0) - Divider( - thickness: 1, - height: 1, - color: dividerColor, - ), - if (endSidebar.top != null) - Padding( - padding: - const EdgeInsets.symmetric(horizontal: 8.0), - child: endSidebar.top!, - ), - Expanded( - child: MacosScrollbar( - controller: _endSidebarScrollController, - child: Padding( - padding: endSidebar.padding, - child: endSidebar.builder( - context, - _endSidebarScrollController, - ), + child: Column( + children: [ + if (endSidebar.topOffset > 0) + SizedBox(height: endSidebar.topOffset), + if (_endSidebarScrollController.hasClients && + _endSidebarScrollController.offset > 0.0) + Divider( + thickness: 1, + height: 1, + color: dividerColor, + ), + if (endSidebar.top != null) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8.0), + child: endSidebar.top!, + ), + Expanded( + child: MacosScrollbar( + controller: _endSidebarScrollController, + child: Padding( + padding: endSidebar.padding, + child: endSidebar.builder( + context, + _endSidebarScrollController, ), ), ), - if (endSidebar.bottom != null) - Padding( - padding: const EdgeInsets.all(16.0), - child: endSidebar.bottom!, - ), - ], - ), + ), + if (endSidebar.bottom != null) + Padding( + padding: const EdgeInsets.all(16.0), + child: endSidebar.bottom!, + ), + ], ), ), ), diff --git a/lib/src/selectors/date_picker.dart b/lib/src/selectors/date_picker.dart index 2b3cd9b0..25515a7d 100644 --- a/lib/src/selectors/date_picker.dart +++ b/lib/src/selectors/date_picker.dart @@ -21,7 +21,7 @@ enum DatePickerStyle { /// {template onDateChanged} /// The action to perform when a new date is selected. /// {endtemplate} -typedef OnDateChanged = Function(DateTime date); +typedef OnDateChanged = void Function(DateTime date); /// {template macosDatePicker} /// A [MacosDatePicker] lets the user choose a date. diff --git a/lib/src/selectors/time_picker.dart b/lib/src/selectors/time_picker.dart index 815b23d5..47b4bb15 100644 --- a/lib/src/selectors/time_picker.dart +++ b/lib/src/selectors/time_picker.dart @@ -20,8 +20,8 @@ enum TimePickerStyle { /// {template onTimeChanged} /// The action to perform when a new time is selected. -/// {endtemplate} -typedef OnTimeChanged = Function(TimeOfDay time); +/// {end-template} +typedef OnTimeChanged = void Function(TimeOfDay time); /// {template macosTimePicker} /// A [MacosTimePicker] lets the user choose a time. @@ -36,15 +36,21 @@ typedef OnTimeChanged = Function(TimeOfDay time); /// /// The [onTimeChanged] callback passes through the user's selected time, and /// must be provided. -/// {endtemplate} +/// {end-template} class MacosTimePicker extends StatefulWidget { /// {@macro macosTimePicker} const MacosTimePicker({ super.key, required this.onTimeChanged, + this.initialTime, this.style = TimePickerStyle.combined, }); + /// Set an initial date for the picker. + /// + /// Defaults to `TimeOfDay.now()`. + final TimeOfDay? initialTime; + /// The [TimePickerStyle] to use. /// /// Defaults to [TimePickerStyle.combined]. @@ -58,7 +64,7 @@ class MacosTimePicker extends StatefulWidget { } class _MacosTimePickerState extends State { - final _initialTime = TimeOfDay.now(); + late final _initialTime = widget.initialTime ?? TimeOfDay.now(); late int _selectedHour; late int _selectedMinute; late DayPeriod _selectedPeriod; diff --git a/pubspec.lock b/pubspec.lock index 237d2d6d..2fe57d44 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -223,18 +223,18 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.15" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.2.0" meta: dependency: transitive description: @@ -364,10 +364,10 @@ packages: dependency: transitive description: name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.9.1" stack_trace: dependency: transitive description: @@ -456,14 +456,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.0" - web: - dependency: transitive - description: - name: web - sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 - url: "https://pub.dev" - source: hosted - version: "0.3.0" web_socket_channel: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 8d81c2da..0cfba245 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.0.2 +version: 2.0.5 homepage: "https://macosui.dev" repository: "https://github.com/GroovinChip/macos_ui"