refactoring
This commit is contained in:
@@ -70,7 +70,7 @@ class _CreateTeamsViewState extends State<CreateTeamsView> {
|
|||||||
hintText: '${loc.team} ${index + 1}',
|
hintText: '${loc.team} ${index + 1}',
|
||||||
onDelete: teams.length <= 2
|
onDelete: teams.length <= 2
|
||||||
? null
|
? null
|
||||||
: () => _removeTeam(index),
|
: () => removeTeam(index),
|
||||||
onColorSelection: (color) {
|
onColorSelection: (color) {
|
||||||
setState(() {
|
setState(() {
|
||||||
teams[index] = teams[index].copyWith(color: color);
|
teams[index] = teams[index].copyWith(color: color);
|
||||||
@@ -121,16 +121,6 @@ class _CreateTeamsViewState extends State<CreateTeamsView> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a new team to the list of teams, creates a corresponding controller,
|
|
||||||
/// and redistributes the players among all teams.
|
|
||||||
void addTeam() {
|
|
||||||
setState(() {
|
|
||||||
final newTeam = getNewTeam();
|
|
||||||
teams.add(newTeam);
|
|
||||||
nameController.add(getNewController(newTeam));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a new team with a default name and color based on the current number
|
/// Creates a new team with a default name and color based on the current number
|
||||||
Team getNewTeam() {
|
Team getNewTeam() {
|
||||||
final loc = AppLocalizations.of(context);
|
final loc = AppLocalizations.of(context);
|
||||||
@@ -153,9 +143,19 @@ class _CreateTeamsViewState extends State<CreateTeamsView> {
|
|||||||
return textController;
|
return textController;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Adds a new team to the list of teams, creates a corresponding controller,
|
||||||
|
/// and redistributes the players among all teams.
|
||||||
|
void addTeam() {
|
||||||
|
setState(() {
|
||||||
|
final newTeam = getNewTeam();
|
||||||
|
teams.add(newTeam);
|
||||||
|
nameController.add(getNewController(newTeam));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// Removes the team with the given index. If there are less than 2 teams the
|
/// Removes the team with the given index. If there are less than 2 teams the
|
||||||
/// removed team gets replaced with a new one
|
/// removed team gets replaced with a new one
|
||||||
void _removeTeam(int index) {
|
void removeTeam(int index) {
|
||||||
final loc = AppLocalizations.of(context);
|
final loc = AppLocalizations.of(context);
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|||||||
Reference in New Issue
Block a user