diff --git a/mobile/packages/ui/lib/src/components/column_button.dart b/mobile/packages/ui/lib/src/components/column_button.dart index f990dbc065..03b6933389 100644 --- a/mobile/packages/ui/lib/src/components/column_button.dart +++ b/mobile/packages/ui/lib/src/components/column_button.dart @@ -43,21 +43,10 @@ class _ImmichColumnButtonState extends State { } } - Future? _onPressed() { - if (_isDisabled) { - return null; - } + VoidCallback? get _onPressed => _isDisabled ? null : () => _runAction(widget.onPressed); - return _runAction(widget.onPressed); - } - - Future? _onLongPress() { - if (_isDisabled || widget.onLongPress == null) { - return null; - } - - return _runAction(widget.onLongPress!); - } + VoidCallback? get _onLongPress => + _isDisabled || widget.onLongPress == null ? null : () => _runAction(widget.onLongPress!); @override Widget build(BuildContext context) { diff --git a/mobile/packages/ui/lib/src/components/icon_button.dart b/mobile/packages/ui/lib/src/components/icon_button.dart index 1c02f30ed3..c0e1bcc3fa 100644 --- a/mobile/packages/ui/lib/src/components/icon_button.dart +++ b/mobile/packages/ui/lib/src/components/icon_button.dart @@ -44,21 +44,10 @@ class _ImmichIconButtonState extends State { } } - Future? _onPressed() { - if (_isDisabled) { - return null; - } + VoidCallback? get _onPressed => _isDisabled ? null : () => _runAction(widget.onPressed); - return _runAction(widget.onPressed); - } - - Future? _onLongPress() { - if (_isDisabled || widget.onLongPress == null) { - return null; - } - - return _runAction(widget.onLongPress!); - } + VoidCallback? get _onLongPress => + _isDisabled || widget.onLongPress == null ? null : () => _runAction(widget.onLongPress!); @override Widget build(BuildContext context) { diff --git a/mobile/packages/ui/lib/src/components/text_button.dart b/mobile/packages/ui/lib/src/components/text_button.dart index bbcfe4a3a7..6cbc08473b 100644 --- a/mobile/packages/ui/lib/src/components/text_button.dart +++ b/mobile/packages/ui/lib/src/components/text_button.dart @@ -46,21 +46,10 @@ class _ImmichTextButtonState extends State { } } - Future? _onPressed() { - if (_isDisabled) { - return null; - } + VoidCallback? get _onPressed => _isDisabled ? null : () => _runAction(widget.onPressed); - return _runAction(widget.onPressed); - } - - Future? _onLongPress() { - if (_isDisabled || widget.onLongPress == null) { - return null; - } - - return _runAction(widget.onLongPress!); - } + VoidCallback? get _onLongPress => + _isDisabled || widget.onLongPress == null ? null : () => _runAction(widget.onLongPress!); @override Widget build(BuildContext context) {