94 lines
2.9 KiB
Dart
94 lines
2.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:mileograph_flutter/services/authservice.dart';
|
|
import 'package:mileograph_flutter/services/dataService.dart';
|
|
import 'package:mileograph_flutter/components/dashboard/topTractionPanel.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
class Dashboard extends StatelessWidget {
|
|
const Dashboard({super.key});
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final data = context.watch<DataService>();
|
|
final auth = context.watch<AuthService>();
|
|
return DashboardHeader(auth: auth, data: data);
|
|
}
|
|
}
|
|
|
|
class DashboardHeader extends StatelessWidget {
|
|
const DashboardHeader({super.key, required this.auth, required this.data});
|
|
|
|
final AuthService auth;
|
|
final DataService data;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Card(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Column(
|
|
children: [
|
|
Text.rich(
|
|
TextSpan(
|
|
children: [
|
|
TextSpan(text: "Total Mileage: "),
|
|
TextSpan(
|
|
text:
|
|
data.homepageStats?.totalMileage
|
|
.toString() ??
|
|
"0",
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Text.rich(
|
|
TextSpan(
|
|
children: [
|
|
TextSpan(text: DateTime.now().year.toString()),
|
|
TextSpan(text: " Mileage: "),
|
|
TextSpan(
|
|
text: data
|
|
.getMileageForCurrentYear()
|
|
.toString(),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Card(
|
|
child: Padding(
|
|
padding: EdgeInsets.all(8),
|
|
child: Column(
|
|
children: [
|
|
Text("Total Winners: 123"),
|
|
Text("Average mileage: 45.6"),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
|
|
Expanded(
|
|
child: ListView(
|
|
scrollDirection: Axis.vertical,
|
|
children: [TopTractionPanel()],
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|