| 
									
										
										
										
											2019-12-15 12:22:39 +01:00
										 |  |  | import 'package:flutter/material.dart'; | 
					
						
							| 
									
										
										
										
											2020-06-02 16:47:46 +02:00
										 |  |  | import 'package:musicus_client/musicus_client.dart'; | 
					
						
							| 
									
										
										
										
											2020-05-04 21:49:44 +02:00
										 |  |  | import 'package:musicus_common/musicus_common.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) { | 
					
						
							| 
									
										
										
										
											2020-05-04 21:49:44 +02:00
										 |  |  |     final backend = MusicusBackend.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}', | 
					
						
							|  |  |  |           ), | 
					
						
							|  |  |  |         ), | 
					
						
							| 
									
										
										
										
											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, | 
					
						
							|  |  |  |               ), | 
					
						
							|  |  |  |             ), | 
					
						
							|  |  |  |           ), | 
					
						
							| 
									
										
										
										
											2020-05-13 21:46:53 +02:00
										 |  |  |           onLongPress: () { | 
					
						
							|  |  |  |             showDialog( | 
					
						
							|  |  |  |               context: context, | 
					
						
							|  |  |  |               builder: (context) { | 
					
						
							|  |  |  |                 return SimpleDialog( | 
					
						
							|  |  |  |                   children: <Widget>[ | 
					
						
							|  |  |  |                     ListTile( | 
					
						
							|  |  |  |                       title: Text('Edit work'), | 
					
						
							|  |  |  |                       onTap: () async { | 
					
						
							|  |  |  |                         Navigator.pushReplacement( | 
					
						
							|  |  |  |                           context, | 
					
						
							|  |  |  |                           MaterialPageRoute( | 
					
						
							|  |  |  |                             builder: (context) => WorkEditor( | 
					
						
							|  |  |  |                               workInfo: workInfo, | 
					
						
							|  |  |  |                             ), | 
					
						
							|  |  |  |                             fullscreenDialog: true, | 
					
						
							|  |  |  |                           ), | 
					
						
							|  |  |  |                         ); | 
					
						
							|  |  |  |                       }, | 
					
						
							|  |  |  |                     ), | 
					
						
							|  |  |  |                   ], | 
					
						
							|  |  |  |                 ); | 
					
						
							|  |  |  |               }, | 
					
						
							|  |  |  |             ); | 
					
						
							|  |  |  |           }, | 
					
						
							| 
									
										
										
										
											2020-05-03 23:01:16 +02:00
										 |  |  |         ), | 
					
						
							| 
									
										
										
										
											2019-12-15 12:22:39 +01:00
										 |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |