2021-12-11 16:17:38 +00:00
|
|
|
import 'dart:convert';
|
|
|
|
|
2021-12-10 10:40:20 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-08-29 15:16:51 +00:00
|
|
|
import 'package:openmediacentermobile/DrawerPage.dart';
|
2021-12-10 10:40:20 +00:00
|
|
|
|
2022-08-28 20:51:12 +00:00
|
|
|
import '../api/api.dart';
|
2022-08-28 16:48:53 +00:00
|
|
|
import '../log/log.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';
|
2022-08-28 20:51:12 +00:00
|
|
|
import '../types/video.dart';
|
2021-12-10 10:40:20 +00:00
|
|
|
|
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-04-15 07:16:41 +00:00
|
|
|
Future<List<VideoT>> loadData() async {
|
2022-08-28 16:48:53 +00:00
|
|
|
final data = await API.query(
|
|
|
|
"video", "getMovies", {'Tag': widget.tag?.tagId ?? 1, 'Sort': 0});
|
2022-04-15 07:16:41 +00:00
|
|
|
|
|
|
|
final d = jsonDecode(data);
|
|
|
|
|
2022-08-25 20:48:44 +00:00
|
|
|
List<VideoT> dta =
|
|
|
|
(d['Videos'] as List).map((e) => VideoT.fromJson(e)).toList();
|
2022-04-15 07:16:41 +00:00
|
|
|
|
|
|
|
return dta;
|
|
|
|
}
|
2021-12-11 16:17:38 +00:00
|
|
|
|
2021-12-10 10:40:20 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-04-15 07:16:41 +00:00
|
|
|
double width = MediaQuery.of(context).size.width;
|
|
|
|
Log.d(width);
|
|
|
|
|
2022-08-29 15:16:51 +00:00
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
title: Text(widget.tag?.tagName ?? "OpenMediaCenter"),
|
|
|
|
),
|
|
|
|
body: PreviewGrid(
|
|
|
|
videoLoader: () => loadData(),
|
|
|
|
),
|
|
|
|
drawer: widget.tag == null ? MyDrawer() : null);
|
2021-12-10 10:40:20 +00:00
|
|
|
}
|
|
|
|
}
|