Changed SegmendetControl size proportional to player names length
This commit is contained in:
@@ -30,6 +30,15 @@ class GameSession {
|
|||||||
'playerScores: $playerScores]');
|
'playerScores: $playerScores]');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getLengthOfPlayerNames() {
|
||||||
|
int length = 0;
|
||||||
|
for (String player in players) {
|
||||||
|
length += player.length;
|
||||||
|
}
|
||||||
|
print('Namenslänge: $length');
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns a string representation of the scores for a specific round.
|
/// Returns a string representation of the scores for a specific round.
|
||||||
/// The method takes a round number as a parameter and returns a string
|
/// The method takes a round number as a parameter and returns a string
|
||||||
/// containing the name of each player and their corressponding score in
|
/// containing the name of each player and their corressponding score in
|
||||||
|
|||||||
@@ -104,10 +104,13 @@ class _RoundViewState extends State<RoundView> {
|
|||||||
widget.gameSession.players.asMap().keys,
|
widget.gameSession.players.asMap().keys,
|
||||||
value: (index) => Padding(
|
value: (index) => Padding(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
horizontal: gameSession.players.length < 3
|
horizontal: gameSession.getLengthOfPlayerNames() >
|
||||||
? 15
|
20
|
||||||
: (gameSession.players.length > 4 ? 2 : 11),
|
? (gameSession.getLengthOfPlayerNames() > 32
|
||||||
),
|
? 5
|
||||||
|
: 10)
|
||||||
|
: 15,
|
||||||
|
vertical: 6),
|
||||||
child: Text(
|
child: Text(
|
||||||
widget.gameSession.players[index],
|
widget.gameSession.players[index],
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
@@ -115,7 +118,9 @@ class _RoundViewState extends State<RoundView> {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize:
|
fontSize:
|
||||||
gameSession.players.length > 3 ? 15 : 18),
|
gameSession.getLengthOfPlayerNames() > 28
|
||||||
|
? 14
|
||||||
|
: 18),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user