Merge branch 'development' into feature/168-teamspiele-implementieren
# Conflicts: # lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart # lib/presentation/views/main_menu/match_view/match_detail_view.dart # lib/presentation/views/main_menu/match_view/match_result_view.dart # lib/presentation/widgets/buttons/main_menu_button.dart # pubspec.yaml
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:tallee/core/custom_theme.dart';
|
||||
import 'package:tallee/core/enums.dart';
|
||||
|
||||
@@ -48,7 +49,12 @@ class CustomWidthButton extends StatelessWidget {
|
||||
)!;
|
||||
|
||||
return ElevatedButton(
|
||||
onPressed: onPressed,
|
||||
onPressed: onPressed == null
|
||||
? null
|
||||
: () async {
|
||||
await HapticFeedback.selectionClick();
|
||||
onPressed!.call();
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
foregroundColor: textcolor,
|
||||
disabledForegroundColor: disabledTextColor,
|
||||
@@ -78,7 +84,12 @@ class CustomWidthButton extends StatelessWidget {
|
||||
: Color.lerp(CustomTheme.primaryColor, Colors.black, 0.5)!;
|
||||
|
||||
return OutlinedButton(
|
||||
onPressed: onPressed,
|
||||
onPressed: onPressed == null
|
||||
? null
|
||||
: () async {
|
||||
await HapticFeedback.selectionClick();
|
||||
onPressed!.call();
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: textcolor,
|
||||
disabledForegroundColor: disabledTextColor,
|
||||
@@ -110,7 +121,12 @@ class CustomWidthButton extends StatelessWidget {
|
||||
disabledBackgroundColor = Colors.transparent;
|
||||
|
||||
return TextButton(
|
||||
onPressed: onPressed,
|
||||
onPressed: onPressed == null
|
||||
? null
|
||||
: () async {
|
||||
await HapticFeedback.selectionClick();
|
||||
onPressed!.call();
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: textcolor,
|
||||
disabledForegroundColor: disabledTextColor,
|
||||
|
||||
23
lib/presentation/widgets/buttons/haptic_back_button.dart
Normal file
23
lib/presentation/widgets/buttons/haptic_back_button.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tallee/presentation/widgets/buttons/haptic_icon_button.dart';
|
||||
|
||||
class HapticBackButton extends StatelessWidget {
|
||||
const HapticBackButton({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final iconData = switch (defaultTargetPlatform) {
|
||||
TargetPlatform.iOS ||
|
||||
TargetPlatform.macOS => Icons.arrow_back_ios_new_rounded,
|
||||
_ => Icons.arrow_back_rounded,
|
||||
};
|
||||
|
||||
return HapticIconButton(
|
||||
icon: Icon(iconData),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).maybePop();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
23
lib/presentation/widgets/buttons/haptic_close_button.dart
Normal file
23
lib/presentation/widgets/buttons/haptic_close_button.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tallee/presentation/widgets/buttons/haptic_icon_button.dart';
|
||||
|
||||
class HapticCloseButton extends StatelessWidget {
|
||||
const HapticCloseButton({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final iconData = switch (defaultTargetPlatform) {
|
||||
TargetPlatform.iOS || TargetPlatform.macOS => CupertinoIcons.xmark,
|
||||
_ => Icons.close_rounded,
|
||||
};
|
||||
|
||||
return HapticIconButton(
|
||||
icon: Icon(iconData),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).maybePop();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
51
lib/presentation/widgets/buttons/haptic_icon_button.dart
Normal file
51
lib/presentation/widgets/buttons/haptic_icon_button.dart
Normal file
@@ -0,0 +1,51 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class HapticIconButton extends StatelessWidget {
|
||||
const HapticIconButton({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.onPressed,
|
||||
this.iconSize,
|
||||
this.color,
|
||||
this.padding,
|
||||
this.alignment,
|
||||
this.constraints,
|
||||
this.style,
|
||||
this.isSelected,
|
||||
this.selectedIcon,
|
||||
});
|
||||
|
||||
final Widget icon;
|
||||
final VoidCallback? onPressed;
|
||||
final double? iconSize;
|
||||
final Color? color;
|
||||
final EdgeInsetsGeometry? padding;
|
||||
final AlignmentGeometry? alignment;
|
||||
final BoxConstraints? constraints;
|
||||
final ButtonStyle? style;
|
||||
final bool? isSelected;
|
||||
final Widget? selectedIcon;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return IconButton(
|
||||
iconSize: iconSize,
|
||||
highlightColor: Colors.transparent, //disable splash animation
|
||||
color: color,
|
||||
padding: padding,
|
||||
alignment: alignment ?? Alignment.center,
|
||||
constraints: constraints,
|
||||
style: style,
|
||||
isSelected: isSelected,
|
||||
selectedIcon: selectedIcon,
|
||||
icon: icon,
|
||||
onPressed: onPressed == null
|
||||
? null
|
||||
: () async {
|
||||
await HapticFeedback.selectionClick();
|
||||
onPressed!.call();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class MainMenuButton extends StatefulWidget {
|
||||
/// A button for the main menu with an optional icon and a press animation.
|
||||
@@ -84,14 +85,21 @@ class _MainMenuButtonState extends State<MainMenuButton>
|
||||
} else {
|
||||
_animationController.forward();
|
||||
if (widget.onLongPressed != null) {
|
||||
_longPressTimer = Timer(const Duration(milliseconds: 400), () {
|
||||
_isLongPressing = true;
|
||||
widget.onLongPressed?.call();
|
||||
_repeatTimer = Timer.periodic(
|
||||
const Duration(milliseconds: 250),
|
||||
(_) => widget.onLongPressed?.call(),
|
||||
);
|
||||
});
|
||||
_longPressTimer = Timer(
|
||||
const Duration(milliseconds: 400),
|
||||
() async {
|
||||
_isLongPressing = true;
|
||||
widget.onLongPressed?.call();
|
||||
await HapticFeedback.heavyImpact();
|
||||
_repeatTimer = Timer.periodic(
|
||||
const Duration(milliseconds: 250),
|
||||
(_) async {
|
||||
widget.onLongPressed?.call();
|
||||
await HapticFeedback.heavyImpact();
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -101,6 +109,7 @@ class _MainMenuButtonState extends State<MainMenuButton>
|
||||
} else {
|
||||
_cancelTimers();
|
||||
if (mounted && !_isLongPressing) {
|
||||
await HapticFeedback.selectionClick();
|
||||
widget.onPressed?.call();
|
||||
}
|
||||
_isLongPressing = false;
|
||||
|
||||
Reference in New Issue
Block a user