Skip to content

Commit

Permalink
fix: leaderboad pages rebuiling when switching tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
IamMuuo committed Sep 6, 2024
1 parent e2daca3 commit e670e3d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
6 changes: 5 additions & 1 deletion lib/tools/leaderboard/achievements_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ class AchievementPage extends StatefulWidget {
State<AchievementPage> createState() => _AchievementPageState();
}

class _AchievementPageState extends State<AchievementPage> {
class _AchievementPageState extends State<AchievementPage>
with AutomaticKeepAliveClientMixin {
final rewardsController = Get.find<RewardController>();
@override
bool get wantKeepAlive => true;

String dateFormat(DateTime date) {
return DateFormat('EEEE, MMMM d, y').format(date);
}

@override
Widget build(BuildContext context) {
super.build(context);
return RefreshIndicator(
onRefresh: () async {
final result = await rewardsController.fetchCurrentUserRewards();
Expand Down
17 changes: 10 additions & 7 deletions lib/tools/leaderboard/hall_of_fame_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ import 'package:academia/tools/leaderboard/widgets/top_three_widget.dart';
import 'package:get/get.dart';
import 'package:lottie/lottie.dart';

class HallOfFamePage extends StatelessWidget {
class HallOfFamePage extends StatefulWidget {
const HallOfFamePage({super.key});

// @override
// void initState() {
// super.initState();
// leaderBoardResult = rewardsController.fetchLeaderBoard();
// }
@override
State<HallOfFamePage> createState() => _HallOfFamePageState();
}

class _HallOfFamePageState extends State<HallOfFamePage>
with AutomaticKeepAliveClientMixin {
@override
bool get wantKeepAlive => true;

@override
Widget build(BuildContext context) {
super.build(context);
final rewardsController = Get.find<RewardController>();
// late Future<Either<String, List<User>>> leaderBoardResult;
Future leaderBoardResult = rewardsController.fetchLeaderBoard();

return FutureBuilder(
Expand Down

0 comments on commit e670e3d

Please sign in to comment.