mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-25 02:48:54 +01:00
Refactoring: unify fn naming
This commit is contained in:
parent
7bb41887b3
commit
0f3dbda458
5 changed files with 191 additions and 197 deletions
|
@ -209,7 +209,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
|||
);
|
||||
if (isEditMode) {
|
||||
content = Listener(
|
||||
onPointerMove: _onEditModePointerMove,
|
||||
onPointerMove: _onEditPointerMove,
|
||||
child: content,
|
||||
);
|
||||
}
|
||||
|
@ -254,13 +254,13 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
|||
icon: const Icon(Icons.share),
|
||||
tooltip: L10n.global().shareTooltip,
|
||||
onPressed: () {
|
||||
_onSelectionAppBarSharePressed(context);
|
||||
_onSelectionSharePressed(context);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.remove),
|
||||
tooltip: L10n.global().removeSelectedFromAlbumTooltip,
|
||||
onPressed: _onSelectionAppBarRemovePressed,
|
||||
onPressed: _onSelectionRemovePressed,
|
||||
),
|
||||
PopupMenuButton<_SelectionMenuOption>(
|
||||
tooltip: MaterialLocalizations.of(context).moreButtonTooltip,
|
||||
|
@ -280,12 +280,12 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
|||
IconButton(
|
||||
icon: const Icon(Icons.text_fields),
|
||||
tooltip: L10n.global().albumAddTextTooltip,
|
||||
onPressed: _onEditAppBarAddTextPressed,
|
||||
onPressed: _onEditAddTextPressed,
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.sort_by_alpha),
|
||||
tooltip: L10n.global().sortTooltip,
|
||||
onPressed: _onEditAppBarSortPressed,
|
||||
onPressed: _onEditSortPressed,
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
@ -324,7 +324,19 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
|||
);
|
||||
}
|
||||
|
||||
void _onSelectionAppBarSharePressed(BuildContext context) {
|
||||
void _onSelectionMenuSelected(
|
||||
BuildContext context, _SelectionMenuOption option) {
|
||||
switch (option) {
|
||||
case _SelectionMenuOption.download:
|
||||
_onSelectionDownloadPressed();
|
||||
break;
|
||||
default:
|
||||
_log.shout("[_onSelectionMenuSelected] Unknown option: $option");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void _onSelectionSharePressed(BuildContext context) {
|
||||
assert(platform_k.isAndroid);
|
||||
final selected = selectedListItems
|
||||
.whereType<_FileListItem>()
|
||||
|
@ -344,7 +356,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
|||
});
|
||||
}
|
||||
|
||||
Future<void> _onSelectionAppBarRemovePressed() async {
|
||||
Future<void> _onSelectionRemovePressed() async {
|
||||
final selectedIndexes =
|
||||
selectedListItems.map((e) => (e as _ListItem).index).toList();
|
||||
final selectedItems = _sortedItems.takeIndex(selectedIndexes).toList();
|
||||
|
@ -372,18 +384,6 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
|||
}
|
||||
}
|
||||
|
||||
void _onSelectionMenuSelected(
|
||||
BuildContext context, _SelectionMenuOption option) {
|
||||
switch (option) {
|
||||
case _SelectionMenuOption.download:
|
||||
_onSelectionDownloadPressed();
|
||||
break;
|
||||
default:
|
||||
_log.shout("[_onSelectionMenuSelected] Unknown option: $option");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void _onSelectionDownloadPressed() {
|
||||
final selected = selectedListItems
|
||||
.whereType<_FileListItem>()
|
||||
|
@ -395,55 +395,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
|||
});
|
||||
}
|
||||
|
||||
void _onEditAppBarSortPressed() {
|
||||
final sortProvider = _editAlbum!.sortProvider;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => FancyOptionPicker(
|
||||
title: L10n.global().sortOptionDialogTitle,
|
||||
items: [
|
||||
FancyOptionPickerItem(
|
||||
label: L10n.global().sortOptionTimeDescendingLabel,
|
||||
isSelected: sortProvider is AlbumTimeSortProvider &&
|
||||
!sortProvider.isAscending,
|
||||
onSelect: () {
|
||||
_onSortNewestPressed();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
FancyOptionPickerItem(
|
||||
label: L10n.global().sortOptionTimeAscendingLabel,
|
||||
isSelected: sortProvider is AlbumTimeSortProvider &&
|
||||
sortProvider.isAscending,
|
||||
onSelect: () {
|
||||
_onSortOldestPressed();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _onSortOldestPressed() {
|
||||
_editAlbum = _editAlbum!.copyWith(
|
||||
sortProvider: const AlbumTimeSortProvider(isAscending: true),
|
||||
);
|
||||
setState(() {
|
||||
_transformItems();
|
||||
});
|
||||
}
|
||||
|
||||
void _onSortNewestPressed() {
|
||||
_editAlbum = _editAlbum!.copyWith(
|
||||
sortProvider: const AlbumTimeSortProvider(isAscending: false),
|
||||
);
|
||||
setState(() {
|
||||
_transformItems();
|
||||
});
|
||||
}
|
||||
|
||||
void _onEditModePointerMove(PointerMoveEvent event) {
|
||||
void _onEditPointerMove(PointerMoveEvent event) {
|
||||
assert(isEditMode);
|
||||
if (!_isDragging) {
|
||||
return;
|
||||
|
@ -455,7 +407,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
|||
}
|
||||
final maxExtent =
|
||||
_itemListMaxExtent ?? _scrollController.position.maxScrollExtent;
|
||||
_log.fine("[_onEditModePointerMove] Begin scrolling down");
|
||||
_log.fine("[_onEditPointerMove] Begin scrolling down");
|
||||
if (_scrollController.offset <
|
||||
_scrollController.position.maxScrollExtent) {
|
||||
_scrollController.animateTo(maxExtent,
|
||||
|
@ -470,7 +422,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
|||
if (_isDragScrollingDown == false) {
|
||||
return;
|
||||
}
|
||||
_log.fine("[_onEditModePointerMove] Begin scrolling up");
|
||||
_log.fine("[_onEditPointerMove] Begin scrolling up");
|
||||
if (_scrollController.offset > 0) {
|
||||
_scrollController.animateTo(0,
|
||||
duration: Duration(
|
||||
|
@ -479,13 +431,13 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
|||
_isDragScrollingDown = false;
|
||||
}
|
||||
} else if (_isDragScrollingDown != null) {
|
||||
_log.fine("[_onEditModePointerMove] Stop scrolling");
|
||||
_log.fine("[_onEditPointerMove] Stop scrolling");
|
||||
_scrollController.jumpTo(_scrollController.offset);
|
||||
_isDragScrollingDown = null;
|
||||
}
|
||||
}
|
||||
|
||||
void _onItemMoved(int fromIndex, int toIndex, bool isBefore) {
|
||||
void _onEditItemMoved(int fromIndex, int toIndex, bool isBefore) {
|
||||
if (fromIndex == toIndex) {
|
||||
return;
|
||||
}
|
||||
|
@ -505,7 +457,55 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
|||
});
|
||||
}
|
||||
|
||||
void _onEditAppBarAddTextPressed() {
|
||||
void _onEditSortPressed() {
|
||||
final sortProvider = _editAlbum!.sortProvider;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => FancyOptionPicker(
|
||||
title: L10n.global().sortOptionDialogTitle,
|
||||
items: [
|
||||
FancyOptionPickerItem(
|
||||
label: L10n.global().sortOptionTimeDescendingLabel,
|
||||
isSelected: sortProvider is AlbumTimeSortProvider &&
|
||||
!sortProvider.isAscending,
|
||||
onSelect: () {
|
||||
_onEditSortNewestPressed();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
FancyOptionPickerItem(
|
||||
label: L10n.global().sortOptionTimeAscendingLabel,
|
||||
isSelected: sortProvider is AlbumTimeSortProvider &&
|
||||
sortProvider.isAscending,
|
||||
onSelect: () {
|
||||
_onEditSortOldestPressed();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _onEditSortOldestPressed() {
|
||||
_editAlbum = _editAlbum!.copyWith(
|
||||
sortProvider: const AlbumTimeSortProvider(isAscending: true),
|
||||
);
|
||||
setState(() {
|
||||
_transformItems();
|
||||
});
|
||||
}
|
||||
|
||||
void _onEditSortNewestPressed() {
|
||||
_editAlbum = _editAlbum!.copyWith(
|
||||
sortProvider: const AlbumTimeSortProvider(isAscending: false),
|
||||
);
|
||||
setState(() {
|
||||
_transformItems();
|
||||
});
|
||||
}
|
||||
|
||||
void _onEditAddTextPressed() {
|
||||
showDialog<String>(
|
||||
context: context,
|
||||
builder: (context) => SimpleInputDialog(
|
||||
|
@ -529,7 +529,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
|||
});
|
||||
}
|
||||
|
||||
void _onLabelItemEditPressed(AlbumLabelItem item, int index) {
|
||||
void _onEditLabelItemEditPressed(AlbumLabelItem item, int index) {
|
||||
showDialog<String>(
|
||||
context: context,
|
||||
builder: (context) => SimpleInputDialog(
|
||||
|
@ -590,9 +590,9 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
|||
previewUrl: previewUrl,
|
||||
onTap: () => _onItemTap(i),
|
||||
onDropBefore: (dropItem) =>
|
||||
_onItemMoved((dropItem as _ListItem).index, i, true),
|
||||
_onEditItemMoved((dropItem as _ListItem).index, i, true),
|
||||
onDropAfter: (dropItem) =>
|
||||
_onItemMoved((dropItem as _ListItem).index, i, false),
|
||||
_onEditItemMoved((dropItem as _ListItem).index, i, false),
|
||||
onDragStarted: () {
|
||||
_isDragging = true;
|
||||
},
|
||||
|
@ -608,9 +608,9 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
|||
previewUrl: previewUrl,
|
||||
onTap: () => _onItemTap(i),
|
||||
onDropBefore: (dropItem) =>
|
||||
_onItemMoved((dropItem as _ListItem).index, i, true),
|
||||
_onEditItemMoved((dropItem as _ListItem).index, i, true),
|
||||
onDropAfter: (dropItem) =>
|
||||
_onItemMoved((dropItem as _ListItem).index, i, false),
|
||||
_onEditItemMoved((dropItem as _ListItem).index, i, false),
|
||||
onDragStarted: () {
|
||||
_isDragging = true;
|
||||
},
|
||||
|
@ -627,11 +627,11 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
|||
yield _EditLabelListItem(
|
||||
index: i,
|
||||
text: item.text,
|
||||
onEditPressed: () => _onLabelItemEditPressed(item, i),
|
||||
onEditPressed: () => _onEditLabelItemEditPressed(item, i),
|
||||
onDropBefore: (dropItem) =>
|
||||
_onItemMoved((dropItem as _ListItem).index, i, true),
|
||||
_onEditItemMoved((dropItem as _ListItem).index, i, true),
|
||||
onDropAfter: (dropItem) =>
|
||||
_onItemMoved((dropItem as _ListItem).index, i, false),
|
||||
_onEditItemMoved((dropItem as _ListItem).index, i, false),
|
||||
onDragStarted: () {
|
||||
_isDragging = true;
|
||||
},
|
||||
|
|
|
@ -244,7 +244,7 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
|
|||
onSelectedMenuItem: (option) {
|
||||
switch (option) {
|
||||
case _menuValueConvertBasic:
|
||||
_onAppBarConvertBasicPressed(context);
|
||||
_onConvertBasicPressed(context);
|
||||
break;
|
||||
case _menuValueDownload:
|
||||
_onDownloadPressed();
|
||||
|
@ -264,7 +264,7 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
|
|||
icon: const Icon(Icons.share),
|
||||
tooltip: L10n.global().shareTooltip,
|
||||
onPressed: () {
|
||||
_onSelectionAppBarSharePressed(context);
|
||||
_onSelectionSharePressed(context);
|
||||
},
|
||||
),
|
||||
PopupMenuButton<_SelectionMenuOption>(
|
||||
|
@ -289,7 +289,7 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
|
|||
IconButton(
|
||||
icon: const Icon(Icons.sort_by_alpha),
|
||||
tooltip: L10n.global().sortTooltip,
|
||||
onPressed: _onEditAppBarSortPressed,
|
||||
onPressed: _onEditSortPressed,
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
|
|||
album: widget.album));
|
||||
}
|
||||
|
||||
Future<void> _onAppBarConvertBasicPressed(BuildContext context) async {
|
||||
Future<void> _onConvertBasicPressed(BuildContext context) async {
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
|
@ -335,7 +335,7 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
|
|||
return;
|
||||
}
|
||||
_log.info(
|
||||
"[_onAppBarConvertBasicPressed] Converting album '${_album!.name}' to static");
|
||||
"[_onConvertBasicPressed] Converting album '${_album!.name}' to static");
|
||||
final albumRepo = AlbumRepo(AlbumCachedDataSource());
|
||||
try {
|
||||
await UpdateAlbum(albumRepo)(
|
||||
|
@ -356,7 +356,7 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
|
|||
}
|
||||
} catch (e, stackTrace) {
|
||||
_log.shout(
|
||||
"[_onAppBarConvertBasicPressed] Failed while converting to basic album",
|
||||
"[_onConvertBasicPressed] Failed while converting to basic album",
|
||||
e,
|
||||
stackTrace);
|
||||
SnackBarManager().showSnackBar(SnackBar(
|
||||
|
@ -374,7 +374,22 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
|
|||
);
|
||||
}
|
||||
|
||||
void _onSelectionAppBarSharePressed(BuildContext context) {
|
||||
void _onSelectionMenuSelected(
|
||||
BuildContext context, _SelectionMenuOption option) {
|
||||
switch (option) {
|
||||
case _SelectionMenuOption.delete:
|
||||
_onSelectionDeletePressed();
|
||||
break;
|
||||
case _SelectionMenuOption.download:
|
||||
_onSelectionDownloadPressed();
|
||||
break;
|
||||
default:
|
||||
_log.shout("[_onSelectionMenuSelected] Unknown option: $option");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void _onSelectionSharePressed(BuildContext context) {
|
||||
assert(platform_k.isAndroid);
|
||||
final selected = selectedListItems
|
||||
.whereType<_FileListItem>()
|
||||
|
@ -387,22 +402,7 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
|
|||
});
|
||||
}
|
||||
|
||||
void _onSelectionMenuSelected(
|
||||
BuildContext context, _SelectionMenuOption option) {
|
||||
switch (option) {
|
||||
case _SelectionMenuOption.delete:
|
||||
_onSelectionAppBarDeletePressed();
|
||||
break;
|
||||
case _SelectionMenuOption.download:
|
||||
_onSelectionDownloadPressed();
|
||||
break;
|
||||
default:
|
||||
_log.shout("[_onSelectionMenuSelected] Unknown option: $option");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void _onSelectionAppBarDeletePressed() async {
|
||||
void _onSelectionDeletePressed() async {
|
||||
SnackBarManager().showSnackBar(SnackBar(
|
||||
content: Text(L10n.global()
|
||||
.deleteSelectedProcessingNotification(selectedListItems.length)),
|
||||
|
@ -424,7 +424,7 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
|
|||
successes.add(item);
|
||||
} catch (e, stacktrace) {
|
||||
_log.shout(
|
||||
"[_onSelectionAppBarDeletePressed] Failed while removing file" +
|
||||
"[_onSelectionDeletePressed] Failed while removing file" +
|
||||
(shouldLogFileName ? ": ${item.file.path}" : ""),
|
||||
e,
|
||||
stacktrace);
|
||||
|
@ -466,7 +466,7 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
|
|||
});
|
||||
}
|
||||
|
||||
void _onEditAppBarSortPressed() {
|
||||
void _onEditSortPressed() {
|
||||
final sortProvider = _editAlbum!.sortProvider;
|
||||
showDialog(
|
||||
context: context,
|
||||
|
@ -478,7 +478,7 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
|
|||
isSelected: sortProvider is AlbumTimeSortProvider &&
|
||||
!sortProvider.isAscending,
|
||||
onSelect: () {
|
||||
_onSortNewestPressed();
|
||||
_onEditSortNewestPressed();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
|
@ -487,7 +487,7 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
|
|||
isSelected: sortProvider is AlbumTimeSortProvider &&
|
||||
sortProvider.isAscending,
|
||||
onSelect: () {
|
||||
_onSortOldestPressed();
|
||||
_onEditSortOldestPressed();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
|
@ -496,7 +496,7 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
|
|||
);
|
||||
}
|
||||
|
||||
void _onSortOldestPressed() {
|
||||
void _onEditSortOldestPressed() {
|
||||
_editAlbum = _editAlbum!.copyWith(
|
||||
sortProvider: const AlbumTimeSortProvider(isAscending: true),
|
||||
);
|
||||
|
@ -505,7 +505,7 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
|
|||
});
|
||||
}
|
||||
|
||||
void _onSortNewestPressed() {
|
||||
void _onEditSortNewestPressed() {
|
||||
_editAlbum = _editAlbum!.copyWith(
|
||||
sortProvider: const AlbumTimeSortProvider(isAscending: false),
|
||||
);
|
||||
|
|
|
@ -157,7 +157,7 @@ class _HomeAlbumsState extends State<HomeAlbums>
|
|||
icon: const Icon(Icons.delete),
|
||||
tooltip: L10n.global().deleteTooltip,
|
||||
onPressed: () {
|
||||
_onSelectionAppBarDeletePressed();
|
||||
_onSelectionDeletePressed();
|
||||
},
|
||||
),
|
||||
],
|
||||
|
@ -191,7 +191,7 @@ class _HomeAlbumsState extends State<HomeAlbums>
|
|||
break;
|
||||
|
||||
case _menuValueImport:
|
||||
_onAppBarImportPressed(context);
|
||||
_onImportPressed(context);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
@ -307,6 +307,17 @@ class _HomeAlbumsState extends State<HomeAlbums>
|
|||
});
|
||||
}
|
||||
|
||||
void _onSearchPressed(BuildContext context) {
|
||||
showSearch(
|
||||
context: context,
|
||||
delegate: AlbumSearchDelegate(context, widget.account),
|
||||
).then((value) {
|
||||
if (value is Album) {
|
||||
_openAlbum(context, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _onSortPressed(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
|
@ -357,12 +368,12 @@ class _HomeAlbumsState extends State<HomeAlbums>
|
|||
});
|
||||
}
|
||||
|
||||
void _onAppBarImportPressed(BuildContext context) {
|
||||
void _onImportPressed(BuildContext context) {
|
||||
Navigator.of(context).pushNamed(AlbumImporter.routeName,
|
||||
arguments: AlbumImporterArguments(widget.account));
|
||||
}
|
||||
|
||||
Future<void> _onSelectionAppBarDeletePressed() async {
|
||||
Future<void> _onSelectionDeletePressed() async {
|
||||
final selected = selectedListItems
|
||||
.whereType<_AlbumListItem>()
|
||||
.map((e) => e.album)
|
||||
|
@ -384,7 +395,7 @@ class _HomeAlbumsState extends State<HomeAlbums>
|
|||
await Remove(fileRepo, albumRepo)(widget.account, f);
|
||||
} catch (e, stacktrace) {
|
||||
_log.shout(
|
||||
"[_onSelectionAppBarDeletePressed] Failed while removing file" +
|
||||
"[_onSelectionDeletePressed] Failed while removing file" +
|
||||
(shouldLogFileName ? ": ${f.path}" : ""),
|
||||
e,
|
||||
stacktrace);
|
||||
|
@ -405,17 +416,6 @@ class _HomeAlbumsState extends State<HomeAlbums>
|
|||
}
|
||||
}
|
||||
|
||||
void _onSearchPressed(BuildContext context) {
|
||||
showSearch(
|
||||
context: context,
|
||||
delegate: AlbumSearchDelegate(context, widget.account),
|
||||
).then((value) {
|
||||
if (value is Album) {
|
||||
_openAlbum(context, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Transform an Album list to grid items
|
||||
void _transformItems(List<ListAlbumBlocItem> items) {
|
||||
final sort = _getSortFromPref();
|
||||
|
|
|
@ -185,14 +185,14 @@ class _HomePhotosState extends State<HomePhotos>
|
|||
icon: const Icon(Icons.share),
|
||||
tooltip: L10n.global().shareTooltip,
|
||||
onPressed: () {
|
||||
_onSelectionAppBarSharePressed(context);
|
||||
_onSelectionSharePressed(context);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.playlist_add),
|
||||
tooltip: L10n.global().addToAlbumTooltip,
|
||||
onPressed: () {
|
||||
_onAddToAlbumPressed(context);
|
||||
_onSelectionAddToAlbumPressed(context);
|
||||
},
|
||||
),
|
||||
PopupMenuButton<_SelectionMenuOption>(
|
||||
|
@ -212,7 +212,7 @@ class _HomePhotosState extends State<HomePhotos>
|
|||
),
|
||||
],
|
||||
onSelected: (option) {
|
||||
_onSelectionAppBarMenuSelected(context, option);
|
||||
_onSelectionMenuSelected(context, option);
|
||||
},
|
||||
),
|
||||
],
|
||||
|
@ -357,7 +357,30 @@ class _HomePhotosState extends State<HomePhotos>
|
|||
arguments: ViewerArguments(widget.account, _backingFiles, index));
|
||||
}
|
||||
|
||||
void _onSelectionAppBarSharePressed(BuildContext context) {
|
||||
void _onRefreshSelected() {
|
||||
_hasFiredMetadataTask.value = false;
|
||||
_reqRefresh();
|
||||
}
|
||||
|
||||
void _onSelectionMenuSelected(
|
||||
BuildContext context, _SelectionMenuOption option) {
|
||||
switch (option) {
|
||||
case _SelectionMenuOption.archive:
|
||||
_onSelectionArchivePressed(context);
|
||||
break;
|
||||
case _SelectionMenuOption.delete:
|
||||
_onSelectionDeletePressed(context);
|
||||
break;
|
||||
case _SelectionMenuOption.download:
|
||||
_onSelectionDownloadPressed();
|
||||
break;
|
||||
default:
|
||||
_log.shout("[_onSelectionMenuSelected] Unknown option: $option");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void _onSelectionSharePressed(BuildContext context) {
|
||||
assert(platform_k.isAndroid);
|
||||
final selected = selectedListItems
|
||||
.whereType<_FileListItem>()
|
||||
|
@ -370,7 +393,7 @@ class _HomePhotosState extends State<HomePhotos>
|
|||
});
|
||||
}
|
||||
|
||||
Future<void> _onAddToAlbumPressed(BuildContext context) async {
|
||||
Future<void> _onSelectionAddToAlbumPressed(BuildContext context) async {
|
||||
try {
|
||||
final value = await showDialog<Album>(
|
||||
context: context,
|
||||
|
@ -383,7 +406,7 @@ class _HomePhotosState extends State<HomePhotos>
|
|||
return;
|
||||
}
|
||||
|
||||
_log.info("[_onAddToAlbumPressed] Album picked: ${value.name}");
|
||||
_log.info("[_onSelectionAddToAlbumPressed] Album picked: ${value.name}");
|
||||
await NotifiedAction(
|
||||
() async {
|
||||
assert(value.provider is AlbumStaticProvider);
|
||||
|
@ -402,11 +425,11 @@ class _HomePhotosState extends State<HomePhotos>
|
|||
failureText: L10n.global().addSelectedToAlbumFailureNotification,
|
||||
)();
|
||||
} catch (e, stackTrace) {
|
||||
_log.shout("[_onAddToAlbumPressed] Exception", e, stackTrace);
|
||||
_log.shout("[_onSelectionAddToAlbumPressed] Exception", e, stackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
void _onDownloadPressed() {
|
||||
void _onSelectionDownloadPressed() {
|
||||
final selected = selectedListItems
|
||||
.whereType<_FileListItem>()
|
||||
.map((e) => e.file)
|
||||
|
@ -417,7 +440,7 @@ class _HomePhotosState extends State<HomePhotos>
|
|||
});
|
||||
}
|
||||
|
||||
Future<void> _onArchivePressed(BuildContext context) async {
|
||||
Future<void> _onSelectionArchivePressed(BuildContext context) async {
|
||||
final selectedFiles = selectedListItems
|
||||
.whereType<_FileListItem>()
|
||||
.map((e) => e.file)
|
||||
|
@ -439,7 +462,7 @@ class _HomePhotosState extends State<HomePhotos>
|
|||
L10n.global().archiveSelectedFailureNotification(failures.length),
|
||||
onActionError: (file, e, stackTrace) {
|
||||
_log.shout(
|
||||
"[_onArchivePressed] Failed while archiving file" +
|
||||
"[_onSelectionArchivePressed] Failed while archiving file" +
|
||||
(shouldLogFileName ? ": ${file.path}" : ""),
|
||||
e,
|
||||
stackTrace);
|
||||
|
@ -447,7 +470,7 @@ class _HomePhotosState extends State<HomePhotos>
|
|||
)();
|
||||
}
|
||||
|
||||
Future<void> _onDeletePressed(BuildContext context) async {
|
||||
Future<void> _onSelectionDeletePressed(BuildContext context) async {
|
||||
final selectedFiles = selectedListItems
|
||||
.whereType<_FileListItem>()
|
||||
.map((e) => e.file)
|
||||
|
@ -469,7 +492,7 @@ class _HomePhotosState extends State<HomePhotos>
|
|||
L10n.global().deleteSelectedFailureNotification(failures.length),
|
||||
onActionError: (file, e, stackTrace) {
|
||||
_log.shout(
|
||||
"[_onDeletePressed] Failed while removing file" +
|
||||
"[_onSelectionDeletePressed] Failed while removing file" +
|
||||
(shouldLogFileName ? ": ${file.path}" : ""),
|
||||
e,
|
||||
stackTrace);
|
||||
|
@ -477,32 +500,6 @@ class _HomePhotosState extends State<HomePhotos>
|
|||
)();
|
||||
}
|
||||
|
||||
void _onSelectionAppBarMenuSelected(
|
||||
BuildContext context, _SelectionMenuOption option) {
|
||||
switch (option) {
|
||||
case _SelectionMenuOption.archive:
|
||||
_onArchivePressed(context);
|
||||
break;
|
||||
|
||||
case _SelectionMenuOption.delete:
|
||||
_onDeletePressed(context);
|
||||
break;
|
||||
|
||||
case _SelectionMenuOption.download:
|
||||
_onDownloadPressed();
|
||||
break;
|
||||
|
||||
default:
|
||||
_log.shout("[_onSelectionAppBarMenuSelected] Unknown option: $option");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void _onRefreshSelected() {
|
||||
_hasFiredMetadataTask.value = false;
|
||||
_reqRefresh();
|
||||
}
|
||||
|
||||
void _onMetadataTaskStateChanged(MetadataTaskStateChangedEvent ev) {
|
||||
if (ev.state == MetadataTaskState.idle) {
|
||||
_metadataTaskProcessCount = 0;
|
||||
|
|
|
@ -267,14 +267,14 @@ class _PersonBrowserState extends State<PersonBrowser>
|
|||
icon: const Icon(Icons.share),
|
||||
tooltip: L10n.global().shareTooltip,
|
||||
onPressed: () {
|
||||
_onSharePressed(context);
|
||||
_onSelectionSharePressed(context);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.playlist_add),
|
||||
tooltip: L10n.global().addToAlbumTooltip,
|
||||
onPressed: () {
|
||||
_onAddToAlbumPressed(context);
|
||||
_onSelectionAddToAlbumPressed(context);
|
||||
},
|
||||
),
|
||||
PopupMenuButton<_SelectionMenuOption>(
|
||||
|
@ -294,7 +294,7 @@ class _PersonBrowserState extends State<PersonBrowser>
|
|||
),
|
||||
],
|
||||
onSelected: (option) {
|
||||
_onOptionMenuSelected(context, option);
|
||||
_onSelectionMenuSelected(context, option);
|
||||
},
|
||||
),
|
||||
],
|
||||
|
@ -320,7 +320,25 @@ class _PersonBrowserState extends State<PersonBrowser>
|
|||
arguments: ViewerArguments(widget.account, _backingFiles!, index));
|
||||
}
|
||||
|
||||
void _onSharePressed(BuildContext context) {
|
||||
void _onSelectionMenuSelected(
|
||||
BuildContext context, _SelectionMenuOption option) {
|
||||
switch (option) {
|
||||
case _SelectionMenuOption.archive:
|
||||
_onSelectionArchivePressed(context);
|
||||
break;
|
||||
case _SelectionMenuOption.delete:
|
||||
_onSelectionDeletePressed(context);
|
||||
break;
|
||||
case _SelectionMenuOption.download:
|
||||
_onSelectionDownloadPressed();
|
||||
break;
|
||||
default:
|
||||
_log.shout("[_onSelectionMenuSelected] Unknown option: $option");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void _onSelectionSharePressed(BuildContext context) {
|
||||
assert(platform_k.isAndroid);
|
||||
final selected =
|
||||
selectedListItems.whereType<_ListItem>().map((e) => e.file).toList();
|
||||
|
@ -331,7 +349,7 @@ class _PersonBrowserState extends State<PersonBrowser>
|
|||
});
|
||||
}
|
||||
|
||||
Future<void> _onAddToAlbumPressed(BuildContext context) async {
|
||||
Future<void> _onSelectionAddToAlbumPressed(BuildContext context) async {
|
||||
try {
|
||||
final value = await showDialog<Album>(
|
||||
context: context,
|
||||
|
@ -344,7 +362,7 @@ class _PersonBrowserState extends State<PersonBrowser>
|
|||
return;
|
||||
}
|
||||
|
||||
_log.info("[_onAddToAlbumPressed] Album picked: ${value.name}");
|
||||
_log.info("[_onSelectionAddToAlbumPressed] Album picked: ${value.name}");
|
||||
await NotifiedAction(
|
||||
() async {
|
||||
assert(value.provider is AlbumStaticProvider);
|
||||
|
@ -363,11 +381,11 @@ class _PersonBrowserState extends State<PersonBrowser>
|
|||
failureText: L10n.global().addSelectedToAlbumFailureNotification,
|
||||
)();
|
||||
} catch (e, stackTrace) {
|
||||
_log.shout("[_onAddToAlbumPressed] Exception", e, stackTrace);
|
||||
_log.shout("[_onSelectionAddToAlbumPressed] Exception", e, stackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
void _onDownloadPressed() {
|
||||
void _onSelectionDownloadPressed() {
|
||||
final selected =
|
||||
selectedListItems.whereType<_ListItem>().map((e) => e.file).toList();
|
||||
DownloadHandler().downloadFiles(widget.account, selected);
|
||||
|
@ -376,7 +394,7 @@ class _PersonBrowserState extends State<PersonBrowser>
|
|||
});
|
||||
}
|
||||
|
||||
Future<void> _onArchivePressed(BuildContext context) async {
|
||||
Future<void> _onSelectionArchivePressed(BuildContext context) async {
|
||||
final selectedFiles =
|
||||
selectedListItems.whereType<_ListItem>().map((e) => e.file).toList();
|
||||
setState(() {
|
||||
|
@ -396,7 +414,7 @@ class _PersonBrowserState extends State<PersonBrowser>
|
|||
L10n.global().archiveSelectedFailureNotification(failures.length),
|
||||
onActionError: (file, e, stackTrace) {
|
||||
_log.shout(
|
||||
"[_onArchivePressed] Failed while archiving file" +
|
||||
"[_onSelectionArchivePressed] Failed while archiving file" +
|
||||
(shouldLogFileName ? ": ${file.path}" : ""),
|
||||
e,
|
||||
stackTrace);
|
||||
|
@ -404,7 +422,7 @@ class _PersonBrowserState extends State<PersonBrowser>
|
|||
)();
|
||||
}
|
||||
|
||||
Future<void> _onDeletePressed(BuildContext context) async {
|
||||
Future<void> _onSelectionDeletePressed(BuildContext context) async {
|
||||
final selectedFiles =
|
||||
selectedListItems.whereType<_ListItem>().map((e) => e.file).toList();
|
||||
setState(() {
|
||||
|
@ -424,7 +442,7 @@ class _PersonBrowserState extends State<PersonBrowser>
|
|||
L10n.global().deleteSelectedFailureNotification(failures.length),
|
||||
onActionError: (file, e, stackTrace) {
|
||||
_log.shout(
|
||||
"[_onDeletePressed] Failed while removing file" +
|
||||
"[_onSelectionDeletePressed] Failed while removing file" +
|
||||
(shouldLogFileName ? ": ${file.path}" : ""),
|
||||
e,
|
||||
stackTrace);
|
||||
|
@ -432,27 +450,6 @@ class _PersonBrowserState extends State<PersonBrowser>
|
|||
)();
|
||||
}
|
||||
|
||||
void _onOptionMenuSelected(
|
||||
BuildContext context, _SelectionMenuOption option) {
|
||||
switch (option) {
|
||||
case _SelectionMenuOption.archive:
|
||||
_onArchivePressed(context);
|
||||
break;
|
||||
|
||||
case _SelectionMenuOption.delete:
|
||||
_onDeletePressed(context);
|
||||
break;
|
||||
|
||||
case _SelectionMenuOption.download:
|
||||
_onDownloadPressed();
|
||||
break;
|
||||
|
||||
default:
|
||||
_log.shout("[_onOptionMenuSelected] Unknown option: $option");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void _onFilePropertyUpdated(FilePropertyUpdatedEvent ev) {
|
||||
if (_backingFiles?.containsIf(ev.file, (a, b) => a.fileId == b.fileId) !=
|
||||
true) {
|
||||
|
|
Loading…
Reference in a new issue