diff --git a/lib/main.dart b/lib/main.dart index 66a3ab8..fd594ae 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -7,6 +7,7 @@ import "main_menu/main_menu.dart"; import "main_menu/projects/projects_screen.dart"; import "prefs.dart"; import "project_view/close_project_button.dart"; +import "project_view/open_in_explorer_button.dart"; import "project_view/project_view.dart"; import "tech_app.dart"; @@ -61,7 +62,10 @@ class MyHomePage extends ConsumerWidget { title: Text(title), actions: [ const Text("Version: $version\nBlueMap: $blueMapTag"), - if (projectDirectory != null) const CloseProjectButton(), + if (projectDirectory != null) ...[ + const OpenInFileManagerButton(), + const CloseProjectButton(), + ] ], ), body: projectDirectory == null ? const MainMenu() : const ProjectView(), diff --git a/lib/project_view/open_in_explorer_button.dart b/lib/project_view/open_in_explorer_button.dart new file mode 100644 index 0000000..cb52908 --- /dev/null +++ b/lib/project_view/open_in_explorer_button.dart @@ -0,0 +1,24 @@ +import "dart:io"; + +import "package:flutter/material.dart"; +import "package:flutter_riverpod/flutter_riverpod.dart"; +import "package:url_launcher/url_launcher.dart"; + +import "../main_menu/projects/projects_screen.dart"; + +class OpenInFileManagerButton extends ConsumerWidget { + const OpenInFileManagerButton({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + return IconButton( + tooltip: "Open in file manager", + onPressed: () { + final Directory? projectDirectory = ref.read(openProjectProvider); + if (projectDirectory == null) return; + launchUrl(projectDirectory.uri); + }, + icon: const Icon(Icons.folder_open), + ); + } +}