Compare commits

...

2 Commits

2 changed files with 165 additions and 2 deletions

View File

@ -3,6 +3,7 @@ import 'package:markdown/markdown.dart' as md;
import 'api_service.dart';
import 'structs.dart';
import 'emailView.dart';
import 'Compose.dart';
class EmailListScreen extends StatefulWidget {
final List<GetThreadResponse> emails;
@ -193,6 +194,10 @@ class _EmailListScreenState extends State<EmailListScreen>
print(email.messages); //email ids of the thread
if (widget.folder == "Drafts") {
print("IN DRAFTS MOVE THE CONTENT TO THE WRITING THING");
//open the compose
OverlayService _thisInstance = OverlayService();
_thisInstance.draftID = email;
_thisInstance.showPersistentWidget(context);
} else {
Navigator.push(
context,

View File

@ -1,4 +1,5 @@
import 'package:crab_ui/sonicEmailView.dart';
import 'package:pointer_interceptor/pointer_interceptor.dart';
import 'folder_drawer.dart';
import 'structs.dart';
@ -35,6 +36,7 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
List<String> _tabs = ['Emails'];
Map<String, Widget> _tabWidgets = {};
TabController? _tabController;
OverlayEntry? _overlayEntry;
@override
void initState() {
@ -415,7 +417,163 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
icon: Icon(
Icons.mark_email_read_outlined)),
IconButton(
onPressed: null,
onPressed: () {
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!;
_emailPageKey.currentState! //the one selected
.moveSelectedOfFolder(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!);
}
// _emailPageKey.currentState! //the one selected
// .moveSelectedOfFolder();
},
icon: Icon(
Icons.drive_file_move_outlined)),
],
@ -441,7 +599,7 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
.selectAllEmails(true);
_emailPageKey.currentState!
.markSelectedAsRead(true);
_emailPageKey.currentState!
_emailPageKey.currentState!
.selectAllEmails(false);
},
),