diff --git a/lib/data/game_session.dart b/lib/data/game_session.dart index ca3751d..5895cd1 100644 --- a/lib/data/game_session.dart +++ b/lib/data/game_session.dart @@ -30,6 +30,15 @@ class GameSession { '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. /// The method takes a round number as a parameter and returns a string /// containing the name of each player and their corressponding score in diff --git a/lib/views/round_view.dart b/lib/views/round_view.dart index 804d5c6..cee71f1 100644 --- a/lib/views/round_view.dart +++ b/lib/views/round_view.dart @@ -104,10 +104,13 @@ class _RoundViewState extends State { widget.gameSession.players.asMap().keys, value: (index) => Padding( padding: EdgeInsets.symmetric( - horizontal: gameSession.players.length < 3 - ? 15 - : (gameSession.players.length > 4 ? 2 : 11), - ), + horizontal: gameSession.getLengthOfPlayerNames() > + 20 + ? (gameSession.getLengthOfPlayerNames() > 32 + ? 5 + : 10) + : 15, + vertical: 6), child: Text( widget.gameSession.players[index], textAlign: TextAlign.center, @@ -115,7 +118,9 @@ class _RoundViewState extends State { style: TextStyle( fontWeight: FontWeight.bold, fontSize: - gameSession.players.length > 3 ? 15 : 18), + gameSession.getLengthOfPlayerNames() > 28 + ? 14 + : 18), ), ), ),