mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
Refactoring: improve code
This commit is contained in:
parent
d8f157838f
commit
d418364fee
2 changed files with 12 additions and 7 deletions
|
@ -24,6 +24,7 @@ class AlbumGridItemBuilder {
|
|||
AlbumGridItem build(BuildContext context) {
|
||||
var subtitle = "";
|
||||
String? subtitle2;
|
||||
IconData? icon;
|
||||
if (album.provider is AlbumStaticProvider) {
|
||||
subtitle =
|
||||
L10n.global().albumSize(AlbumStaticProvider.of(album).items.length);
|
||||
|
@ -33,6 +34,7 @@ class AlbumGridItemBuilder {
|
|||
if (provider.dirs.length > 1) {
|
||||
subtitle2 = "+${provider.dirs.length - 1}";
|
||||
}
|
||||
icon = Icons.folder;
|
||||
}
|
||||
if (isShared) {
|
||||
subtitle = "${L10n.global().albumSharedLabel} | $subtitle";
|
||||
|
@ -42,7 +44,7 @@ class AlbumGridItemBuilder {
|
|||
title: album.name,
|
||||
subtitle: subtitle,
|
||||
subtitle2: subtitle2,
|
||||
icon: album.provider is AlbumDirProvider ? Icons.folder : null,
|
||||
icon: icon,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ class _NewAlbumDialogState extends State<NewAlbumDialog> {
|
|||
DropdownButtonHideUnderline(
|
||||
child: DropdownButtonFormField<_Provider>(
|
||||
value: _provider,
|
||||
items: [_Provider.static, _Provider.dir]
|
||||
items: _Provider.values
|
||||
.map((e) => DropdownMenuItem<_Provider>(
|
||||
value: e,
|
||||
child: Text(e.toValueString(context)),
|
||||
|
@ -109,11 +109,14 @@ class _NewAlbumDialogState extends State<NewAlbumDialog> {
|
|||
void _onOkPressed(BuildContext context) {
|
||||
if (_formKey.currentState?.validate() == true) {
|
||||
_formKey.currentState!.save();
|
||||
if (_formValue.provider == _Provider.static ||
|
||||
_formValue.provider == null) {
|
||||
_onConfirmStaticAlbum();
|
||||
} else {
|
||||
_onConfirmDirAlbum();
|
||||
switch (_formValue.provider) {
|
||||
case _Provider.static:
|
||||
case null:
|
||||
_onConfirmStaticAlbum();
|
||||
break;
|
||||
case _Provider.dir:
|
||||
_onConfirmDirAlbum();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue