mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 18:57:25 +01:00
Everything related to file system access has been rewritten to make use of the storage access framework. This means that the WRITE_EXTERNAL_STORAGE is no longer needed. Because of that, the dependency on permission_handler could be dropped and all code related to permission handling has been removed. To be able to open a whole document tree, the minSdkVersion was bumped to 21. Finally the file selector was rewritten using custom platform dependent code.
108 lines
2.8 KiB
Dart
108 lines
2.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../backend.dart';
|
|
import '../database.dart';
|
|
import '../selectors/files.dart';
|
|
import '../selectors/recording.dart';
|
|
import '../widgets/recording_tile.dart';
|
|
|
|
// TODO: Update for storage access framework.
|
|
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: ReorderableListView(
|
|
header: Column(
|
|
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(),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
children: tracks
|
|
.map((t) => ListTile(
|
|
key: Key(t.hashCode.toString()),
|
|
title: Text(t.path),
|
|
trailing: IconButton(
|
|
icon: const Icon(Icons.delete),
|
|
onPressed: () {
|
|
setState(() {
|
|
tracks.remove(t);
|
|
});
|
|
},
|
|
),
|
|
))
|
|
.toList(),
|
|
onReorder: (i1, i2) {
|
|
setState(() {
|
|
final track = tracks.removeAt(i1);
|
|
final newIndex = i2 > i1 ? i2 - 1 : i2;
|
|
tracks.insert(newIndex, track);
|
|
});
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
void selectRecording() async {
|
|
final Recording recording = await Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => RecordingsSelector(),
|
|
),
|
|
);
|
|
|
|
if (recording != null) {
|
|
setState(() {
|
|
recordingId = recording.id;
|
|
});
|
|
}
|
|
}
|
|
}
|