OpenMediacenterMobileFlutter/lib/video_feed.dart

39 lines
905 B
Dart

import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:openmediacentermobile/api/api.dart';
import 'package:openmediacentermobile/preview_grid.dart';
import 'log/log.dart';
import 'preview_tile.dart';
class VideoFeed extends StatefulWidget {
const VideoFeed({Key? key}) : super(key: key);
@override
State<StatefulWidget> createState() {
return VideoFeedState();
}
}
class VideoFeedState extends State<VideoFeed> {
Future<List<VideoT>> loadData() async {
final data = await API.query("video", "getMovies", {'Tag': 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 PreviewGrid(videoLoader: () => loadData(),);
}
}