Skip to content

Commit

Permalink
[results] show dnf reason on tap when available
Browse files Browse the repository at this point in the history
  • Loading branch information
BrightDV committed Oct 23, 2023
1 parent 7e51928 commit 7cc812e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
2 changes: 2 additions & 0 deletions lib/api/driver_components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class DriverResult {
final String? points;
final String? raceId;
final String? raceName;
final String? status;

DriverResult(
this.driverId,
Expand All @@ -82,6 +83,7 @@ class DriverResult {
this.points,
this.raceId,
this.raceName,
this.status,
});
}

Expand Down
2 changes: 2 additions & 0 deletions lib/api/ergast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class _ErgastApiCalls {
fastestLapRank != '0' ? element['FastestLap']['lap'] : fastestLapRank,
lapsDone: element['laps'],
points: element['points'],
status: element['status'],
),
);
}
Expand Down Expand Up @@ -153,6 +154,7 @@ class _ErgastApiCalls {
: fastestLapRank,
lapsDone: element['laps'],
points: element['points'],
status: element['status'],
),
);
}
Expand Down
53 changes: 35 additions & 18 deletions lib/helpers/driver_result_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import 'package:boxbox/api/driver_components.dart';
import 'package:boxbox/helpers/team_background_color.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:fluttertoast/fluttertoast.dart';

class DriverResultItem extends StatelessWidget {
final DriverResult item;
Expand All @@ -38,6 +39,7 @@ class DriverResultItem extends StatelessWidget {
Widget build(BuildContext context) {
Color finalTeamColors = getTeamColors(item.team);
return GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
Navigator.push(
context,
Expand Down Expand Up @@ -95,25 +97,40 @@ class DriverResultItem extends StatelessWidget {
flex: 6,
child: Padding(
padding: const EdgeInsets.only(left: 5, right: 5),
child: Container(
decoration: BoxDecoration(
color: item.isFastest
? const Color(0xffab01ab)
: const Color(0xff383840),
borderRadius: BorderRadius.circular(7),
),
child: Padding(
padding: const EdgeInsets.only(top: 7, bottom: 7),
child: Text(
item.time,
style: TextStyle(
color: item.isFastest
? Colors.white
: item.time == 'DNF'
? Colors.yellow
: const Color(0xff00ff00),
child: GestureDetector(
onTap: () => item.time == 'DNF'
? Fluttertoast.showToast(
msg: item.status ?? 'DNF',
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 2,
backgroundColor: Colors.grey.shade500,
fontSize: 16.0,
)
: null,
child: Container(
decoration: BoxDecoration(
color: item.isFastest
? const Color(0xffab01ab)
: const Color(0xff383840),
borderRadius: BorderRadius.circular(7),
),
child: Padding(
padding: const EdgeInsets.only(top: 7, bottom: 7),
child: Text(
item.time,
style: TextStyle(
color: item.isFastest
? Colors.white
: item.time == 'DNF'
? Colors.yellow
: const Color(0xff00ff00),
decoration: item.time == 'DNF'
? TextDecoration.underline
: null,
),
textAlign: TextAlign.center,
),
textAlign: TextAlign.center,
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ dependencies:
flutter_markdown: ^0.6.10
flutter_swiper_view: ^1.1.8
flutter_timer_countdown: ^1.0.3
fluttertoast: ^8.2.1
fluttertoast: ^8.2.2
font_awesome_flutter: ^10.2.1
geojson_vi: ^2.0.7
hidable: ^1.0.6
Expand Down

0 comments on commit 7cc812e

Please sign in to comment.