add filter button

This commit is contained in:
lukas-heiligenbrunner 2022-08-30 11:57:50 +02:00
parent c732ab31df
commit b0f913f8d1
5 changed files with 48 additions and 10 deletions

View File

@ -36,7 +36,7 @@ class _ActorScreenState extends State<ActorScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text("Temp"), title: Text("Actors"),
), ),
body: FutureBuilder( body: FutureBuilder(
future: _categories, future: _categories,

View File

@ -36,7 +36,7 @@ class _CategorieScreenState extends State<CategorieScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text("Temp"), title: Text("Categories"),
), ),
body: FutureBuilder( body: FutureBuilder(
future: _categories, future: _categories,

View File

@ -29,7 +29,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text("Temp"), title: Text("Settings"),
), ),
body: Column( body: Column(
children: [ children: [

View File

@ -34,7 +34,7 @@ class _ShuffleScreenState extends State<ShuffleScreen> {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text("Temp"), title: Text("Shuffle"),
), ),
body: PreviewGrid( body: PreviewGrid(
videoLoader: () { videoLoader: () {

View File

@ -4,11 +4,12 @@ import 'package:flutter/material.dart';
import 'package:openmediacentermobile/DrawerPage.dart'; import 'package:openmediacentermobile/DrawerPage.dart';
import '../api/api.dart'; import '../api/api.dart';
import '../log/log.dart';
import '../preview/preview_grid.dart'; import '../preview/preview_grid.dart';
import '../types/tag.dart'; import '../types/tag.dart';
import '../types/video.dart'; import '../types/video.dart';
enum FilterTypes { DATE, LIKES, RANDOM, NAMES, LENGTH }
class VideoFeed extends StatefulWidget { class VideoFeed extends StatefulWidget {
const VideoFeed({Key? key, this.tag}) : super(key: key); const VideoFeed({Key? key, this.tag}) : super(key: key);
final Tag? tag; final Tag? tag;
@ -20,9 +21,12 @@ class VideoFeed extends StatefulWidget {
} }
class VideoFeedState extends State<VideoFeed> { class VideoFeedState extends State<VideoFeed> {
FilterTypes filterSelection = FilterTypes.DATE;
Key _refreshKey = UniqueKey();
Future<List<VideoT>> loadData() async { Future<List<VideoT>> loadData() async {
final data = await API.query( final data = await API.query("video", "getMovies",
"video", "getMovies", {'Tag': widget.tag?.tagId ?? 1, 'Sort': 0}); {'Tag': widget.tag?.tagId ?? 1, 'Sort': filterSelection.index});
final d = jsonDecode(data); final d = jsonDecode(data);
@ -34,14 +38,48 @@ class VideoFeedState extends State<VideoFeed> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
Log.d(width);
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(widget.tag?.tagName ?? "OpenMediaCenter"), title: Text(widget.tag?.tagName ?? "OpenMediaCenter"),
actions: [
PopupMenuButton<FilterTypes>(
// add icon, by default "3 dot" icon
icon: Icon(Icons.filter_alt),
initialValue: filterSelection,
itemBuilder: (context) {
return [
PopupMenuItem<FilterTypes>(
value: FilterTypes.DATE,
child: Text("Date"),
),
PopupMenuItem<FilterTypes>(
value: FilterTypes.LIKES,
child: Text("Likes"),
),
PopupMenuItem<FilterTypes>(
value: FilterTypes.RANDOM,
child: Text("Random"),
),
PopupMenuItem<FilterTypes>(
value: FilterTypes.NAMES,
child: Text("Names"),
),
PopupMenuItem<FilterTypes>(
value: FilterTypes.LENGTH,
child: Text("Length"),
),
];
},
onSelected: (FilterTypes t) {
setState(() {
filterSelection = t;
_refreshKey = UniqueKey();
});
}),
],
), ),
body: PreviewGrid( body: PreviewGrid(
key: _refreshKey,
videoLoader: () => loadData(), videoLoader: () => loadData(),
), ),
drawer: widget.tag == null ? MyDrawer() : null); drawer: widget.tag == null ? MyDrawer() : null);