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