Skip to content

Commit

Permalink
Merge pull request #10 from Atulin/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Atulin authored Sep 4, 2019
2 parents 533d29d + dd464ba commit 0f4e2d8
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 46 deletions.
28 changes: 20 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,36 @@ Derpibooru client made with Flutter

## Screenshots

### Main grid view
| Main grid view | Full image view | Image details | App drawer |
| -------------- | --------------- | ------------- | ---------- |
| ![Main grid view](screenshots/gridview.jpg) | ![Full image view](screenshots/fullview.jpg) | ![Image details](screenshots/details.jpg) | ![App drawer](screenshots/drawer.jpg) |

![Main grid view](screenshots/gridview.jpg)
<!--### Main grid view-->

### Full image view
<!--![Main grid view](screenshots/gridview.jpg)-->

![Full image view](screenshots/fullview.jpg)
<!--### Full image view-->

### Image details
<!--![Full image view](screenshots/fullview.jpg)-->

![Image details](screenshots/details.jpg)
<!--### Image details-->

### App drawer
<!--![Image details](screenshots/details.jpg)-->

![App drawer](screenshots/drawer.jpg)
<!--### App drawer-->

<!--![App drawer](screenshots/drawer.jpg)-->

## Changelog

* **04.09.2019**
* Added favourites list
* Made history and favourites dismissable
* Added video progress bar
* If a video is playing, all other videos will autostart, if a video
is paused, all other videos will be paused as well
* Rating filter is now saved on change

* **02.06.2019**
* Webm files now show their gif thumbnail previews in grid view!
* Webm files in the big view *kinda* work now!
Expand Down
97 changes: 97 additions & 0 deletions lib/Elements/FavouritesModal.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import 'package:chryssibooru/API.dart';
import 'package:chryssibooru/DerpisRepo.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';

class FavouritesModal extends StatefulWidget {
FavouritesModal({@required this.repo});

final DerpisRepo repo;

@override
_FavouritesModal createState() => _FavouritesModal();
}

class _FavouritesModal extends State<FavouritesModal> {
List<String> _favourites = List<String>();
DerpisRepo _repo;
Color _dismissColor = Colors.red;

@override
void initState() {
_repo = widget.repo;
super.initState();
}

void _getSearchFavourites() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
_favourites = prefs.getStringList("favourites");
});
}

void _removeSearchFromFavourites(int index) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
List<String> favourites = prefs.getStringList("favourites") ?? new List<String>();

if (favourites == null) return;

favourites.removeAt(index);
prefs.setStringList("favourites", favourites);

_getSearchFavourites();
}

@override
Widget build(BuildContext context) {
_getSearchFavourites();
return new AlertDialog(
contentPadding: EdgeInsets.all(0.0),
title: new Container(
child: Text("Favourites"),
padding: EdgeInsets.only(bottom: 3.0),
decoration: new BoxDecoration(
border:
new Border(bottom: BorderSide(width: 1.0, color: Colors.grey))),
),
content: new ListView.builder(
padding: EdgeInsets.only(top: 5.0),
itemCount: _favourites.length,
itemBuilder: (BuildContext context, int index) {
return new Dismissible(
key: Key(_favourites[index]),
background: Container(
color: _dismissColor,
),
onDismissed: (direction) {
_removeSearchFromFavourites(index);
},
child: InkWell(
child: Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20.0, top: 10.0, bottom: 10.0),
child: Text(_favourites[index]),
),
onTap: () {
if (_favourites[index] != _repo.query) {
_repo.derpis = new List<Derpi>();
_repo.page = 1;
_repo.query = _favourites[index];
setState(() {
_repo.loadDerpis();
});
}
},
));
}),
actions: <Widget>[
// usually buttons at the bottom of the dialog
new FlatButton(
child: new Text("Close"),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
}
}
69 changes: 49 additions & 20 deletions lib/Elements/HistoryModal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:chryssibooru/API.dart';
import 'package:chryssibooru/DerpisRepo.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_slidable/flutter_slidable.dart';

