mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 18:57:25 +01:00
Properly handle permissions
The backend has a new state called "needsPermissions" and the app widget reacts accordingly.
This commit is contained in:
parent
bd844c44ea
commit
723977daec
3 changed files with 62 additions and 4 deletions
33
lib/app.dart
33
lib/app.dart
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue