select list of which foilder to move your email
This commit is contained in:
parent
9297468f6f
commit
7a1e735f11
@ -46,6 +46,7 @@ class ApiService {
|
||||
}
|
||||
}
|
||||
}
|
||||
currFolder = folder;
|
||||
return allEmails;
|
||||
} else {
|
||||
throw Exception('Failed to load threads');
|
||||
|
173
lib/augment.dart
173
lib/augment.dart
@ -1,7 +1,10 @@
|
||||
// import 'dart:ffi';
|
||||
|
||||
import 'package:crab_ui/api_service.dart';
|
||||
import 'package:crab_ui/attachmentDownload.dart';
|
||||
import 'package:crab_ui/structs.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pdfrx/pdfrx.dart';
|
||||
import 'package:pointer_interceptor/pointer_interceptor.dart';
|
||||
import 'dart:html' as html;
|
||||
import 'dart:js' as js;
|
||||
@ -88,6 +91,12 @@ class _DynamicClassesAugment extends State<EmailToolbar> {
|
||||
onPressed: AugmentClasses.handleStop,
|
||||
child: Text('Stop'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
AugmentClasses.handleMove(context);
|
||||
},
|
||||
child: Text('Move'),
|
||||
),
|
||||
Spacer(),
|
||||
PopupMenuButton<String>(
|
||||
onSelected: (String value) {
|
||||
@ -212,8 +221,9 @@ class _DynamicClassesAugment extends State<EmailToolbar> {
|
||||
}
|
||||
|
||||
class AugmentClasses {
|
||||
ApiService _apiService = ApiService();
|
||||
static OverlayEntry? _overlayEntry;
|
||||
static String? selectedFolder; // Manage selected folder at the class level
|
||||
|
||||
static void handleHome(BuildContext context) {
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
}
|
||||
@ -222,11 +232,165 @@ class AugmentClasses {
|
||||
print("reload");
|
||||
}
|
||||
|
||||
Widget listOfFolders(BuildContext context) {
|
||||
//list the emails and make some sort of selection box
|
||||
return FutureBuilder<List<String>>(
|
||||
future: ApiService().fetchFolders(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return Center(child: CircularProgressIndicator());
|
||||
} else if (snapshot.hasError) {
|
||||
return Center(child: Text('Error: ${snapshot.error}'));
|
||||
} else if (snapshot.hasData) {
|
||||
String? selectedFolder; // Declare the selected folder state
|
||||
return StatefulBuilder(
|
||||
builder: (context, setState) {
|
||||
return ListView(
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
children: snapshot.data!.map((folder) {
|
||||
return RadioListTile<String>(
|
||||
title: Text(folder),
|
||||
value: folder,
|
||||
groupValue: selectedFolder,
|
||||
onChanged: (String? value) {
|
||||
setState(() {
|
||||
selectedFolder = value; // Update the selected folder
|
||||
});
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return const Center(child: Text('No folders found.'));
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
static void handleMove(BuildContext context) async {
|
||||
print("current folder: ${ApiService.currFolder}");
|
||||
final overlay = Overlay.of(context);
|
||||
String? selectedFolder; // Variable to store the selected folder
|
||||
|
||||
_overlayEntry = OverlayEntry(
|
||||
builder: (context) => Stack(
|
||||
children: [
|
||||
// Dimmed background
|
||||
Container(
|
||||
color: Colors.black54,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
),
|
||||
// Focused content window
|
||||
PointerInterceptor(
|
||||
child: Center(
|
||||
child: Material(
|
||||
elevation: 8,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: 400,
|
||||
maxHeight: 500,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'Move email from folder ${ApiService.currFolder} to:',
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
Divider(height: 1),
|
||||
Expanded(
|
||||
child: FutureBuilder<List<String>>(
|
||||
future: ApiService().fetchFolders(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
ConnectionState.waiting) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator());
|
||||
} else if (snapshot.hasError) {
|
||||
return Center(
|
||||
child: Text('Error: ${snapshot.error}'));
|
||||
} else if (snapshot.hasData) {
|
||||
return StatefulBuilder(
|
||||
builder: (context, setState) {
|
||||
return ListView(
|
||||
shrinkWrap: true,
|
||||
children: snapshot.data!.map((folder) {
|
||||
return RadioListTile<String>(
|
||||
title: Text(folder),
|
||||
value: folder,
|
||||
groupValue: selectedFolder,
|
||||
onChanged: (String? value) {
|
||||
setState(() {
|
||||
selectedFolder = value; // Update the selected folder
|
||||
});
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return const Center(
|
||||
child: Text('No folders found.'));
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
Divider(height: 1),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
// Handle Accept button
|
||||
if (selectedFolder != null) {
|
||||
print("Selected folder: $selectedFolder");
|
||||
// Store the selected folder or perform any action
|
||||
// ApiService.currFolder = selectedFolder!;
|
||||
ApiService()
|
||||
.moveEmail(ApiService.currFolder, ApiService.currThreadID, selectedFolder!);
|
||||
_overlayEntry?.remove();
|
||||
} else {
|
||||
print("No folder selected");
|
||||
}
|
||||
},
|
||||
child: Text('Accept'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
// Handle Cancel button
|
||||
_overlayEntry?.remove();
|
||||
},
|
||||
child: Text('Cancel'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (_overlayEntry != null) {
|
||||
overlay.insert(_overlayEntry!);
|
||||
}
|
||||
}
|
||||
|
||||
static void handleImages(BuildContext context) {
|
||||
//rename to handle attachments
|
||||
print("Images button pressed");
|
||||
final overlay = Overlay.of(context);
|
||||
final renderBox = context.findRenderObject() as RenderBox;
|
||||
final offset = renderBox.localToGlobal(Offset.zero);
|
||||
// final renderBox = context.findRenderObject() as RenderBox;
|
||||
// final offset = renderBox.localToGlobal(Offset.zero);
|
||||
|
||||
_overlayEntry = OverlayEntry(
|
||||
builder: (context) => Stack(
|
||||
@ -295,8 +459,7 @@ class AugmentClasses {
|
||||
static List<Widget> _buildMenuItem(BuildContext context) {
|
||||
List<Widget> listOfFiles = [];
|
||||
for (AttachmentResponse file in ApiService.threadAttachments) {
|
||||
listOfFiles.add(
|
||||
ListTile (
|
||||
listOfFiles.add(ListTile(
|
||||
leading: Icon(Icons.file_present),
|
||||
title: Text(file.name.toString()),
|
||||
trailing: GestureDetector(
|
||||
|
Loading…
Reference in New Issue
Block a user