-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
99b11de
commit 3cb9570
Showing
10 changed files
with
2,003 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import 'dart:io'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:saveit/constants/appConstant.dart'; | ||
|
||
Directory dir = Directory('/storage/emulated/0/SaveIt/Tiktok'); | ||
Directory thumbDir = Directory('/storage/emulated/0/.saveit/.thumbs'); | ||
|
||
class TiktokGallery extends StatefulWidget { | ||
@override | ||
_TiktokGalleryState createState() => _TiktokGalleryState(); | ||
} | ||
|
||
class _TiktokGalleryState extends State<TiktokGallery> { | ||
List<bool> _isImage = []; | ||
|
||
void _checkType() { | ||
for (var item in dir.listSync()) { | ||
if (item.toString().endsWith(".jpg'")) { | ||
_isImage.add(true); | ||
} else { | ||
_isImage.add(false); | ||
} | ||
} | ||
} | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
if (dir.existsSync()) { | ||
_checkType(); | ||
} | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
if (!dir.existsSync()) { | ||
return Center( | ||
child: Text( | ||
'Sorry, No Downloads Found!', | ||
style: TextStyle(fontSize: 18.0), | ||
), | ||
); | ||
} else { | ||
var fileList = dir.listSync(); | ||
if (fileList.length > 0) { | ||
return Container( | ||
padding: EdgeInsets.only(bottom: 150.0), | ||
margin: EdgeInsets.only(left: 8.0, right: 8.0), | ||
child: GridView.builder( | ||
itemCount: fileList.length, | ||
itemBuilder: (context, index) { | ||
File file = fileList[index]; | ||
if (_isImage[index] == false) { | ||
String thumb = fileList[index].toString().replaceAll('File: \'/storage/emulated/0/SaveIt/Tiktok/', ''); | ||
thumb = thumb.substring(0, thumb.length - 4) + 'jpg'; | ||
var path = thumbDir.path + '/' + thumb; | ||
file = File(path); | ||
} | ||
return Column( | ||
children: <Widget>[ | ||
_isImage[index] | ||
? Container( | ||
height: screenWidthSize(120, context), | ||
width: screenWidthSize(120, context), | ||
decoration: BoxDecoration( | ||
shape: BoxShape.rectangle, | ||
color: Theme.of(context).primaryColor, | ||
), | ||
child: Image.file( | ||
file, | ||
fit: BoxFit.fitWidth, | ||
), | ||
) | ||
: Stack( | ||
children: <Widget>[ | ||
Container( | ||
height: screenWidthSize(120, context), | ||
width: screenWidthSize(120, context), | ||
decoration: BoxDecoration( | ||
shape: BoxShape.rectangle, | ||
color: Theme.of(context).primaryColor, | ||
), | ||
child: Image.file( | ||
file, | ||
fit: BoxFit.fitWidth, | ||
), | ||
), | ||
Align( | ||
alignment: Alignment.center, | ||
child: Padding( | ||
padding: EdgeInsets.all(4.0), | ||
child: Icon(Icons.videocam), | ||
), | ||
), | ||
], | ||
) | ||
], | ||
); | ||
}, | ||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( | ||
crossAxisCount: 3, | ||
mainAxisSpacing: 1.0, | ||
crossAxisSpacing: 10.0, | ||
childAspectRatio: 0.9, | ||
), | ||
), | ||
); | ||
} else { | ||
return Scaffold( | ||
body: Center( | ||
child: new Container( | ||
padding: EdgeInsets.only(bottom: 60.0), | ||
child: Text( | ||
'Sorry, No Downloads Found!', | ||
style: TextStyle(fontSize: 18.0), | ||
)), | ||
), | ||
); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.