2022-08-28 20:51:12 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:openmediacentermobile/types/actor.dart';
|
|
|
|
import 'package:openmediacentermobile/preview/actor_tile.dart';
|
|
|
|
|
2022-08-30 21:25:21 +00:00
|
|
|
import '../api/actor_api.dart';
|
2022-08-30 21:37:24 +00:00
|
|
|
import '../drawer/my_drawer.dart';
|
2022-08-28 20:51:12 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
2022-08-30 21:25:21 +00:00
|
|
|
_categories = loadAllActors();
|
2022-08-28 20:51:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-08-29 15:16:51 +00:00
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
2022-08-30 09:57:50 +00:00
|
|
|
title: Text("Actors"),
|
2022-08-29 15:16:51 +00:00
|
|
|
),
|
|
|
|
body: FutureBuilder(
|
|
|
|
future: _categories,
|
|
|
|
builder: (context, AsyncSnapshot<List<Actor>> snapshot) {
|
|
|
|
if (snapshot.connectionState != ConnectionState.done) {
|
|
|
|
return ScreenLoading();
|
|
|
|
}
|
2022-08-28 20:51:12 +00:00
|
|
|
|
2022-08-29 15:16:51 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
drawer: MyDrawer());
|
2022-08-28 20:51:12 +00:00
|
|
|
}
|
|
|
|
}
|