-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial version of multi-project support!!
Needs a looot more polish though...
- Loading branch information
1 parent
cbe5e53
commit fbd09f2
Showing
14 changed files
with
360 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import "package:flutter/material.dart"; | ||
|
||
class Hover extends StatefulWidget { | ||
final Widget alwaysChild; | ||
final Widget hoverChild; | ||
|
||
const Hover({ | ||
super.key, | ||
required this.alwaysChild, | ||
required this.hoverChild, | ||
}); | ||
|
||
@override | ||
State<Hover> createState() => _HoverState(); | ||
} | ||
|
||
class _HoverState extends State<Hover> { | ||
bool _isHovering = false; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MouseRegion( | ||
onEnter: (_) => setState(() => _isHovering = true), | ||
onHover: (_) => setState(() => _isHovering = true), | ||
onExit: (_) => setState(() => _isHovering = false), | ||
child: Stack( | ||
children: [ | ||
widget.alwaysChild, | ||
if (_isHovering) widget.hoverChild, | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import "dart:io"; | ||
|
||
import "package:flutter/material.dart"; | ||
import "package:flutter_riverpod/flutter_riverpod.dart"; | ||
import "package:path/path.dart" as p; | ||
import "package:path_provider/path_provider.dart"; | ||
|
||
import "../../prefs.dart"; | ||
|
||
//TODO: This thing needs a LOT of polish and error checking! | ||
class NewProjectDialog extends ConsumerStatefulWidget { | ||
const NewProjectDialog({super.key}); | ||
|
||
@override | ||
NewProjectDialogState createState() => NewProjectDialogState(); | ||
} | ||
|
||
class NewProjectDialogState extends ConsumerState<NewProjectDialog> { | ||
final TextEditingController _nameController = TextEditingController(text: "untitled"); | ||
TextEditingController? _locationController; | ||
|
||
String get _projectPath => | ||
p.join(_locationController?.text ?? "", _nameController.text); | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
getApplicationDocumentsDirectory().then((documentsDirectory) { | ||
final String projectDir = p.join(documentsDirectory.path, "BlueMapGUI"); | ||
setState(() { | ||
_locationController = TextEditingController(text: projectDir); | ||
}); | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return AlertDialog( | ||
title: const Text("New project"), | ||
content: ConstrainedBox( | ||
constraints: const BoxConstraints(minWidth: 600), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
TextField( | ||
controller: _nameController, | ||
onChanged: (_) => setState(() {}), | ||
decoration: const InputDecoration( | ||
labelText: "Name:", | ||
), | ||
), | ||
const SizedBox(height: 16), | ||
TextField( | ||
controller: _locationController, | ||
onChanged: (_) => setState(() {}), | ||
decoration: const InputDecoration( | ||
labelText: "Location:", | ||
), | ||
), | ||
const SizedBox(height: 8), | ||
Text( | ||
"Project will be created in: $_projectPath", | ||
style: | ||
Theme.of(context).textTheme.labelMedium?.copyWith(color: Colors.grey), | ||
), | ||
], | ||
), | ||
), | ||
actions: [ | ||
TextButton( | ||
onPressed: () => Navigator.of(context).pop(), | ||
child: const Text("Cancel"), | ||
), | ||
ElevatedButton( | ||
onPressed: () { | ||
ref.read(knownProjectsProvider.notifier).addProject(Directory(_projectPath)); | ||
Navigator.of(context).pop(); | ||
}, | ||
child: const Text("Create"), | ||
), | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.