class HistoryModal extends StatefulWidget {
HistoryModal({@required this.repo});
Expand All @@ -15,6 +16,7 @@ class HistoryModal extends StatefulWidget {
class _HistoryModal extends State<HistoryModal> {
List<String> _history = List<String>();
DerpisRepo _repo;
Color _dismissColor = Colors.red;

@override
void initState() {
Expand All @@ -41,33 +43,60 @@ class _HistoryModal extends State<HistoryModal> {
_getSearchHistory();
}

void _addSearchToFavourites(int index) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
List<String> history = prefs.getStringList("history") ?? new List<String>();
List<String> favourites = prefs.getStringList("favourites") ?? new List<String>();

if (favourites == null) return;

favourites.add(history[index]);
prefs.setStringList("favourites", favourites);
}

@override
Widget build(BuildContext context) {
_getSearchHistory();
return new AlertDialog(
title: new Text("History"),
contentPadding: EdgeInsets.all(0.0),
title: new Container(
child: Text("History"),
padding: EdgeInsets.only(bottom: 3.0),
decoration: new BoxDecoration(
border:
new Border(bottom: BorderSide(width: 1.0, color: Colors.grey))),
),
content: new ListView.builder(
padding: EdgeInsets.only(top: 5.0),
itemCount: _history.length,
itemBuilder: (BuildContext context, int index) {
return new InkWell(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(_history[index]),
),
onTap: () {
if (_history[index] != _repo.query) {
_repo.derpis = new List<Derpi>();
_repo.page = 1;
_repo.query = _history[index];
setState(() {
_repo.loadDerpis();
});
}
},
onLongPress: () {
_removeSearchFromHistory(index);
},
);
return new Dismissible(
key: Key(_history[index]),
background: Container(
color: _dismissColor,
),
onDismissed: (direction) {
_removeSearchFromHistory(index);
},
child: InkWell(
child: Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20.0, top: 10.0, bottom: 10.0),
child: Text(_history[index]),
),
onTap: () {
if (_history[index] != _repo.query) {
_repo.derpis = new List<Derpi>();
_repo.page = 1;
_repo.query = _history[index];
setState(() {
_repo.loadDerpis();
});
}
},
onLongPress: () {
_addSearchToFavourites(index);
},
));
}),
actions: <Widget>[
// usually buttons at the bottom of the dialog
Expand Down
36 changes: 35 additions & 1 deletion lib/Views/HomePage.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:chryssibooru/API.dart';
import 'package:chryssibooru/DerpisRepo.dart';
import 'package:chryssibooru/Elements/FavouritesModal.dart';
import 'package:chryssibooru/Elements/FilterSheet.dart';
import 'package:chryssibooru/Elements/HistoryModal.dart';
import 'package:chryssibooru/Views/ImageViewer.dart';
Expand Down Expand Up @@ -63,6 +64,7 @@ class HomePageState extends State<HomePage> {
@override
void initState() {
getCacheSize();
_getRatingPrefs();
_scrollController = ScrollController();
_scrollController.addListener(_loadDerpisListener);
super.initState();
Expand All @@ -79,6 +81,22 @@ class HomePageState extends State<HomePage> {
}
}

void _getRatingPrefs() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
_s = prefs.getBool('safe');
_q = prefs.getBool('questionable');
_e = prefs.getBool('explicit');
});
}

void _saveRatingPrefs() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setBool('safe', _s);
prefs.setBool('questionable', _q);
prefs.setBool('explicit', _e);
}

void _saveKey(String key) async {
setState(() {
repo.key = key;
Expand Down Expand Up @@ -230,14 +248,17 @@ class HomePageState extends State<HomePage> {
safe: _s,
safeChanged: (value) {
_s = value;
_saveRatingPrefs();
},
questionable: _q,
questionableChanged: (value) {
_q = value;
_saveRatingPrefs();
},
explicit: _e,
explicitChanged: (value) {
_e = value;
_saveRatingPrefs();
},
);
},
Expand All @@ -255,7 +276,7 @@ class HomePageState extends State<HomePage> {
DrawerHeader(
child: SvgPicture.asset('assets/logo.svg'),
decoration: BoxDecoration(
color: Colors.black
color: Color.fromARGB(1, 100, 150, 150)
),
),
ListTile(
Expand Down Expand Up @@ -284,6 +305,19 @@ class HomePageState extends State<HomePage> {
}
),
),
ListTile(
title: Text("Favourites"),
subtitle: Text("See your favourite searches", style: TextStyle(fontSize: 12.0)),
leading: Icon(Icons.favorite),
onTap: () => showDialog(
context: context,
builder: (BuildContext context) {
return new FavouritesModal(
repo: repo,
);
}
),
),
Divider(),
ListTile(
title: Text("Buy me a coffe"),
Expand Down
Loading

0 comments on commit 0f4e2d8

Please sign in to comment.