|
@@ -51,7 +51,9 @@ class EmailListScreen extends StatelessWidget {
|
|
|
class EmailPage extends StatefulWidget {
|
|
|
EmailPage({Key? key}) : super(key: key);
|
|
|
String selectedFolder = "INBOX";
|
|
|
-
|
|
|
+ int offset = 0;
|
|
|
+ int page = 1;
|
|
|
+
|
|
|
@override
|
|
|
EmailPageState createState() => EmailPageState();
|
|
|
}
|
|
@@ -60,6 +62,12 @@ class EmailPageState extends State<EmailPage> {
|
|
|
final ApiService apiService = ApiService();
|
|
|
List<GetThreadResponse> emails = [];
|
|
|
|
|
|
+ @override
|
|
|
+ void initState() {
|
|
|
+ super.initState();
|
|
|
+ widget.page = widget.page;
|
|
|
+ }
|
|
|
+
|
|
|
void updateSelectedFolder(String folder) {
|
|
|
setState(() {
|
|
|
widget.selectedFolder = folder;
|
|
@@ -68,11 +76,31 @@ class EmailPageState extends State<EmailPage> {
|
|
|
_fetchEmails();
|
|
|
}
|
|
|
|
|
|
+ String getPage() {
|
|
|
+ return widget.page.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ void updatePagenation(String option) {
|
|
|
+ if (option == "next") {
|
|
|
+ setState(() {
|
|
|
+ widget.offset += 20;
|
|
|
+ widget.page += 1;
|
|
|
+ });
|
|
|
+ } else if (option == "back") {
|
|
|
+ setState(() {
|
|
|
+ widget.offset -= 20;
|
|
|
+ widget.page -= 1;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // print(currentPage);
|
|
|
+ _fetchEmails();
|
|
|
+ }
|
|
|
+
|
|
|
void _fetchEmails() async {
|
|
|
// print(selectedFolder)
|
|
|
try {
|
|
|
- List<GetThreadResponse> fetchedEmails =
|
|
|
- await apiService.fetchEmailsFromFolder(widget.selectedFolder, 0);
|
|
|
+ List<GetThreadResponse> fetchedEmails = await apiService
|
|
|
+ .fetchEmailsFromFolder(widget.selectedFolder, widget.offset);
|
|
|
setState(() {
|
|
|
emails = fetchedEmails; // Update the list of emails
|
|
|
});
|