2021-04-21 16:17:18 +02:00
|
|
|
import 'package:flutter/foundation.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/widgets.dart';
|
2021-07-06 15:03:29 +02:00
|
|
|
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
import 'package:logging/logging.dart';
|
|
|
|
import 'package:nc_photos/account.dart';
|
|
|
|
import 'package:nc_photos/api/api_util.dart' as api_util;
|
2021-07-25 07:00:38 +02:00
|
|
|
import 'package:nc_photos/app_localizations.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
import 'package:nc_photos/entity/album.dart';
|
2021-07-05 09:54:01 +02:00
|
|
|
import 'package:nc_photos/entity/album/item.dart';
|
2021-06-24 18:26:56 +02:00
|
|
|
import 'package:nc_photos/entity/album/provider.dart';
|
2021-07-07 20:40:43 +02:00
|
|
|
import 'package:nc_photos/entity/album/sort_provider.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
import 'package:nc_photos/entity/file.dart';
|
|
|
|
import 'package:nc_photos/entity/file_util.dart' as file_util;
|
2021-08-13 22:18:35 +02:00
|
|
|
import 'package:nc_photos/event/event.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
import 'package:nc_photos/exception_util.dart' as exception_util;
|
2021-07-09 11:00:55 +02:00
|
|
|
import 'package:nc_photos/iterable_extension.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
import 'package:nc_photos/k.dart' as k;
|
2021-07-22 08:15:41 +02:00
|
|
|
import 'package:nc_photos/or_null.dart';
|
2021-07-10 17:06:04 +02:00
|
|
|
import 'package:nc_photos/platform/k.dart' as platform_k;
|
2021-07-08 10:57:20 +02:00
|
|
|
import 'package:nc_photos/session_storage.dart';
|
2021-07-10 17:06:04 +02:00
|
|
|
import 'package:nc_photos/share_handler.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
import 'package:nc_photos/snack_bar_manager.dart';
|
|
|
|
import 'package:nc_photos/theme.dart';
|
2021-06-14 15:51:29 +02:00
|
|
|
import 'package:nc_photos/use_case/resync_album.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
import 'package:nc_photos/use_case/update_album.dart';
|
2021-07-31 19:16:14 +02:00
|
|
|
import 'package:nc_photos/widget/album_browser_mixin.dart';
|
2021-07-08 10:57:20 +02:00
|
|
|
import 'package:nc_photos/widget/draggable_item_list_mixin.dart';
|
2021-07-10 21:25:23 +02:00
|
|
|
import 'package:nc_photos/widget/fancy_option_picker.dart';
|
2021-05-06 13:29:20 +02:00
|
|
|
import 'package:nc_photos/widget/photo_list_item.dart';
|
2021-04-23 09:55:53 +02:00
|
|
|
import 'package:nc_photos/widget/selectable_item_stream_list_mixin.dart';
|
2021-07-09 12:07:37 +02:00
|
|
|
import 'package:nc_photos/widget/simple_input_dialog.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
import 'package:nc_photos/widget/viewer.dart';
|
2021-06-14 15:51:29 +02:00
|
|
|
import 'package:quiver/iterables.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
|
2021-07-31 19:16:14 +02:00
|
|
|
class AlbumBrowserArguments {
|
|
|
|
AlbumBrowserArguments(this.account, this.album);
|
2021-04-10 06:28:12 +02:00
|
|
|
|
|
|
|
final Account account;
|
|
|
|
final Album album;
|
|
|
|
}
|
|
|
|
|
2021-07-31 19:16:14 +02:00
|
|
|
class AlbumBrowser extends StatefulWidget {
|
|
|
|
static const routeName = "/album-browser";
|
2021-04-10 06:28:12 +02:00
|
|
|
|
2021-07-31 19:16:14 +02:00
|
|
|
static Route buildRoute(AlbumBrowserArguments args) => MaterialPageRoute(
|
|
|
|
builder: (context) => AlbumBrowser.fromArgs(args),
|
2021-07-23 22:05:57 +02:00
|
|
|
);
|
|
|
|
|
2021-07-31 19:16:14 +02:00
|
|
|
AlbumBrowser({
|
2021-07-23 22:05:57 +02:00
|
|
|
Key? key,
|
|
|
|
required this.account,
|
|
|
|
required this.album,
|
2021-04-10 06:28:12 +02:00
|
|
|
}) : super(key: key);
|
|
|
|
|
2021-07-31 19:16:14 +02:00
|
|
|
AlbumBrowser.fromArgs(AlbumBrowserArguments args, {Key? key})
|
2021-04-10 06:28:12 +02:00
|
|
|
: this(
|
|
|
|
key: key,
|
|
|
|
account: args.account,
|
|
|
|
album: args.album,
|
|
|
|
);
|
|
|
|
|
|
|
|
@override
|
2021-07-31 19:16:14 +02:00
|
|
|
createState() => _AlbumBrowserState();
|
2021-04-10 06:28:12 +02:00
|
|
|
|
|
|
|
final Account account;
|
|
|
|
final Album album;
|
|
|
|
}
|
|
|
|
|
2021-07-31 19:16:14 +02:00
|
|
|
class _AlbumBrowserState extends State<AlbumBrowser>
|
2021-06-26 16:28:21 +02:00
|
|
|
with
|
2021-07-31 19:16:14 +02:00
|
|
|
SelectableItemStreamListMixin<AlbumBrowser>,
|
|
|
|
DraggableItemListMixin<AlbumBrowser>,
|
|
|
|
AlbumBrowserMixin<AlbumBrowser> {
|
2021-04-10 06:28:12 +02:00
|
|
|
@override
|
|
|
|
initState() {
|
|
|
|
super.initState();
|
2021-06-14 15:51:29 +02:00
|
|
|
_initAlbum();
|
2021-08-13 22:18:35 +02:00
|
|
|
|
|
|
|
_albumUpdatedListener =
|
|
|
|
AppEventListener<AlbumUpdatedEvent>(_onAlbumUpdatedEvent);
|
|
|
|
_albumUpdatedListener.begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
dispose() {
|
|
|
|
super.dispose();
|
|
|
|
_albumUpdatedListener.end();
|
2021-04-10 06:28:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
build(BuildContext context) {
|
|
|
|
return AppTheme(
|
|
|
|
child: Scaffold(
|
2021-07-02 13:55:52 +02:00
|
|
|
body: Builder(
|
|
|
|
builder: (context) {
|
|
|
|
if (isEditMode) {
|
|
|
|
return Form(
|
|
|
|
key: _editFormKey,
|
|
|
|
child: _buildContent(context),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return _buildContent(context);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
2021-04-10 06:28:12 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-07-25 22:25:16 +02:00
|
|
|
@protected
|
|
|
|
get canEdit => _album != null;
|
|
|
|
|
2021-07-08 06:13:36 +02:00
|
|
|
@override
|
|
|
|
enterEditMode() {
|
|
|
|
super.enterEditMode();
|
2021-07-23 22:05:57 +02:00
|
|
|
_editAlbum = _album!.copyWith();
|
2021-07-09 12:07:37 +02:00
|
|
|
setState(() {
|
|
|
|
_transformItems();
|
|
|
|
});
|
2021-07-08 10:57:20 +02:00
|
|
|
|
|
|
|
if (!SessionStorage().hasShowDragRearrangeNotification) {
|
|
|
|
SnackBarManager().showSnackBar(SnackBar(
|
2021-07-25 07:00:38 +02:00
|
|
|
content: Text(L10n.of(context).albumEditDragRearrangeNotification),
|
2021-07-08 10:57:20 +02:00
|
|
|
duration: k.snackBarDurationNormal,
|
|
|
|
));
|
|
|
|
SessionStorage().hasShowDragRearrangeNotification = true;
|
|
|
|
}
|
2021-07-08 06:13:36 +02:00
|
|
|
}
|
|
|
|
|
2021-07-08 21:26:14 +02:00
|
|
|
@override
|
2021-07-23 22:05:57 +02:00
|
|
|
validateEditMode() => _editFormKey.currentState?.validate() == true;
|
2021-07-08 21:26:14 +02:00
|
|
|
|
2021-07-02 13:55:52 +02:00
|
|
|
@override
|
|
|
|
doneEditMode() {
|
2021-07-08 21:26:14 +02:00
|
|
|
try {
|
|
|
|
// persist the changes
|
2021-07-23 22:05:57 +02:00
|
|
|
_editFormKey.currentState!.save();
|
|
|
|
final newAlbum = makeEdited(_editAlbum!);
|
|
|
|
if (newAlbum.copyWith(lastUpdated: OrNull(_album!.lastUpdated)) !=
|
2021-07-22 08:15:41 +02:00
|
|
|
_album) {
|
2021-07-08 21:26:14 +02:00
|
|
|
_log.info("[doneEditMode] Album modified: $newAlbum");
|
|
|
|
final albumRepo = AlbumRepo(AlbumCachedDataSource());
|
2021-07-02 13:55:52 +02:00
|
|
|
setState(() {
|
2021-07-08 21:26:14 +02:00
|
|
|
_album = newAlbum;
|
|
|
|
});
|
|
|
|
UpdateAlbum(albumRepo)(widget.account, newAlbum)
|
|
|
|
.catchError((e, stacktrace) {
|
|
|
|
SnackBarManager().showSnackBar(SnackBar(
|
|
|
|
content: Text(exception_util.toUserString(e, context)),
|
|
|
|
duration: k.snackBarDurationNormal,
|
|
|
|
));
|
2021-07-02 13:55:52 +02:00
|
|
|
});
|
2021-07-08 21:26:14 +02:00
|
|
|
} else {
|
|
|
|
_log.fine("[doneEditMode] Album not modified");
|
2021-07-02 13:55:52 +02:00
|
|
|
}
|
2021-07-08 21:26:14 +02:00
|
|
|
} finally {
|
|
|
|
setState(() {
|
|
|
|
// reset edits
|
|
|
|
_editAlbum = null;
|
|
|
|
// update the list to show the real album
|
|
|
|
_transformItems();
|
|
|
|
});
|
2021-07-02 13:55:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-14 15:51:29 +02:00
|
|
|
void _initAlbum() {
|
2021-06-24 18:26:56 +02:00
|
|
|
assert(widget.album.provider is AlbumStaticProvider);
|
2021-06-14 15:51:29 +02:00
|
|
|
ResyncAlbum()(widget.account, widget.album).then((album) {
|
|
|
|
if (_shouldPropagateResyncedAlbum(album)) {
|
2021-07-17 16:35:26 +02:00
|
|
|
_propagateResyncedAlbum(album);
|
2021-06-14 15:51:29 +02:00
|
|
|
}
|
|
|
|
if (mounted) {
|
|
|
|
setState(() {
|
|
|
|
_album = album;
|
|
|
|
_transformItems();
|
2021-08-13 12:41:02 +02:00
|
|
|
initCover(widget.account, album);
|
2021-06-14 15:51:29 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-04-10 06:28:12 +02:00
|
|
|
Widget _buildContent(BuildContext context) {
|
2021-06-14 15:51:29 +02:00
|
|
|
if (_album == null) {
|
|
|
|
return CustomScrollView(
|
|
|
|
slivers: [
|
2021-06-26 16:28:21 +02:00
|
|
|
buildNormalAppBar(context, widget.account, widget.album),
|
2021-06-14 15:51:29 +02:00
|
|
|
const SliverToBoxAdapter(
|
|
|
|
child: const LinearProgressIndicator(),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
2021-07-08 10:57:20 +02:00
|
|
|
|
|
|
|
Widget content = CustomScrollView(
|
|
|
|
controller: _scrollController,
|
|
|
|
slivers: [
|
|
|
|
_buildAppBar(context),
|
|
|
|
SliverPadding(
|
2021-07-09 18:57:13 +02:00
|
|
|
padding: const EdgeInsets.only(top: 8),
|
2021-07-08 10:57:20 +02:00
|
|
|
sliver: isEditMode
|
|
|
|
? buildDraggableItemList(
|
|
|
|
maxCrossAxisExtent: thumbSize.toDouble(),
|
|
|
|
onMaxExtentChanged: (value) {
|
|
|
|
_itemListMaxExtent = value;
|
|
|
|
},
|
|
|
|
)
|
|
|
|
: buildItemStreamList(
|
|
|
|
maxCrossAxisExtent: thumbSize.toDouble(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
if (isEditMode) {
|
|
|
|
content = Listener(
|
|
|
|
onPointerMove: _onEditModePointerMove,
|
|
|
|
child: content,
|
|
|
|
);
|
|
|
|
}
|
2021-04-23 09:55:53 +02:00
|
|
|
return buildItemStreamListOuter(
|
|
|
|
context,
|
|
|
|
child: Theme(
|
|
|
|
data: Theme.of(context).copyWith(
|
|
|
|
accentColor: AppTheme.getOverscrollIndicatorColor(context),
|
|
|
|
),
|
2021-07-08 10:57:20 +02:00
|
|
|
child: content,
|
2021-04-10 06:28:12 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildAppBar(BuildContext context) {
|
2021-07-02 13:55:52 +02:00
|
|
|
if (isEditMode) {
|
|
|
|
return _buildEditAppBar(context);
|
|
|
|
} else if (isSelectionMode) {
|
|
|
|
return _buildSelectionAppBar(context);
|
2021-06-26 16:28:21 +02:00
|
|
|
} else {
|
2021-07-23 22:05:57 +02:00
|
|
|
return buildNormalAppBar(context, widget.account, _album!);
|
2021-06-26 16:28:21 +02:00
|
|
|
}
|
2021-04-10 06:28:12 +02:00
|
|
|
}
|
|
|
|
|
2021-07-02 13:55:52 +02:00
|
|
|
Widget _buildSelectionAppBar(BuildContext context) {
|
|
|
|
return buildSelectionAppBar(context, [
|
2021-07-10 17:06:04 +02:00
|
|
|
if (platform_k.isAndroid)
|
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Icons.share),
|
2021-08-02 13:59:05 +02:00
|
|
|
tooltip: L10n.of(context).shareTooltip,
|
2021-07-10 17:06:04 +02:00
|
|
|
onPressed: () {
|
|
|
|
_onSelectionAppBarSharePressed(context);
|
|
|
|
},
|
|
|
|
),
|
2021-07-02 13:55:52 +02:00
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Icons.remove),
|
2021-07-25 07:00:38 +02:00
|
|
|
tooltip: L10n.of(context).removeSelectedFromAlbumTooltip,
|
2021-07-02 13:55:52 +02:00
|
|
|
onPressed: () {
|
|
|
|
_onSelectionAppBarRemovePressed();
|
|
|
|
},
|
|
|
|
)
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildEditAppBar(BuildContext context) {
|
2021-07-08 06:13:36 +02:00
|
|
|
return buildEditAppBar(context, widget.account, widget.album, actions: [
|
2021-07-09 12:07:37 +02:00
|
|
|
IconButton(
|
|
|
|
icon: Icon(Icons.text_fields),
|
2021-07-25 07:00:38 +02:00
|
|
|
tooltip: L10n.of(context).albumAddTextTooltip,
|
2021-07-09 12:07:37 +02:00
|
|
|
onPressed: _onEditAppBarAddTextPressed,
|
|
|
|
),
|
2021-07-08 06:13:36 +02:00
|
|
|
IconButton(
|
|
|
|
icon: Icon(Icons.sort_by_alpha),
|
2021-07-25 07:00:38 +02:00
|
|
|
tooltip: L10n.of(context).sortTooltip,
|
2021-07-08 06:13:36 +02:00
|
|
|
onPressed: _onEditAppBarSortPressed,
|
|
|
|
),
|
|
|
|
]);
|
2021-07-02 13:55:52 +02:00
|
|
|
}
|
|
|
|
|
2021-04-23 09:55:53 +02:00
|
|
|
void _onItemTap(int index) {
|
2021-07-09 11:00:55 +02:00
|
|
|
// convert item index to file index
|
|
|
|
var fileIndex = index;
|
|
|
|
for (int i = 0; i < index; ++i) {
|
|
|
|
if (_sortedItems[i] is! AlbumFileItem ||
|
|
|
|
!file_util
|
|
|
|
.isSupportedFormat((_sortedItems[i] as AlbumFileItem).file)) {
|
|
|
|
--fileIndex;
|
|
|
|
}
|
|
|
|
}
|
2021-04-23 09:55:53 +02:00
|
|
|
Navigator.pushNamed(context, Viewer.routeName,
|
2021-08-13 22:18:35 +02:00
|
|
|
arguments: ViewerArguments(widget.account, _backingFiles, fileIndex,
|
|
|
|
album: widget.album));
|
2021-04-10 06:28:12 +02:00
|
|
|
}
|
|
|
|
|
2021-07-10 17:06:04 +02:00
|
|
|
void _onSelectionAppBarSharePressed(BuildContext context) {
|
|
|
|
assert(platform_k.isAndroid);
|
|
|
|
final selected = selectedListItems
|
|
|
|
.whereType<_FileListItem>()
|
|
|
|
.map((e) => e.file)
|
|
|
|
.toList();
|
|
|
|
if (selected.isEmpty) {
|
|
|
|
SnackBarManager().showSnackBar(SnackBar(
|
2021-07-25 07:00:38 +02:00
|
|
|
content: Text(L10n.of(context).shareSelectedEmptyNotification),
|
2021-07-10 17:06:04 +02:00
|
|
|
duration: k.snackBarDurationNormal,
|
|
|
|
));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ShareHandler().shareFiles(context, widget.account, selected).then((_) {
|
|
|
|
setState(() {
|
|
|
|
clearSelectedItems();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-04-10 06:28:12 +02:00
|
|
|
void _onSelectionAppBarRemovePressed() {
|
|
|
|
final selectedIndexes =
|
2021-07-09 11:00:55 +02:00
|
|
|
selectedListItems.map((e) => (e as _ListItem).index).toList();
|
|
|
|
final newItems = _sortedItems
|
|
|
|
.withIndex()
|
|
|
|
.where((element) => !selectedIndexes.contains(element.item1))
|
|
|
|
.map((e) => e.item2)
|
|
|
|
.toList();
|
|
|
|
|
2021-04-10 06:28:12 +02:00
|
|
|
final albumRepo = AlbumRepo(AlbumCachedDataSource());
|
2021-07-23 22:05:57 +02:00
|
|
|
final newAlbum = _album!.copyWith(
|
2021-06-24 18:26:56 +02:00
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: newItems,
|
|
|
|
),
|
2021-04-10 06:28:12 +02:00
|
|
|
);
|
|
|
|
UpdateAlbum(albumRepo)(widget.account, newAlbum).then((_) {
|
|
|
|
SnackBarManager().showSnackBar(SnackBar(
|
2021-07-25 07:00:38 +02:00
|
|
|
content: Text(L10n.of(context)
|
2021-04-10 06:28:12 +02:00
|
|
|
.removeSelectedFromAlbumSuccessNotification(
|
|
|
|
selectedIndexes.length)),
|
|
|
|
duration: k.snackBarDurationNormal,
|
|
|
|
));
|
|
|
|
setState(() {
|
|
|
|
_album = newAlbum;
|
|
|
|
_transformItems();
|
2021-08-13 12:41:02 +02:00
|
|
|
initCover(widget.account, newAlbum);
|
2021-04-10 06:28:12 +02:00
|
|
|
});
|
|
|
|
}).catchError((e, stacktrace) {
|
2021-04-27 22:06:16 +02:00
|
|
|
_log.shout("[_onSelectionRemovePressed] Failed while updating album", e,
|
2021-04-10 06:28:12 +02:00
|
|
|
stacktrace);
|
|
|
|
SnackBarManager().showSnackBar(SnackBar(
|
|
|
|
content: Text(
|
2021-07-25 07:00:38 +02:00
|
|
|
"${L10n.of(context).removeSelectedFromAlbumFailureNotification}: "
|
2021-04-10 06:28:12 +02:00
|
|
|
"${exception_util.toUserString(e, context)}"),
|
|
|
|
duration: k.snackBarDurationNormal,
|
|
|
|
));
|
|
|
|
});
|
|
|
|
setState(() {
|
2021-04-23 09:55:53 +02:00
|
|
|
clearSelectedItems();
|
2021-04-10 06:28:12 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-07-08 06:13:36 +02:00
|
|
|
void _onEditAppBarSortPressed() {
|
2021-07-23 22:05:57 +02:00
|
|
|
final sortProvider = _editAlbum!.sortProvider;
|
2021-07-08 06:13:36 +02:00
|
|
|
showDialog(
|
|
|
|
context: context,
|
2021-07-10 21:25:23 +02:00
|
|
|
builder: (context) => FancyOptionPicker(
|
2021-07-25 07:00:38 +02:00
|
|
|
title: L10n.of(context).sortOptionDialogTitle,
|
2021-07-10 21:25:23 +02:00
|
|
|
items: [
|
|
|
|
FancyOptionPickerItem(
|
2021-07-25 07:00:38 +02:00
|
|
|
label: L10n.of(context).sortOptionTimeAscendingLabel,
|
2021-07-10 21:25:23 +02:00
|
|
|
isSelected: sortProvider is AlbumTimeSortProvider &&
|
|
|
|
sortProvider.isAscending,
|
|
|
|
onSelect: () {
|
|
|
|
_onSortOldestPressed();
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
2021-07-08 06:13:36 +02:00
|
|
|
),
|
2021-07-10 21:25:23 +02:00
|
|
|
FancyOptionPickerItem(
|
2021-07-25 07:00:38 +02:00
|
|
|
label: L10n.of(context).sortOptionTimeDescendingLabel,
|
2021-07-10 21:25:23 +02:00
|
|
|
isSelected: sortProvider is AlbumTimeSortProvider &&
|
|
|
|
!sortProvider.isAscending,
|
|
|
|
onSelect: () {
|
|
|
|
_onSortNewestPressed();
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
2021-07-08 06:13:36 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _onSortOldestPressed() {
|
2021-07-23 22:05:57 +02:00
|
|
|
_editAlbum = _editAlbum!.copyWith(
|
2021-07-08 06:13:36 +02:00
|
|
|
sortProvider: AlbumTimeSortProvider(isAscending: true),
|
|
|
|
);
|
|
|
|
setState(() {
|
|
|
|
_transformItems();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void _onSortNewestPressed() {
|
2021-07-23 22:05:57 +02:00
|
|
|
_editAlbum = _editAlbum!.copyWith(
|
2021-07-08 06:13:36 +02:00
|
|
|
sortProvider: AlbumTimeSortProvider(isAscending: false),
|
|
|
|
);
|
|
|
|
setState(() {
|
|
|
|
_transformItems();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-07-08 10:57:20 +02:00
|
|
|
void _onEditModePointerMove(PointerMoveEvent event) {
|
|
|
|
assert(isEditMode);
|
|
|
|
if (!_isDragging) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (event.position.dy >= MediaQuery.of(context).size.height - 100) {
|
|
|
|
// near bottom of screen
|
|
|
|
if (_isDragScrollingDown == true) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
final maxExtent =
|
|
|
|
_itemListMaxExtent ?? _scrollController.position.maxScrollExtent;
|
|
|
|
_log.fine("[_onEditModePointerMove] Begin scrolling down");
|
|
|
|
if (_scrollController.offset <
|
|
|
|
_scrollController.position.maxScrollExtent) {
|
|
|
|
_scrollController.animateTo(maxExtent,
|
|
|
|
duration: Duration(
|
|
|
|
milliseconds:
|
|
|
|
((maxExtent - _scrollController.offset) * 1.6).round()),
|
|
|
|
curve: Curves.linear);
|
|
|
|
_isDragScrollingDown = true;
|
|
|
|
}
|
|
|
|
} else if (event.position.dy <= 100) {
|
|
|
|
// near top of screen
|
|
|
|
if (_isDragScrollingDown == false) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_log.fine("[_onEditModePointerMove] Begin scrolling up");
|
|
|
|
if (_scrollController.offset > 0) {
|
|
|
|
_scrollController.animateTo(0,
|
|
|
|
duration: Duration(
|
|
|
|
milliseconds: (_scrollController.offset * 1.6).round()),
|
|
|
|
curve: Curves.linear);
|
|
|
|
_isDragScrollingDown = false;
|
|
|
|
}
|
|
|
|
} else if (_isDragScrollingDown != null) {
|
|
|
|
_log.fine("[_onEditModePointerMove] Stop scrolling");
|
|
|
|
_scrollController.jumpTo(_scrollController.offset);
|
|
|
|
_isDragScrollingDown = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void _onItemMoved(int fromIndex, int toIndex, bool isBefore) {
|
|
|
|
if (fromIndex == toIndex) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
final item = _sortedItems.removeAt(fromIndex);
|
|
|
|
final newIndex =
|
|
|
|
toIndex + (isBefore ? 0 : 1) + (fromIndex < toIndex ? -1 : 0);
|
|
|
|
_sortedItems.insert(newIndex, item);
|
2021-07-23 22:05:57 +02:00
|
|
|
_editAlbum = _editAlbum!.copyWith(
|
2021-07-08 10:57:20 +02:00
|
|
|
sortProvider: AlbumNullSortProvider(),
|
|
|
|
// save the current order
|
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: _sortedItems,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
setState(() {
|
|
|
|
_transformItems();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-07-09 12:07:37 +02:00
|
|
|
void _onEditAppBarAddTextPressed() {
|
2021-07-23 22:05:57 +02:00
|
|
|
showDialog<String>(
|
2021-07-09 12:07:37 +02:00
|
|
|
context: context,
|
|
|
|
builder: (context) => SimpleInputDialog(),
|
|
|
|
).then((value) {
|
|
|
|
if (value == null) {
|
|
|
|
return;
|
|
|
|
}
|
2021-07-23 22:05:57 +02:00
|
|
|
_editAlbum = _editAlbum!.copyWith(
|
2021-07-09 12:07:37 +02:00
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [
|
|
|
|
AlbumLabelItem(text: value),
|
|
|
|
..._sortedItems,
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
setState(() {
|
|
|
|
_transformItems();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void _onLabelItemEditPressed(AlbumLabelItem item, int index) {
|
2021-07-23 22:05:57 +02:00
|
|
|
showDialog<String>(
|
2021-07-09 12:07:37 +02:00
|
|
|
context: context,
|
|
|
|
builder: (context) => SimpleInputDialog(
|
|
|
|
initialText: item.text,
|
|
|
|
),
|
|
|
|
).then((value) {
|
|
|
|
if (value == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_sortedItems[index] = AlbumLabelItem(text: value);
|
2021-07-23 22:05:57 +02:00
|
|
|
_editAlbum = _editAlbum!.copyWith(
|
2021-07-09 12:07:37 +02:00
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: _sortedItems,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
setState(() {
|
|
|
|
_transformItems();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-08-13 22:18:35 +02:00
|
|
|
void _onAlbumUpdatedEvent(AlbumUpdatedEvent ev) {
|
|
|
|
if (ev.album.albumFile!.path == _album?.albumFile?.path) {
|
|
|
|
setState(() {
|
|
|
|
_album = ev.album;
|
|
|
|
initCover(widget.account, ev.album);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-10 06:28:12 +02:00
|
|
|
void _transformItems() {
|
2021-07-08 06:13:36 +02:00
|
|
|
if (_editAlbum != null) {
|
|
|
|
// edit mode
|
2021-07-23 22:05:57 +02:00
|
|
|
_sortedItems =
|
|
|
|
_editAlbum!.sortProvider.sort(_getAlbumItemsOf(_editAlbum!));
|
2021-07-08 06:13:36 +02:00
|
|
|
} else {
|
2021-07-23 22:05:57 +02:00
|
|
|
_sortedItems = _album!.sortProvider.sort(_getAlbumItemsOf(_album!));
|
2021-07-08 06:13:36 +02:00
|
|
|
}
|
2021-07-08 10:57:20 +02:00
|
|
|
_backingFiles = _sortedItems
|
2021-04-10 06:28:12 +02:00
|
|
|
.whereType<AlbumFileItem>()
|
|
|
|
.map((e) => e.file)
|
|
|
|
.where((element) => file_util.isSupportedFormat(element))
|
2021-07-07 20:40:43 +02:00
|
|
|
.toList();
|
2021-04-10 06:28:12 +02:00
|
|
|
|
2021-07-08 10:57:20 +02:00
|
|
|
final items = () sync* {
|
2021-07-09 11:00:55 +02:00
|
|
|
for (int i = 0; i < _sortedItems.length; ++i) {
|
|
|
|
final item = _sortedItems[i];
|
|
|
|
if (item is AlbumFileItem) {
|
|
|
|
final previewUrl = api_util.getFilePreviewUrl(
|
|
|
|
widget.account,
|
|
|
|
item.file,
|
|
|
|
width: thumbSize,
|
|
|
|
height: thumbSize,
|
2021-05-06 13:36:20 +02:00
|
|
|
);
|
2021-07-09 11:00:55 +02:00
|
|
|
if (file_util.isSupportedImageFormat(item.file)) {
|
|
|
|
yield _ImageListItem(
|
|
|
|
index: i,
|
|
|
|
file: item.file,
|
|
|
|
account: widget.account,
|
|
|
|
previewUrl: previewUrl,
|
|
|
|
onTap: () => _onItemTap(i),
|
|
|
|
onDropBefore: (dropItem) =>
|
|
|
|
_onItemMoved((dropItem as _ListItem).index, i, true),
|
|
|
|
onDropAfter: (dropItem) =>
|
|
|
|
_onItemMoved((dropItem as _ListItem).index, i, false),
|
|
|
|
onDragStarted: () {
|
|
|
|
_isDragging = true;
|
|
|
|
},
|
|
|
|
onDragEndedAny: () {
|
|
|
|
_isDragging = false;
|
|
|
|
},
|
|
|
|
);
|
|
|
|
} else if (file_util.isSupportedVideoFormat(item.file)) {
|
|
|
|
yield _VideoListItem(
|
|
|
|
index: i,
|
2021-07-10 17:06:04 +02:00
|
|
|
file: item.file,
|
2021-07-09 11:00:55 +02:00
|
|
|
account: widget.account,
|
|
|
|
previewUrl: previewUrl,
|
|
|
|
onTap: () => _onItemTap(i),
|
|
|
|
onDropBefore: (dropItem) =>
|
|
|
|
_onItemMoved((dropItem as _ListItem).index, i, true),
|
|
|
|
onDropAfter: (dropItem) =>
|
|
|
|
_onItemMoved((dropItem as _ListItem).index, i, false),
|
|
|
|
onDragStarted: () {
|
|
|
|
_isDragging = true;
|
|
|
|
},
|
|
|
|
onDragEndedAny: () {
|
|
|
|
_isDragging = false;
|
|
|
|
},
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
_log.shout(
|
|
|
|
"[_transformItems] Unsupported file format: ${item.file.contentType}");
|
|
|
|
}
|
2021-07-09 12:07:37 +02:00
|
|
|
} else if (item is AlbumLabelItem) {
|
|
|
|
if (isEditMode) {
|
|
|
|
yield _EditLabelListItem(
|
|
|
|
index: i,
|
|
|
|
text: item.text,
|
|
|
|
onEditPressed: () => _onLabelItemEditPressed(item, i),
|
|
|
|
onDropBefore: (dropItem) =>
|
|
|
|
_onItemMoved((dropItem as _ListItem).index, i, true),
|
|
|
|
onDropAfter: (dropItem) =>
|
|
|
|
_onItemMoved((dropItem as _ListItem).index, i, false),
|
|
|
|
onDragStarted: () {
|
|
|
|
_isDragging = true;
|
|
|
|
},
|
|
|
|
onDragEndedAny: () {
|
|
|
|
_isDragging = false;
|
|
|
|
},
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
yield _LabelListItem(
|
|
|
|
index: i,
|
|
|
|
text: item.text,
|
|
|
|
);
|
|
|
|
}
|
2021-05-06 13:36:20 +02:00
|
|
|
}
|
|
|
|
}
|
2021-07-07 20:51:34 +02:00
|
|
|
}()
|
|
|
|
.toList();
|
2021-07-08 10:57:20 +02:00
|
|
|
itemStreamListItems = items;
|
|
|
|
draggableItemList = items;
|
2021-04-10 06:28:12 +02:00
|
|
|
}
|
|
|
|
|
2021-07-17 16:35:26 +02:00
|
|
|
void _propagateResyncedAlbum(Album album) {
|
|
|
|
final propagateItems =
|
|
|
|
zip([_getAlbumItemsOf(album), _getAlbumItemsOf(widget.album)]).map((e) {
|
|
|
|
if (e[0] is AlbumFileItem) {
|
|
|
|
final item = e[0] as AlbumFileItem;
|
2021-07-22 08:16:56 +02:00
|
|
|
if (!item.file.isOwned(widget.account.username)) {
|
2021-07-17 16:35:26 +02:00
|
|
|
// don't propagate shared file not owned by this user, this is to
|
|
|
|
// prevent multiple user having different properties to keep
|
|
|
|
// overriding each others
|
|
|
|
_log.info(
|
|
|
|
"[_propagateResyncedAlbum] Skip shared file: ${item.file.path}");
|
|
|
|
return e[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return e[0];
|
|
|
|
}).toList();
|
|
|
|
final propagateAlbum = album.copyWith(
|
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: propagateItems,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
UpdateAlbum(AlbumRepo(AlbumCachedDataSource()))(
|
|
|
|
widget.account, propagateAlbum)
|
|
|
|
.catchError((e, stacktrace) {
|
|
|
|
_log.shout("[_propagateResyncedAlbum] Failed while updating album", e,
|
|
|
|
stacktrace);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-06-14 15:51:29 +02:00
|
|
|
bool _shouldPropagateResyncedAlbum(Album album) {
|
2021-06-24 18:26:56 +02:00
|
|
|
final origItems = _getAlbumItemsOf(widget.album);
|
|
|
|
final resyncItems = _getAlbumItemsOf(album);
|
|
|
|
if (origItems.length != resyncItems.length) {
|
2021-06-14 15:51:29 +02:00
|
|
|
_log.info(
|
2021-06-24 18:26:56 +02:00
|
|
|
"[_shouldPropagateResyncedAlbum] Item length differ: ${origItems.length}, ${resyncItems.length}");
|
2021-06-14 15:51:29 +02:00
|
|
|
return true;
|
|
|
|
}
|
2021-06-24 18:26:56 +02:00
|
|
|
for (final z in zip([origItems, resyncItems])) {
|
2021-06-14 15:51:29 +02:00
|
|
|
final a = z[0], b = z[1];
|
|
|
|
bool isEqual;
|
|
|
|
if (a is AlbumFileItem && b is AlbumFileItem) {
|
2021-07-22 08:16:56 +02:00
|
|
|
if (!a.file.isOwned(widget.account.username)) {
|
2021-07-17 16:35:26 +02:00
|
|
|
// ignore shared files
|
|
|
|
continue;
|
|
|
|
}
|
2021-06-14 15:51:29 +02:00
|
|
|
// faster compare
|
|
|
|
isEqual = a.equals(b, isDeep: false);
|
|
|
|
} else {
|
|
|
|
isEqual = a == b;
|
|
|
|
}
|
|
|
|
if (!isEqual) {
|
|
|
|
_log.info(
|
|
|
|
"[_shouldPropagateResyncedAlbum] Item differ:\nOriginal: ${z[0]}\nResynced: ${z[1]}");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_log.info("[_shouldPropagateResyncedAlbum] false");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-06-24 18:26:56 +02:00
|
|
|
static List<AlbumItem> _getAlbumItemsOf(Album a) =>
|
|
|
|
AlbumStaticProvider.of(a).items;
|
|
|
|
|
2021-07-23 22:05:57 +02:00
|
|
|
Album? _album;
|
2021-07-08 10:57:20 +02:00
|
|
|
var _sortedItems = <AlbumItem>[];
|
2021-04-10 06:28:12 +02:00
|
|
|
var _backingFiles = <File>[];
|
|
|
|
|
2021-07-08 10:57:20 +02:00
|
|
|
final _scrollController = ScrollController();
|
2021-07-23 22:05:57 +02:00
|
|
|
double? _itemListMaxExtent;
|
2021-07-08 10:57:20 +02:00
|
|
|
bool _isDragging = false;
|
|
|
|
// == null if not drag scrolling
|
2021-07-23 22:05:57 +02:00
|
|
|
bool? _isDragScrollingDown;
|
2021-07-02 13:55:52 +02:00
|
|
|
final _editFormKey = GlobalKey<FormState>();
|
2021-07-23 22:05:57 +02:00
|
|
|
Album? _editAlbum;
|
2021-07-02 13:55:52 +02:00
|
|
|
|
2021-08-13 22:18:35 +02:00
|
|
|
late AppEventListener<AlbumUpdatedEvent> _albumUpdatedListener;
|
|
|
|
|
2021-07-31 19:16:14 +02:00
|
|
|
static final _log = Logger("widget.album_browser._AlbumBrowserState");
|
2021-04-10 06:28:12 +02:00
|
|
|
}
|
|
|
|
|
2021-07-08 10:57:20 +02:00
|
|
|
abstract class _ListItem implements SelectableItem, DraggableItem {
|
2021-07-06 15:03:29 +02:00
|
|
|
_ListItem({
|
2021-07-23 22:05:57 +02:00
|
|
|
required this.index,
|
|
|
|
VoidCallback? onTap,
|
|
|
|
DragTargetAccept<DraggableItem>? onDropBefore,
|
|
|
|
DragTargetAccept<DraggableItem>? onDropAfter,
|
|
|
|
VoidCallback? onDragStarted,
|
|
|
|
VoidCallback? onDragEndedAny,
|
2021-07-08 10:57:20 +02:00
|
|
|
}) : _onTap = onTap,
|
|
|
|
_onDropBefore = onDropBefore,
|
|
|
|
_onDropAfter = onDropAfter,
|
|
|
|
_onDragStarted = onDragStarted,
|
|
|
|
_onDragEndedAny = onDragEndedAny;
|
2021-07-06 15:03:29 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
get onTap => _onTap;
|
|
|
|
|
|
|
|
@override
|
|
|
|
get isSelectable => true;
|
|
|
|
|
2021-07-08 10:57:20 +02:00
|
|
|
@override
|
|
|
|
get isDraggable => true;
|
|
|
|
|
|
|
|
@override
|
|
|
|
get onDropBefore => _onDropBefore;
|
|
|
|
|
|
|
|
@override
|
|
|
|
get onDropAfter => _onDropAfter;
|
|
|
|
|
|
|
|
@override
|
|
|
|
get onDragStarted => _onDragStarted;
|
|
|
|
|
|
|
|
@override
|
|
|
|
get onDragEndedAny => _onDragEndedAny;
|
|
|
|
|
2021-07-06 15:03:29 +02:00
|
|
|
@override
|
|
|
|
get staggeredTile => const StaggeredTile.count(1, 1);
|
|
|
|
|
2021-07-09 12:07:37 +02:00
|
|
|
@override
|
|
|
|
buildDragFeedbackWidget(BuildContext context) => null;
|
|
|
|
|
2021-07-08 10:57:20 +02:00
|
|
|
@override
|
|
|
|
toString() {
|
|
|
|
return "$runtimeType {"
|
|
|
|
"index: $index, "
|
|
|
|
"}";
|
|
|
|
}
|
|
|
|
|
|
|
|
final int index;
|
|
|
|
|
2021-07-23 22:05:57 +02:00
|
|
|
final VoidCallback? _onTap;
|
|
|
|
final DragTargetAccept<DraggableItem>? _onDropBefore;
|
|
|
|
final DragTargetAccept<DraggableItem>? _onDropAfter;
|
|
|
|
final VoidCallback? _onDragStarted;
|
|
|
|
final VoidCallback? _onDragEndedAny;
|
2021-07-06 15:03:29 +02:00
|
|
|
}
|
|
|
|
|
2021-07-10 17:06:04 +02:00
|
|
|
abstract class _FileListItem extends _ListItem {
|
|
|
|
_FileListItem({
|
2021-07-23 22:05:57 +02:00
|
|
|
required int index,
|
|
|
|
required this.file,
|
|
|
|
VoidCallback? onTap,
|
|
|
|
DragTargetAccept<DraggableItem>? onDropBefore,
|
|
|
|
DragTargetAccept<DraggableItem>? onDropAfter,
|
|
|
|
VoidCallback? onDragStarted,
|
|
|
|
VoidCallback? onDragEndedAny,
|
2021-07-10 17:06:04 +02:00
|
|
|
}) : super(
|
|
|
|
index: index,
|
|
|
|
onTap: onTap,
|
|
|
|
onDropBefore: onDropBefore,
|
|
|
|
onDropAfter: onDropAfter,
|
|
|
|
onDragStarted: onDragStarted,
|
|
|
|
onDragEndedAny: onDragEndedAny,
|
|
|
|
);
|
|
|
|
|
|
|
|
final File file;
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ImageListItem extends _FileListItem {
|
|
|
|
_ImageListItem({
|
2021-07-23 22:05:57 +02:00
|
|
|
required int index,
|
|
|
|
required File file,
|
|
|
|
required this.account,
|
|
|
|
required this.previewUrl,
|
|
|
|
VoidCallback? onTap,
|
|
|
|
DragTargetAccept<DraggableItem>? onDropBefore,
|
|
|
|
DragTargetAccept<DraggableItem>? onDropAfter,
|
|
|
|
VoidCallback? onDragStarted,
|
|
|
|
VoidCallback? onDragEndedAny,
|
2021-07-08 10:57:20 +02:00
|
|
|
}) : super(
|
|
|
|
index: index,
|
2021-07-10 17:06:04 +02:00
|
|
|
file: file,
|
2021-07-08 10:57:20 +02:00
|
|
|
onTap: onTap,
|
|
|
|
onDropBefore: onDropBefore,
|
|
|
|
onDropAfter: onDropAfter,
|
|
|
|
onDragStarted: onDragStarted,
|
|
|
|
onDragEndedAny: onDragEndedAny,
|
|
|
|
);
|
2021-04-10 06:28:12 +02:00
|
|
|
|
2021-04-23 09:55:53 +02:00
|
|
|
@override
|
|
|
|
buildWidget(BuildContext context) {
|
2021-05-06 13:29:20 +02:00
|
|
|
return PhotoListImage(
|
|
|
|
account: account,
|
|
|
|
previewUrl: previewUrl,
|
2021-06-22 07:24:37 +02:00
|
|
|
isGif: file.contentType == "image/gif",
|
2021-04-23 09:55:53 +02:00
|
|
|
);
|
|
|
|
}
|
2021-04-10 06:28:12 +02:00
|
|
|
|
2021-04-23 09:55:53 +02:00
|
|
|
final Account account;
|
2021-04-10 06:28:12 +02:00
|
|
|
final String previewUrl;
|
|
|
|
}
|
2021-05-06 13:36:20 +02:00
|
|
|
|
2021-07-10 17:06:04 +02:00
|
|
|
class _VideoListItem extends _FileListItem {
|
2021-05-06 13:36:20 +02:00
|
|
|
_VideoListItem({
|
2021-07-23 22:05:57 +02:00
|
|
|
required int index,
|
|
|
|
required File file,
|
|
|
|
required this.account,
|
|
|
|
required this.previewUrl,
|
|
|
|
VoidCallback? onTap,
|
|
|
|
DragTargetAccept<DraggableItem>? onDropBefore,
|
|
|
|
DragTargetAccept<DraggableItem>? onDropAfter,
|
|
|
|
VoidCallback? onDragStarted,
|
|
|
|
VoidCallback? onDragEndedAny,
|
2021-07-08 10:57:20 +02:00
|
|
|
}) : super(
|
|
|
|
index: index,
|
2021-07-10 17:06:04 +02:00
|
|
|
file: file,
|
2021-07-08 10:57:20 +02:00
|
|
|
onTap: onTap,
|
|
|
|
onDropBefore: onDropBefore,
|
|
|
|
onDropAfter: onDropAfter,
|
|
|
|
onDragStarted: onDragStarted,
|
|
|
|
onDragEndedAny: onDragEndedAny,
|
|
|
|
);
|
2021-05-06 13:36:20 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
buildWidget(BuildContext context) {
|
|
|
|
return PhotoListVideo(
|
|
|
|
account: account,
|
|
|
|
previewUrl: previewUrl,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
final Account account;
|
|
|
|
final String previewUrl;
|
|
|
|
}
|
2021-07-09 12:07:37 +02:00
|
|
|
|
|
|
|
class _LabelListItem extends _ListItem {
|
|
|
|
_LabelListItem({
|
2021-07-23 22:05:57 +02:00
|
|
|
required int index,
|
|
|
|
required this.text,
|
|
|
|
DragTargetAccept<DraggableItem>? onDropBefore,
|
|
|
|
DragTargetAccept<DraggableItem>? onDropAfter,
|
|
|
|
VoidCallback? onDragStarted,
|
|
|
|
VoidCallback? onDragEndedAny,
|
2021-07-09 12:07:37 +02:00
|
|
|
}) : super(
|
|
|
|
index: index,
|
|
|
|
onDropBefore: onDropBefore,
|
|
|
|
onDropAfter: onDropAfter,
|
|
|
|
onDragStarted: onDragStarted,
|
|
|
|
onDragEndedAny: onDragEndedAny,
|
|
|
|
);
|
|
|
|
|
|
|
|
@override
|
|
|
|
get staggeredTile => const StaggeredTile.extent(99, 56);
|
|
|
|
|
|
|
|
@override
|
|
|
|
buildWidget(BuildContext context) {
|
2021-08-10 12:10:22 +02:00
|
|
|
return PhotoListLabel(
|
|
|
|
text: text,
|
2021-07-09 12:07:37 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
final String text;
|
|
|
|
}
|
|
|
|
|
|
|
|
class _EditLabelListItem extends _LabelListItem {
|
|
|
|
_EditLabelListItem({
|
2021-07-23 22:05:57 +02:00
|
|
|
required int index,
|
|
|
|
required String text,
|
|
|
|
required this.onEditPressed,
|
|
|
|
DragTargetAccept<DraggableItem>? onDropBefore,
|
|
|
|
DragTargetAccept<DraggableItem>? onDropAfter,
|
|
|
|
VoidCallback? onDragStarted,
|
|
|
|
VoidCallback? onDragEndedAny,
|
2021-07-09 12:07:37 +02:00
|
|
|
}) : super(
|
|
|
|
index: index,
|
|
|
|
text: text,
|
|
|
|
onDropBefore: onDropBefore,
|
|
|
|
onDropAfter: onDropAfter,
|
|
|
|
onDragStarted: onDragStarted,
|
|
|
|
onDragEndedAny: onDragEndedAny,
|
|
|
|
);
|
|
|
|
|
|
|
|
@override
|
|
|
|
buildWidget(BuildContext context) {
|
2021-08-10 12:10:22 +02:00
|
|
|
return PhotoListLabelEdit(
|
|
|
|
text: text,
|
|
|
|
onEditPressed: onEditPressed,
|
2021-07-09 12:07:37 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
buildDragFeedbackWidget(BuildContext context) {
|
|
|
|
return super.buildWidget(context);
|
|
|
|
}
|
|
|
|
|
2021-07-23 22:05:57 +02:00
|
|
|
final VoidCallback? onEditPressed;
|
2021-07-09 12:07:37 +02:00
|
|
|
}
|