Haptisches Feedback hinzufügen #216

Merged
flixcoo merged 14 commits from feature/215-haptisches-feedback-hinzufügen into development 2026-05-14 13:09:01 +00:00
6 changed files with 45 additions and 18 deletions
Showing only changes of commit f1899bfe44 - Show all commits

View File

@@ -112,7 +112,10 @@ class _ChooseGroupViewState extends State<ChooseGroupView> {
padding: const EdgeInsets.only(bottom: 85), padding: const EdgeInsets.only(bottom: 85),
itemCount: filteredGroups.length, itemCount: filteredGroups.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return GestureDetector( return GroupTile(
group: filteredGroups[index],
isHighlighted:
selectedGroupId == filteredGroups[index].id,
onTap: () { onTap: () {
setState(() { setState(() {
if (selectedGroupId != filteredGroups[index].id) { if (selectedGroupId != filteredGroups[index].id) {
@@ -122,11 +125,6 @@ class _ChooseGroupViewState extends State<ChooseGroupView> {
} }
}); });
}, },
child: GroupTile(
group: filteredGroups[index],
isHighlighted:
selectedGroupId == filteredGroups[index].id,
),
); );
}, },
), ),

View File

@@ -1,6 +1,7 @@
import 'dart:math'; import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_popup/flutter_popup.dart'; import 'package:flutter_popup/flutter_popup.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:tallee/core/common.dart'; import 'package:tallee/core/common.dart';
@@ -330,6 +331,12 @@ class _CreateGameViewState extends State<CreateGameView> {
contentPadding: const EdgeInsets.symmetric(horizontal: 0, vertical: 10), contentPadding: const EdgeInsets.symmetric(horizontal: 0, vertical: 10),
barrierColor: Colors.transparent, barrierColor: Colors.transparent,
contentDecoration: CustomTheme.standardBoxDecoration, contentDecoration: CustomTheme.standardBoxDecoration,
onBeforePopup: () async {
await HapticFeedback.selectionClick();
},
onAfterPopup: () async {
await HapticFeedback.selectionClick();
},
content: StatefulBuilder( content: StatefulBuilder(
builder: (context, setPopupState) => SizedBox( builder: (context, setPopupState) => SizedBox(
width: 280, width: 280,
@@ -339,7 +346,8 @@ class _CreateGameViewState extends State<CreateGameView> {
children: List.generate( children: List.generate(
_rulesets.length, _rulesets.length,
(index) => GestureDetector( (index) => GestureDetector(
onTap: () { onTap: () async {
await HapticFeedback.selectionClick();
setState(() { setState(() {
selectedRuleset = _rulesets[index].$1; selectedRuleset = _rulesets[index].$1;
}); });
@@ -413,6 +421,12 @@ class _CreateGameViewState extends State<CreateGameView> {
contentPadding: const EdgeInsets.symmetric(horizontal: 0, vertical: 10), contentPadding: const EdgeInsets.symmetric(horizontal: 0, vertical: 10),
barrierColor: Colors.transparent, barrierColor: Colors.transparent,
contentDecoration: CustomTheme.standardBoxDecoration, contentDecoration: CustomTheme.standardBoxDecoration,
onBeforePopup: () async {
await HapticFeedback.selectionClick();
},
onAfterPopup: () async {
await HapticFeedback.selectionClick();
},
content: StatefulBuilder( content: StatefulBuilder(
builder: (context, setPopupState) => SizedBox( builder: (context, setPopupState) => SizedBox(
width: 150, width: 150,
@@ -422,7 +436,8 @@ class _CreateGameViewState extends State<CreateGameView> {
children: List.generate( children: List.generate(
_colors.length, _colors.length,
(index) => GestureDetector( (index) => GestureDetector(
onTap: () { onTap: () async {
await HapticFeedback.selectionClick();
setState(() { setState(() {
selectedColor = _colors[index].$1; selectedColor = _colors[index].$1;
}); });

View File

@@ -172,7 +172,6 @@ class _CreateMatchViewState extends State<CreateMatchView> {
) ?? ) ??
false, false,
); );
selectedGroup = await Navigator.of(context).push( selectedGroup = await Navigator.of(context).push(
adaptivePageRoute( adaptivePageRoute(
builder: (context) => ChooseGroupView( builder: (context) => ChooseGroupView(

View File

@@ -31,12 +31,14 @@ class _ChooseTileState extends State<ChooseTile> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( return GestureDetector(
onTap: () async { onTap: widget.onPressed != null
await HapticFeedback.vibrate(); ? () async {
if (widget.onPressed != null) { await HapticFeedback.selectionClick();
widget.onPressed!.call(); if (widget.onPressed != null) {
} widget.onPressed!.call();
}, }
}
: null,
child: Container( child: Container(
margin: CustomTheme.tileMargin, margin: CustomTheme.tileMargin,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:tallee/core/common.dart'; import 'package:tallee/core/common.dart';
import 'package:tallee/core/custom_theme.dart'; import 'package:tallee/core/custom_theme.dart';
import 'package:tallee/core/enums.dart'; import 'package:tallee/core/enums.dart';
@@ -53,8 +54,18 @@ class GameTile extends StatelessWidget {
final gameColor = badgeColor ?? getColorFromGameColor(GameColor.orange); final gameColor = badgeColor ?? getColorFromGameColor(GameColor.orange);
return GestureDetector( return GestureDetector(
onTap: onTap, onTap: () async {
onLongPress: onLongPress, await HapticFeedback.selectionClick();
if (onTap != null) {
onTap!.call();
}
},
onLongPress: () async {
await HapticFeedback.vibrate();
if (onLongPress != null) {
onLongPress!.call();
}
},
child: AnimatedContainer( child: AnimatedContainer(
margin: const EdgeInsets.symmetric(vertical: 10, horizontal: 10), margin: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
decoration: !isHighlighted decoration: !isHighlighted

View File

@@ -36,7 +36,9 @@ class _GroupTileState extends State<GroupTile> {
return GestureDetector( return GestureDetector(
onTap: () async { onTap: () async {
await HapticFeedback.selectionClick(); await HapticFeedback.selectionClick();
widget.onTap?.call(); if (widget.onTap != null) {
widget.onTap!.call();
}
}, },
child: AnimatedContainer( child: AnimatedContainer(
margin: CustomTheme.standardMargin, margin: CustomTheme.standardMargin,