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