Add music library path setting

This introduces a new state of the backend called "setup". If the
music library path is not set, the backend goes into that state and the
app widget can show the UI to set it up. This also introduces a new
dependency on shared_preferences.
This commit is contained in:
Elias Projahn 2020-03-28 10:18:52 +01:00
parent 723977daec
commit f0644e4058
3 changed files with 66 additions and 1 deletions

View file

@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'backend.dart';
import 'screens/home.dart';
import 'selectors/files.dart';
import 'widgets/player_bar.dart';
class App extends StatelessWidget {
@ -64,6 +65,42 @@ class App extends StatelessWidget {
],
),
);
} else if (backend.status == BackendStatus.setup) {
return Material(
color: Theme.of(context).scaffoldBackgroundColor,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Choose the base path for\nyour music library.',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headline6,
),
SizedBox(
height: 16.0,
),
ListTile(
leading: const Icon(Icons.folder_open),
title: Text('Choose path'),
onTap: () async {
final path = await Navigator.push<String>(
context,
MaterialPageRoute(
builder: (context) => FilesSelector(
mode: FilesSelectorMode.directory,
),
fullscreenDialog: true,
),
);
if (path != null) {
backend.setMusicLibraryPath(path);
}
},
),
],
),
);
} else {
return Content();
}