sdf
This commit is contained in:
1 parent
4d377c1336
commit
02ab7f390d
3 files changed
+84
-31
No files matched your search
@@ -25,13 +25,14 @@
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"score": 1,
|
||||
"goal_type": 1,
|
||||
"elapsed": 88,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"goal_type": 0,
|
||||
"elapsed": 66,
|
||||
"team": 0
|
||||
}
|
||||
@@ -62,18 +63,21 @@
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 1,
|
||||
"elapsed": 88,
|
||||
"team": 1
|
||||
"team": 2
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:20:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 0,
|
||||
"elapsed": 32,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"goal_type": 2,
|
||||
"elapsed": 66,
|
||||
"team": 0
|
||||
}
|
||||
@@ -97,18 +101,21 @@
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"elapsed": 88,
|
||||
"goal_type": 2,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:20:00Z",
|
||||
"player": 32,
|
||||
"elapsed": 32,
|
||||
"goal_type": 1,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"elapsed": 66,
|
||||
"goal_type": 0,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../domain/models/hockey_game.dart' show CardType, Match, Team;
|
||||
|
||||
import '../../../../domain/models/hockey_game.dart'
|
||||
show CardType, GoalType, Match, Team;
|
||||
import '../view_models/match_results_view_model.dart';
|
||||
|
||||
class MatchResultsView extends StatelessWidget {
|
||||
@@ -25,9 +27,8 @@ class MatchResultsView extends StatelessWidget {
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: viewModel.matches.length,
|
||||
itemBuilder: (context, index) => _MatchCard(
|
||||
match: viewModel.matches[index],
|
||||
),
|
||||
itemBuilder: (context, index) =>
|
||||
_MatchCard(match: viewModel.matches[index]),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -46,17 +47,18 @@ class _MatchCard extends StatelessWidget {
|
||||
final date = DateTime.tryParse(match.datetime)?.toLocal();
|
||||
final dateLabel = date == null
|
||||
? match.datetime
|
||||
: '${date.year}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}';
|
||||
: '${date.year}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')} ${date.hour.toString().padLeft(2, '0')}:${date.minute.toString().padLeft(2, '0')}';
|
||||
|
||||
return Card(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
child: ExpansionTile(
|
||||
shape: const Border(),
|
||||
collapsedShape: const Border(),
|
||||
title: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(dateLabel, style: textTheme.labelLarge),
|
||||
const SizedBox(height: 12),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@@ -71,21 +73,35 @@ class _MatchCard extends StatelessWidget {
|
||||
const Text('Away'),
|
||||
],
|
||||
),
|
||||
if (match.goals.isNotEmpty || match.cards.isNotEmpty) ...[
|
||||
const Divider(height: 24),
|
||||
...match.goals.map((goal) => _EventLine(
|
||||
icon: Icons.sports_hockey,
|
||||
label: 'Goal · ${_teamName(goal.team)} · #${goal.player}',
|
||||
seconds: goal.seconds,
|
||||
)),
|
||||
...match.cards.map((card) => _EventLine(
|
||||
icon: Icons.style_outlined,
|
||||
label: '${_cardName(card.cardType)} card · ${_teamName(card.team)} · #${card.player}',
|
||||
seconds: card.seconds,
|
||||
)),
|
||||
],
|
||||
],
|
||||
),
|
||||
childrenPadding: const EdgeInsets.fromLTRB(16, 8, 16, 8),
|
||||
children: [
|
||||
...match.goals.map(
|
||||
(goal) => _EventLine(
|
||||
icon: Icons.sports_hockey,
|
||||
label:
|
||||
'${_goalTypeName(goal.goalType)} · ${_teamName(goal.team)} · #${goal.player}',
|
||||
seconds: goal.seconds,
|
||||
),
|
||||
),
|
||||
...match.cards.map(
|
||||
(card) => _EventLine(
|
||||
icon: Icons.style_outlined,
|
||||
label:
|
||||
'${_cardName(card.cardType)} card · ${_teamName(card.team)} · #${card.player} · ${card.duration}s',
|
||||
seconds: card.seconds,
|
||||
),
|
||||
),
|
||||
if (match.goals.isEmpty && match.cards.isEmpty)
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(bottom: 8),
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text('No recorded events'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -113,7 +129,10 @@ class _EventLine extends StatelessWidget {
|
||||
Icon(icon, size: 18, color: Theme.of(context).colorScheme.secondary),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(child: Text(label)),
|
||||
Text('$minute:$second', style: Theme.of(context).textTheme.labelMedium),
|
||||
Text(
|
||||
'$minute:$second',
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -122,8 +141,14 @@ class _EventLine extends StatelessWidget {
|
||||
|
||||
String _teamName(Team team) => team == Team.home ? 'Home' : 'Away';
|
||||
|
||||
String _goalTypeName(GoalType type) => switch (type) {
|
||||
GoalType.fieldGoal => 'Field goal',
|
||||
GoalType.shortCorner => 'Short corner',
|
||||
GoalType.penaltyStroke => 'Penalty stroke',
|
||||
};
|
||||
|
||||
String _cardName(CardType type) => switch (type) {
|
||||
CardType.red => 'Red',
|
||||
CardType.yellow => 'Yellow',
|
||||
CardType.green => 'Green',
|
||||
};
|
||||
CardType.red => 'Red',
|
||||
CardType.yellow => 'Yellow',
|
||||
CardType.green => 'Green',
|
||||
};
|
||||
@@ -1,15 +1,36 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mobile_app/app.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('App smoke test - renders match results, navigates to settings',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('App smoke test - renders match results, navigates to settings', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await tester.pumpWidget(const MobileApp());
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Match Results'), findsOneWidget);
|
||||
expect(find.text('Home'), findsWidgets);
|
||||
expect(find.text('Away'), findsWidgets);
|
||||
expect(
|
||||
find.textContaining(RegExp(r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}')),
|
||||
findsWidgets,
|
||||
);
|
||||
expect(find.text('Field goal · Away · #32'), findsNothing);
|
||||
|
||||
await tester.tap(
|
||||
find.textContaining(RegExp(r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}')).first,
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Field goal · Away · #32'), findsWidgets);
|
||||
expect(find.textContaining('card · Away · #5 · 120s'), findsWidgets);
|
||||
expect(find.byType(Divider), findsNothing);
|
||||
final matchTile = tester.widget<ExpansionTile>(
|
||||
find.byType(ExpansionTile).first,
|
||||
);
|
||||
expect(matchTile.shape, const Border());
|
||||
expect(matchTile.collapsedShape, const Border());
|
||||
|
||||
// Switch to Settings tab
|
||||
final settingsNav = find.text('Settings');
|
||||
|
||||
Reference in new issue
Block a user