2021-12-11 16:17:38 +00:00
|
|
|
import 'dart:convert';
|
|
|
|
|
2021-12-10 10:40:20 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2021-12-11 16:17:38 +00:00
|
|
|
import 'package:openmediacentermobile/api/api.dart';
|
2021-12-10 10:40:20 +00:00
|
|
|
|
2021-12-11 12:33:46 +00:00
|
|
|
import 'log/log.dart';
|
2021-12-10 10:40:20 +00:00
|
|
|
import 'preview_tile.dart';
|
|
|
|
|
2021-12-11 16:17:38 +00:00
|
|
|
class VideoFeed extends StatefulWidget {
|
|
|
|
const VideoFeed({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return VideoFeedState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class VideoFeedState extends State<VideoFeed> {
|
|
|
|
List<VideoT> _vids = [];
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
2021-12-10 10:40:20 +00:00
|
|
|
|
2021-12-11 16:17:38 +00:00
|
|
|
API.query("video", "getMovies", {'Tag': 1, 'Sort': 0}).then((value) {
|
|
|
|
final d = jsonDecode(value);
|
2021-12-10 10:40:20 +00:00
|
|
|
|
2021-12-11 16:17:38 +00:00
|
|
|
List<VideoT> dta =
|
|
|
|
(d['Videos'] as List).map((e) => VideoT.fromJson(e)).toList();
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
_vids = dta;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2021-12-10 10:40:20 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return GridView.builder(
|
|
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
crossAxisCount: 2,
|
|
|
|
childAspectRatio: MediaQuery.of(context).size.width /
|
|
|
|
MediaQuery.of(context).size.height,
|
|
|
|
crossAxisSpacing: 10),
|
|
|
|
itemCount: _vids.length,
|
|
|
|
itemBuilder: (context, index) {
|
2021-12-11 12:33:46 +00:00
|
|
|
Log.d("item $index built!");
|
2021-12-10 10:40:20 +00:00
|
|
|
return PreviewTile(dta: _vids[index]);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|