mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 18:57:25 +01:00
36 lines
975 B
Dart
36 lines
975 B
Dart
|
|
import 'package:flutter/material.dart';
|
||
|
|
|
||
|
|
import '../backend.dart';
|
||
|
|
|
||
|
|
class PersonsSelector extends StatelessWidget {
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
final backend = Backend.of(context);
|
||
|
|
|
||
|
|
return Scaffold(
|
||
|
|
appBar: AppBar(
|
||
|
|
title: Text('Select person'),
|
||
|
|
),
|
||
|
|
body: StreamBuilder(
|
||
|
|
stream: backend.db.allPersons().watch(),
|
||
|
|
builder: (context, snapshot) {
|
||
|
|
if (snapshot.hasData) {
|
||
|
|
return ListView.builder(
|
||
|
|
itemCount: snapshot.data.length,
|
||
|
|
itemBuilder: (context, index) {
|
||
|
|
final person = snapshot.data[index];
|
||
|
|
|
||
|
|
return ListTile(
|
||
|
|
title: Text('${person.lastName}, ${person.firstName}'),
|
||
|
|
onTap: () => Navigator.pop(context, person),
|
||
|
|
);
|
||
|
|
},
|
||
|
|
);
|
||
|
|
} else {
|
||
|
|
return Container();
|
||
|
|
}
|
||
|
|
}),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|