Merge branch 'develop' into enhance/68-improve-file-import
# Conflicts: # pubspec.yaml
This commit is contained in:
3
devtools_options.yaml
Normal file
3
devtools_options.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
description: This file stores settings for Dart & Flutter DevTools.
|
||||||
|
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
|
||||||
|
extensions:
|
||||||
@@ -72,11 +72,13 @@ class GameSession extends ChangeNotifier {
|
|||||||
roundList =
|
roundList =
|
||||||
(json['roundList'] as List).map((e) => Round.fromJson(e)).toList();
|
(json['roundList'] as List).map((e) => Round.fromJson(e)).toList();
|
||||||
|
|
||||||
/// Returns the length of all player names combined.
|
/// Returns the length of the longest player name.
|
||||||
int getLengthOfPlayerNames() {
|
int getMaxLengthOfPlayerNames() {
|
||||||
int length = 0;
|
int length = 0;
|
||||||
for (String player in players) {
|
for (String player in players) {
|
||||||
length += player.length;
|
if (player.length >= length) {
|
||||||
|
length = player.length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ class _CreateGameState extends State<CreateGame> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: CupertinoTextField(
|
child: CupertinoTextField(
|
||||||
controller: _playerNameTextControllers[index],
|
controller: _playerNameTextControllers[index],
|
||||||
|
maxLength: 12,
|
||||||
placeholder:
|
placeholder:
|
||||||
'${AppLocalizations.of(context).player} ${index + 1}',
|
'${AppLocalizations.of(context).player} ${index + 1}',
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ class _RoundViewState extends State<RoundView> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final bottomInset = MediaQuery.of(context).viewInsets.bottom;
|
final bottomInset = MediaQuery.of(context).viewInsets.bottom;
|
||||||
|
final maxLength = widget.gameSession.getMaxLengthOfPlayerNames();
|
||||||
|
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
@@ -122,28 +123,21 @@ class _RoundViewState extends State<RoundView> {
|
|||||||
index,
|
index,
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
horizontal: widget.gameSession
|
horizontal: 4 +
|
||||||
.getLengthOfPlayerNames() >
|
_getSegmentedControlPadding(maxLength),
|
||||||
20
|
|
||||||
? (widget.gameSession
|
|
||||||
.getLengthOfPlayerNames() >
|
|
||||||
32
|
|
||||||
? 5
|
|
||||||
: 10)
|
|
||||||
: 15,
|
|
||||||
vertical: 6,
|
vertical: 6,
|
||||||
),
|
),
|
||||||
|
child: FittedBox(
|
||||||
|
fit: BoxFit.scaleDown,
|
||||||
child: Text(
|
child: Text(
|
||||||
name,
|
name,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: widget.gameSession
|
fontSize: _getSegmentedControlFontSize(
|
||||||
.getLengthOfPlayerNames() >
|
maxLength),
|
||||||
28
|
),
|
||||||
? 14
|
|
||||||
: 18,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -191,7 +185,13 @@ class _RoundViewState extends State<RoundView> {
|
|||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
child: CupertinoListTile(
|
child: CupertinoListTile(
|
||||||
backgroundColor: CupertinoColors.secondaryLabel,
|
backgroundColor: CupertinoColors.secondaryLabel,
|
||||||
title: Row(children: [Text(name)]),
|
title: Row(children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
name,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
))
|
||||||
|
]),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
'${widget.gameSession.playerScores[index]}'
|
'${widget.gameSession.playerScores[index]}'
|
||||||
' ${AppLocalizations.of(context).points}'),
|
' ${AppLocalizations.of(context).points}'),
|
||||||
@@ -395,6 +395,32 @@ class _RoundViewState extends State<RoundView> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double _getSegmentedControlFontSize(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 _getSegmentedControlPadding(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
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
for (final controller in _scoreControllerList) {
|
for (final controller in _scoreControllerList) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ name: cabo_counter
|
|||||||
description: "Mobile app for the card game Cabo"
|
description: "Mobile app for the card game Cabo"
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 0.3.2+254
|
version: 0.3.3+265
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.5.4
|
sdk: ^3.5.4
|
||||||
|
|||||||
@@ -61,9 +61,8 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
group('Helper Functions', () {
|
group('Helper Functions', () {
|
||||||
test('getLengthOfPlayerNames', () {
|
test('getMaxLengthOfPlayerNames', () {
|
||||||
expect(session.getLengthOfPlayerNames(),
|
expect(session.getMaxLengthOfPlayerNames(), equals(7)); // Charlie (7)
|
||||||
equals(15)); // Alice(5) + Bob(3) + Charlie(7)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('increaseRound', () {
|
test('increaseRound', () {
|
||||||
|
|||||||
Reference in New Issue
Block a user