1+ import 'dart:io' ;
2+
13import 'package:fdupes_gui/core/util.dart' as util;
24import 'package:fdupes_gui/domain/fdupes_bloc.dart' ;
35import 'package:fdupes_gui/presentation/dupes_body.dart' ;
@@ -14,7 +16,7 @@ class DupeScreen extends StatelessWidget {
1416 return Center (
1517 child: ElevatedButton (
1618 child: Text ('Select folder' ),
17- onPressed: () => _showSelectFolderDialog (context, null ),
19+ onPressed: () => _showSelectFolderDialog (context, initialDir : null , currentDirs : [] ),
1820 ),
1921 );
2022 }
@@ -61,25 +63,69 @@ class DupeScreen extends StatelessWidget {
6163 padding: EdgeInsets .all (8 ),
6264 child: Column (
6365 children: < Widget > [
64- Row (children: [
65- ElevatedButton (
66- child: Text ('Change folder' ),
67- onPressed: () => _showSelectFolderDialog (context, state.dir),
68- ),
69- SizedBox (width: 8 ),
70- Expanded (child: Text (state.dir)),
71- SizedBox (width: 8 ),
72- ElevatedButton (
73- child: Icon (Icons .refresh),
74- onPressed: () => BlocProvider .of <FdupesBloc >(context).add (FdupesEventDirSelected (state.dir)),
75- ),
76- ]),
66+ Row (
67+ mainAxisSize: MainAxisSize .max,
68+ crossAxisAlignment: CrossAxisAlignment .start,
69+ children: [
70+ Expanded (
71+ child: Column (
72+ children: state.dirs
73+ .map ((dir) => [
74+ Row (children: [
75+ ElevatedButton (
76+ child: Text ('Change folder' ),
77+ onPressed: () => _showSelectFolderDialog (
78+ context,
79+ initialDir: dir,
80+ currentDirs: state.dirs,
81+ ),
82+ ),
83+ SizedBox (width: 8 ),
84+ Text (dir.path),
85+ IconButton (
86+ icon: Icon (Icons .remove_circle),
87+ visualDensity: VisualDensity .compact,
88+ iconSize: 14 ,
89+ onPressed: () => BlocProvider .of <FdupesBloc >(context)
90+ .add (FdupesEventDirsSelected (state.dirs..remove (dir))),
91+ ),
92+ ]),
93+ SizedBox (height: 8 ),
94+ ])
95+ .expand ((e) => e)
96+ .toList (),
97+ ),
98+ ),
99+ SizedBox (width: 8 ),
100+ Column (
101+ children: [
102+ Tooltip (
103+ message: 'Find duplicates' ,
104+ child: ElevatedButton (
105+ child: Icon (Icons .refresh),
106+ onPressed: () =>
107+ BlocProvider .of <FdupesBloc >(context).add (FdupesEventDirsSelected (state.dirs)),
108+ ),
109+ ),
110+ SizedBox (height: 8 ),
111+ Tooltip (
112+ message: 'Add input folder' ,
113+ child: ElevatedButton (
114+ child: Icon (Icons .add),
115+ onPressed: () =>
116+ _showSelectFolderDialog (context, initialDir: null , currentDirs: state.dirs),
117+ ),
118+ ),
119+ ],
120+ ),
121+ ],
122+ ),
77123 SizedBox (height: 8 ),
78124 if (state.dupeGroups.isEmpty)
79125 Text ('no dupes found' )
80126 else
81127 DupesBody (
82- baseDir : state.dir ,
128+ baseDirs : state.dirs ,
83129 dupeGroups: state.dupeGroups,
84130 selectedDupeGroup: state.selectedDupeGroup,
85131 ),
@@ -92,11 +138,19 @@ class DupeScreen extends StatelessWidget {
92138 );
93139 }
94140
95- Future <void > _showSelectFolderDialog (BuildContext context, String ? initialDir) async {
141+ Future <void > _showSelectFolderDialog (
142+ BuildContext context, {
143+ Directory ? initialDir,
144+ required List <Directory > currentDirs,
145+ }) async {
96146 final dir = await FileSelectorPlatform .instance
97- .getDirectoryPath (initialDirectory: initialDir ?? util.userHome, confirmButtonText: 'Select' );
147+ .getDirectoryPath (initialDirectory: initialDir? .path ?? util.userHome, confirmButtonText: 'Select' );
98148 if (dir != null ) {
99- BlocProvider .of <FdupesBloc >(context).add (FdupesEventDirSelected (dir));
149+ if (initialDir != null ) {
150+ currentDirs.remove (initialDir);
151+ }
152+ currentDirs.add (Directory (dir));
153+ BlocProvider .of <FdupesBloc >(context).add (FdupesEventDirsSelected (currentDirs));
100154 }
101155 }
102156
0 commit comments