lukas-heiligenbrunner
5fc77b4abb
cache previews in sqlite db actor page outsouce different players in seperate classes
68 lines
1.7 KiB
Dart
68 lines
1.7 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:openmediacentermobile/preview/tag_tile.dart';
|
|
import '../screen_loading.dart';
|
|
|
|
import '../api/api.dart';
|
|
import '../types/tag.dart';
|
|
|
|
class CategorieScreen extends StatefulWidget {
|
|
const CategorieScreen({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<CategorieScreen> createState() => _CategorieScreenState();
|
|
}
|
|
|
|
class _CategorieScreenState extends State<CategorieScreen> {
|
|
late Future<List<Tag>> _categories;
|
|
|
|
Future<List<Tag>> loadVideoData() async {
|
|
final data = await API.query("tags", "getAllTags", {});
|
|
|
|
final d = (jsonDecode(data) ?? []) as List<dynamic>;
|
|
final tags = d.map((e) => Tag.fromJson(e)).toList(growable: false);
|
|
return tags;
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_categories = loadVideoData();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return FutureBuilder(
|
|
future: _categories,
|
|
builder: (context, AsyncSnapshot<List<Tag>> snapshot) {
|
|
if (snapshot.connectionState != ConnectionState.done) {
|
|
return ScreenLoading();
|
|
}
|
|
|
|
if (snapshot.hasError) {
|
|
return Text("Error");
|
|
} else if (snapshot.hasData) {
|
|
return Padding(
|
|
padding: EdgeInsets.all(5),
|
|
child: SingleChildScrollView(
|
|
child: Wrap(
|
|
spacing: 5,
|
|
runSpacing: 5,
|
|
alignment: WrapAlignment.start,
|
|
children: snapshot.data!
|
|
.map((e) => TagTile(
|
|
tag: e,
|
|
))
|
|
.toList(growable: false),
|
|
),
|
|
),
|
|
);
|
|
} else {
|
|
return ScreenLoading();
|
|
}
|
|
},
|
|
);
|
|
}
|
|
}
|