musicus_mobile/mobile/lib/selectors/person.dart

42 lines
1.1 KiB
Dart
Raw Normal View History

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
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);
},
),
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,
),
);
if (person != null) {
Navigator.pop(context, person);
}
},
),
2019-12-04 20:48:55 +01:00
);
}
}