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 createState() { return VideoFeedState(); } } class VideoFeedState extends State { Future> loadData() async { final data = await API.query( "video", "getMovies", {'Tag': widget.tag?.tagId ?? 1, 'Sort': 0}); final d = jsonDecode(data); List 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); } }