From 57ebc186eb10570e253e21a1139838531d4d6ed8 Mon Sep 17 00:00:00 2001 From: m0nac0 <58807793+m0nac0@users.noreply.github.com> Date: Mon, 27 Dec 2021 11:46:13 +0100 Subject: [PATCH] desktop gui: allow choosing between two locations for project dir --- lib/gui/aia_compiler_widget_desktop.dart | 65 +++++++++++++++++++++--- 1 file changed, 58 insertions(+), 7 deletions(-) diff --git a/lib/gui/aia_compiler_widget_desktop.dart b/lib/gui/aia_compiler_widget_desktop.dart index 427b488..d55d163 100644 --- a/lib/gui/aia_compiler_widget_desktop.dart +++ b/lib/gui/aia_compiler_widget_desktop.dart @@ -82,6 +82,14 @@ class _AIAAccepterDesktopState extends State { if (Platform.isLinux) BuildTarget.linux, ]; + // The directory selected by the user to create the project directory in + int selectedDir = 0; + final dirPathSystemTemp = Directory.systemTemp.absolute.path; + final dirPathAtExecutable = Platform.resolvedExecutable.substring( + 0, Platform.resolvedExecutable.lastIndexOf(Platform.pathSeparator)) + + Platform.pathSeparator + + "xaif_projects"; + @override void initState() { super.initState(); @@ -109,21 +117,61 @@ class _AIAAccepterDesktopState extends State { @override Widget build(BuildContext context) { const spacer = SizedBox(height: 10); + return Row( children: [ Expanded( child: Column( children: [ + if (dir == null) + IntrinsicWidth( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + spacer, + const Text( + "Create new project directory in: ", + style: TextStyle( + fontSize: 18, fontWeight: FontWeight.bold), + ), + spacer, + RadioListTile( + value: 0, + groupValue: selectedDir, + title: Text(dirPathSystemTemp), + onChanged: (value) { + setState(() { + selectedDir = value!; + }); + }, + ), + RadioListTile( + value: 1, + groupValue: selectedDir, + title: Text(dirPathAtExecutable), + onChanged: (value) { + setState(() { + selectedDir = value!; + }); + }, + ), + ], + ), + ), + if (dir == null) Divider(), spacer, SizedBox( width: 400, - height: code.split("\n").length > 2 ? 50 : 400, + height: code.split("\n").length > 2 ? 50 : 200, child: ElevatedButton( - child: Text("Select AIA file " + - (runningFlutterProcesses.values - .any((process) => process != null) - ? "to update" - : "to run")), + child: Text( + "Select AIA file " + + (dir != null + ? "to update" + : ""), + style: + TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + ), onPressed: () => pickAndHandleAIAFile(context), )), spacer, @@ -553,7 +601,10 @@ class _AIAAccepterDesktopState extends State { /// Ensures that the working / project directory exists and returns it Future ensureDirectory() async { if (dir == null) { - dir = await Directory.systemTemp.createTemp(dirPrefix); + dir = await (await Directory( + selectedDir == 1 ? dirPathAtExecutable : dirPathSystemTemp) + .create()) + .createTemp(dirPrefix); setState(() { dir = dir; });