1- import 'dart:io' ;
2-
31import 'package:fdupes_gui/core/util.dart' as util;
42import 'package:fdupes_gui/domain/fdupes_bloc.dart' ;
53import 'package:fdupes_gui/presentation/dupes_body.dart' ;
4+ import 'package:fdupes_gui/presentation/dupes_top_bar.dart' ;
5+ import 'package:fdupes_gui/presentation/select_folder_dialog.dart' ;
66import 'package:file_selector_platform_interface/file_selector_platform_interface.dart' ;
77import 'package:flutter/material.dart' ;
88import 'package:flutter_bloc/flutter_bloc.dart' ;
@@ -16,7 +16,7 @@ class DupeScreen extends StatelessWidget {
1616 return Center (
1717 child: ElevatedButton (
1818 child: Text ('Select folder' ),
19- onPressed: () => _showSelectFolderDialog (context, initialDir: null , currentDirs: []),
19+ onPressed: () => showSelectFolderDialog (context, initialDir: null , currentDirs: []),
2020 ),
2121 );
2222 }
@@ -63,63 +63,7 @@ class DupeScreen extends StatelessWidget {
6363 padding: EdgeInsets .all (8 ),
6464 child: Column (
6565 children: < Widget > [
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- ),
66+ DupesTopBar (baseDirs: state.dirs),
12367 SizedBox (height: 8 ),
12468 if (state.dupeGroups.isEmpty)
12569 Text ('no dupes found' )
@@ -138,22 +82,6 @@ class DupeScreen extends StatelessWidget {
13882 );
13983 }
14084
141- Future <void > _showSelectFolderDialog (
142- BuildContext context, {
143- Directory ? initialDir,
144- required List <Directory > currentDirs,
145- }) async {
146- final dir = await FileSelectorPlatform .instance
147- .getDirectoryPath (initialDirectory: initialDir? .path ?? util.userHome, confirmButtonText: 'Select' );
148- if (dir != null ) {
149- if (initialDir != null ) {
150- currentDirs.remove (initialDir);
151- }
152- currentDirs.add (Directory (dir));
153- BlocProvider .of <FdupesBloc >(context).add (FdupesEventDirsSelected (currentDirs));
154- }
155- }
156-
15785 Future <void > _locateBinary (BuildContext context) async {
15886 final fdupesBloc = context.read <FdupesBloc >();
15987 final fdupesLocation = await FileSelectorPlatform .instance.openFile (
0 commit comments