-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Show match-up list in the league page (closes #5)
- Loading branch information
Showing
6 changed files
with
102 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
wrestling_scoreboard_client/lib/ui/overview/shared/matches_widget.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
import 'package:wrestling_scoreboard_client/ui/components/consumer.dart'; | ||
import 'package:wrestling_scoreboard_client/ui/components/grouped_list.dart'; | ||
import 'package:wrestling_scoreboard_client/ui/edit/team_match_edit.dart'; | ||
import 'package:wrestling_scoreboard_client/ui/match/match_sequence.dart'; | ||
import 'package:wrestling_scoreboard_client/util/date_time.dart'; | ||
import 'package:wrestling_scoreboard_common/common.dart'; | ||
|
||
class MatchesWidget<T extends DataObject?> extends StatelessWidget { | ||
final T? filterObject; | ||
|
||
const MatchesWidget({super.key, required this.filterObject}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final localizations = AppLocalizations.of(context)!; | ||
return ManyConsumer<TeamMatch, T>( | ||
filterObject: filterObject, | ||
builder: (BuildContext context, List<TeamMatch> matches) { | ||
return ListGroup( | ||
header: HeadingItem( | ||
title: localizations.matches, | ||
trailing: IconButton( | ||
icon: const Icon(Icons.add), | ||
onPressed: () => | ||
Navigator.push( | ||
context, | ||
MaterialPageRoute( | ||
builder: (context) => | ||
TeamMatchEdit( | ||
initialHomeTeam: filterObject is Team ? filterObject as Team : null, | ||
initialGuestTeam: filterObject is Team ? filterObject as Team : null, | ||
), | ||
), | ||
), | ||
), | ||
), | ||
items: matches.map( | ||
(e) => | ||
SingleConsumer<TeamMatch>( | ||
id: e.id!, | ||
initialData: e, | ||
builder: (context, match) => | ||
ListTile( | ||
title: RichText( | ||
text: TextSpan( | ||
text: '${match!.date.toDateString(context)}, ${match.no ?? 'no ID'}, ', | ||
children: [ | ||
TextSpan( | ||
text: match.home.team.name, | ||
style: match.home.team == filterObject | ||
? const TextStyle(color: Colors.red, fontWeight: FontWeight.bold) | ||
: null), | ||
const TextSpan(text: ' - '), | ||
TextSpan( | ||
text: match.guest.team.name, | ||
style: match.guest.team == filterObject | ||
? const TextStyle(color: Colors.blue, fontWeight: FontWeight.bold) | ||
: null), | ||
], | ||
), | ||
), | ||
leading: const Icon(Icons.event), | ||
onTap: () => handleSelectedMatch(match, context), | ||
), | ||
), | ||
), | ||
); | ||
}, | ||
); | ||
} | ||
|
||
handleSelectedMatch(TeamMatch match, BuildContext context) async { | ||
Navigator.push(context, MaterialPageRoute(builder: (context) => MatchSequence(match))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters