mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 18:57:25 +01:00
Add basic track editor
This replaces the recording selector in the main menu.
This commit is contained in:
parent
0145206ed2
commit
20d685a3eb
2 changed files with 110 additions and 3 deletions
106
lib/editors/tracks.dart
Normal file
106
lib/editors/tracks.dart
Normal file
|
|
@ -0,0 +1,106 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../backend.dart';
|
||||||
|
import '../database.dart';
|
||||||
|
import '../selectors/files.dart';
|
||||||
|
import '../selectors/recording.dart';
|
||||||
|
import '../widgets/recording_tile.dart';
|
||||||
|
|
||||||
|
class TrackModel {
|
||||||
|
String path;
|
||||||
|
|
||||||
|
TrackModel(this.path);
|
||||||
|
}
|
||||||
|
|
||||||
|
class TracksEditor extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_TracksEditorState createState() => _TracksEditorState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TracksEditorState extends State<TracksEditor> {
|
||||||
|
int recordingId;
|
||||||
|
List<TrackModel> tracks = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final backend = Backend.of(context);
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text('Tracks'),
|
||||||
|
actions: <Widget>[
|
||||||
|
FlatButton(
|
||||||
|
child: Text('DONE'),
|
||||||
|
onPressed: () async {
|
||||||
|
// TODO: Save tracks.
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: ListView(
|
||||||
|
children: <Widget>[
|
||||||
|
recordingId != null
|
||||||
|
? RecordingTile(
|
||||||
|
recordingId: recordingId,
|
||||||
|
onTap: selectRecording,
|
||||||
|
)
|
||||||
|
: ListTile(
|
||||||
|
title: Text('Select recording'),
|
||||||
|
onTap: selectRecording,
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text('Files'),
|
||||||
|
trailing: IconButton(
|
||||||
|
icon: const Icon(Icons.add),
|
||||||
|
onPressed: () async {
|
||||||
|
final Set<String> paths = await Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => FilesSelector(
|
||||||
|
baseDirectory: backend.musicLibraryPath,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (paths != null) {
|
||||||
|
setState(() {
|
||||||
|
for (final path in paths) {
|
||||||
|
tracks.add(TrackModel(path));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
for (final track in tracks)
|
||||||
|
ListTile(
|
||||||
|
title: Text(track.path),
|
||||||
|
trailing: IconButton(
|
||||||
|
icon: const Icon(Icons.delete),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
tracks.remove(track);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void selectRecording() async {
|
||||||
|
final Recording recording = await Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => RecordingsSelector(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (recording != null) {
|
||||||
|
setState(() {
|
||||||
|
recordingId = recording.id;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../backend.dart';
|
import '../backend.dart';
|
||||||
import '../database.dart';
|
import '../database.dart';
|
||||||
import '../selectors/recording.dart';
|
import '../editors/tracks.dart';
|
||||||
|
|
||||||
import 'person.dart';
|
import 'person.dart';
|
||||||
import 'settings.dart';
|
import 'settings.dart';
|
||||||
|
|
@ -25,7 +25,7 @@ class HomeScreen extends StatelessWidget {
|
||||||
),
|
),
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
value: 1,
|
value: 1,
|
||||||
child: Text('Select recording'),
|
child: Text('Add tracks'),
|
||||||
),
|
),
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
value: 2,
|
value: 2,
|
||||||
|
|
@ -39,7 +39,8 @@ class HomeScreen extends StatelessWidget {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => RecordingsSelector(),
|
builder: (context) => TracksEditor(),
|
||||||
|
fullscreenDialog: true,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else if (selected == 2) {
|
} else if (selected == 2) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue