HtmlPostMediumBloc constructor
HtmlPostMediumBloc(
- String appId
Implementation
HtmlPostMediumBloc(String appId)
: super(appId, postRepository(appId: appId)!, null) {
on<HtmlMediaMoveEvent<PostModel, MemberMediumContainerModel>>(
(event, emit) async {
var theState = state as ExtEditorBaseInitialised;
var items = theState.model.htmlMedia!;
var newListedItems = copyOf(items);
var index = items.indexOf(event.item);
if (index != -1) {
if (event.isUp) {
if (index > 0) {
var old = newListedItems[index - 1];
newListedItems[index - 1] = newListedItems[index];
newListedItems[index] = old;
emit(ExtEditorBaseInitialised(
model: theState.model.copyWith(htmlMedia: newListedItems),
currentEdit: theState.currentEdit));
}
} else {
if (index < newListedItems.length - 1) {
var old = newListedItems[index + 1];
newListedItems[index + 1] = newListedItems[index];
newListedItems[index] = old;
emit(ExtEditorBaseInitialised(
model: theState.model.copyWith(htmlMedia: newListedItems),
currentEdit: theState.currentEdit));
}
}
}
});
}