Skip to content

Commit

Permalink
Merge pull request #74 from icapps/bugfix/#73-fix-touch-feedback-ios
Browse files Browse the repository at this point in the history
#73: Fixed the touch feedback on iOS
  • Loading branch information
vanlooverenkoen committed Feb 22, 2022
2 parents b6591fc + 40e7cc6 commit 20416b0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,10 @@
# Changelog

## [0.6.4] - 2022-02-22
### Fixed

- iOS Touchfeedback when 2 TouchFeedbackIOS widgets are on top of eachother

## [0.6.3] - 2022-01-26
### Added

Expand Down
22 changes: 20 additions & 2 deletions lib/src/widget/touch_feedback/touch_feedback.dart
Expand Up @@ -90,13 +90,23 @@ class TouchFeedBackIOS extends StatefulWidget {
class _TouchFeedBackIOSState extends State<TouchFeedBackIOS> {
static const touchScale = 0.98;
static const defaultScale = 1.0;

static final _touchPoints = <UniqueKey, Offset>{};
final _key = UniqueKey();

var touched = false;

@override
void dispose() {
_touchPoints.remove(_key);
super.dispose();
}

@override
Widget build(BuildContext context) {
return GestureDetector(
excludeFromSemantics: widget.onClick == null,
onTapDown: (details) => _setTouched(true),
onTapDown: _onTapDown,
onTap: widget.onClick,
onTapCancel: () => _setTouched(false),
onTapUp: (details) => _setTouched(false),
Expand All @@ -115,7 +125,15 @@ class _TouchFeedBackIOSState extends State<TouchFeedBackIOS> {
}

void _setTouched(bool touched) {
if (widget.onClick == null) return;
if (!touched) _touchPoints.remove(_key);
if (widget.onClick == null || this.touched == touched) return;
setState(() => this.touched = touched);
}

void _onTapDown(TapDownDetails details) {
final touchPosition = details.globalPosition;
if (_touchPoints.containsValue(touchPosition)) return;
_touchPoints[_key] = touchPosition;
_setTouched(true);
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Expand Up @@ -4,7 +4,7 @@ homepage: https://github.com/icapps/flutter-icapps-architecture
repository: https://github.com/icapps/flutter-icapps-architecture
issue_tracker: https://github.com/icapps/flutter-icapps-architecture/issues

version: 0.6.3
version: 0.6.4

environment:
sdk: '>=2.14.0 <3.0.0'
Expand Down
2 changes: 1 addition & 1 deletion test/util/logging/logging_test.dart
Expand Up @@ -181,7 +181,7 @@ void testWithLogger() {
expect(
messages[4].lines[4],
matches(
'\\d+:\\d+:\\d+\\.\\d+\\s+#2 StackZoneSpecification._registerUnaryCallback.<anonymous closure> \\(package:stack_trace/src/stack_zone_specification.dart\\)'));
'\\d+:\\d+:\\d+\\.\\d+\\s+#2 StackZoneSpecification._registerUnaryCallback.<anonymous closure> \\(package:stack_trace/src/stack_zone_specification.dart:125:47\\)'));
expect(messages[4].lines[5],
matches('\\d+:\\d+:\\d+\\.\\d+\\s+#3 <asynchronous suspension>'));
expect(messages[4].lines[0],
Expand Down

0 comments on commit 20416b0

Please sign in to comment.