lukas-heiligenbrunner
5fc77b4abb
cache previews in sqlite db actor page outsouce different players in seperate classes
66 lines
1.7 KiB
Dart
66 lines
1.7 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:openmediacentermobile/types/actor.dart';
|
|
import 'package:openmediacentermobile/preview/actor_tile.dart';
|
|
|
|
import '../api/api.dart';
|
|
import '../screen_loading.dart';
|
|
|
|
class ActorScreen extends StatefulWidget {
|
|
const ActorScreen({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<ActorScreen> createState() => _ActorScreenState();
|
|
}
|
|
|
|
class _ActorScreenState extends State<ActorScreen> {
|
|
late Future<List<Actor>> _categories;
|
|
|
|
Future<List<Actor>> loadVideoData() async {
|
|
final data = await API.query("actor", "getAllActors", {});
|
|
|
|
final d = (jsonDecode(data) ?? []) as List<dynamic>;
|
|
final actors = d.map((e) => Actor.fromJson(e)).toList(growable: false);
|
|
return actors;
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_categories = loadVideoData();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return FutureBuilder(
|
|
future: _categories,
|
|
builder: (context, AsyncSnapshot<List<Actor>> 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) => ActorTile(actor: e))
|
|
.toList(growable: false),
|
|
),
|
|
),
|
|
);
|
|
} else {
|
|
return ScreenLoading();
|
|
}
|
|
},
|
|
);
|
|
}
|
|
}
|