OpenMediacenterMobileFlutter/lib/dialog/add_actor_dialog.dart
lukas-heiligenbrunner 9ef317f0ba outsourced lots of api calls to api folder
centered error message when failed loading video feed
display server url on settings page
2022-10-15 20:28:31 +02:00

54 lines
1.5 KiB
Dart

import 'package:flutter/material.dart';
import '../api/actor_api.dart';
import '../screen_loading.dart';
import '../types/actor.dart';
class AddActorDialog extends StatefulWidget {
const AddActorDialog({Key? key, required this.movieId}) : super(key: key);
final int movieId;
@override
State<AddActorDialog> createState() => _AddActorDialogState();
}
class _AddActorDialogState extends State<AddActorDialog> {
late Future<List<Actor>> actors = loadAllActors();
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return AlertDialog(
scrollable: true,
title: Text("Add Actor"),
content: FutureBuilder(
future: actors,
builder: (context, snapshot) {
if (snapshot.hasError) {
return Text("Error");
} else if (snapshot.hasData) {
final data = snapshot.data! as List<Actor>;
return Column(
mainAxisSize: MainAxisSize.min,
children: data
.map((e) => ListTile(
title: Text(e.name),
onTap: () async {
await addActorToVideo(e.actorId, widget.movieId);
Navigator.pop(context, e);
},
))
.toList(),
);
} else {
return ScreenLoading();
}
},
));
}
}