feature/pagination #42

Merged
v4l3n71n merged 10 commits from feature/pagination into main 2025-06-02 21:22:14 +00:00
2 changed files with 8 additions and 26 deletions
Showing only changes of commit 3a64f1ae36 - Show all commits

View File

@ -54,24 +54,13 @@ class _MyHomePageState extends State<ListItemOrganizers> {
}); });
} }
void _decrementFetchCount() {
setState(() {
if (_fetchCount > 0) {
_fetchCount--;
}
});
}
void _scrollListener() { void _scrollListener() {
if (_scrollController.position.pixels == if (_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent) { _scrollController.position.maxScrollExtent) {
_incrementFetchCount(); _incrementFetchCount();
} else if (_scrollController.position.pixels ==
_scrollController.position.minScrollExtent) {
_decrementFetchCount();
}
_fetchData(); _fetchData();
} }
}
Future<void> _fetchData() async { Future<void> _fetchData() async {
print("Counter : ${_fetchCount}"); print("Counter : ${_fetchCount}");
@ -97,8 +86,9 @@ class _MyHomePageState extends State<ListItemOrganizers> {
final List<Events> body = []; final List<Events> body = [];
if (accessToken.isNotEmpty) { if (accessToken.isNotEmpty) {
DateTime currentDatetime = DateTime.now(); DateTime currentDatetime = DateTime.now();
num limit = 20 * (count + 1);
var url = Uri.parse( var url = Uri.parse(
"${globals.api}/events?organizers=${organizer}&skip=${count}&current_datetime=${currentDatetime.toString()}"); "${globals.api}/events?organizers=${organizer}&limit=${limit}&current_datetime=${currentDatetime.toString()}");
final response = await http.get(url, headers: { final response = await http.get(url, headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
HttpHeaders.cookieHeader: "access_token=${accessToken}" HttpHeaders.cookieHeader: "access_token=${accessToken}"

View File

@ -56,24 +56,14 @@ class _MyHomePageState extends State<ListItemTags> {
}); });
} }
void _decrementFetchCount() {
setState(() {
if (_fetchCount > 0) {
_fetchCount--;
}
});
}
void _scrollListener() { void _scrollListener() {
if (_scrollController.position.pixels == if (_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent) { _scrollController.position.maxScrollExtent) {
_incrementFetchCount(); _incrementFetchCount();
} else if (_scrollController.position.pixels ==
_scrollController.position.minScrollExtent) {
_decrementFetchCount();
}
_fetchData(); _fetchData();
} }
}
Future<void> _fetchData() async { Future<void> _fetchData() async {
print("Counter : ${_fetchCount}"); print("Counter : ${_fetchCount}");
@ -97,8 +87,10 @@ class _MyHomePageState extends State<ListItemTags> {
final List<Events> body = []; final List<Events> body = [];
if (accessToken.isNotEmpty) { if (accessToken.isNotEmpty) {
DateTime currentDatetime = DateTime.now(); DateTime currentDatetime = DateTime.now();
num limit = 20 * (count + 1);
var url = Uri.parse( var url = Uri.parse(
"${globals.api}/events?tags=${tags}&skip=${count}&current_datetime=${currentDatetime.toString()}"); "${globals.api}/events?tags=${tags}&limit=${limit}&current_datetime=${currentDatetime.toString()}");
final response = await http.get(url, headers: { final response = await http.get(url, headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
HttpHeaders.cookieHeader: "access_token=${accessToken}" HttpHeaders.cookieHeader: "access_token=${accessToken}"