mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 18:57:25 +01:00
Add access to person editor to person selector
The person editor can be reached via the FAB. If a new person is created, it will be selected.
This commit is contained in:
parent
2ee49246e4
commit
cc45018c83
1 changed files with 35 additions and 17 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../backend.dart';
|
import '../backend.dart';
|
||||||
|
import '../database.dart';
|
||||||
|
import '../editors/person.dart';
|
||||||
|
|
||||||
class PersonsSelector extends StatelessWidget {
|
class PersonsSelector extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
|
|
@ -12,24 +14,40 @@ class PersonsSelector extends StatelessWidget {
|
||||||
title: Text('Select person'),
|
title: Text('Select person'),
|
||||||
),
|
),
|
||||||
body: StreamBuilder(
|
body: StreamBuilder(
|
||||||
stream: backend.db.allPersons().watch(),
|
stream: backend.db.allPersons().watch(),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
itemCount: snapshot.data.length,
|
itemCount: snapshot.data.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final person = snapshot.data[index];
|
final person = snapshot.data[index];
|
||||||
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text('${person.lastName}, ${person.firstName}'),
|
title: Text('${person.lastName}, ${person.firstName}'),
|
||||||
onTap: () => Navigator.pop(context, person),
|
onTap: () => Navigator.pop(context, person),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
|
floatingActionButton: FloatingActionButton(
|
||||||
|
child: const Icon(Icons.add),
|
||||||
|
onPressed: () async {
|
||||||
|
final Person person = await Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => PersonEditor(),
|
||||||
|
fullscreenDialog: true,
|
||||||
|
));
|
||||||
|
|
||||||
|
if (person != null) {
|
||||||
|
Navigator.pop(context, person);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue