mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-03-25 00:14:42 +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.g.dart';
|
||||||
part 'collection_browser/app_bar.dart';
|
part 'collection_browser/app_bar.dart';
|
||||||
part 'collection_browser/bloc.dart';
|
part 'collection_browser/bloc.dart';
|
||||||
|
part 'collection_browser/item_view.dart';
|
||||||
part 'collection_browser/state_event.dart';
|
part 'collection_browser/state_event.dart';
|
||||||
part 'collection_browser/type.dart';
|
part 'collection_browser/type.dart';
|
||||||
part 'collection_browser/view.dart';
|
part 'collection_browser/view.dart';
|
||||||
|
|
|
@ -497,22 +497,14 @@ class _Bloc extends Bloc<_Event, _State>
|
||||||
"[_transformItems] Unsupported file format: ${item.file.fdMime}");
|
"[_transformItems] Unsupported file format: ${item.file.fdMime}");
|
||||||
}
|
}
|
||||||
} else if (item is CollectionLabelItem) {
|
} else if (item is CollectionLabelItem) {
|
||||||
if (state.isEditMode) {
|
transformed.add(_LabelItem(
|
||||||
transformed.add(_EditLabelListItem(
|
original: item,
|
||||||
original: item,
|
id: item.id,
|
||||||
id: item.id,
|
text: item.text,
|
||||||
text: item.text,
|
onEditPressed: () {
|
||||||
onEditPressed: () {
|
// TODO
|
||||||
// TODO
|
},
|
||||||
},
|
));
|
||||||
));
|
|
||||||
} else {
|
|
||||||
transformed.add(_LabelItem(
|
|
||||||
original: item,
|
|
||||||
id: item.id,
|
|
||||||
text: item.text,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _TransformResult(
|
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 super.original,
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.text,
|
required this.text,
|
||||||
|
required this.onEditPressed,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get isDraggable => true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) =>
|
bool operator ==(Object other) =>
|
||||||
identical(this, other) || (other is _LabelItem && id == other.id);
|
identical(this, other) || (other is _LabelItem && id == other.id);
|
||||||
|
@ -115,39 +119,24 @@ class _LabelItem extends _ActualItem {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget buildWidget(BuildContext context) {
|
Widget buildWidget(BuildContext context) {
|
||||||
return PhotoListLabel(
|
return _BlocSelector(
|
||||||
text: text,
|
selector: (state) => state.isEditMode,
|
||||||
);
|
builder: (context, isEditMode) => isEditMode
|
||||||
}
|
? _EditLabelView(
|
||||||
|
text: text,
|
||||||
final Object id;
|
onEditPressed: onEditPressed,
|
||||||
final String text;
|
)
|
||||||
}
|
: _LabelView(text: 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,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget? buildDragFeedbackWidget(BuildContext context) {
|
Widget? buildDragFeedbackWidget(BuildContext context) {
|
||||||
return super.buildWidget(context);
|
return _LabelView(text: text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Object id;
|
||||||
|
final String text;
|
||||||
final VoidCallback? onEditPressed;
|
final VoidCallback? onEditPressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue