initial codex commit
This commit is contained in:
@@ -4,8 +4,18 @@ import 'package:mileograph_flutter/services/dataService.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class LeaderboardPanel extends StatelessWidget {
|
||||
const LeaderboardPanel({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final data = context.watch<DataService>();
|
||||
final leaderboard = data.homepageStats?.leaderboard ?? [];
|
||||
if (data.isHomepageLoading && leaderboard.isEmpty) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
}
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Card(
|
||||
@@ -20,19 +30,23 @@ class LeaderboardPanel extends StatelessWidget {
|
||||
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),
|
||||
if (leaderboard.isEmpty)
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Text('No leaderboard data yet'),
|
||||
)
|
||||
else
|
||||
Column(
|
||||
children: List.generate(
|
||||
leaderboard.length,
|
||||
(index) {
|
||||
final leaderboardEntry = leaderboard[index];
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 0, vertical: 8),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@@ -41,12 +55,12 @@ class LeaderboardPanel extends StatelessWidget {
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '${index + 1}. ',
|
||||
style: TextStyle(
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: '${leaderboardEntry.userFullName}',
|
||||
text: leaderboardEntry.userFullName,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -57,11 +71,10 @@ class LeaderboardPanel extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -4,8 +4,19 @@ import 'package:mileograph_flutter/services/dataService.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class TopTractionPanel extends StatelessWidget {
|
||||
const TopTractionPanel({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final data = context.watch<DataService>();
|
||||
final stats = data.homepageStats;
|
||||
final locos = stats?.topLocos ?? [];
|
||||
if (data.isHomepageLoading && locos.isEmpty) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
}
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Card(
|
||||
@@ -20,18 +31,23 @@ class TopTractionPanel extends StatelessWidget {
|
||||
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),
|
||||
if (locos.isEmpty)
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Text('No traction data yet'),
|
||||
)
|
||||
else
|
||||
Column(
|
||||
children: List.generate(
|
||||
locos.length,
|
||||
(index) {
|
||||
final loco = locos[index];
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
margin:
|
||||
const EdgeInsets.symmetric(horizontal: 0, vertical: 8),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@@ -43,7 +59,7 @@ class TopTractionPanel extends StatelessWidget {
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '${index + 1}. ',
|
||||
style: TextStyle(
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
@@ -55,8 +71,9 @@ class TopTractionPanel extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${loco.name}',
|
||||
style: TextStyle(fontStyle: FontStyle.italic),
|
||||
loco.name ?? '',
|
||||
style:
|
||||
const TextStyle(fontStyle: FontStyle.italic),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -64,11 +81,10 @@ class TopTractionPanel extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user