Properly handle permissions

The backend has a new state called "needsPermissions" and the app widget
reacts accordingly.
This commit is contained in:
Elias Projahn 2020-03-28 09:54:04 +01:00
parent bd844c44ea
commit 723977daec
3 changed files with 62 additions and 4 deletions

View file

@ -30,9 +30,40 @@ class App extends StatelessWidget {
home: Builder(
builder: (context) {
if (backend.status == BackendStatus.loading) {
return Container(
return Material(
color: Theme.of(context).scaffoldBackgroundColor,
);
} else if (backend.status == BackendStatus.needsPermissions) {
return Material(
color: Theme.of(context).scaffoldBackgroundColor,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Musicus needs permissions\nto access your files.',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headline6,
),
SizedBox(
height: 16.0,
),
ListTile(
leading: const Icon(Icons.done),
title: Text('Grant permissions'),
onTap: () {
backend.requestPermissions();
},
),
ListTile(
leading: const Icon(Icons.settings),
title: Text('Open system\'s app settings'),
onTap: () {
backend.openAppSettings();
},
),
],
),
);
} else {
return Content();
}