Skip to content

Commit

Permalink
0.9.2 - Fix mouse cursors (#165)
Browse files Browse the repository at this point in the history
* feat(package): upgrade mouse cursors and add configurable MouseCursor props

Mouse cursors now almost all default to SystemMouseCursors.basic to more closely adhere with Apple norms

* chore(package): update version, CHANGELOG.md

* chore(package): finish editing, CHANGELOG.md
  • Loading branch information
GroovinChip authored Oct 13, 2021
1 parent 6fdc5fc commit 1f1de2c
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [0.9.2]
* Nearly all `MouseRegion`s have been updated to use `SystemMouseCursors.basic` in order to more closely adhere to Apple norms
* `mouseCursor` properties have been added to most buttons

## [0.9.1]
* Added top-level theming for `MacosIconButton`
* Introduces the `MacosIconButtonTheme` InheritedTheme and the `MacosIconButtonThemeData` theme class
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.9.1"
version: "0.9.2"
matcher:
dependency: transitive
description:
Expand Down
6 changes: 5 additions & 1 deletion lib/src/buttons/back_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class MacosBackButton extends StatefulWidget {
this.onPressed,
this.fillColor,
this.semanticLabel,
this.mouseCursor = SystemMouseCursors.basic,
}) : super(key: key);

/// An override callback to perform instead of the default behavior which is
Expand All @@ -23,6 +24,9 @@ class MacosBackButton extends StatefulWidget {
/// The semantic label used by screen readers.
final String? semanticLabel;

/// The mouse cursor to use when hovering over this widget.
final MouseCursor? mouseCursor;

/// Whether the button is enabled or disabled. Buttons are disabled by default. To
/// enable a button, set its [onPressed] property to a non-null value.
bool get enabled => onPressed != null;
Expand Down Expand Up @@ -136,7 +140,7 @@ class MacosBackButtonState extends State<MacosBackButton>
}

return MouseRegion(
cursor: SystemMouseCursors.click,
cursor: widget.mouseCursor!,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTapDown: enabled ? _handleTapDown : null,
Expand Down
6 changes: 5 additions & 1 deletion lib/src/buttons/help_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class HelpButton extends StatefulWidget {
this.pressedOpacity = 0.4,
this.alignment = Alignment.center,
this.semanticLabel,
this.mouseCursor = SystemMouseCursors.basic,
}) : assert(pressedOpacity == null ||
(pressedOpacity >= 0.0 && pressedOpacity <= 1.0)),
super(key: key);
Expand Down Expand Up @@ -59,6 +60,9 @@ class HelpButton extends StatefulWidget {
/// The semantic label used by screen readers.
final String? semanticLabel;

/// The mouse cursor to use when hovering over this widget.
final MouseCursor? mouseCursor;

/// Whether the button is enabled or disabled. Buttons are disabled by default. To
/// enable a button, set its [onPressed] property to a non-null value.
bool get enabled => onPressed != null;
Expand Down Expand Up @@ -173,7 +177,7 @@ class HelpButtonState extends State<HelpButton>
: const Color.fromRGBO(0, 0, 0, 0.25);

return MouseRegion(
cursor: SystemMouseCursors.click,
cursor: widget.mouseCursor!,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTapDown: enabled ? _handleTapDown : null,
Expand Down
6 changes: 5 additions & 1 deletion lib/src/buttons/icon_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class MacosIconButton extends StatefulWidget {
maxWidth: 30,
maxHeight: 30,
),
this.mouseCursor = SystemMouseCursors.basic,
}) : assert(pressedOpacity == null ||
(pressedOpacity >= 0.0 && pressedOpacity <= 1.0)),
super(key: key);
Expand Down Expand Up @@ -88,6 +89,9 @@ class MacosIconButton extends StatefulWidget {
/// The semantic label used by screen readers.
final String? semanticLabel;

/// The mouse cursor to use when hovering over this widget.
final MouseCursor? mouseCursor;

/// Whether the button is enabled or disabled. Buttons are disabled by default. To
/// enable a button, set its [onPressed] property to a non-null value.
bool get enabled => onPressed != null;
Expand Down Expand Up @@ -201,7 +205,7 @@ class MacosIconButtonState extends State<MacosIconButton>
}

return MouseRegion(
cursor: SystemMouseCursors.click,
cursor: widget.mouseCursor!,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTapDown: enabled ? _handleTapDown : null,
Expand Down
6 changes: 5 additions & 1 deletion lib/src/buttons/push_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class PushButton extends StatefulWidget {
this.borderRadius = const BorderRadius.all(Radius.circular(4.0)),
this.alignment = Alignment.center,
this.semanticLabel,
this.mouseCursor = SystemMouseCursors.basic,
}) : assert(pressedOpacity == null ||
(pressedOpacity >= 0.0 && pressedOpacity <= 1.0)),
super(key: key);
Expand Down Expand Up @@ -99,6 +100,9 @@ class PushButton extends StatefulWidget {
/// Always defaults to [Alignment.center].
final AlignmentGeometry alignment;

/// The mouse cursor to use when hovering over this widget.
final MouseCursor? mouseCursor;

/// The semantic label used by screen readers.
final String? semanticLabel;

Expand Down Expand Up @@ -239,7 +243,7 @@ class PushButtonState extends State<PushButton>
theme.typography.headline.copyWith(color: foregroundColor);

return MouseRegion(
cursor: SystemMouseCursors.click,
cursor: widget.mouseCursor!,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTapDown: enabled ? _handleTapDown : null,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/layout/sidebar_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class _SidebarItem extends StatelessWidget {
focusNode: item.focusNode,
descendantsAreFocusable: false,
enabled: onClick != null,
mouseCursor: SystemMouseCursors.click,
mouseCursor: SystemMouseCursors.basic,
actions: _actionMap,
child: Container(
width: 134.0 + theme.visualDensity.horizontal,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: macos_ui
description: Flutter widgets and themes implementing the current macOS design language.
version: 0.9.1
version: 0.9.2
homepage: "https://github.com/GroovinChip/macos_ui"

environment:
Expand Down

0 comments on commit 1f1de2c

Please sign in to comment.