mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-11-16 10:27:40 +00:00
fix: reorder view and field animation
This commit is contained in:
parent
0285b286a6
commit
371c52022b
@ -27,12 +27,24 @@ class GridHeaderBloc extends Bloc<GridHeaderEvent, GridHeaderState> {
|
|||||||
emit(state.copyWith(fields: value.fields));
|
emit(state.copyWith(fields: value.fields));
|
||||||
},
|
},
|
||||||
moveField: (_MoveField value) async {
|
moveField: (_MoveField value) async {
|
||||||
final result = await _fieldService.moveField(value.field.id, value.fromIndex, value.toIndex);
|
await _moveField(value, emit);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _moveField(_MoveField value, Emitter<GridHeaderState> emit) async {
|
||||||
|
final fields = List<Field>.from(state.fields);
|
||||||
|
fields.insert(value.toIndex, fields.removeAt(value.fromIndex));
|
||||||
|
emit(state.copyWith(fields: fields));
|
||||||
|
|
||||||
|
final result = await _fieldService.moveField(
|
||||||
|
value.field.id,
|
||||||
|
value.fromIndex,
|
||||||
|
value.toIndex,
|
||||||
|
);
|
||||||
result.fold((l) {}, (err) => Log.error(err));
|
result.fold((l) {}, (err) => Log.error(err));
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _startListening() async {
|
Future<void> _startListening() async {
|
||||||
|
|||||||
@ -32,7 +32,7 @@ class ViewSectionBloc extends Bloc<ViewSectionEvent, ViewSectionState> {
|
|||||||
emit(state.copyWith(views: value.views));
|
emit(state.copyWith(views: value.views));
|
||||||
},
|
},
|
||||||
moveView: (_MoveView value) async {
|
moveView: (_MoveView value) async {
|
||||||
await _moveView(value);
|
_moveView(value, emit);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -59,9 +59,13 @@ class ViewSectionBloc extends Bloc<ViewSectionEvent, ViewSectionState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _moveView(_MoveView value) async {
|
Future<void> _moveView(_MoveView value, Emitter<ViewSectionState> emit) async {
|
||||||
if (value.fromIndex < state.views.length) {
|
if (value.fromIndex < state.views.length) {
|
||||||
final viewId = state.views[value.fromIndex].id;
|
final viewId = state.views[value.fromIndex].id;
|
||||||
|
final views = List<View>.from(state.views);
|
||||||
|
views.insert(value.toIndex, views.removeAt(value.fromIndex));
|
||||||
|
emit(state.copyWith(views: views));
|
||||||
|
|
||||||
final result = await _appService.moveView(
|
final result = await _appService.moveView(
|
||||||
viewId: viewId,
|
viewId: viewId,
|
||||||
fromIndex: value.fromIndex,
|
fromIndex: value.fromIndex,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user