Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
katariyanikhil committed Jul 31, 2020
1 parent 99b11de commit 3cb9570
Show file tree
Hide file tree
Showing 10 changed files with 2,003 additions and 0 deletions.
122 changes: 122 additions & 0 deletions lib/screens/tiktokDownload/galleryScreen.dart
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),
)),
),
);
}
}
}
}
Loading

0 comments on commit 3cb9570

Please sign in to comment.