Updated responsive design in segmented control

This commit is contained in:
2025-06-29 01:56:32 +02:00
parent 9cf4a6947a
commit 3da8c886ff
3 changed files with 43 additions and 16 deletions

View File

@@ -67,6 +67,7 @@ class _RoundViewState extends State<RoundView> {
@override
Widget build(BuildContext context) {
final bottomInset = MediaQuery.of(context).viewInsets.bottom;
final maxLength = widget.gameSession.getMaxLengthOfPlayerNames();
return CupertinoPageScaffold(
resizeToAvoidBottomInset: false,
@@ -122,15 +123,8 @@ class _RoundViewState extends State<RoundView> {
index,
Padding(
padding: EdgeInsets.symmetric(
horizontal: widget.gameSession
.getLengthOfPlayerNames() >
20
? (widget.gameSession
.getLengthOfPlayerNames() >
32
? 5
: 10)
: 15,
horizontal:
_getSegmendetControlPadding(maxLength),
vertical: 6,
),
child: Text(
@@ -139,11 +133,9 @@ class _RoundViewState extends State<RoundView> {
maxLines: 1,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: widget.gameSession
.getLengthOfPlayerNames() >
28
? 14
: 18,
fontSize: _getSegmendetControlFontSize(
widget.gameSession
.getMaxLengthOfPlayerNames()),
),
),
),
@@ -191,7 +183,13 @@ class _RoundViewState extends State<RoundView> {
borderRadius: BorderRadius.circular(12),
child: CupertinoListTile(
backgroundColor: CupertinoColors.secondaryLabel,
title: Row(children: [Text(name)]),
title: Row(children: [
Expanded(
child: Text(
name,
overflow: TextOverflow.ellipsis,
))
]),
subtitle: Text(
'${widget.gameSession.playerScores[index]}'
' ${AppLocalizations.of(context).points}'),
@@ -395,6 +393,32 @@ class _RoundViewState extends State<RoundView> {
}
}
double _getSegmendetControlFontSize(int maxLength) {
if (maxLength > 8) {
// 9 - 12 characters
return 9.0;
} else if (maxLength > 4) {
// 5 - 8 characters
return 15.0;
} else {
// 0 - 4 characters
return 18.0;
}
}
double _getSegmendetControlPadding(int maxLength) {
if (maxLength > 8) {
// 9 - 12 characters
return 0.0;
} else if (maxLength > 4) {
// 5 - 8 characters
return 5.0;
} else {
// 0 - 4 characters
return 8.0;
}
}
@override
void dispose() {
for (final controller in _scoreControllerList) {