feat: make the directory where machines are stored more obvious
This commit is contained in:
parent
42b1ee4493
commit
60b96496f2
|
@ -3,15 +3,16 @@ import 'dart:convert';
|
||||||
import 'dart:core';
|
import 'dart:core';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:path/path.dart' as path;
|
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
|
import 'package:flutter/gestures.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:gettext_i18n/gettext_i18n.dart';
|
import 'package:gettext_i18n/gettext_i18n.dart';
|
||||||
|
import 'package:path/path.dart' as path;
|
||||||
|
|
||||||
import '../globals.dart';
|
import '../globals.dart';
|
||||||
import '../model/vminfo.dart';
|
|
||||||
import '../mixins/preferences_mixin.dart';
|
import '../mixins/preferences_mixin.dart';
|
||||||
|
import '../model/vminfo.dart';
|
||||||
|
|
||||||
/// VM manager page.
|
/// VM manager page.
|
||||||
/// Displays a list of available VMs, running state and connection info,
|
/// Displays a list of available VMs, running state and connection info,
|
||||||
|
@ -175,34 +176,47 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
|
||||||
final Color buttonColor = Theme.of(context).brightness == Brightness.dark
|
final Color buttonColor = Theme.of(context).brightness == Brightness.dark
|
||||||
? Colors.white70
|
? Colors.white70
|
||||||
: Theme.of(context).colorScheme.primary;
|
: Theme.of(context).colorScheme.primary;
|
||||||
_widgetList.add(
|
_widgetList.addAll(
|
||||||
Row(
|
[
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
Padding(
|
||||||
children: [
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||||
Text(
|
child: Row(
|
||||||
Directory.current.path,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
),
|
children: [
|
||||||
const SizedBox(
|
Text(
|
||||||
width: 8,
|
"${context.t('Directory where the machines are stored')}:",
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
const SizedBox(
|
||||||
style: ElevatedButton.styleFrom(
|
width: 8,
|
||||||
primary: Theme.of(context).canvasColor, onPrimary: buttonColor),
|
),
|
||||||
onPressed: () async {
|
Text.rich(
|
||||||
String? result = await FilePicker.platform.getDirectoryPath();
|
TextSpan(
|
||||||
if (result != null) {
|
recognizer: TapGestureRecognizer()
|
||||||
setState(() {
|
..onTap = () async {
|
||||||
Directory.current = result;
|
String? result =
|
||||||
});
|
await FilePicker.platform.getDirectoryPath();
|
||||||
|
if (result != null) {
|
||||||
|
setState(() {
|
||||||
|
Directory.current = result;
|
||||||
|
});
|
||||||
|
|
||||||
savePreference(prefWorkingDirectory, Directory.current.path);
|
savePreference(
|
||||||
_getVms(context);
|
prefWorkingDirectory, Directory.current.path);
|
||||||
}
|
_getVms(context);
|
||||||
},
|
}
|
||||||
child: const Icon(Icons.more_horiz),
|
},
|
||||||
|
text: Directory.current.path,
|
||||||
|
style:
|
||||||
|
TextStyle(color: Theme.of(context).colorScheme.primary),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
const Divider(
|
||||||
|
thickness: 2,
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
List<List<Widget>> rows = _currentVms.map((vm) {
|
List<List<Widget>> rows = _currentVms.map((vm) {
|
||||||
return _buildRow(vm, buttonColor);
|
return _buildRow(vm, buttonColor);
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gettext_i18n/gettext_i18n.dart';
|
||||||
|
|
||||||
import '../../globals.dart';
|
import '../../globals.dart';
|
||||||
import '../../mixins/preferences_mixin.dart';
|
import '../../mixins/preferences_mixin.dart';
|
||||||
|
@ -33,6 +36,42 @@ class _DownloaderMenuState extends State<DownloaderMenu> with PreferencesMixin {
|
||||||
: Theme.of(context).colorScheme.primary,
|
: Theme.of(context).colorScheme.primary,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"${context.t('Directory where the machines are stored')}:",
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 8,
|
||||||
|
),
|
||||||
|
Text.rich(
|
||||||
|
TextSpan(
|
||||||
|
recognizer: TapGestureRecognizer()
|
||||||
|
..onTap = () async {
|
||||||
|
var folder = await FilePicker.platform
|
||||||
|
.getDirectoryPath(dialogTitle: "Pick a folder");
|
||||||
|
if (folder != null) {
|
||||||
|
setState(() {
|
||||||
|
Directory.current = folder;
|
||||||
|
});
|
||||||
|
savePreference(
|
||||||
|
prefWorkingDirectory, Directory.current.path);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
text: Directory.current.path,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.primary),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Divider(
|
||||||
|
thickness: 2,
|
||||||
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
|
@ -48,41 +87,6 @@ class _DownloaderMenuState extends State<DownloaderMenu> with PreferencesMixin {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
Directory.current.path,
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.subtitle1!
|
|
||||||
.copyWith(color: Colors.white),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
width: 8,
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
primary: Theme.of(context).canvasColor,
|
|
||||||
onPrimary: Theme.of(context).brightness == Brightness.dark
|
|
||||||
? Colors.white70
|
|
||||||
: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
onPressed: () async {
|
|
||||||
var folder = await FilePicker.platform
|
|
||||||
.getDirectoryPath(dialogTitle: "Pick a folder");
|
|
||||||
if (folder != null) {
|
|
||||||
setState(() {
|
|
||||||
Directory.current = folder;
|
|
||||||
});
|
|
||||||
savePreference(
|
|
||||||
prefWorkingDirectory, Directory.current.path);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: const Icon(Icons.more_horiz),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue