settings: scrollable access grant list
This commit is contained in:
parent
15857ccc9f
commit
876b2af432
1 changed files with 64 additions and 51 deletions
|
@ -52,59 +52,72 @@ class _StorageAccessPageState extends State<StorageAccessPage> {
|
||||||
title: Text(context.l10n.settingsStorageAccessTitle),
|
title: Text(context.l10n.settingsStorageAccessTitle),
|
||||||
),
|
),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Column(
|
child: FutureBuilder<List<String>>(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
future: _pathLoader,
|
||||||
children: [
|
builder: (context, snapshot) {
|
||||||
Padding(
|
if (snapshot.hasError) {
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
return Text(snapshot.error.toString());
|
||||||
child: Row(
|
}
|
||||||
|
if (snapshot.connectionState != ConnectionState.done && _lastPaths == null) {
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
_lastPaths = snapshot.data!..sort();
|
||||||
|
if (_lastPaths!.isEmpty) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const _Header(),
|
||||||
|
const Divider(),
|
||||||
|
Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
child: EmptyContent(
|
||||||
|
text: context.l10n.settingsStorageAccessEmpty,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ListView(
|
||||||
children: [
|
children: [
|
||||||
const Icon(AIcons.info),
|
const _Header(),
|
||||||
const SizedBox(width: 16),
|
const Divider(),
|
||||||
Expanded(child: Text(context.l10n.settingsStorageAccessBanner)),
|
..._lastPaths!.map((path) => ListTile(
|
||||||
|
title: Text(path),
|
||||||
|
dense: true,
|
||||||
|
trailing: IconButton(
|
||||||
|
icon: const Icon(AIcons.clear),
|
||||||
|
onPressed: () async {
|
||||||
|
await storageService.revokeDirectoryAccess(path);
|
||||||
|
_load();
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
tooltip: context.l10n.settingsStorageAccessRevokeTooltip,
|
||||||
|
),
|
||||||
|
)),
|
||||||
],
|
],
|
||||||
),
|
);
|
||||||
),
|
}),
|
||||||
const Divider(),
|
),
|
||||||
Expanded(
|
);
|
||||||
child: FutureBuilder<List<String>>(
|
}
|
||||||
future: _pathLoader,
|
}
|
||||||
builder: (context, snapshot) {
|
|
||||||
if (snapshot.hasError) {
|
class _Header extends StatelessWidget {
|
||||||
return Text(snapshot.error.toString());
|
const _Header({Key? key}) : super(key: key);
|
||||||
}
|
|
||||||
if (snapshot.connectionState != ConnectionState.done && _lastPaths == null) {
|
@override
|
||||||
return const SizedBox.shrink();
|
Widget build(BuildContext context) {
|
||||||
}
|
return Padding(
|
||||||
_lastPaths = snapshot.data!..sort();
|
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||||
if (_lastPaths!.isEmpty) {
|
child: Row(
|
||||||
return EmptyContent(
|
children: [
|
||||||
text: context.l10n.settingsStorageAccessEmpty,
|
const Icon(AIcons.info),
|
||||||
);
|
const SizedBox(width: 16),
|
||||||
}
|
Expanded(child: Text(context.l10n.settingsStorageAccessBanner)),
|
||||||
return Column(
|
],
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: _lastPaths!
|
|
||||||
.map((path) => ListTile(
|
|
||||||
title: Text(path),
|
|
||||||
dense: true,
|
|
||||||
trailing: IconButton(
|
|
||||||
icon: const Icon(AIcons.clear),
|
|
||||||
onPressed: () async {
|
|
||||||
await storageService.revokeDirectoryAccess(path);
|
|
||||||
_load();
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
tooltip: context.l10n.settingsStorageAccessRevokeTooltip,
|
|
||||||
),
|
|
||||||
))
|
|
||||||
.toList(),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue