list traction and add leaderboard panel
This commit is contained in:
70
lib/components/dashboard/leaderboardPanel.dart
Normal file
70
lib/components/dashboard/leaderboardPanel.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mileograph_flutter/services/dataService.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class LeaderboardPanel extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final data = context.watch<DataService>();
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Card(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Leaderboard",
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: List.generate(
|
||||
data.homepageStats?.leaderboard.length ?? 0,
|
||||
(index) {
|
||||
final leaderboardEntry =
|
||||
data.homepageStats!.leaderboard[index];
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 0, vertical: 8),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '${index + 1}. ',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: '${leaderboardEntry.userFullName}',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${leaderboardEntry.mileage.toStringAsFixed(1)} mi',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -8,52 +8,69 @@ class TopTractionPanel extends StatelessWidget {
|
||||
final data = context.watch<DataService>();
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Card( child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("Top Traction", style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold, decoration: TextDecoration.underline)),
|
||||
Column(
|
||||
children: List.generate(
|
||||
data.homepageStats?.topLocos.length ?? 0,
|
||||
(index) {
|
||||
final loco = data.homepageStats!.topLocos[index];
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
child: Card(
|
||||
margin: EdgeInsets.symmetric(horizontal: 0, vertical: 8),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
child: Card(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Top Traction",
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: List.generate(data.homepageStats?.topLocos.length ?? 0, (
|
||||
index,
|
||||
) {
|
||||
final loco = data.homepageStats!.topLocos[index];
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 0, vertical: 8),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
TextSpan(text: '${index + 1}. ', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
TextSpan(text: '${loco.locoClass} ${loco.locoNumber}'),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '${index + 1}. ',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text:
|
||||
'${loco.locoClass} ${loco.locoNumber}',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${loco.locoName}',
|
||||
style: TextStyle(fontStyle: FontStyle.italic),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text('${loco.locoMileage?.toStringAsFixed(1)} mi'),
|
||||
],
|
||||
),
|
||||
),
|
||||
Text('${loco.locoName}', style: TextStyle(fontStyle: FontStyle.italic)),
|
||||
|
||||
],
|
||||
),
|
||||
Text('${loco.locoMileage?.toStringAsFixed(1)} mi'),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
],
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mileograph_flutter/components/dashboard/leaderboardPanel.dart';
|
||||
import 'package:mileograph_flutter/services/authservice.dart';
|
||||
import 'package:mileograph_flutter/services/dataService.dart';
|
||||
import 'package:mileograph_flutter/components/dashboard/topTractionPanel.dart';
|
||||
@@ -84,7 +85,7 @@ class DashboardHeader extends StatelessWidget {
|
||||
Expanded(
|
||||
child: ListView(
|
||||
scrollDirection: Axis.vertical,
|
||||
children: [TopTractionPanel()],
|
||||
children: [TopTractionPanel(), LeaderboardPanel()],
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
23
lib/components/pages/traction.dart
Normal file
23
lib/components/pages/traction.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mileograph_flutter/objects/objects.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:mileograph_flutter/services/dataService.dart';
|
||||
|
||||
class TractionPage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final data = context.watch<DataService>();
|
||||
return ListView.builder(
|
||||
itemCount: data.traction.length,
|
||||
itemBuilder: (context, index) {
|
||||
final loco = data.traction[index];
|
||||
return Card(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Text('${loco.locoClass} ${loco.locoNumber}'),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user