Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show Different Months Data in MonthlyLeaderBoard #252

Merged
merged 2 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 78 additions & 7 deletions lib/src/pages/leaderboards/monthly_leaderboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ScrollController _scrollController = new ScrollController();

class _MonthlyLeaderBoardPageState extends ConsumerState<MonthlyLeaderBoardPage> {
late String? paginatedUrl;

late int monthActive ;
CircleAvatar buildAvatar(String partUrl) {
try {
if (partUrl == "")
Expand Down Expand Up @@ -56,6 +56,7 @@ class _MonthlyLeaderBoardPageState extends ConsumerState<MonthlyLeaderBoardPage>
loadMoreLeaders();
}
});
monthActive = DateTime.now().month;
super.initState();

}
Expand All @@ -67,11 +68,17 @@ class _MonthlyLeaderBoardPageState extends ConsumerState<MonthlyLeaderBoardPage>
}
}


@override
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
final monthlyLeadersState = ref.watch(monthlyLeaderBoardProvider);
return Scaffold(
return WillPopScope(
onWillPop: () async{
ref.watch(monthlyLeaderBoardProvider.notifier).refreshMonthlyLeaderList(DateTime.now().year,DateTime.now().month);
return true;
},
child : Scaffold(
appBar: AppBar(
leading: IconButton(
icon: Icon(
Expand Down Expand Up @@ -108,15 +115,79 @@ class _MonthlyLeaderBoardPageState extends ConsumerState<MonthlyLeaderBoardPage>
),
Container(
padding: EdgeInsets.fromLTRB(0, 0, 0, 16),
child: Text(
"These are the most active users on BLT in ${monthsInYear[DateTime.now().month]}",
child: Column(

children: [ Text(
"These are the most active users on BLT in",
style: GoogleFonts.aBeeZee(
textStyle: TextStyle(
color: Color(0xFF737373),
),
),
),
),
TextButton.icon(
onPressed: (){
showModalBottomSheet(
context: context,
isScrollControlled: true,
constraints: BoxConstraints(
maxHeight: 250,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10),
)
),
useSafeArea: true,
builder: (BuildContext context){
return
Container(
height: 250,
alignment: Alignment.bottomCenter,
child : ListView.builder(
itemCount: DateTime.now().month,
itemBuilder: (context,index){
return ListTile(
onTap: (){
ref.watch(monthlyLeaderBoardProvider.notifier).refreshMonthlyLeaderList(DateTime.now().year,index+1);
setState(() {
monthActive = index+1;
});
Navigator.pop(context);
},
tileColor: Color(0xFFECECEC).withOpacity(0.42),
title: Text(
"${monthsInYear[index+1]}",
style: GoogleFonts.ubuntu(
textStyle: TextStyle(
color: Color(0xFF737373),
),
),
));
},));
},
);
},
icon: Icon(
Icons.calendar_month,
color: Colors.white,
),
label: Text(
"${monthsInYear[monthActive]}",
style: GoogleFonts.aBeeZee(
textStyle: TextStyle(
color: Colors.white,
fontSize: 15,
),
),
),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Color(0xFFDC4654)),
),
),
]
),)
],
),
),
Expand All @@ -128,7 +199,7 @@ class _MonthlyLeaderBoardPageState extends ConsumerState<MonthlyLeaderBoardPage>
if(leaderList!.isEmpty){
return Center(
child: Text(
"Looks Like There aren't any active users this month .",
"Looks Like There isn't any activity in this month .",
textAlign: TextAlign.center,
),
);
Expand Down Expand Up @@ -217,6 +288,6 @@ class _MonthlyLeaderBoardPageState extends ConsumerState<MonthlyLeaderBoardPage>
],
),
),
);
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MonthlyLeaderBoardNotifier
_cacheState();
try{
final LeaderData leaderData = await LeaderboardApiClient.getMoreMonthlyLeaders(nextUrl);
nextUrl = leaderData!.nextQuery;
nextUrl = leaderData.nextQuery;
state = state!.whenData((leaderList){
leaderList!.addAll(leaderData.leaderList!);
return leaderList;
Expand Down
1 change: 0 additions & 1 deletion lib/src/util/api/leaderboard_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class LeaderboardApiClient {
previousQuery: decodedResponse["previous"],
leaderList: leaderList,
);
print(leaderList);
return leaderData;
});
}
Expand Down