diff --git a/lib/Screens/race_details.dart b/lib/Screens/race_details.dart index 092d4a5..05af9c1 100644 --- a/lib/Screens/race_details.dart +++ b/lib/Screens/race_details.dart @@ -568,10 +568,15 @@ class _RaceResultsProviderState extends State { Future> getRaceStandingsFromApi({ Race? race, String? meetingId, + String? raceUrl, }) async { - if (meetingId != null) { + if (meetingId != null && raceUrl != null) { // starting to do like official api devs... - return await Formula1().getRaceStandings(meetingId, '66666'); + if (raceUrl == 'race') { + return await Formula1().getRaceStandings(meetingId, '66666'); + } else { + return await Formula1().getSprintStandings(meetingId); + } } else { bool useOfficialDataSoure = Hive.box('settings') .get('useOfficialDataSoure', defaultValue: false) as bool; @@ -676,7 +681,12 @@ class _RaceResultsProviderState extends State { return raceUrl != '' ? FutureBuilder>( future: championship == 'Formula 1' - ? getRaceStandingsFromApi(meetingId: raceUrl.split('/')[7]) + ? getRaceStandingsFromApi( + meetingId: raceUrl.startsWith('http') + ? raceUrl.split('/')[7] + : widget.raceId, + raceUrl: raceUrl, + ) : getRaceStandingsFromFE(widget.raceId!, raceUrl), builder: (context, snapshot) { if (snapshot.hasError) { @@ -871,12 +881,12 @@ class _SprintResultsProviderState extends State { }) async { if (meetingId != null) { // same as race results... - return await Formula1().getSprintStandings(meetingId, '66666'); + return await Formula1().getSprintStandings(meetingId); } else { bool useOfficialDataSoure = Hive.box('settings') .get('useOfficialDataSoure', defaultValue: false) as bool; if (useOfficialDataSoure) { - return await Formula1().getSprintStandings(race!.meetingId, race.round); + return await Formula1().getSprintStandings(race!.meetingId); } else { return await ErgastApi().getSprintStandings(race!.round); } @@ -1054,7 +1064,9 @@ class _QualificationResultsProviderState : FutureBuilder( future: widget.raceUrl != null ? getQualificationStandings( - meetingId: widget.raceUrl!.split('/')[7], + meetingId: widget.raceUrl!.startsWith('http') + ? widget.raceUrl!.split('/')[7] + : widget.sessionId, ) : getQualificationStandings( race: widget.race!, diff --git a/lib/Screens/session_screen.dart b/lib/Screens/session_screen.dart index 9356515..8115814 100644 --- a/lib/Screens/session_screen.dart +++ b/lib/Screens/session_screen.dart @@ -351,26 +351,28 @@ class _SessionScreenState extends State { ? RaceResultsProvider( raceUrl: championship == 'Formula 1' ? widget.session.sessionsAbbreviation == 'r' - ? widget.session.baseUrl.replaceAll( - 'session-type', 'race-result') - : widget.session.baseUrl.replaceAll( - 'session-type', - 'sprint-results', - ) + ? 'race' + : 'sprint-results' : widget.session.baseUrl, raceId: widget.meetingId, ) : championship == 'Formula 1' ? QualificationResultsProvider( raceUrl: championship == 'Formula 1' - ? widget.session.baseUrl.replaceAll( - 'session-type', - widget.session.sessionsAbbreviation == - 'ss' - ? 'sprint-qualifying' - : 'qualifying', - ) + ? widget.session.sessionsAbbreviation == + 'ss' + ? 'sprint-qualifying' + : 'qualifying' : widget.session.baseUrl, + sessionId: widget.meetingId, + hasSprint: + widget.session.sessionsAbbreviation == 'ss' + ? true + : false, + isSprintQualifying: + widget.session.sessionsAbbreviation == 'ss' + ? true + : false, ) : FreePracticeResultsProvider( widget.sessionFullName, diff --git a/lib/api/formula1.dart b/lib/api/formula1.dart index 4663ee0..4b06988 100644 --- a/lib/api/formula1.dart +++ b/lib/api/formula1.dart @@ -553,8 +553,7 @@ class Formula1 { } } - FutureOr> getSprintStandings( - String meetingId, String session) async { + FutureOr> getSprintStandings(String meetingId) async { List driversResults = []; String time; String endpoint = Hive.box('settings') diff --git a/lib/helpers/driver_result_item.dart b/lib/helpers/driver_result_item.dart index 7d907bc..3c3b353 100644 --- a/lib/helpers/driver_result_item.dart +++ b/lib/helpers/driver_result_item.dart @@ -486,7 +486,7 @@ class QualificationResultsItem extends StatelessWidget { color: winningTimeQOne == item.timeq1 ? Colors.white : item.timeq1 != '--' - ? item.timeq1 == 'DNF' + ? item.timeq1 == 'DNF' || item.timeq1 == 'DNS' ? Colors.yellow : const Color(0xff00ff00) : Colors.white, @@ -531,7 +531,7 @@ class QualificationResultsItem extends StatelessWidget { color: winningTimeQTwo == item.timeq2 ? Colors.white : item.timeq2 != '--' - ? item.timeq2 == 'DNF' + ? item.timeq2 == 'DNF' || item.timeq2 == 'DNS' ? Colors.yellow : const Color(0xff00ff00) : Colors.white, @@ -575,7 +575,7 @@ class QualificationResultsItem extends StatelessWidget { color: index == 0 ? Colors.white : item.timeq3 != '--' - ? item.timeq3 == 'DNF' + ? item.timeq3 == 'DNF' || item.timeq3 == 'DNS' ? Colors.yellow : const Color(0xff00ff00) : Colors.white,