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",
|
"datetime": "2023-10-01T12:15:00Z",
|
||||||
"player": 32,
|
"player": 32,
|
||||||
"score": 1,
|
"goal_type": 1,
|
||||||
"elapsed": 88,
|
"elapsed": 88,
|
||||||
"team": 1
|
"team": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"datetime": "2023-10-01T12:30:00Z",
|
"datetime": "2023-10-01T12:30:00Z",
|
||||||
"player": 2,
|
"player": 2,
|
||||||
|
"goal_type": 0,
|
||||||
"elapsed": 66,
|
"elapsed": 66,
|
||||||
"team": 0
|
"team": 0
|
||||||
}
|
}
|
||||||
@@ -62,18 +63,21 @@
|
|||||||
{
|
{
|
||||||
"datetime": "2023-10-01T12:15:00Z",
|
"datetime": "2023-10-01T12:15:00Z",
|
||||||
"player": 32,
|
"player": 32,
|
||||||
|
"goal_type": 1,
|
||||||
"elapsed": 88,
|
"elapsed": 88,
|
||||||
"team": 1
|
"team": 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"datetime": "2023-10-01T12:20:00Z",
|
"datetime": "2023-10-01T12:20:00Z",
|
||||||
"player": 32,
|
"player": 32,
|
||||||
|
"goal_type": 0,
|
||||||
"elapsed": 32,
|
"elapsed": 32,
|
||||||
"team": 1
|
"team": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"datetime": "2023-10-01T12:30:00Z",
|
"datetime": "2023-10-01T12:30:00Z",
|
||||||
"player": 2,
|
"player": 2,
|
||||||
|
"goal_type": 2,
|
||||||
"elapsed": 66,
|
"elapsed": 66,
|
||||||
"team": 0
|
"team": 0
|
||||||
}
|
}
|
||||||
@@ -97,18 +101,21 @@
|
|||||||
"datetime": "2023-10-01T12:15:00Z",
|
"datetime": "2023-10-01T12:15:00Z",
|
||||||
"player": 32,
|
"player": 32,
|
||||||
"elapsed": 88,
|
"elapsed": 88,
|
||||||
|
"goal_type": 2,
|
||||||
"team": 1
|
"team": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"datetime": "2023-10-01T12:20:00Z",
|
"datetime": "2023-10-01T12:20:00Z",
|
||||||
"player": 32,
|
"player": 32,
|
||||||
"elapsed": 32,
|
"elapsed": 32,
|
||||||
|
"goal_type": 1,
|
||||||
"team": 1
|
"team": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"datetime": "2023-10-01T12:30:00Z",
|
"datetime": "2023-10-01T12:30:00Z",
|
||||||
"player": 2,
|
"player": 2,
|
||||||
"elapsed": 66,
|
"elapsed": 66,
|
||||||
|
"goal_type": 0,
|
||||||
"team": 0
|
"team": 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
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';
|
import '../view_models/match_results_view_model.dart';
|
||||||
|
|
||||||
class MatchResultsView extends StatelessWidget {
|
class MatchResultsView extends StatelessWidget {
|
||||||
@@ -25,9 +27,8 @@ class MatchResultsView extends StatelessWidget {
|
|||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
itemCount: viewModel.matches.length,
|
itemCount: viewModel.matches.length,
|
||||||
itemBuilder: (context, index) => _MatchCard(
|
itemBuilder: (context, index) =>
|
||||||
match: viewModel.matches[index],
|
_MatchCard(match: viewModel.matches[index]),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -46,17 +47,18 @@ class _MatchCard extends StatelessWidget {
|
|||||||
final date = DateTime.tryParse(match.datetime)?.toLocal();
|
final date = DateTime.tryParse(match.datetime)?.toLocal();
|
||||||
final dateLabel = date == null
|
final dateLabel = date == null
|
||||||
? match.datetime
|
? 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(
|
return Card(
|
||||||
margin: const EdgeInsets.only(bottom: 12),
|
margin: const EdgeInsets.only(bottom: 12),
|
||||||
child: Padding(
|
child: ExpansionTile(
|
||||||
padding: const EdgeInsets.all(16),
|
shape: const Border(),
|
||||||
child: Column(
|
collapsedShape: const Border(),
|
||||||
|
title: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(dateLabel, style: textTheme.labelLarge),
|
Text(dateLabel, style: textTheme.labelLarge),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 8),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@@ -71,21 +73,35 @@ class _MatchCard extends StatelessWidget {
|
|||||||
const Text('Away'),
|
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),
|
Icon(icon, size: 18, color: Theme.of(context).colorScheme.secondary),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Expanded(child: Text(label)),
|
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 _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) {
|
String _cardName(CardType type) => switch (type) {
|
||||||
CardType.red => 'Red',
|
CardType.red => 'Red',
|
||||||
CardType.yellow => 'Yellow',
|
CardType.yellow => 'Yellow',
|
||||||
CardType.green => 'Green',
|
CardType.green => 'Green',
|
||||||
};
|
};
|
||||||
@@ -1,15 +1,36 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:mobile_app/app.dart';
|
import 'package:mobile_app/app.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('App smoke test - renders match results, navigates to settings',
|
testWidgets('App smoke test - renders match results, navigates to settings', (
|
||||||
(WidgetTester tester) async {
|
WidgetTester tester,
|
||||||
|
) async {
|
||||||
await tester.pumpWidget(const MobileApp());
|
await tester.pumpWidget(const MobileApp());
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(find.text('Match Results'), findsOneWidget);
|
expect(find.text('Match Results'), findsOneWidget);
|
||||||
expect(find.text('Home'), findsWidgets);
|
expect(find.text('Home'), findsWidgets);
|
||||||
expect(find.text('Away'), 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
|
// Switch to Settings tab
|
||||||
final settingsNav = find.text('Settings');
|
final settingsNav = find.text('Settings');
|
||||||
|
|||||||
Reference in new issue
Block a user