mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 08:46:18 +01:00
Fix edit label view not activating in album
This commit is contained in:
parent
94d042dfa0
commit
3a1f6d64cf
4 changed files with 56 additions and 42 deletions
|
@ -68,6 +68,7 @@ import 'package:to_string/to_string.dart';
|
|||
part 'collection_browser.g.dart';
|
||||
part 'collection_browser/app_bar.dart';
|
||||
part 'collection_browser/bloc.dart';
|
||||
part 'collection_browser/item_view.dart';
|
||||
part 'collection_browser/state_event.dart';
|
||||
part 'collection_browser/type.dart';
|
||||
part 'collection_browser/view.dart';
|
||||
|
|
|
@ -497,22 +497,14 @@ class _Bloc extends Bloc<_Event, _State>
|
|||
"[_transformItems] Unsupported file format: ${item.file.fdMime}");
|
||||
}
|
||||
} else if (item is CollectionLabelItem) {
|
||||
if (state.isEditMode) {
|
||||
transformed.add(_EditLabelListItem(
|
||||
original: item,
|
||||
id: item.id,
|
||||
text: item.text,
|
||||
onEditPressed: () {
|
||||
// TODO
|
||||
},
|
||||
));
|
||||
} else {
|
||||
transformed.add(_LabelItem(
|
||||
original: item,
|
||||
id: item.id,
|
||||
text: item.text,
|
||||
));
|
||||
}
|
||||
transformed.add(_LabelItem(
|
||||
original: item,
|
||||
id: item.id,
|
||||
text: item.text,
|
||||
onEditPressed: () {
|
||||
// TODO
|
||||
},
|
||||
));
|
||||
}
|
||||
}
|
||||
return _TransformResult(
|
||||
|
|
32
app/lib/widget/collection_browser/item_view.dart
Normal file
32
app/lib/widget/collection_browser/item_view.dart
Normal file
|
@ -0,0 +1,32 @@
|
|||
part of '../collection_browser.dart';
|
||||
|
||||
class _LabelView extends StatelessWidget {
|
||||
const _LabelView({
|
||||
required this.text,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PhotoListLabel(text: text);
|
||||
}
|
||||
|
||||
final String text;
|
||||
}
|
||||
|
||||
class _EditLabelView extends StatelessWidget {
|
||||
const _EditLabelView({
|
||||
required this.text,
|
||||
required this.onEditPressed,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PhotoListLabelEdit(
|
||||
text: text,
|
||||
onEditPressed: onEditPressed,
|
||||
);
|
||||
}
|
||||
|
||||
final String text;
|
||||
final VoidCallback? onEditPressed;
|
||||
}
|
|
@ -101,8 +101,12 @@ class _LabelItem extends _ActualItem {
|
|||
required super.original,
|
||||
required this.id,
|
||||
required this.text,
|
||||
required this.onEditPressed,
|
||||
});
|
||||
|
||||
@override
|
||||
bool get isDraggable => true;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) || (other is _LabelItem && id == other.id);
|
||||
|
@ -115,39 +119,24 @@ class _LabelItem extends _ActualItem {
|
|||
|
||||
@override
|
||||
Widget buildWidget(BuildContext context) {
|
||||
return PhotoListLabel(
|
||||
text: text,
|
||||
);
|
||||
}
|
||||
|
||||
final Object id;
|
||||
final String text;
|
||||
}
|
||||
|
||||
class _EditLabelListItem extends _LabelItem {
|
||||
const _EditLabelListItem({
|
||||
required super.original,
|
||||
required super.id,
|
||||
required super.text,
|
||||
required this.onEditPressed,
|
||||
});
|
||||
|
||||
@override
|
||||
bool get isDraggable => true;
|
||||
|
||||
@override
|
||||
Widget buildWidget(BuildContext context) {
|
||||
return PhotoListLabelEdit(
|
||||
text: text,
|
||||
onEditPressed: onEditPressed,
|
||||
return _BlocSelector(
|
||||
selector: (state) => state.isEditMode,
|
||||
builder: (context, isEditMode) => isEditMode
|
||||
? _EditLabelView(
|
||||
text: text,
|
||||
onEditPressed: onEditPressed,
|
||||
)
|
||||
: _LabelView(text: text),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget? buildDragFeedbackWidget(BuildContext context) {
|
||||
return super.buildWidget(context);
|
||||
return _LabelView(text: text);
|
||||
}
|
||||
|
||||
final Object id;
|
||||
final String text;
|
||||
final VoidCallback? onEditPressed;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue