Skip to content

Commit

Permalink
Fix wrong settings page of inputs and behaviors routes and refreshing…
Browse files Browse the repository at this point in the history
… of move
  • Loading branch information
CodeDoctorDE committed Sep 16, 2024
1 parent 9c5df0e commit 50f00f5
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 20 deletions.
6 changes: 3 additions & 3 deletions app/lib/actions/change_path.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ class ChangePathAction extends Action<ChangePathIntent> {
var asset = await fileSystem.getAsset(location.path);
if (asset == null) return;
if (context.mounted) {
var newPath = await showDialog<String?>(
var newPaths = await showDialog<List<String>>(
context: context,
builder: (context) => FileSystemAssetMoveDialog(
assets: [asset.location],
fileSystem: fileSystem,
));
if (newPath == null) return;
if (newPaths == null) return;
state.currentIndexCubit.setSaveState(
location: location.copyWith(path: newPath),
location: location.copyWith(path: newPaths.first),
);
state.save();
}
Expand Down
9 changes: 5 additions & 4 deletions app/lib/dialogs/file_system/move.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class _FileSystemAssetMoveDialogState extends State<FileSystemAssetMoveDialog> {

Future<void> _move(bool duplicate) async {
final navigator = Navigator.of(context);
String newPath = '';
final newPaths = <String>[];
for (final asset in widget.assets) {
newPath = selectedPath;
var newPath = selectedPath;
if (selectedPath != '/') {
newPath += '/';
}
Expand All @@ -58,8 +58,9 @@ class _FileSystemAssetMoveDialogState extends State<FileSystemAssetMoveDialog> {
} else {
await widget.fileSystem.moveAsset(asset.path, newPath);
}
newPaths.add(newPath);
}
navigator.pop(newPath);
navigator.pop(newPaths);
}

@override
Expand All @@ -73,7 +74,7 @@ class _FileSystemAssetMoveDialogState extends State<FileSystemAssetMoveDialog> {
actions: [
TextButton(
child: Text(AppLocalizations.of(context).cancel),
onPressed: () => Navigator.of(context).pop(),
onPressed: () => Navigator.of(context).pop(null),
),
if (widget.moveMode != null)
ElevatedButton(
Expand Down
8 changes: 7 additions & 1 deletion app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:args/args.dart';
import 'package:butterfly/api/file_system.dart';
import 'package:butterfly/api/intent.dart';
import 'package:butterfly/services/sync.dart';
import 'package:butterfly/settings/behaviors.dart';
import 'package:butterfly/settings/inputs/mouse.dart';
import 'package:butterfly/settings/experiments.dart';
import 'package:dynamic_color/dynamic_color.dart';
Expand Down Expand Up @@ -180,7 +181,7 @@ class ButterflyApp extends StatelessWidget {
builder: (context, state) => const GeneralSettingsPage(),
),
GoRoute(
path: 'behaviors',
path: 'inputs',
builder: (context, state) => const InputsSettingsPage(),
routes: [
GoRoute(
Expand All @@ -204,6 +205,11 @@ class ButterflyApp extends StatelessWidget {
),
],
),
GoRoute(
path: 'behaviors',
builder: (context, state) =>
const BehaviorsSettingsPage(),
),
GoRoute(
path: 'personalization',
builder: (context, state) =>
Expand Down
11 changes: 4 additions & 7 deletions app/lib/settings/inputs/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,25 @@ class InputsSettingsPage extends StatelessWidget {
leading:
const PhosphorIcon(PhosphorIconsLight.mouse),
title: Text(AppLocalizations.of(context).mouse),
onTap: () =>
context.push('/settings/behaviors/mouse'),
onTap: () => context.push('/settings/inputs/mouse'),
),
ListTile(
leading:
const PhosphorIcon(PhosphorIconsLight.hand),
title: Text(AppLocalizations.of(context).touch),
onTap: () =>
context.push('/settings/behaviors/touch'),
onTap: () => context.push('/settings/inputs/touch'),
),
ListTile(
leading:
const PhosphorIcon(PhosphorIconsLight.keyboard),
title: Text(AppLocalizations.of(context).keyboard),
onTap: () =>
context.push('/settings/behaviors/keyboard'),
context.push('/settings/inputs/keyboard'),
),
ListTile(
leading: const PhosphorIcon(PhosphorIconsLight.pen),
title: Text(AppLocalizations.of(context).pen),
onTap: () =>
context.push('/settings/behaviors/pen'),
onTap: () => context.push('/settings/inputs/pen'),
),
]),
)),
Expand Down
4 changes: 3 additions & 1 deletion app/lib/views/files/grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,9 @@ class FilesActionMenu extends StatelessWidget {
assets: [entity.location],
fileSystem: documentSystem,
),
).then((value) => onReload()),
).then((value) {
if (value != null) onReload();
}),
leadingIcon: const PhosphorIcon(PhosphorIconsLight.arrowsDownUp),
child: Text(AppLocalizations.of(context).move),
),
Expand Down
4 changes: 3 additions & 1 deletion app/lib/views/files/list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ class FileEntityListTile extends StatelessWidget {
assets: [entity.location],
fileSystem: documentSystem,
),
).then((value) => onReload()),
).then((value) {
if (value != null) onReload();
}),
tooltip: AppLocalizations.of(context).move,
icon: const PhosphorIcon(
PhosphorIconsLight.arrowsDownUp),
Expand Down
6 changes: 3 additions & 3 deletions app/lib/views/files/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,9 @@ class FilesViewState extends State<FilesView> {
.toList(),
fileSystem: _documentSystem,
),
).then(
(value) => reloadFileSystem(),
),
).then((value) {
if (value != null) reloadFileSystem();
}),
),
Builder(
builder: (context) => IconButton(
Expand Down
4 changes: 4 additions & 0 deletions metadata/en-US/changelogs/114.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* Fix wrong settings page of inputs and behaviors routes
* Fix file system refreshing on cancelling moving a file

Read more here: https://linwood.dev/butterfly/2.2.0-rc.1

0 comments on commit 50f00f5

Please sign in to comment.