android/ios-adaption feature, markdown, and augment #6
					 1 changed files with 160 additions and 2 deletions
				
			
		| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
import 'package:crab_ui/sonicEmailView.dart';
 | 
					import 'package:crab_ui/sonicEmailView.dart';
 | 
				
			||||||
 | 
					import 'package:pointer_interceptor/pointer_interceptor.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import 'folder_drawer.dart';
 | 
					import 'folder_drawer.dart';
 | 
				
			||||||
import 'structs.dart';
 | 
					import 'structs.dart';
 | 
				
			||||||
| 
						 | 
					@ -35,6 +36,7 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
 | 
				
			||||||
  List<String> _tabs = ['Emails'];
 | 
					  List<String> _tabs = ['Emails'];
 | 
				
			||||||
  Map<String, Widget> _tabWidgets = {};
 | 
					  Map<String, Widget> _tabWidgets = {};
 | 
				
			||||||
  TabController? _tabController;
 | 
					  TabController? _tabController;
 | 
				
			||||||
 | 
					  OverlayEntry? _overlayEntry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
  void initState() {
 | 
					  void initState() {
 | 
				
			||||||
| 
						 | 
					@ -415,7 +417,163 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
 | 
				
			||||||
                                          icon: Icon(
 | 
					                                          icon: Icon(
 | 
				
			||||||
                                              Icons.mark_email_read_outlined)),
 | 
					                                              Icons.mark_email_read_outlined)),
 | 
				
			||||||
                                      IconButton(
 | 
					                                      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(
 | 
					                                          icon: Icon(
 | 
				
			||||||
                                              Icons.drive_file_move_outlined)),
 | 
					                                              Icons.drive_file_move_outlined)),
 | 
				
			||||||
                                    ],
 | 
					                                    ],
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue