Different scroll management in round view
This commit is contained in:
@@ -39,12 +39,11 @@ class _RoundViewState extends State<RoundView> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
print('Runde ${widget.roundNumber} geöffnet');
|
print('=== Runde ${widget.roundNumber} geöffnet ===');
|
||||||
print('Neuste Runde: ${widget.gameSession.round}');
|
if (widget.roundNumber < widget.gameSession.round ||
|
||||||
if (widget.roundNumber < widget.gameSession.round) {
|
widget.gameSession.finished == true) {
|
||||||
print('Die Runde ${widget.roundNumber} ist kleiner als die neuste '
|
print('Die Runde ${widget.roundNumber} wurde bereits gespielt, deshalb '
|
||||||
'Runde ${widget.gameSession.round}, somit werden '
|
'werden die alten Punktestaende angezeigt');
|
||||||
'die bereits eingetragenen Punkte angezeigt.');
|
|
||||||
|
|
||||||
// If the current round has already been played, the text fields
|
// If the current round has already been played, the text fields
|
||||||
// are filled with the scores from this round
|
// are filled with the scores from this round
|
||||||
@@ -56,235 +55,253 @@ class _RoundViewState extends State<RoundView> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final bottomInset = MediaQuery.of(context).viewInsets.bottom;
|
||||||
|
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: CupertinoNavigationBar(
|
||||||
transitionBetweenRoutes: true,
|
transitionBetweenRoutes: true,
|
||||||
middle: const Text('Ergebnisse'),
|
middle: const Text('Ergebnisse'),
|
||||||
previousPageTitle: 'Übersicht',
|
previousPageTitle: 'Übersicht',
|
||||||
leading: CupertinoButton(
|
leading: CupertinoButton(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
onPressed: () => Navigator.pop(context, widget.gameSession),
|
onPressed: () => Navigator.pop(context, widget.gameSession),
|
||||||
child: Text('Abbrechen'),
|
child: const Text('Abbrechen'),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: Stack(
|
),
|
||||||
children: [
|
child: Stack(
|
||||||
SafeArea(
|
children: [
|
||||||
|
Positioned.fill(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: EdgeInsets.only(bottom: 100 + bottomInset),
|
||||||
|
child: SafeArea(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
const SizedBox(height: 40),
|
||||||
padding: const EdgeInsets.fromLTRB(0, 40, 0, 50),
|
Text('Runde ${widget.roundNumber}',
|
||||||
child: Text(
|
style: theme.roundTitle),
|
||||||
'Runde ${widget.roundNumber}',
|
const SizedBox(height: 10),
|
||||||
style: theme.roundTitle,
|
const Text(
|
||||||
),
|
'Wer hat CABO gesagt?',
|
||||||
),
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
Padding(
|
),
|
||||||
padding: const EdgeInsets.fromLTRB(0, 0, 0, 10),
|
Padding(
|
||||||
child: Text('Wer hat CABO gesagt?',
|
padding: EdgeInsets.symmetric(
|
||||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
horizontal:
|
||||||
),
|
widget.gameSession.players.length > 3 ? 5 : 20,
|
||||||
Padding(
|
vertical: 10,
|
||||||
padding: EdgeInsets.symmetric(
|
),
|
||||||
horizontal: gameSession.players.length > 3 ? 5 : 20,
|
child: SizedBox(
|
||||||
vertical: 10),
|
height: 40,
|
||||||
child: SizedBox(
|
child: CupertinoSegmentedControl<int>(
|
||||||
height: 40,
|
unselectedColor: theme.backgroundTintColor,
|
||||||
child: CupertinoSegmentedControl<int>(
|
selectedColor: theme.primaryColor,
|
||||||
unselectedColor: theme.backgroundTintColor,
|
groupValue: _caboPlayerIndex,
|
||||||
selectedColor: theme.primaryColor,
|
children: Map.fromEntries(widget.gameSession.players
|
||||||
groupValue: _caboPlayerIndex,
|
.asMap()
|
||||||
children: Map<int, Widget>.fromIterable(
|
.entries
|
||||||
widget.gameSession.players.asMap().keys,
|
.map((entry) {
|
||||||
value: (index) => Padding(
|
final index = entry.key;
|
||||||
padding: EdgeInsets.symmetric(
|
final name = entry.value;
|
||||||
horizontal: gameSession.getLengthOfPlayerNames() >
|
return MapEntry(
|
||||||
20
|
index,
|
||||||
? (gameSession.getLengthOfPlayerNames() > 32
|
Padding(
|
||||||
? 5
|
padding: EdgeInsets.symmetric(
|
||||||
: 10)
|
horizontal: widget.gameSession
|
||||||
: 15,
|
.getLengthOfPlayerNames() >
|
||||||
vertical: 6),
|
20
|
||||||
child: Text(
|
? (widget.gameSession
|
||||||
widget.gameSession.players[index],
|
.getLengthOfPlayerNames() >
|
||||||
textAlign: TextAlign.center,
|
32
|
||||||
maxLines: 1,
|
? 5
|
||||||
style: TextStyle(
|
: 10)
|
||||||
fontWeight: FontWeight.bold,
|
: 15,
|
||||||
fontSize:
|
vertical: 6,
|
||||||
gameSession.getLengthOfPlayerNames() > 28
|
),
|
||||||
|
child: Text(
|
||||||
|
name,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
maxLines: 1,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: widget.gameSession
|
||||||
|
.getLengthOfPlayerNames() >
|
||||||
|
28
|
||||||
? 14
|
? 14
|
||||||
: 18),
|
: 18,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
})),
|
||||||
|
onValueChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
_caboPlayerIndex = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onValueChanged: (int value) {
|
|
||||||
setState(() {
|
|
||||||
_caboPlayerIndex = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
Padding(
|
||||||
),
|
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||||
Padding(
|
child: CupertinoListTile(
|
||||||
padding:
|
title: const Text('Spieler:in'),
|
||||||
EdgeInsets.symmetric(vertical: 0.0, horizontal: 20.0),
|
trailing: Row(
|
||||||
child: CupertinoListTile(
|
children: const [
|
||||||
title: Text('Spieler:in'),
|
SizedBox(
|
||||||
trailing: Row(
|
width: 100,
|
||||||
children: [
|
child: Center(child: Text('Punkte'))),
|
||||||
SizedBox(
|
SizedBox(width: 28),
|
||||||
width: 100,
|
SizedBox(
|
||||||
child: Center(child: Text('Punkte')),
|
width: 70,
|
||||||
|
child: Center(child: Text('Kamikaze'))),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
SizedBox(width: 28),
|
),
|
||||||
SizedBox(
|
|
||||||
width: 70,
|
|
||||||
child: Center(child: Text('Kamikaze')),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
ListView.builder(
|
||||||
),
|
shrinkWrap: true,
|
||||||
Expanded(
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
child: ListView.builder(
|
itemCount: widget.gameSession.players.length,
|
||||||
shrinkWrap: true,
|
itemBuilder: (context, index) {
|
||||||
itemCount: widget.gameSession.players.length,
|
final name = widget.gameSession.players[index];
|
||||||
itemBuilder: (BuildContext context, int index) {
|
return Padding(
|
||||||
return Padding(
|
padding: const EdgeInsets.symmetric(
|
||||||
padding: EdgeInsets.symmetric(
|
vertical: 10, horizontal: 20),
|
||||||
vertical: 10.0, horizontal: 20.0),
|
child: ClipRRect(
|
||||||
child: ClipRRect(
|
borderRadius: BorderRadius.circular(12),
|
||||||
borderRadius:
|
|
||||||
BorderRadius.circular(12), // Radius der Ecken
|
|
||||||
child: CupertinoListTile(
|
child: CupertinoListTile(
|
||||||
backgroundColor: CupertinoColors.secondaryLabel,
|
backgroundColor: CupertinoColors.secondaryLabel,
|
||||||
title: Row(
|
title: Row(children: [Text(name)]),
|
||||||
children: [
|
subtitle: Text(
|
||||||
Text(widget.gameSession.players[index]),
|
'${widget.gameSession.playerScores[index][0]} Punkte'),
|
||||||
],
|
trailing: Row(
|
||||||
),
|
children: [
|
||||||
subtitle: Text(
|
SizedBox(
|
||||||
'${widget.gameSession.playerScores[index][0]}'
|
width: 100,
|
||||||
' Punkte',
|
child: CupertinoTextField(
|
||||||
),
|
maxLength: 3,
|
||||||
trailing: Row(
|
focusNode: _focusNodeList[index],
|
||||||
children: [
|
keyboardType:
|
||||||
SizedBox(
|
const TextInputType.numberWithOptions(
|
||||||
width: 100,
|
signed: true,
|
||||||
child: CupertinoTextField(
|
decimal: false,
|
||||||
maxLength: 3,
|
|
||||||
focusNode: _focusNodeList[index],
|
|
||||||
keyboardType:
|
|
||||||
TextInputType.numberWithOptions(
|
|
||||||
signed: true,
|
|
||||||
decimal: false,
|
|
||||||
),
|
|
||||||
inputFormatters: [
|
|
||||||
FilteringTextInputFormatter
|
|
||||||
.digitsOnly,
|
|
||||||
],
|
|
||||||
textInputAction: index ==
|
|
||||||
widget.gameSession.players
|
|
||||||
.length -
|
|
||||||
1
|
|
||||||
? TextInputAction.done
|
|
||||||
: TextInputAction.next,
|
|
||||||
controller: _scoreControllerList[index],
|
|
||||||
placeholder: 'Punkte',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
onSubmitted: (_) =>
|
|
||||||
_focusNextTextfield(index),
|
|
||||||
),
|
),
|
||||||
|
inputFormatters: [
|
||||||
|
FilteringTextInputFormatter.digitsOnly,
|
||||||
|
],
|
||||||
|
textInputAction: index ==
|
||||||
|
widget.gameSession.players
|
||||||
|
.length -
|
||||||
|
1
|
||||||
|
? TextInputAction.done
|
||||||
|
: TextInputAction.next,
|
||||||
|
controller: _scoreControllerList[index],
|
||||||
|
placeholder: 'Punkte',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
onSubmitted: (_) =>
|
||||||
|
_focusNextTextfield(index),
|
||||||
),
|
),
|
||||||
SizedBox(width: 50),
|
),
|
||||||
GestureDetector(
|
const SizedBox(width: 50),
|
||||||
onTap: () {
|
GestureDetector(
|
||||||
setState(() {
|
onTap: () {
|
||||||
_kamikazePlayerIndex =
|
setState(() {
|
||||||
(_kamikazePlayerIndex == index)
|
_kamikazePlayerIndex =
|
||||||
? null
|
(_kamikazePlayerIndex == index)
|
||||||
: index;
|
? null
|
||||||
});
|
: index;
|
||||||
},
|
});
|
||||||
child: Container(
|
},
|
||||||
width: 24,
|
child: Container(
|
||||||
height: 24,
|
width: 24,
|
||||||
decoration: BoxDecoration(
|
height: 24,
|
||||||
shape: BoxShape.circle,
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: _kamikazePlayerIndex == index
|
||||||
|
? CupertinoColors.systemRed
|
||||||
|
: CupertinoColors
|
||||||
|
.tertiarySystemFill,
|
||||||
|
border: Border.all(
|
||||||
color: _kamikazePlayerIndex == index
|
color: _kamikazePlayerIndex == index
|
||||||
? CupertinoColors.systemRed
|
? CupertinoColors.systemRed
|
||||||
: CupertinoColors
|
: CupertinoColors.systemGrey,
|
||||||
.tertiarySystemFill,
|
|
||||||
border: Border.all(
|
|
||||||
color: _kamikazePlayerIndex == index
|
|
||||||
? CupertinoColors.systemRed
|
|
||||||
: CupertinoColors.systemGrey,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: _kamikazePlayerIndex == index
|
|
||||||
? Icon(
|
|
||||||
CupertinoIcons.exclamationmark,
|
|
||||||
size: 16,
|
|
||||||
color: CupertinoColors.white)
|
|
||||||
: null,
|
|
||||||
),
|
),
|
||||||
|
child: _kamikazePlayerIndex == index
|
||||||
|
? const Icon(
|
||||||
|
CupertinoIcons.exclamationmark,
|
||||||
|
size: 16,
|
||||||
|
color: CupertinoColors.white,
|
||||||
|
)
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
SizedBox(width: 22),
|
),
|
||||||
],
|
const SizedBox(width: 22),
|
||||||
))));
|
],
|
||||||
},
|
),
|
||||||
)),
|
),
|
||||||
],
|
),
|
||||||
)),
|
);
|
||||||
Positioned(
|
},
|
||||||
bottom: 0,
|
),
|
||||||
left: 0,
|
],
|
||||||
right: 0,
|
|
||||||
child: Container(
|
|
||||||
height: 80,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: theme.backgroundTintColor,
|
|
||||||
),
|
),
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.fromLTRB(0, 0, 0, 20),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
CupertinoButton(
|
|
||||||
onPressed: _areRoundInputsValid()
|
|
||||||
? () => {
|
|
||||||
_finishRound(),
|
|
||||||
Navigator.pop(context, widget.gameSession)
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
child: const Text('Fertig'),
|
|
||||||
),
|
|
||||||
CupertinoButton(
|
|
||||||
onPressed: _areRoundInputsValid()
|
|
||||||
? () => {
|
|
||||||
_finishRound(),
|
|
||||||
Navigator.pushReplacement(context,
|
|
||||||
CupertinoPageRoute(
|
|
||||||
builder: (context) {
|
|
||||||
return RoundView(
|
|
||||||
gameSession: widget.gameSession,
|
|
||||||
roundNumber:
|
|
||||||
widget.roundNumber + 1);
|
|
||||||
})),
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
child: const Text('Nächste Runde')),
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
));
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: bottomInset,
|
||||||
|
child: Container(
|
||||||
|
height: 80,
|
||||||
|
padding: const EdgeInsets.only(bottom: 20),
|
||||||
|
color: theme.backgroundTintColor,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: [
|
||||||
|
CupertinoButton(
|
||||||
|
onPressed: _areRoundInputsValid()
|
||||||
|
? () {
|
||||||
|
_finishRound();
|
||||||
|
Navigator.pop(context, widget.gameSession);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
child: const Text('Fertig'),
|
||||||
|
),
|
||||||
|
CupertinoButton(
|
||||||
|
onPressed: _areRoundInputsValid()
|
||||||
|
? () {
|
||||||
|
_finishRound();
|
||||||
|
if (widget.gameSession.finished == true) {
|
||||||
|
Navigator.pop(context, widget.gameSession);
|
||||||
|
} else {
|
||||||
|
Navigator.pushReplacement(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) => RoundView(
|
||||||
|
gameSession: widget.gameSession,
|
||||||
|
roundNumber: widget.roundNumber + 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
child: const Text('Nächste Runde'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Focuses the next text field in the list of text fields.
|
/// Focuses the next text field in the list of text fields.
|
||||||
@@ -332,13 +349,19 @@ class _RoundViewState extends State<RoundView> {
|
|||||||
print('Alte Punktestaende:');
|
print('Alte Punktestaende:');
|
||||||
print(gameSession.printRoundScores(widget.roundNumber));
|
print(gameSession.printRoundScores(widget.roundNumber));
|
||||||
}
|
}
|
||||||
if (widget.roundNumber >= widget.gameSession.playerScores[0].length) {
|
|
||||||
gameSession.expandPlayerScoreLists();
|
|
||||||
print('Das Punkte-Array wurde erweitert');
|
|
||||||
}
|
|
||||||
_calculateScoredPoints();
|
_calculateScoredPoints();
|
||||||
widget.gameSession.sumPoints();
|
widget.gameSession.sumPoints();
|
||||||
widget.gameSession.increaseRound();
|
if (widget.gameSession.finished == true) {
|
||||||
|
print('Das Spiel ist beendet');
|
||||||
|
} else {
|
||||||
|
if (widget.roundNumber >= widget.gameSession.playerScores[0].length - 1) {
|
||||||
|
gameSession.expandPlayerScoreLists();
|
||||||
|
print('Das Punkte-Array wurde erweitert');
|
||||||
|
}
|
||||||
|
widget.gameSession.increaseRound();
|
||||||
|
}
|
||||||
|
|
||||||
print('Die Punktesummen wurden aktualisiert');
|
print('Die Punktesummen wurden aktualisiert');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user