Skip to content

Commit

Permalink
[schedule] should fix images
Browse files Browse the repository at this point in the history
  • Loading branch information
BrightDV committed Jan 4, 2025
1 parent 4c141d3 commit 14510f8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/Screens/circuit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,8 @@ class RaceImageProvider extends StatelessWidget {
if (scheduleLastSavedFormat == 'ergast') {
return RaceTracksUrls().getRaceTrackImageUrl(race.circuitId);
} else {
String coverUrl = race.raceCoverUrl!;
String coverUrl =
'https://media.formula1.com/image/upload/f_auto,c_limit,w_1440,q_auto/f_auto/q_auto/content/dam/fom-website/2018-redesign-assets/Racehub%20header%20images%2016x9/${race.country.replaceAll(" ", "_")}.jpg';
if (race.country == 'Great Britain') {
coverUrl = race.raceCoverUrl!
.replaceFirst('United_Kingdom', 'Great_Britain');
Expand Down
14 changes: 13 additions & 1 deletion lib/api/formula1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,18 @@ class Formula1 {
} else if (element['meetingCountryName'] == 'Las Vegas') {
detailsPath = 'Las_Vegas';
}
String raceCoverUrl = element['thumbnail']['image']['url'];
if (element['meetingName'] != 'Pre-Season Testing') {
var tmp = element['thumbnail']['image']['url']
.replaceAll('race-listing/', '')
.split('/');
tmp.removeLast();
raceCoverUrl = tmp.join('/') +
'/' +
element['meetingName'].replaceAll(" ", "_") +
'.jpg';
}

races.add(
Race(
finalJson.indexOf(element).toString(),
Expand All @@ -830,7 +842,7 @@ class Formula1 {
element['meetingCountryName'],
[],
isFirst: races.isEmpty,
raceCoverUrl: element['thumbnail']['image']['url'],
raceCoverUrl: raceCoverUrl,
detailsPath: detailsPath,
isPreSeasonTesting: element['type'] == 'fom-testing',
),
Expand Down

0 comments on commit 14510f8

Please sign in to comment.