Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
🐛 インポート時のバックアップフォルダーで D&D できないバグ
Browse files Browse the repository at this point in the history
  • Loading branch information
wappon28dev committed Oct 14, 2023
1 parent d333ee3 commit 1405635
Showing 1 changed file with 52 additions and 40 deletions.
92 changes: 52 additions & 40 deletions lib/view/components/create_pj/set_pj_config.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'dart:io';

import 'package:cross_file/cross_file.dart';
import 'package:desktop_drop/desktop_drop.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
Expand Down Expand Up @@ -98,6 +100,14 @@ class CompSetPjConfig extends HookConsumerWidget {
isValidContentsNotifier.state = isPjNameValid && isWorkingDirValid;
}

void updateDir(Directory dir) {
backupDirNotifier.state = dir;
}

Future<void> onDragDone(List<XFile> files) async {
updateDir(await Contents.getSingleDirectory(files));
}

// view
final pjNameField = Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
Expand Down Expand Up @@ -189,48 +199,52 @@ class CompSetPjConfig extends HookConsumerWidget {
],
);

final backupDirField = Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Expanded(
flex: 2,
child: Column(
children: [
Icon(Icons.folder_copy, size: 47),
Text('バックアップ\nフォルダー', textAlign: TextAlign.center),
],
final backupDirField = DropTarget(
onDragDone: (details) => {onDragDone(details.files)},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Expanded(
flex: 2,
child: Column(
children: [
Icon(Icons.folder_copy, size: 47),
Text('バックアップ\nフォルダー', textAlign: TextAlign.center),
],
),
),
),
Expanded(
flex: 12,
child: Focus(
child: TextFormField(
controller: backupDirFormController,
autovalidateMode: AutovalidateMode.always,
validator: backupDirValidator,
onChanged: (_) => updateValidState(),
decoration: InputDecoration(
hintText: getBackupDirStr() ?? '(ドラッグアンドドロップでも指定可)',
border: const OutlineInputBorder(),
Expanded(
flex: 12,
child: Focus(
child: TextFormField(
controller: backupDirFormController,
autovalidateMode: AutovalidateMode.always,
validator: backupDirValidator,
onChanged: (_) => updateValidState(),
decoration: InputDecoration(
hintText: getBackupDirStr() ?? '(ドラッグアンドドロップでも指定可)',
border: const OutlineInputBorder(),
),
),
),
onFocusChange: (hasFocus) {
if (!hasFocus) {
if (backupDirValidator(backupDirFormController.text) == null) {
backupDirNotifier.state =
Directory(backupDirFormController.text);
onFocusChange: (hasFocus) {
if (!hasFocus) {
if (backupDirValidator(backupDirFormController.text) ==
null) {
backupDirNotifier.state =
Directory(backupDirFormController.text);
}
}
}
},
},
),
),
),
Expanded(
child: IconButton(
onPressed: handleClick,
icon: const Icon(Icons.more_horiz),
Expanded(
child: IconButton(
onPressed: handleClick,
icon: const Icon(Icons.more_horiz),
),
),
),
],
],
),
);

return Column(
Expand Down Expand Up @@ -258,9 +272,7 @@ class CompSetPjConfig extends HookConsumerWidget {
onPressed: () {
pjNameFormController.text = workingDirState?.name ?? '';
backupDirFormController.text =
contentsState.defaultBackupDir?.path ??
backupDirState?.path ??
'';
contentsState.defaultBackupDir?.path ?? '';
},
),
),
Expand Down

0 comments on commit 1405635

Please sign in to comment.