Skip to content

Commit

Permalink
Merge pull request #19 from Hardik0307/Hardik_Controller
Browse files Browse the repository at this point in the history
Hardik controller
  • Loading branch information
Barad7987 authored Feb 19, 2020
2 parents ce518b1 + 50807c7 commit cbaf031
Show file tree
Hide file tree
Showing 15 changed files with 157 additions and 201 deletions.
4 changes: 1 addition & 3 deletions lib/displays/audios_display.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,9 @@ class _AudioDisplayScreenState extends State<AudioDisplayScreen>
));
},
);

}

}
return Container();
return Container();
});
} else {
return Center(
Expand Down
95 changes: 47 additions & 48 deletions lib/displays/duplicate_display.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import 'package:file_explorer/views/file_folder_dialog.dart';

import 'package:md5_plugin/md5_plugin.dart';


class DuplicateFileDisplayScreen extends StatefulWidget {
final String path;
final bool home;
Expand Down Expand Up @@ -49,34 +48,31 @@ class _DuplicateFileDisplayScreenState extends State<DuplicateFileDisplayScreen>
super.dispose();
}



bool calculateMD5SumAsyncWithPlugin(String filePath, String filePath1) {
bool calculateMD5SumAsyncWithPlugin(String filePath, String filePath1) {
Future<String> ret;
Future<String> ret1;
String x;
String y;
ret = Md5Plugin.getMD5WithPath(filePath);
ret.then((val){
print(val);
x = val;
});
ret1 = Md5Plugin.getMD5WithPath(filePath1);
ret1.then((val){
print(val);
y = val;
});
if(x == y)

ret = Md5Plugin.getMD5WithPath(filePath);
ret.then((val) {
print(val);
x = val;
});

ret1 = Md5Plugin.getMD5WithPath(filePath1);
ret1.then((val) {
print(val);
y = val;
});

if (x == y)
return true;
else
return false;
//return ret;
}


@override
Widget build(BuildContext context) {
super.build(context);
Expand Down Expand Up @@ -126,7 +122,7 @@ bool calculateMD5SumAsyncWithPlugin(String filePath, String filePath1) {
future: filesystem.searchFiles(
model.currentPath.absolute.path, '',
recursive: true),
builder: (BuildContext context, AsyncSnapshot snapshot) {
builder: (BuildContext context, AsyncSnapshot snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
return Text('Press button to start.');
Expand All @@ -137,7 +133,6 @@ bool calculateMD5SumAsyncWithPlugin(String filePath, String filePath1) {
if (snapshot.hasError) {
return Center(child: Text('Error: ${snapshot.error}'));
} else if (snapshot.data.length != 0) {

return GridView.builder(
physics: const AlwaysScrollableScrollPhysics(),
controller: _scrollController,
Expand All @@ -149,7 +144,6 @@ bool calculateMD5SumAsyncWithPlugin(String filePath, String filePath1) {
crossAxisCount: 4),
itemCount: snapshot.data.length,
itemBuilder: (context, index) {

String s;
if (snapshot.data[index] is MyFile &&
mime(snapshot.data[index].path) != null) {
Expand All @@ -158,40 +152,45 @@ bool calculateMD5SumAsyncWithPlugin(String filePath, String filePath1) {
list.add(snapshot.data[index]);
list2.add(snapshot.data[index].name);


for (int i = index + 1;
i < snapshot.data.length;
i++) {
int x=1,y=2;
String x1="a",y1="b";
bool exists1 = Directory(snapshot.data[index].path).existsSync();
bool exists2 = Directory(snapshot.data[i].path).existsSync();

if(mime(snapshot.data[index].path) != null && exists1 == false)
{
var file = File(snapshot.data[index].path);
x = file.lengthSync();
x1 = mime(snapshot.data[index].path);
}
if(mime(snapshot.data[i].path) != null && exists2 == false)
{
var file1 = File(snapshot.data[i].path);
y = file1.lengthSync() ;
y1 = mime(snapshot.data[i].path);
}
if ((x == y) && (x1== y1) && calculateMD5SumAsyncWithPlugin(snapshot.data[index].path,snapshot.data[i].path))// == snapshot.data[i].name)
{
for (int i = index + 1;
i < snapshot.data.length;
i++) {
int x = 1, y = 2;
String x1 = "a", y1 = "b";
bool exists1 =
Directory(snapshot.data[index].path)
.existsSync();
bool exists2 = Directory(snapshot.data[i].path)
.existsSync();

if (mime(snapshot.data[index].path) != null &&
exists1 == false) {
var file = File(snapshot.data[index].path);
x = file.lengthSync();
x1 = mime(snapshot.data[index].path);
}
if (mime(snapshot.data[i].path) != null &&
exists2 == false) {
var file1 = File(snapshot.data[i].path);
y = file1.lengthSync();
y1 = mime(snapshot.data[i].path);
}
if ((x == y) &&
(x1 == y1) &&
calculateMD5SumAsyncWithPlugin(
snapshot.data[index].path,
snapshot.data[i]
.path)) // == snapshot.data[i].name)
{
list.add(snapshot.data[i]);
list2.add(snapshot.data[i].name);
snapshot.data.removeAt(i);

}
}
}

if (list.length >= 2) {
print(list2);
for (int j = 0; j < list.length; j++) {

return FileWidget(
name: list[j].name,
onTap: () {
Expand Down
14 changes: 7 additions & 7 deletions lib/displays/folder_display.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ class _FolderListScreenState extends State<FolderListScreen>
VIdeoDisplayScreen(path: '/storage/emulated/0/')));
},
),
new ListTile(
new ListTile(
leading: Image.asset('assets/duplicateicon.png'),
title: Text('Duplicate Files'),
dense: false,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
DuplicateFileDisplayScreen(path: '/storage/emulated/0/')));
builder: (context) => DuplicateFileDisplayScreen(
path: '/storage/emulated/0/')));
},
)
],
Expand Down Expand Up @@ -272,9 +272,9 @@ class FolderFloatingActionButton extends StatelessWidget {
context: context, builder: (context) => CreateFolderDialog()),
);
} else
return Container(
width: 0.0,
height: 0.0,
);
return Container(
width: 0.0,
height: 0.0,
);
}
}
58 changes: 28 additions & 30 deletions lib/displays/images_display.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ import 'package:file_explorer/views/search.dart';
import 'package:file_explorer/notifiers/preferences.dart';
import 'package:file_explorer/views/file.dart';
import 'package:file_explorer/models/file.dart';
import 'package:file_explorer/models/folder.dart';
import 'package:file_explorer/views/folder.dart';
import 'package:file_explorer/utilities/dir_utils.dart' as filesystem;
import 'package:file_explorer/views/file_folder_dialog.dart';
import 'package:file_explorer/views/search.dart';

class ImageDisplayScreen extends StatefulWidget {
final String path;
Expand Down Expand Up @@ -115,35 +112,36 @@ class _ImageDisplayScreenState extends State<ImageDisplayScreen>
crossAxisCount: 4),
itemCount: snapshot.data.length,
itemBuilder: (context, index) {

String s = mime(snapshot.data[index].path);
String s = mime(snapshot.data[index].path);
if (snapshot.data[index] is MyFile &&
snapshot.data[index].name != null && s!=null && (s == 'image/bmp ' ||
s == 'image/cis-cod' ||
s == 'image/jpeg' ||
s == 'image/tiff' ||
s == 'image/gif' ||
s == 'image/ief' ||
s == 'image/png')) {
snapshot.data[index].name != null &&
s != null &&
(s == 'image/bmp ' ||
s == 'image/cis-cod' ||
s == 'image/jpeg' ||
s == 'image/tiff' ||
s == 'image/gif' ||
s == 'image/ief' ||
s == 'image/png')) {
//print(s);
return FileWidget(
name: snapshot.data[index].name,
onTap: () {
_printFuture(OpenFile.open(
snapshot.data[index].path));
},
onLongPress: () {
showDialog(
context: context,
builder: (context) => FileContextDialog(
path: snapshot.data[index].path,
name: snapshot.data[index].name,
));
},
);
}

return FileWidget(
name: snapshot.data[index].name,
onTap: () {
_printFuture(
OpenFile.open(snapshot.data[index].path));
},
onLongPress: () {
showDialog(
context: context,
builder: (context) => FileContextDialog(
path: snapshot.data[index].path,
name: snapshot.data[index].name,
));
},
);
}

return Container();
});
} else {
Expand Down
12 changes: 1 addition & 11 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ main() {
));
}



class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
Expand All @@ -36,15 +34,7 @@ class MyApp extends StatelessWidget {
themedWidgetBuilder: (context, theme) {
FlutterStatusbarcolor.setStatusBarColor(theme.primaryColor);
return MaterialApp(
title: 'Flutter Demo',
theme: theme,

home: StorageScreen()
);
title: 'Flutter Demo', theme: theme, home: StorageScreen());
});
}
}




12 changes: 4 additions & 8 deletions lib/models/file.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class MyFile implements Comparable<MyFile>
{
class MyFile implements Comparable<MyFile> {
final String path;
final String name;
bool selected;
Expand All @@ -8,14 +7,11 @@ class MyFile implements Comparable<MyFile>
// Wheather it's a directory or a file.
final String type;

MyFile
(
{this.path, this.name, this.type, this.selected: false, this.extension}
);
MyFile(
{this.path, this.name, this.type, this.selected: false, this.extension});

@override
int compareTo(other)
{
int compareTo(other) {
return type.compareTo(other.type);
}
}
13 changes: 4 additions & 9 deletions lib/models/folder.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class MyFolder implements Comparable<MyFolder>
{
class MyFolder implements Comparable<MyFolder> {
final String path;
final String name;
bool selected;
Expand All @@ -8,14 +7,10 @@ class MyFolder implements Comparable<MyFolder>

final String type;

MyFolder
(
{this.path, this.name, this.type, this.selected: false}
);
MyFolder({this.path, this.name, this.type, this.selected: false});

@override
int compareTo(other)
{
int compareTo(other) {
return type.compareTo(other.type);
}
}
}
Loading

0 comments on commit cbaf031

Please sign in to comment.