AppFlowy/frontend/appflowy_flutter/lib/plugins/util.dart
Nathan.fooo 5facb61e23
refactor: crates (#4258)
* chore: rename flowy-folder2 to flowy-folder

* chore: rename flowy-document2 to flowy-document

* chore: fix test

* chore: move lib-infra crate

* chore: remove shared-lib

* chore: fix clippy
2023-12-31 07:29:40 +08:00

37 lines
1015 B
Dart

import 'package:appflowy/startup/plugin/plugin.dart';
import 'package:appflowy/workspace/application/view/view_listener.dart';
import 'package:dartz/dartz.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:flutter/material.dart';
class ViewPluginNotifier extends PluginNotifier<Option<DeletedViewPB>> {
final ViewListener? _viewListener;
ViewPB view;
@override
final ValueNotifier<Option<DeletedViewPB>> isDeleted = ValueNotifier(none());
ViewPluginNotifier({
required this.view,
}) : _viewListener = ViewListener(viewId: view.id) {
_viewListener?.start(
onViewUpdated: (updatedView) {
view = updatedView;
},
onViewMoveToTrash: (result) {
result.fold(
(deletedView) => isDeleted.value = some(deletedView),
(err) => Log.error(err),
);
},
);
}
@override
void dispose() {
isDeleted.dispose();
_viewListener?.stop();
}
}