AppFlowy/frontend/app_flowy/lib/plugins/util.dart
Nathan.fooo 37f269b08b
Chore/rename flowy sdk (#1679)
* chore: run flutter create on flowy_sdk

* chore: rename flowy-sdk to flowy-core

* chore: rename flowy_sdk to appflowy_backend

* chore: fix windows build

* chore: replace bloctest with test

Co-authored-by: nathan <nathan@appflowy.io>
Co-authored-by: vedon <vedon.fu@gmail.com>
2023-01-08 12:10:53 +08:00

44 lines
1.2 KiB
Dart

import 'package:app_flowy/startup/plugin/plugin.dart';
import 'package:app_flowy/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());
@override
final ValueNotifier<int> isDisplayChanged = ValueNotifier(0);
ViewPluginNotifier({
required this.view,
}) : _viewListener = ViewListener(view: view) {
_viewListener?.start(onViewUpdated: (result) {
result.fold(
(updatedView) {
view = updatedView;
isDisplayChanged.value = updatedView.hashCode;
},
(err) => Log.error(err),
);
}, onViewMoveToTrash: (result) {
result.fold(
(deletedView) => isDeleted.value = some(deletedView),
(err) => Log.error(err),
);
});
}
@override
void dispose() {
isDeleted.dispose();
isDisplayChanged.dispose();
_viewListener?.stop();
}
}