Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stats #109

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft

Stats #109

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
Original file line number Diff line number Diff line change
Expand Up @@ -17,87 +17,87 @@ public final class GeneratedPluginRegistrant {
public static void registerWith(@NonNull FlutterEngine flutterEngine) {
try {
flutterEngine.getPlugins().add(new com.javih.add_2_calendar.Add2CalendarPlugin());
} catch(Exception e) {
} catch (Exception e) {
Log.e(TAG, "Error registering plugin add_2_calendar, com.javih.add_2_calendar.Add2CalendarPlugin", e);
}
try {
flutterEngine.getPlugins().add(new me.carda.awesome_notifications.AwesomeNotificationsPlugin());
} catch(Exception e) {
} catch (Exception e) {
Log.e(TAG, "Error registering plugin awesome_notifications, me.carda.awesome_notifications.AwesomeNotificationsPlugin", e);
}
try {
flutterEngine.getPlugins().add(new com.jhomlala.better_player.BetterPlayerPlugin());
} catch(Exception e) {
} catch (Exception e) {
Log.e(TAG, "Error registering plugin better_player, com.jhomlala.better_player.BetterPlayerPlugin", e);
}
try {
flutterEngine.getPlugins().add(new dev.fluttercommunity.plus.connectivity.ConnectivityPlugin());
} catch(Exception e) {
} catch (Exception e) {
Log.e(TAG, "Error registering plugin connectivity_plus, dev.fluttercommunity.plus.connectivity.ConnectivityPlugin", e);
}
try {
flutterEngine.getPlugins().add(new dev.fluttercommunity.plus.device_info.DeviceInfoPlusPlugin());
} catch(Exception e) {
} catch (Exception e) {
Log.e(TAG, "Error registering plugin device_info_plus, dev.fluttercommunity.plus.device_info.DeviceInfoPlusPlugin", e);
}
try {
flutterEngine.getPlugins().add(new com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin());
} catch(Exception e) {
} catch (Exception e) {
Log.e(TAG, "Error registering plugin flutter_inappwebview, com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.github.ponnamkarthik.toast.fluttertoast.FlutterToastPlugin());
} catch(Exception e) {
} catch (Exception e) {
Log.e(TAG, "Error registering plugin fluttertoast, io.github.ponnamkarthik.toast.fluttertoast.FlutterToastPlugin", e);
}
try {
flutterEngine.getPlugins().add(new dev.fluttercommunity.plus.packageinfo.PackageInfoPlugin());
} catch(Exception e) {
} catch (Exception e) {
Log.e(TAG, "Error registering plugin package_info_plus, dev.fluttercommunity.plus.packageinfo.PackageInfoPlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.pathprovider.PathProviderPlugin());
} catch(Exception e) {
} catch (Exception e) {
Log.e(TAG, "Error registering plugin path_provider_android, io.flutter.plugins.pathprovider.PathProviderPlugin", e);
}
try {
flutterEngine.getPlugins().add(new com.kasem.receive_sharing_intent.ReceiveSharingIntentPlugin());
} catch(Exception e) {
} catch (Exception e) {
Log.e(TAG, "Error registering plugin receive_sharing_intent, com.kasem.receive_sharing_intent.ReceiveSharingIntentPlugin", e);
}
try {
flutterEngine.getPlugins().add(new dev.fluttercommunity.plus.share.SharePlusPlugin());
} catch(Exception e) {
} catch (Exception e) {
Log.e(TAG, "Error registering plugin share_plus, dev.fluttercommunity.plus.share.SharePlusPlugin", e);
}
try {
flutterEngine.getPlugins().add(new com.tekartik.sqflite.SqflitePlugin());
} catch(Exception e) {
} catch (Exception e) {
Log.e(TAG, "Error registering plugin sqflite, com.tekartik.sqflite.SqflitePlugin", e);
}
try {
flutterEngine.getPlugins().add(new com.syncfusion.flutter.pdfviewer.SyncfusionFlutterPdfViewerPlugin());
} catch(Exception e) {
} catch (Exception e) {
Log.e(TAG, "Error registering plugin syncfusion_flutter_pdfviewer, com.syncfusion.flutter.pdfviewer.SyncfusionFlutterPdfViewerPlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.urllauncher.UrlLauncherPlugin());
} catch(Exception e) {
} catch (Exception e) {
Log.e(TAG, "Error registering plugin url_launcher_android, io.flutter.plugins.urllauncher.UrlLauncherPlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.videoplayer.VideoPlayerPlugin());
} catch(Exception e) {
} catch (Exception e) {
Log.e(TAG, "Error registering plugin video_player_android, io.flutter.plugins.videoplayer.VideoPlayerPlugin", e);
}
try {
flutterEngine.getPlugins().add(new creativemaybeno.wakelock.WakelockPlugin());
} catch(Exception e) {
} catch (Exception e) {
Log.e(TAG, "Error registering plugin wakelock, creativemaybeno.wakelock.WakelockPlugin", e);
}
try {
flutterEngine.getPlugins().add(new be.tramckrijte.workmanager.WorkmanagerPlugin());
} catch(Exception e) {
} catch (Exception e) {
Log.e(TAG, "Error registering plugin workmanager, be.tramckrijte.workmanager.WorkmanagerPlugin", e);
}
}
Expand Down
Binary file added assets/images/fullscreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
133 changes: 133 additions & 0 deletions lib/Screens/DriverDetails/chart.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import 'package:boxbox/Screens/widgets/driver_image_provider.dart';
import 'package:boxbox/scraping/f1-fansite.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:syncfusion_flutter_charts/charts.dart';

class DriverDetailsStatsChart extends StatefulWidget {
final String driverId;
final TeamMateComparison comparison;

const DriverDetailsStatsChart(this.driverId, this.comparison, {super.key});

@override
State<DriverDetailsStatsChart> createState() =>
_DriverDetailsStatsChartState();
}

class _DriverDetailsStatsChartState extends State<DriverDetailsStatsChart> {
final List<ComparisonData> _chartData = <ComparisonData>[];

@override
void initState() {
for (ComparisonValues element in widget.comparison.pointsComparison) {
_chartData.add(ComparisonData(
element.rowKey, element.driverValue, element.teamMateValue));
}

super.initState();
}

@override
Widget build(BuildContext context) => Expanded(
child: SfCartesianChart(
title: ChartTitle(
text: 'Points comparison between Max verstappen and team mates'),
enableAxisAnimation: true,
trackballBehavior: _buildTrackballBehavior(),
legend: Legend(isVisible: true),
primaryXAxis: CategoryAxis(
edgeLabelPlacement: EdgeLabelPlacement.shift,
interval: 1,
labelRotation: -90,
majorGridLines: const MajorGridLines(width: 0),
axisLabelFormatter: (AxisLabelRenderDetails details) {
return ChartAxisLabel(
details.text.split('-')[0], details.textStyle);
}),
primaryYAxis: NumericAxis(
numberFormat: NumberFormat.decimalPattern(),
axisLine: const AxisLine(width: 0),
majorTickLines: const MajorTickLines(size: 0),
),
series: <ChartSeries>[
LineSeries<ComparisonData, String>(
dataSource: _chartData,
xValueMapper: (ComparisonData sales, _) => sales.rowKey,
yValueMapper: (ComparisonData sales, _) => sales.driverValue,
name: 'Max Verstappen',
width: 2,
markerSettings: const MarkerSettings(isVisible: true)),
LineSeries<ComparisonData, String>(
dataSource: _chartData,
xValueMapper: (ComparisonData sales, _) => sales.rowKey,
yValueMapper: (ComparisonData sales, _) => sales.teamMateValue,
name: 'Team mate',
width: 2,
markerSettings: const MarkerSettings(isVisible: true)),
],
),
);

TrackballBehavior _buildTrackballBehavior() {
return TrackballBehavior(
enable: true,
markerSettings: const TrackballMarkerSettings(
height: 10,
width: 10,
borderWidth: 1,
),
hideDelay: 2000,
activationMode: ActivationMode.singleTap,
// tooltipSettings:
// const InteractiveTooltip(format: null, canShowMarker: true),
// shouldAlwaysShow: true,
builder: (BuildContext context, TrackballDetails trackballDetails) {
return Padding(
padding: EdgeInsets.zero,
child: Container(
height: 50,
width: 120,
decoration: const BoxDecoration(
color: Color.fromRGBO(255, 255, 255, 1),
borderRadius: BorderRadius.all(Radius.circular(6.0)),
),
child: Row(children: <Widget>[
Padding(
padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
child: SizedBox(
height: 35,
width: 35,
child: getDriverImage(trackballDetails),
)),
Center(child: Text(trackballDetails.point!.y.toString()))
])));
});
}

Widget getDriverImage(TrackballDetails trackballDetails) {
if (trackballDetails.series!.name == 'Team mate') {
final String teamMate = trackballDetails.point!.x
.toString()
.split('-')[0]
.split(' ')[1]
.toLowerCase();
return DriverImageProvider(teamMate);
}
return DriverImageProvider(widget.driverId);
}

@override
void dispose() {
_chartData.clear();
super.dispose();
}
}

class ComparisonData {
final String rowKey;
final num driverValue;
final num teamMateValue;

ComparisonData(this.rowKey, this.driverValue, this.teamMateValue);
}
96 changes: 96 additions & 0 deletions lib/Screens/DriverDetails/details.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* This file is part of BoxBox (https://github.com/BrightDV/BoxBox).
*
* BoxBox is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BoxBox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with BoxBox. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright (c) 2022-2023, BrightDV
*/

import 'package:boxbox/Screens/DriverDetails/info.dart';
import 'package:boxbox/Screens/DriverDetails/results.dart';
import 'package:boxbox/Screens/DriverDetails/stats.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:hive_flutter/hive_flutter.dart';

class DriverDetailsScreen extends StatefulWidget {
final String driverId;
final String givenName;
final String familyName;
const DriverDetailsScreen(
this.driverId,
this.givenName,
this.familyName, {
super.key,
});

@override
State<DriverDetailsScreen> createState() => _DriverDetailsScreenState();
}

class _DriverDetailsScreenState extends State<DriverDetailsScreen> {
@override
Widget build(BuildContext context) {
bool useDarkMode =
Hive.box('settings').get('darkMode', defaultValue: true) as bool;
return DefaultTabController(
length: 3,
child: Scaffold(
appBar: AppBar(
title: Text(
'${widget.givenName} ${widget.familyName.toUpperCase()}',
style: const TextStyle(
fontWeight: FontWeight.w600,
),
),
bottom: TabBar(
indicatorColor: Colors.white,
tabs: [
TabItem(AppLocalizations.of(context)!.information),
TabItem(AppLocalizations.of(context)!.results),
TabItem(AppLocalizations.of(context)!.statistics),
],
),
),
backgroundColor: useDarkMode
? Theme.of(context).scaffoldBackgroundColor
: Colors.white,
body: TabBarView(
children: [
DriverInfo(widget.driverId),
DriverResults(widget.driverId),
DriverStats(widget.driverId),
],
),
),
);
}
}

class TabItem extends StatelessWidget {
final String title;

const TabItem(this.title, {super.key});

@override
Widget build(BuildContext context) => Tab(
child: Text(
title.toUpperCase(),
style: const TextStyle(
fontWeight: FontWeight.w600,
),
),
);
}

Loading