Merge branch 'development' into feature/206-Neuer-Regelsatz-Platzierung
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 46s
Pull Request Pipeline / lint (pull_request) Successful in 48s

# Conflicts:
#	lib/l10n/generated/app_localizations.dart
#	lib/presentation/views/main_menu/match_view/match_detail_view.dart
#	lib/presentation/views/main_menu/match_view/match_result_view.dart
This commit is contained in:
2026-05-09 23:04:11 +02:00
14 changed files with 485 additions and 522 deletions

View File

@@ -89,7 +89,7 @@ class CustomWidthButton extends StatelessWidget {
MediaQuery.sizeOf(context).width * sizeRelativeToWidth,
60,
),
side: BorderSide(color: borderSideColor, width: 2),
side: BorderSide(color: borderSideColor, width: 3),
shape: RoundedRectangleBorder(
borderRadius: CustomTheme.standardBorderRadiusAll,
),

View File

@@ -1,3 +1,5 @@
import 'dart:async';
import 'package:flutter/material.dart';
class MainMenuButton extends StatefulWidget {
@@ -10,6 +12,7 @@ class MainMenuButton extends StatefulWidget {
required this.onPressed,
required this.icon,
this.text,
this.onLongPressed,
});
/// The callback to be invoked when the button is pressed.
@@ -21,6 +24,8 @@ class MainMenuButton extends StatefulWidget {
/// The text of the button.
final String? text;
final void Function()? onLongPressed;
@override
State<MainMenuButton> createState() => _MainMenuButtonState();
}
@@ -30,6 +35,14 @@ class _MainMenuButtonState extends State<MainMenuButton>
late AnimationController _animationController;
late Animation<double> _scaleAnimation;
/// How long the button needs to be pressed to register it as long press
Timer? _longPressTimer;
/// How much time between two onLongPressed calls
Timer? _repeatTimer;
bool _isLongPressing = false;
@override
void initState() {
super.initState();
@@ -51,14 +64,29 @@ class _MainMenuButtonState extends State<MainMenuButton>
child: GestureDetector(
onTapDown: (_) {
_animationController.forward();
},
onTapUp: (_) async {
await _animationController.reverse();
if (mounted) {
widget.onPressed();
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(),
);
});
}
},
onTapUp: (_) async {
_cancelTimers();
if (mounted && !_isLongPressing) {
widget.onPressed();
}
_isLongPressing = false;
await Future.delayed(const Duration(milliseconds: 100));
await _animationController.reverse();
},
onTapCancel: () {
_isLongPressing = false;
_cancelTimers();
_animationController.reverse();
},
child: Container(
@@ -92,7 +120,15 @@ class _MainMenuButtonState extends State<MainMenuButton>
@override
void dispose() {
_cancelTimers();
_animationController.dispose();
super.dispose();
}
void _cancelTimers() {
_longPressTimer?.cancel();
_longPressTimer = null;
_repeatTimer?.cancel();
_repeatTimer = null;
}
}

View File

@@ -0,0 +1,125 @@
import 'package:flutter/material.dart';
import 'package:flutter_numeric_text/flutter_numeric_text.dart';
import 'package:tallee/core/custom_theme.dart';
import 'package:tallee/presentation/widgets/buttons/main_menu_button.dart';
class LiveEditListTile extends StatefulWidget {
const LiveEditListTile({
super.key,
required this.title,
required this.value,
this.onChanged,
});
final String title;
final int value;
final void Function(int newValue)? onChanged;
@override
State<LiveEditListTile> createState() => _LiveEditListTileState();
}
class _LiveEditListTileState extends State<LiveEditListTile> {
int _score = 0;
final int maxScore = 9999;
final int minScore = -9999;
@override
void initState() {
_score = widget.value;
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 20),
margin: const EdgeInsets.symmetric(vertical: 12, horizontal: 8),
decoration: CustomTheme.standardBoxDecoration,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
MainMenuButton(
onPressed: () => _score > minScore
? {
setState(() {
_score--;
if (widget.onChanged != null) {
widget.onChanged!(_score);
}
}),
}
: null,
onLongPressed: () => _score > minScore
? {
setState(() {
_score -= 10;
if (widget.onChanged != null) {
widget.onChanged!(_score);
}
}),
}
: null,
icon: Icons.remove_rounded,
),
Expanded(
child: Column(
children: [
Text(
widget.title,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
),
),
SizedBox(
width: 150,
child: NumericText(
_score.toString(),
maxLines: 1,
textAlign: TextAlign.center,
textWidthBasis: TextWidthBasis.longestLine,
textHeightBehavior: const TextHeightBehavior(
applyHeightToFirstAscent: false,
applyHeightToLastDescent: false,
),
style: const TextStyle(
fontSize: 48,
fontWeight: FontWeight.w600,
),
),
),
],
),
),
MainMenuButton(
onPressed: () => _score < maxScore
? {
setState(() {
_score++;
if (widget.onChanged != null) {
widget.onChanged!(_score);
}
}),
}
: null,
onLongPressed: () => _score > minScore
? {
setState(() {
_score += 10;
if (widget.onChanged != null) {
widget.onChanged!(_score);
}
}),
}
: null,
icon: Icons.add_rounded,
),
],
),
);
}
}

View File

@@ -40,9 +40,13 @@ class ScoreListTile extends StatelessWidget {
height: 40,
child: TextField(
controller: controller,
keyboardType: TextInputType.number,
maxLength: 4,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
keyboardType: const TextInputType.numberWithOptions(signed: true),
maxLength: 5,
inputFormatters: [
TextInputFormatter.withFunction((oldValue, newValue) {
return isValidScoreInput(newValue.text) ? newValue : oldValue;
}),
],
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 16,
@@ -62,7 +66,7 @@ class ScoreListTile extends StatelessWidget {
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(
color: CustomTheme.textColor.withAlpha(100),
color: CustomTheme.textColor.withAlpha(250),
width: 2,
),
),
@@ -80,4 +84,21 @@ class ScoreListTile extends StatelessWidget {
),
);
}
/// Validates the input for the score text field.
bool isValidScoreInput(String text) {
if (text.isEmpty || text == '-') {
return true;
}
final isNegative = text.startsWith('-');
final digits = isNegative ? text.substring(1) : text;
if (digits.isEmpty || digits.length > 4) {
return false;
}
// CHeck if all characters are digits 0 <= x <= 9
return digits.codeUnits.every((unit) => unit >= 48 && unit <= 57);
}
}