@@ -109,7 +109,17 @@ class _EditorPageState extends State<EditorPage> {
109109 return children;
110110 }
111111
112- void initializeTreeView () async {
112+ //TODO: Add file under directory
113+ //TODO: Rename file
114+ //TODO: Move file
115+
116+ void deleteFileOrFolder (String filepath) async {
117+ var file = File (filepath);
118+ file.delete ();
119+ refreshFileBrowser ();
120+ }
121+
122+ void refreshFileBrowser () async {
113123 List <Document > docs = List .empty (growable: true );
114124
115125 // Add folders from the solution file
@@ -216,7 +226,10 @@ class _EditorPageState extends State<EditorPage> {
216226 controller: ScrollController (),
217227 child: Container (
218228 constraints: BoxConstraints (
219- minHeight: MediaQuery .of (context).size.height * 2 ),
229+ minHeight: MediaQuery
230+ .of (context)
231+ .size
232+ .height * 2 ),
220233 child: field,
221234 )));
222235 }
@@ -332,11 +345,17 @@ class _EditorPageState extends State<EditorPage> {
332345
333346 @override
334347 Widget build (BuildContext context) {
348+ var _tapPosition;
349+
350+ void _storePosition (TapDownDetails details) {
351+ _tapPosition = details.globalPosition;
352+ }
353+
335354 project = ModalRoute .of (context)! .settings.arguments as CCSolution ;
336355 var query = MediaQuery .of (context);
337356 if (documentList.isEmpty) {
338357 // Populate the file browser tree once
339- initializeTreeView ();
358+ refreshFileBrowser ();
340359 }
341360 var tabController = TabbedViewController (
342361 tabs,
@@ -394,6 +413,19 @@ class _EditorPageState extends State<EditorPage> {
394413 drawer: MyDrawer (documentList, project, (String filepath) {
395414 openFile (filepath);
396415 Navigator .pop (context);
416+ }, (String filepath) async {
417+ var selection = await showMenu (context: context, position: const RelativeRect .fromLTRB (1 , 1 , 1 , 1 ), items: < PopupMenuEntry <String >> [
418+ const PopupMenuItem <String >(
419+ value: "delete" ,
420+ child: Text ('Delete item' ),
421+ ),
422+ ]);
423+ //TODO: Menu should show up at tap location
424+ //TODO: Refactor menu into separate file
425+ switch (selection) {
426+ case 'delete' :
427+ deleteFileOrFolder (filepath);
428+ }
397429 }),
398430 appBar: AppBar (
399431 title: null ,
0 commit comments