album creation dialog: use radio buttons instead of dropdown

This commit is contained in:
Thibault Deckers 2020-08-02 15:43:23 +09:00
parent 5f3d4e5946
commit 5b338ba025

View file

@ -16,6 +16,8 @@ class _CreateAlbumDialogState extends State<CreateAlbumDialog> {
Set<StorageVolume> _allVolumes;
StorageVolume _primaryVolume, _selectedVolume;
static const EdgeInsets hPadding = EdgeInsets.symmetric(horizontal: 24);
@override
void initState() {
super.initState();
@ -35,56 +37,55 @@ class _CreateAlbumDialogState extends State<CreateAlbumDialog> {
Widget build(BuildContext context) {
return AlertDialog(
title: Text('New Album'),
content: Column(
mainAxisSize: MainAxisSize.min,
content: ListView(
shrinkWrap: true,
children: [
if (_allVolumes.length > 1) ...[
Row(
mainAxisSize: MainAxisSize.min,
children: [
Text('Storage:'),
SizedBox(width: 8),
Expanded(
child: DropdownButton<StorageVolume>(
isExpanded: true,
items: _allVolumes
.map((volume) => DropdownMenuItem(
value: volume,
child: Text(
volume.description,
softWrap: false,
overflow: TextOverflow.fade,
maxLines: 1,
),
))
.toList(),
value: _selectedVolume,
onChanged: (volume) {
_selectedVolume = volume;
_checkAlbumExists();
setState(() {});
},
),
),
],
Padding(
padding: hPadding,
child: Text('Storage:'),
),
SizedBox(height: 16),
],
ValueListenableBuilder<bool>(
valueListenable: _existsNotifier,
builder: (context, exists, child) {
return TextField(
controller: _nameController,
decoration: InputDecoration(
helperText: exists ? 'Album already exists' : '',
..._allVolumes.map((volume) => RadioListTile<StorageVolume>(
value: volume,
groupValue: _selectedVolume,
onChanged: (volume) {
_selectedVolume = volume;
_checkAlbumExists();
setState(() {});
},
title: Text(
volume.description,
softWrap: false,
overflow: TextOverflow.fade,
maxLines: 1,
),
onChanged: (_) => _checkAlbumExists(),
onSubmitted: (_) => _submit(context),
);
}),
subtitle: Text(
volume.path,
softWrap: false,
overflow: TextOverflow.fade,
maxLines: 1,
),
)),
SizedBox(height: 8),
],
Padding(
padding: hPadding,
child: ValueListenableBuilder<bool>(
valueListenable: _existsNotifier,
builder: (context, exists, child) {
return TextField(
controller: _nameController,
decoration: InputDecoration(
helperText: exists ? 'Album already exists' : '',
),
onChanged: (_) => _checkAlbumExists(),
onSubmitted: (_) => _submit(context),
);
}),
),
],
),
contentPadding: EdgeInsets.fromLTRB(24, 20, 24, 0),
contentPadding: EdgeInsets.only(top: 20),
actions: [
FlatButton(
onPressed: () => Navigator.pop(context),