diff --git a/CHANGELOG.md b/CHANGELOG.md index 35ac6e8f..697a1246 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [0.0.12] +* Add mouse cursors to help button, push button and `TextField` + ## [0.0.11] * Implement `TextField` diff --git a/example/pubspec.lock b/example/pubspec.lock index 6925f62e..df2fecfe 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -73,7 +73,7 @@ packages: path: ".." relative: true source: path - version: "0.0.11" + version: "0.0.12" matcher: dependency: transitive description: diff --git a/lib/src/buttons/checkbox.dart b/lib/src/buttons/checkbox.dart index f4e6c907..0e01094e 100644 --- a/lib/src/buttons/checkbox.dart +++ b/lib/src/buttons/checkbox.dart @@ -1,4 +1,5 @@ import 'package:flutter/foundation.dart'; +import 'package:flutter/rendering.dart'; import 'package:macos_ui/src/library.dart'; import 'package:macos_ui/macos_ui.dart'; diff --git a/lib/src/buttons/help_button.dart b/lib/src/buttons/help_button.dart index 7aeb2f85..d86ff014 100644 --- a/lib/src/buttons/help_button.dart +++ b/lib/src/buttons/help_button.dart @@ -1,4 +1,5 @@ import 'package:flutter/foundation.dart'; +import 'package:flutter/rendering.dart'; import 'package:macos_ui/src/library.dart'; import 'package:macos_ui/macos_ui.dart'; @@ -170,52 +171,55 @@ class _HelpButtonState extends State ? Color.fromRGBO(255, 255, 255, 0.25) : Color.fromRGBO(0, 0, 0, 0.25); - return GestureDetector( - behavior: HitTestBehavior.opaque, - onTapDown: enabled ? _handleTapDown : null, - onTapUp: enabled ? _handleTapUp : null, - onTapCancel: enabled ? _handleTapCancel : null, - onTap: widget.onPressed, - child: Semantics( - label: widget.semanticLabel, - button: true, - child: ConstrainedBox( - constraints: BoxConstraints( - minWidth: 20, - minHeight: 20, - ), - child: FadeTransition( - opacity: _opacityAnimation, - child: DecoratedBox( - decoration: BoxDecoration( - shape: BoxShape.circle, - color: !enabled - ? DynamicColorX.macosResolve(disabledColor!, context) - : backgroundColor, - boxShadow: [ - BoxShadow( - color: Color.fromRGBO(0, 0, 0, 0.1), - offset: Offset(-0.1, -0.1), - ), - BoxShadow( - color: Color.fromRGBO(0, 0, 0, 0.1), - offset: Offset(0.1, 0.1), - ), - BoxShadow( - color: CupertinoColors.tertiarySystemFill, - offset: Offset(0, 0), - ), - ], - ), - child: Padding( - padding: EdgeInsets.all(8), - child: Align( - alignment: widget.alignment, - widthFactor: 1.0, - heightFactor: 1.0, - child: Icon( - CupertinoIcons.question, - color: foregroundColor, + return MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTapDown: enabled ? _handleTapDown : null, + onTapUp: enabled ? _handleTapUp : null, + onTapCancel: enabled ? _handleTapCancel : null, + onTap: widget.onPressed, + child: Semantics( + label: widget.semanticLabel, + button: true, + child: ConstrainedBox( + constraints: BoxConstraints( + minWidth: 20, + minHeight: 20, + ), + child: FadeTransition( + opacity: _opacityAnimation, + child: DecoratedBox( + decoration: BoxDecoration( + shape: BoxShape.circle, + color: !enabled + ? DynamicColorX.macosResolve(disabledColor!, context) + : backgroundColor, + boxShadow: [ + BoxShadow( + color: Color.fromRGBO(0, 0, 0, 0.1), + offset: Offset(-0.1, -0.1), + ), + BoxShadow( + color: Color.fromRGBO(0, 0, 0, 0.1), + offset: Offset(0.1, 0.1), + ), + BoxShadow( + color: CupertinoColors.tertiarySystemFill, + offset: Offset(0, 0), + ), + ], + ), + child: Padding( + padding: EdgeInsets.all(8), + child: Align( + alignment: widget.alignment, + widthFactor: 1.0, + heightFactor: 1.0, + child: Icon( + CupertinoIcons.question, + color: foregroundColor, + ), ), ), ), diff --git a/lib/src/buttons/push_button.dart b/lib/src/buttons/push_button.dart index cadd627e..01583bec 100644 --- a/lib/src/buttons/push_button.dart +++ b/lib/src/buttons/push_button.dart @@ -1,4 +1,5 @@ import 'package:flutter/foundation.dart'; +import 'package:flutter/rendering.dart'; import 'package:macos_ui/src/library.dart'; import 'package:macos_ui/macos_ui.dart'; @@ -232,39 +233,42 @@ class _PushButtonState extends State final TextStyle textStyle = theme.typography!.headline!.copyWith(color: foregroundColor); - return GestureDetector( - behavior: HitTestBehavior.opaque, - onTapDown: enabled ? _handleTapDown : null, - onTapUp: enabled ? _handleTapUp : null, - onTapCancel: enabled ? _handleTapCancel : null, - onTap: widget.onPressed, - child: Semantics( - button: true, - label: widget.semanticLabel, - child: ConstrainedBox( - constraints: BoxConstraints( - minWidth: 49, - minHeight: 20, - ), - child: FadeTransition( - opacity: _opacityAnimation, - child: DecoratedBox( - decoration: BoxDecoration( - borderRadius: borderRadius, - color: !enabled - ? DynamicColorX.macosResolve(disabledColor, context) - : backgroundColor, - ), - child: Padding( - padding: buttonPadding!, - child: Align( - alignment: widget.alignment, - widthFactor: 1.0, - heightFactor: 1.0, - // TODO(groovin): show proper text color in light theme - child: DefaultTextStyle( - style: textStyle, - child: widget.child, + return MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTapDown: enabled ? _handleTapDown : null, + onTapUp: enabled ? _handleTapUp : null, + onTapCancel: enabled ? _handleTapCancel : null, + onTap: widget.onPressed, + child: Semantics( + button: true, + label: widget.semanticLabel, + child: ConstrainedBox( + constraints: BoxConstraints( + minWidth: 49, + minHeight: 20, + ), + child: FadeTransition( + opacity: _opacityAnimation, + child: DecoratedBox( + decoration: BoxDecoration( + borderRadius: borderRadius, + color: !enabled + ? DynamicColorX.macosResolve(disabledColor, context) + : backgroundColor, + ), + child: Padding( + padding: buttonPadding!, + child: Align( + alignment: widget.alignment, + widthFactor: 1.0, + heightFactor: 1.0, + // TODO(groovin): show proper text color in light theme + child: DefaultTextStyle( + style: textStyle, + child: widget.child, + ), ), ), ), diff --git a/lib/src/buttons/radio_button.dart b/lib/src/buttons/radio_button.dart index aab04c43..71cd35ac 100644 --- a/lib/src/buttons/radio_button.dart +++ b/lib/src/buttons/radio_button.dart @@ -1,4 +1,5 @@ import 'package:flutter/foundation.dart'; +import 'package:flutter/rendering.dart'; import 'package:macos_ui/src/library.dart'; import 'package:macos_ui/macos_ui.dart'; diff --git a/lib/src/fields/text_field.dart b/lib/src/fields/text_field.dart index 51ec1134..9b1dea2e 100644 --- a/lib/src/fields/text_field.dart +++ b/lib/src/fields/text_field.dart @@ -1121,26 +1121,29 @@ class _TextFieldState extends State widget.suffix! // Otherwise, try to show a clear button if its visibility mode matches. else if (_showClearButton(text)) - GestureDetector( - key: _clearGlobalKey, - onTap: widget.enabled ?? true - ? () { - // Special handle onChanged for ClearButton - // Also call onChanged when the clear button is tapped. - final bool textChanged = - _effectiveController.text.isNotEmpty; - _effectiveController.clear(); - if (widget.onChanged != null && textChanged) - widget.onChanged!(_effectiveController.text); - } - : null, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 6.0), - child: Icon( - CupertinoIcons.clear_thick_circled, - size: 18.0, - color: - DynamicColorX.macosResolve(_kClearButtonColor, context), + MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + key: _clearGlobalKey, + onTap: widget.enabled ?? true + ? () { + // Special handle onChanged for ClearButton + // Also call onChanged when the clear button is tapped. + final bool textChanged = + _effectiveController.text.isNotEmpty; + _effectiveController.clear(); + if (widget.onChanged != null && textChanged) + widget.onChanged!(_effectiveController.text); + } + : null, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 6.0), + child: Icon( + CupertinoIcons.clear_thick_circled, + size: 18.0, + color: + DynamicColorX.macosResolve(_kClearButtonColor, context), + ), ), ), ), @@ -1346,7 +1349,7 @@ class _TextFieldState extends State ), ); - final Widget child = Semantics( + Widget child = Semantics( enabled: enabled, onTap: !enabled || widget.readOnly ? null @@ -1386,6 +1389,11 @@ class _TextFieldState extends State ), ); + child = MouseRegion( + cursor: SystemMouseCursors.text, + child: child, + ); + if (kIsWeb) { return Shortcuts( shortcuts: scrollShortcutOverrides, diff --git a/pubspec.yaml b/pubspec.yaml index 2b61bbab..147f51c2 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: 0.0.11 +version: 0.0.12 homepage: 'https://github.com/GroovinChip/macos_ui' environment: