2019-12-02 21:05:49 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2020-05-04 21:49:44 +02:00
|
|
|
import 'package:musicus_common/musicus_common.dart';
|
2020-04-24 22:41:52 +02:00
|
|
|
import 'package:musicus_database/musicus_database.dart';
|
2019-12-02 21:05:49 +01:00
|
|
|
|
2020-05-03 23:30:07 +02:00
|
|
|
import '../icons.dart';
|
2020-03-21 17:46:23 +01:00
|
|
|
|
2020-05-24 11:45:23 +02:00
|
|
|
import 'about.dart';
|
2019-12-15 12:22:39 +01:00
|
|
|
import 'person.dart';
|
2020-03-21 17:46:23 +01:00
|
|
|
import 'settings.dart';
|
2019-12-02 21:05:49 +01:00
|
|
|
|
2020-05-03 23:01:16 +02:00
|
|
|
class HomeScreen extends StatefulWidget {
|
|
|
|
|
@override
|
|
|
|
|
_HomeScreenState createState() => _HomeScreenState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _HomeScreenState extends State<HomeScreen> {
|
|
|
|
|
String _search;
|
|
|
|
|
|
2019-12-02 21:05:49 +01:00
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2020-05-04 21:49:44 +02:00
|
|
|
final backend = MusicusBackend.of(context);
|
2019-12-02 21:05:49 +01:00
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: AppBar(
|
2020-05-03 23:30:07 +02:00
|
|
|
leading: Icon(
|
|
|
|
|
MusicusIcons.musicus,
|
|
|
|
|
color: Colors.amber,
|
|
|
|
|
),
|
2020-05-03 23:01:16 +02:00
|
|
|
title: TextField(
|
|
|
|
|
autofocus: true,
|
|
|
|
|
onChanged: (text) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_search = text;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
decoration: InputDecoration.collapsed(
|
|
|
|
|
hintText: 'Composers',
|
|
|
|
|
),
|
|
|
|
|
),
|
2019-12-15 12:11:40 +01:00
|
|
|
actions: <Widget>[
|
|
|
|
|
PopupMenuButton(
|
|
|
|
|
icon: const Icon(Icons.more_vert),
|
|
|
|
|
itemBuilder: (context) => [
|
|
|
|
|
PopupMenuItem(
|
|
|
|
|
value: 1,
|
2020-04-06 11:43:46 +02:00
|
|
|
child: Text('Add tracks'),
|
2019-12-15 12:11:40 +01:00
|
|
|
),
|
2020-03-21 17:46:23 +01:00
|
|
|
PopupMenuItem(
|
|
|
|
|
value: 2,
|
|
|
|
|
child: Text('Settings'),
|
|
|
|
|
),
|
2020-05-24 11:45:23 +02:00
|
|
|
PopupMenuItem(
|
|
|
|
|
value: 3,
|
|
|
|
|
child: Text('About'),
|
|
|
|
|
),
|
2019-12-15 12:11:40 +01:00
|
|
|
],
|
|
|
|
|
onSelected: (selected) {
|
2020-04-26 17:04:32 +02:00
|
|
|
if (selected == 1) {
|
2019-12-15 12:11:40 +01:00
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
2020-04-06 11:43:46 +02:00
|
|
|
builder: (context) => TracksEditor(),
|
|
|
|
|
fullscreenDialog: true,
|
2019-12-15 12:11:40 +01:00
|
|
|
),
|
|
|
|
|
);
|
2020-03-21 17:46:23 +01:00
|
|
|
} else if (selected == 2) {
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => SettingsScreen(),
|
|
|
|
|
),
|
|
|
|
|
);
|
2020-05-24 11:45:23 +02:00
|
|
|
} else if (selected == 3) {
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => AboutScreen(),
|
|
|
|
|
),
|
|
|
|
|
);
|
2019-12-15 12:11:40 +01:00
|
|
|
}
|
|
|
|
|
},
|
2019-12-11 13:07:46 +01:00
|
|
|
),
|
2019-12-02 21:05:49 +01:00
|
|
|
],
|
|
|
|
|
),
|
2020-05-03 23:01:16 +02:00
|
|
|
body: PagedListView<Person>(
|
|
|
|
|
search: _search,
|
|
|
|
|
fetch: (page, search) async {
|
|
|
|
|
return await backend.db.getPersons(page, search);
|
2019-12-15 12:16:08 +01:00
|
|
|
},
|
2020-05-03 23:01:16 +02:00
|
|
|
builder: (context, person) => ListTile(
|
|
|
|
|
title: Text('${person.lastName}, ${person.firstName}'),
|
|
|
|
|
onTap: () => Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => PersonScreen(
|
|
|
|
|
person: person,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
2020-05-13 21:46:53 +02:00
|
|
|
onLongPress: () {
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (context) {
|
|
|
|
|
return SimpleDialog(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text('Edit person'),
|
|
|
|
|
onTap: () async {
|
|
|
|
|
Navigator.pushReplacement(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => PersonEditor(
|
|
|
|
|
person: person,
|
|
|
|
|
),
|
|
|
|
|
fullscreenDialog: true,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
2020-05-03 23:01:16 +02:00
|
|
|
),
|
2019-12-15 12:16:08 +01:00
|
|
|
),
|
2019-12-02 21:05:49 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|