Skip to content

Commit

Permalink
Handle non-existent project directories better
Browse files Browse the repository at this point in the history
  • Loading branch information
TechnicJelle committed Nov 10, 2024
1 parent 29a8fdc commit 6b48475
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/main_menu/projects/project_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ enum _OpeningStep {
}

enum _OpenError {
directoryNotFound,
downloadFailed,
wrongHash,
}
Expand Down Expand Up @@ -117,7 +118,7 @@ class _PathPickerButtonState extends ConsumerState<ProjectTile> {
Text(projectDirectory.path),
if (!projectDirectoryExists)
Text(
"Error: Directory not found",
"Error: Directory not found.",
style: TextStyle(color: Colors.red[600]),
),
],
Expand Down Expand Up @@ -186,6 +187,8 @@ class _PathPickerButtonState extends ConsumerState<ProjectTile> {

// == Check if project directory exists ==
if (!projectDirectory.existsSync()) {
ref.read(_openingStateProvider.notifier).error(error: _OpenError.directoryNotFound);
setState(() => projectDirectoryExists = false); //to update the subtitle
return;
}

Expand Down Expand Up @@ -294,6 +297,11 @@ class _OpenProjectDialog extends ConsumerWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: switch (ref.read(_openingStateProvider.notifier).getError()) {
_OpenError.directoryNotFound => [
const Text("The project directory could not be found!"),
const SizedBox(height: 8),
const Text("Try removing it from the list and recreating it."),
],
_OpenError.downloadFailed => [
const Text("Failed to download BlueMap CLI JAR.\n"
"Check your internet connection and try again."),
Expand Down

0 comments on commit 6b48475

Please sign in to comment.