Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions lib/services/data_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -927,4 +927,70 @@ class DataService {
// If all parsing attempts fail, throw error
throw FormatException('Unable to parse RSS date: $dateText');
}

// Get all fixtures that have videos, sorted by most recent first (past matches only)
static Future<List<Fixture>> getFixturesWithVideos() async {
try {
debugPrint(
'🎥 [Videos] 🔍 Searching for fixtures with videos across all divisions');

// Get all events to search through their divisions
final events = await getEvents();
final allFixturesWithVideos = <Fixture>[];

for (final event in events) {
try {
// Load seasons for this event if not already loaded
final eventWithSeasons = await loadEventSeasons(event);

for (final season in eventWithSeasons.seasons) {
try {
// Get divisions for this event/season
final divisions = await getDivisions(event.id, season.slug);

for (final division in divisions) {
try {
// Get fixtures for this division
final fixtures = await getFixtures(division.id,
eventId: event.id, season: season.slug);

// Filter for completed fixtures with videos
final fixturesWithVideos = fixtures
.where((fixture) =>
fixture.isCompleted && fixture.videos.isNotEmpty)
.toList();

allFixturesWithVideos.addAll(fixturesWithVideos);

if (fixturesWithVideos.isNotEmpty) {
debugPrint(
'🎥 [Videos] ✅ Found ${fixturesWithVideos.length} fixtures with videos in ${division.name}');
}
} catch (e) {
debugPrint(
'🎥 [Videos] ⚠️ Failed to load fixtures for division ${division.name}: $e');
}
}
} catch (e) {
debugPrint(
'🎥 [Videos] ⚠️ Failed to load divisions for ${event.name}/${season.title}: $e');
}
}
} catch (e) {
debugPrint(
'🎥 [Videos] ⚠️ Failed to load seasons for ${event.name}: $e');
}
}

// Sort by most recent first
allFixturesWithVideos.sort((a, b) => b.dateTime.compareTo(a.dateTime));

debugPrint(
'🎥 [Videos] ✅ Found ${allFixturesWithVideos.length} total fixtures with videos');
return allFixturesWithVideos;
} catch (e) {
debugPrint('🎥 [Videos] ❌ Failed to load fixtures with videos: $e');
rethrow;
}
}
}
22 changes: 21 additions & 1 deletion lib/views/main_navigation_view.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'home_view.dart';
import 'competitions_view.dart';
import 'videos_view.dart';
import 'my_touch_view.dart';

class MainNavigationView extends StatefulWidget {
Expand All @@ -24,11 +25,13 @@ class _MainNavigationViewState extends State<MainNavigationView> {
_navigatorKeys = [
GlobalKey<NavigatorState>(), // News navigator
GlobalKey<NavigatorState>(), // Competitions navigator
GlobalKey<NavigatorState>(), // Videos navigator
GlobalKey<NavigatorState>(), // My Touch navigator
];
_pages = [
_buildNewsNavigator(),
_buildCompetitionsNavigator(),
_buildVideosNavigator(),
_buildMyTouchNavigator(),
];
}
Expand Down Expand Up @@ -57,9 +60,21 @@ class _MainNavigationViewState extends State<MainNavigationView> {
);
}

Widget _buildMyTouchNavigator() {
Widget _buildVideosNavigator() {
return Navigator(
key: _navigatorKeys[2],
onGenerateRoute: (settings) {
return MaterialPageRoute(
builder: (context) => const VideosView(),
settings: settings,
);
},
);
}

Widget _buildMyTouchNavigator() {
return Navigator(
key: _navigatorKeys[3],
onGenerateRoute: (settings) {
return MaterialPageRoute(
builder: (context) => const MyTouchView(),
Expand All @@ -77,6 +92,7 @@ class _MainNavigationViewState extends State<MainNavigationView> {
children: _pages,
),
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: _selectedIndex,
onTap: (index) {
setState(() {
Expand All @@ -92,6 +108,10 @@ class _MainNavigationViewState extends State<MainNavigationView> {
icon: Icon(Icons.sports),
label: 'Events',
),
BottomNavigationBarItem(
icon: Icon(Icons.videocam),
label: 'Videos',
),
BottomNavigationBarItem(
icon: Icon(Icons.star),
label: 'My Touch',
Expand Down
Loading
Loading