2021-12-10 10:40:20 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-10-15 18:28:31 +00:00
|
|
|
import '../api/video_api.dart';
|
2021-12-10 10:40:20 +00:00
|
|
|
|
2022-08-30 21:37:24 +00:00
|
|
|
import '../drawer/my_drawer.dart';
|
2022-08-28 20:51:12 +00:00
|
|
|
import '../preview/preview_grid.dart';
|
2022-08-28 16:48:53 +00:00
|
|
|
import '../types/tag.dart';
|
2021-12-10 10:40:20 +00:00
|
|
|
|
2022-08-30 09:57:50 +00:00
|
|
|
enum FilterTypes { DATE, LIKES, RANDOM, NAMES, LENGTH }
|
|
|
|
|
2021-12-11 16:17:38 +00:00
|
|
|
class VideoFeed extends StatefulWidget {
|
2022-08-28 16:48:53 +00:00
|
|
|
const VideoFeed({Key? key, this.tag}) : super(key: key);
|
|
|
|
final Tag? tag;
|
2021-12-11 16:17:38 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return VideoFeedState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class VideoFeedState extends State<VideoFeed> {
|
2022-08-30 09:57:50 +00:00
|
|
|
FilterTypes filterSelection = FilterTypes.DATE;
|
|
|
|
Key _refreshKey = UniqueKey();
|
|
|
|
|
2021-12-10 10:40:20 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-08-29 15:16:51 +00:00
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
title: Text(widget.tag?.tagName ?? "OpenMediaCenter"),
|
2022-08-30 09:57:50 +00:00
|
|
|
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();
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
],
|
2022-08-29 15:16:51 +00:00
|
|
|
),
|
|
|
|
body: PreviewGrid(
|
2022-08-30 09:57:50 +00:00
|
|
|
key: _refreshKey,
|
2022-10-15 18:28:31 +00:00
|
|
|
videoLoader: () => loadVideo(widget.tag, filterSelection.index),
|
2022-08-29 15:16:51 +00:00
|
|
|
),
|
|
|
|
drawer: widget.tag == null ? MyDrawer() : null);
|
2021-12-10 10:40:20 +00:00
|
|
|
}
|
|
|
|
}
|