OpenMediacenterMobileFlutter/lib/navigation/video_feed.dart

50 lines
1.2 KiB
Dart

import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:openmediacentermobile/DrawerPage.dart';
import '../api/api.dart';
import '../log/log.dart';
import '../preview/preview_grid.dart';
import '../types/tag.dart';
import '../types/video.dart';
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;
}
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
Log.d(width);
return Scaffold(
appBar: AppBar(
title: Text(widget.tag?.tagName ?? "OpenMediaCenter"),
),
body: PreviewGrid(
videoLoader: () => loadData(),
),
drawer: widget.tag == null ? MyDrawer() : null);
}
}