From 4db2a630082da7bdef53ec25dab14e420c36e01b Mon Sep 17 00:00:00 2001 From: SomnusVeritas Date: Sat, 21 Oct 2023 01:32:13 +0200 Subject: [PATCH] first person on leaderboard is actually first --- lib/pages/leaderboard_page.dart | 32 ++++++++++++++++++-------------- lib/services/db_helper.dart | 5 ++++- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/lib/pages/leaderboard_page.dart b/lib/pages/leaderboard_page.dart index 12dd459..1f4a5a9 100644 --- a/lib/pages/leaderboard_page.dart +++ b/lib/pages/leaderboard_page.dart @@ -19,13 +19,15 @@ class LeaderboardPage extends StatelessWidget { color: isLoggedInUser ? Theme.of(context).colorScheme.secondary : null, child: ListTile( - leading: Text((index + 1).toString(), - style: Theme.of(context).textTheme.bodyLarge!.copyWith( - fontWeight: FontWeight.bold, - color: isLoggedInUser - ? Theme.of(context).colorScheme.onSecondary - : null, - )), + leading: Text( + (index + 1).toString(), + style: Theme.of(context).textTheme.bodyLarge!.copyWith( + fontWeight: FontWeight.bold, + color: isLoggedInUser + ? Theme.of(context).colorScheme.onSecondary + : null, + ), + ), title: Text( leaderboard.elementAt(index).username, style: TextStyle( @@ -34,13 +36,15 @@ class LeaderboardPage extends StatelessWidget { : null, ), ), - trailing: Text(leaderboard.elementAt(index).points.toString(), - style: Theme.of(context).textTheme.bodyLarge!.copyWith( - fontWeight: FontWeight.bold, - color: isLoggedInUser - ? Theme.of(context).colorScheme.onSecondary - : null, - )), + trailing: Text( + leaderboard.elementAt(index).points.toString(), + style: Theme.of(context).textTheme.bodyLarge!.copyWith( + fontWeight: FontWeight.bold, + color: isLoggedInUser + ? Theme.of(context).colorScheme.onSecondary + : null, + ), + ), ), ); }); diff --git a/lib/services/db_helper.dart b/lib/services/db_helper.dart index f866be8..c9d0dc5 100644 --- a/lib/services/db_helper.dart +++ b/lib/services/db_helper.dart @@ -83,7 +83,10 @@ class DbHelper { static Future> fetchProfiles() async { List items = []; - final res = await _supabase.from('profiles').select(); + final res = await _supabase.from('profiles').select().order( + 'points', + ascending: false, + ); for (final map in res) { items.add(Profile.fromMap(map)); }