2019-12-04 20:48:55 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2020-04-24 22:41:52 +02:00
|
|
|
import 'package:musicus_database/musicus_database.dart';
|
2019-12-04 20:48:55 +01:00
|
|
|
|
2019-12-04 20:52:52 +01:00
|
|
|
import '../editors/person.dart';
|
2020-04-26 15:35:45 +02:00
|
|
|
import '../widgets/lists.dart';
|
2019-12-04 20:48:55 +01:00
|
|
|
|
2020-04-26 15:35:45 +02:00
|
|
|
/// A screen to select a person.
|
|
|
|
|
///
|
|
|
|
|
/// If the user has selected a person, it will be returned as a [Person] object
|
|
|
|
|
/// using the navigator.
|
2019-12-04 20:48:55 +01:00
|
|
|
class PersonsSelector extends StatelessWidget {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
title: Text('Select person'),
|
|
|
|
|
),
|
2020-04-26 15:35:45 +02:00
|
|
|
body: PersonsList(
|
|
|
|
|
onSelected: (person) {
|
|
|
|
|
Navigator.pop(context, person);
|
2019-12-04 20:52:52 +01:00
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
floatingActionButton: FloatingActionButton(
|
|
|
|
|
child: const Icon(Icons.add),
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
final Person person = await Navigator.push(
|
2020-04-26 15:35:45 +02:00
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => PersonEditor(),
|
|
|
|
|
fullscreenDialog: true,
|
|
|
|
|
),
|
|
|
|
|
);
|
2019-12-04 20:52:52 +01:00
|
|
|
|
|
|
|
|
if (person != null) {
|
|
|
|
|
Navigator.pop(context, person);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
2019-12-04 20:48:55 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|