lukas-heiligenbrunner
9ef317f0ba
centered error message when failed loading video feed display server url on settings page
73 lines
2.2 KiB
Dart
73 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../api/video_api.dart';
|
|
|
|
import '../drawer/my_drawer.dart';
|
|
import '../preview/preview_grid.dart';
|
|
import '../types/tag.dart';
|
|
|
|
enum FilterTypes { DATE, LIKES, RANDOM, NAMES, LENGTH }
|
|
|
|
class VideoFeed extends StatefulWidget {
|
|
const VideoFeed({Key? key, this.tag}) : super(key: key);
|
|
final Tag? tag;
|
|
|
|
@override
|
|
State<StatefulWidget> createState() {
|
|
return VideoFeedState();
|
|
}
|
|
}
|
|
|
|
class VideoFeedState extends State<VideoFeed> {
|
|
FilterTypes filterSelection = FilterTypes.DATE;
|
|
Key _refreshKey = UniqueKey();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
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(
|
|
key: _refreshKey,
|
|
videoLoader: () => loadVideo(widget.tag, filterSelection.index),
|
|
),
|
|
drawer: widget.tag == null ? MyDrawer() : null);
|
|
}
|
|
}
|