From a100e2a29243713d9f5a76f9325da2c2b1935682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gi=C3=A1o=20H=E1=BB=93?= <9401202+joutvhu@users.noreply.github.com> Date: Wed, 16 Aug 2023 02:04:46 +0700 Subject: [PATCH] Fix bug change the Default Distro Location not working (#209) * Fix bug change the Default Distro Location not working * Remove scripts --- docs/api/dialogs_create_dialog/createInstance.html | 2 +- .../screens_settings_screen/SettingsPageState/build.html | 2 +- .../SettingsPageState/settingsList.html | 6 ++++-- lib/dialogs/create_dialog.dart | 2 +- lib/screens/settings_screen.dart | 8 +++++--- pubspec.yaml | 5 ++--- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/docs/api/dialogs_create_dialog/createInstance.html b/docs/api/dialogs_create_dialog/createInstance.html index 86f58f5..552075c 100644 --- a/docs/api/dialogs_create_dialog/createInstance.html +++ b/docs/api/dialogs_create_dialog/createInstance.html @@ -90,7 +90,7 @@

Implementation

statusMsg('creatinginstance-text'.i18n(), loading: true); String location = locationController.text; if (location == '') { - location = prefs.getString("SaveLocation") ?? defaultPath; + location = prefs.getString("DistroPath") ?? defaultPath; location += '/$name'; } var result = await api.create( diff --git a/docs/api/screens_settings_screen/SettingsPageState/build.html b/docs/api/screens_settings_screen/SettingsPageState/build.html index 33f6ac4..56eb3be 100644 --- a/docs/api/screens_settings_screen/SettingsPageState/build.html +++ b/docs/api/screens_settings_screen/SettingsPageState/build.html @@ -236,7 +236,7 @@

Implementation

if (_settings['Default Distro Location']! .text .isNotEmpty) { - prefs.setString("SaveLocation", + prefs.setString("DistroPath", _settings['Default Distro Location']!.text); } String config = ''; diff --git a/docs/api/screens_settings_screen/SettingsPageState/settingsList.html b/docs/api/screens_settings_screen/SettingsPageState/settingsList.html index c0b828a..b07a1de 100644 --- a/docs/api/screens_settings_screen/SettingsPageState/settingsList.html +++ b/docs/api/screens_settings_screen/SettingsPageState/settingsList.html @@ -76,7 +76,9 @@

Implementation

suffix: IconButton( icon: const Icon(FluentIcons.open_folder_horizontal, size: 15.0), onPressed: () async { - String? path = await FilePicker.platform.getDirectoryPath(); + String? path = await FilePicker.platform.getDirectoryPath( + initialDirectory: prefs.getString("DistroPath") ?? defaultPath, + ); if (path != null && _settings['Default Distro Location'] != null) { _settings['Default Distro Location']!.text = path; @@ -85,7 +87,7 @@

Implementation

} }, ), - placeholder: prefs.getString("SaveLocation") ?? defaultPath), + placeholder: prefs.getString("DistroPath") ?? defaultPath), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ diff --git a/lib/dialogs/create_dialog.dart b/lib/dialogs/create_dialog.dart index 9cef034..6ee06b7 100644 --- a/lib/dialogs/create_dialog.dart +++ b/lib/dialogs/create_dialog.dart @@ -85,7 +85,7 @@ Future createInstance( Notify.message('creatinginstance-text'.i18n(), loading: true); String location = locationController.text; if (location == '') { - location = prefs.getString("SaveLocation") ?? defaultPath; + location = prefs.getString("DistroPath") ?? defaultPath; location += '/$name'; } diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart index d54a6bf..d05eb55 100644 --- a/lib/screens/settings_screen.dart +++ b/lib/screens/settings_screen.dart @@ -164,7 +164,7 @@ class SettingsPageState extends State { // Distro location setting if (_settings['Default Distro Location']!.text.isNotEmpty) { prefs.setString( - "SaveLocation", _settings['Default Distro Location']!.text); + "DistroPath", _settings['Default Distro Location']!.text); } _settings.forEach((key, value) { if (key != 'Default Distro Location' && value.text.isNotEmpty) { @@ -189,7 +189,9 @@ class SettingsPageState extends State { suffix: IconButton( icon: const Icon(FluentIcons.open_folder_horizontal, size: 15.0), onPressed: () async { - String? path = await FilePicker.platform.getDirectoryPath(); + String? path = await FilePicker.platform.getDirectoryPath( + initialDirectory: prefs.getString("DistroPath") ?? defaultPath, + ); if (path != null && _settings['Default Distro Location'] != null) { _settings['Default Distro Location']!.text = path; @@ -198,7 +200,7 @@ class SettingsPageState extends State { } }, ), - placeholder: prefs.getString("SaveLocation") ?? defaultPath), + placeholder: prefs.getString("DistroPath") ?? defaultPath), Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.all(8.0), diff --git a/pubspec.yaml b/pubspec.yaml index e95e8b9..771f98e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,11 +2,10 @@ name: wsl2distromanager description: A GUI to quickly manage your WSL instances. publish_to: "none" -version: 1.8.6 # Current version - +version: 1.8.7 # Current version environment: - sdk: ">=2.17.0 <3.0.0" + sdk: ">=2.17.0 <4.0.0" dependencies: flutter: