OpenMediacenterMobileFlutter/lib/navigation/video_feed.dart

44 lines
969 B
Dart
Raw Normal View History

import 'dart:convert';
2021-12-10 10:40:20 +00:00
import 'package:flutter/material.dart';
import '../api/api.dart';
import '../log/log.dart';
import '../preview/preview_grid.dart';
import '../types/tag.dart';
import '../types/video.dart';
2021-12-10 10:40:20 +00:00
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> {
Future<List<VideoT>> loadData() async {
final data = await API.query(
"video", "getMovies", {'Tag': widget.tag?.tagId ?? 1, 'Sort': 0});
final d = jsonDecode(data);
List<VideoT> dta =
(d['Videos'] as List).map((e) => VideoT.fromJson(e)).toList();
return dta;
}
2021-12-10 10:40:20 +00:00
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
Log.d(width);
return PreviewGrid(
videoLoader: () => loadData(),
);
2021-12-10 10:40:20 +00:00
}
}