Skip to content

Commit

Permalink
Merge pull request #188 from conceptadev/fix/remove-function-from-tree
Browse files Browse the repository at this point in the history
  • Loading branch information
leoafarias authored Jan 31, 2024
2 parents 0a600d5 + 1de49c1 commit d4524a1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 41 deletions.
2 changes: 1 addition & 1 deletion lib/src/utils/style_recipe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ abstract class StyleRecipe<T extends StyleRecipe<T>> {

StyleRecipe<T> merge(covariant StyleRecipe<T>? other);

StyleRecipe<T> selectVariants(List<Variant> variants);
StyleRecipe<T> applyVariants(List<Variant> variants);

StyleRecipe<T> copyWith();
}
74 changes: 34 additions & 40 deletions lib/src/widgets/pressable/pressable_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,54 +154,48 @@ class PressableWidgetState extends State<Pressable> {

final onEnabled = currentStatus == WidgetStatus.enabled;

final focusableDetector = FocusableActionDetector(
enabled: onEnabled,
focusNode: _node,
autofocus: widget.autofocus,
onShowFocusHighlight: (v) => updateState(() => _focus = v),
onShowHoverHighlight: (v) => updateState(() => _hover = v),
onFocusChange: widget.onFocusChange,
child: WidgetStateNotifier(
data: WidgetStateData(
focus: _focus,
status: currentStatus,
state: currentGesture,
hover: _hover,
),
child: widget.child,
),
);

return MergeSemantics(
child: Semantics(
enabled: onEnabled,
button: true,
focusable: onEnabled && _node.canRequestFocus,
focused: _node.hasFocus,
child: _buildGestureDetector(
isDisabled: widget.disabled,
child: FocusableActionDetector(
enabled: onEnabled,
focusNode: _node,
autofocus: widget.autofocus,
onShowFocusHighlight: (v) => updateState(() => _focus = v),
onShowHoverHighlight: (v) => updateState(() => _hover = v),
onFocusChange: widget.onFocusChange,
child: WidgetStateNotifier(
data: WidgetStateData(
focus: _focus,
status: currentStatus,
state: currentGesture,
hover: _hover,
),
child: widget.child,
child: widget.disabled
? GestureDetector(
child: focusableDetector,
)
: GestureDetector(
onTapDown: (_) => updateState(() => _pressed = true),
onTapUp: (_) => handleUnpress(),
onTap: widget.onPressed,
onTapCancel: () => handleUnpress(),
onLongPressCancel: () =>
updateState(() => _longpressed = false),
onLongPress: widget.onLongPress,
onLongPressStart: (_) => updateState(() => _longpressed = true),
onLongPressEnd: (_) => updateState(() => _longpressed = false),
behavior: widget.behavior,
child: focusableDetector,
),
)),
),
);
}

GestureDetector _buildGestureDetector({
required bool isDisabled,
required Widget child,
}) {
return isDisabled
? GestureDetector(
child: child,
)
: GestureDetector(
onTapDown: (_) => updateState(() => _pressed = true),
onTapUp: (_) => handleUnpress(),
onTap: widget.onPressed,
onTapCancel: () => handleUnpress(),
onLongPressCancel: () => updateState(() => _longpressed = false),
onLongPress: widget.onLongPress,
onLongPressStart: (_) => updateState(() => _longpressed = true),
onLongPressEnd: (_) => updateState(() => _longpressed = false),
behavior: widget.behavior,
child: child,
);
}
}

0 comments on commit d4524a1

Please sign in to comment.