| 
									
										
										
										
											2019-12-15 12:22:39 +01:00
										 |  |  | import 'package:flutter/material.dart'; | 
					
						
							| 
									
										
										
										
											2020-04-24 22:41:52 +02:00
										 |  |  | import 'package:musicus_database/musicus_database.dart'; | 
					
						
							| 
									
										
										
										
											2019-12-15 12:22:39 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | import '../backend.dart'; | 
					
						
							| 
									
										
										
										
											2020-03-21 15:06:38 +01:00
										 |  |  | import '../editors/person.dart'; | 
					
						
							| 
									
										
										
										
											2020-05-03 23:01:16 +02:00
										 |  |  | import '../widgets/lists.dart'; | 
					
						
							| 
									
										
										
										
											2019-12-15 12:22:39 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-21 15:01:51 +01:00
										 |  |  | import 'work.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-03 23:01:16 +02:00
										 |  |  | class PersonScreen extends StatefulWidget { | 
					
						
							| 
									
										
										
										
											2019-12-15 12:22:39 +01:00
										 |  |  |   final Person person; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   PersonScreen({ | 
					
						
							|  |  |  |     this.person, | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-03 23:01:16 +02:00
										 |  |  |   @override | 
					
						
							|  |  |  |   _PersonScreenState createState() => _PersonScreenState(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class _PersonScreenState extends State<PersonScreen> { | 
					
						
							|  |  |  |   String _search; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-15 12:22:39 +01:00
										 |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							|  |  |  |     final backend = Backend.of(context); | 
					
						
							| 
									
										
										
										
											2020-04-26 17:26:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-15 12:22:39 +01:00
										 |  |  |     return Scaffold( | 
					
						
							|  |  |  |       appBar: AppBar( | 
					
						
							| 
									
										
										
										
											2020-05-03 23:01:16 +02:00
										 |  |  |         title: TextField( | 
					
						
							|  |  |  |           autofocus: true, | 
					
						
							|  |  |  |           onChanged: (text) { | 
					
						
							|  |  |  |             setState(() { | 
					
						
							|  |  |  |               _search = text; | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |           }, | 
					
						
							|  |  |  |           decoration: InputDecoration.collapsed( | 
					
						
							|  |  |  |             hintText: | 
					
						
							|  |  |  |                 'Works by ${widget.person.firstName} ${widget.person.lastName}', | 
					
						
							|  |  |  |           ), | 
					
						
							|  |  |  |         ), | 
					
						
							| 
									
										
										
										
											2020-03-21 15:06:38 +01:00
										 |  |  |         actions: <Widget>[ | 
					
						
							|  |  |  |           IconButton( | 
					
						
							|  |  |  |             icon: const Icon(Icons.edit), | 
					
						
							|  |  |  |             onPressed: () { | 
					
						
							|  |  |  |               Navigator.push( | 
					
						
							|  |  |  |                 context, | 
					
						
							|  |  |  |                 MaterialPageRoute( | 
					
						
							|  |  |  |                   builder: (context) => PersonEditor( | 
					
						
							| 
									
										
										
										
											2020-05-03 23:01:16 +02:00
										 |  |  |                     person: widget.person, | 
					
						
							| 
									
										
										
										
											2020-03-21 15:06:38 +01:00
										 |  |  |                   ), | 
					
						
							|  |  |  |                   fullscreenDialog: true, | 
					
						
							|  |  |  |                 ), | 
					
						
							|  |  |  |               ); | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |           ), | 
					
						
							|  |  |  |         ], | 
					
						
							| 
									
										
										
										
											2019-12-15 12:22:39 +01:00
										 |  |  |       ), | 
					
						
							| 
									
										
										
										
											2020-05-03 23:01:16 +02:00
										 |  |  |       body: PagedListView<WorkInfo>( | 
					
						
							|  |  |  |         search: _search, | 
					
						
							|  |  |  |         fetch: (page, search) async { | 
					
						
							|  |  |  |           return await backend.db.getWorks(widget.person.id, page, search); | 
					
						
							| 
									
										
										
										
											2019-12-15 12:22:39 +01:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2020-05-03 23:01:16 +02:00
										 |  |  |         builder: (context, workInfo) => ListTile( | 
					
						
							|  |  |  |           title: Text(workInfo.work.title), | 
					
						
							|  |  |  |           onTap: () => Navigator.push( | 
					
						
							|  |  |  |             context, | 
					
						
							|  |  |  |             MaterialPageRoute( | 
					
						
							|  |  |  |               builder: (context) => WorkScreen( | 
					
						
							|  |  |  |                 workInfo: workInfo, | 
					
						
							|  |  |  |               ), | 
					
						
							|  |  |  |             ), | 
					
						
							|  |  |  |           ), | 
					
						
							|  |  |  |         ), | 
					
						
							| 
									
										
										
										
											2019-12-15 12:22:39 +01:00
										 |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |