2023-02-26 08:27:17 +00:00
|
|
|
import 'package:appflowy/startup/plugin/plugin.dart';
|
|
|
|
import 'package:appflowy/workspace/application/view/view_listener.dart';
|
2023-01-08 04:10:53 +00:00
|
|
|
import 'package:appflowy_backend/log.dart';
|
2023-12-30 23:29:40 +00:00
|
|
|
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
2022-09-22 05:08:48 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2024-02-24 13:54:10 +00:00
|
|
|
class ViewPluginNotifier extends PluginNotifier<DeletedViewPB?> {
|
2022-09-22 05:08:48 +00:00
|
|
|
ViewPluginNotifier({
|
|
|
|
required this.view,
|
2023-06-14 14:16:33 +00:00
|
|
|
}) : _viewListener = ViewListener(viewId: view.id) {
|
2023-06-20 15:48:34 +00:00
|
|
|
_viewListener?.start(
|
2024-01-25 15:37:36 +00:00
|
|
|
onViewUpdated: (updatedView) => view = updatedView,
|
|
|
|
onViewMoveToTrash: (result) => result.fold(
|
2024-02-24 13:54:10 +00:00
|
|
|
(deletedView) => isDeleted.value = deletedView,
|
2024-01-25 15:37:36 +00:00
|
|
|
(err) => Log.error(err),
|
|
|
|
),
|
2023-06-20 15:48:34 +00:00
|
|
|
);
|
2022-09-22 05:08:48 +00:00
|
|
|
}
|
|
|
|
|
2024-01-25 15:37:36 +00:00
|
|
|
ViewPB view;
|
|
|
|
final ViewListener? _viewListener;
|
|
|
|
|
|
|
|
@override
|
2024-02-24 13:54:10 +00:00
|
|
|
final ValueNotifier<DeletedViewPB?> isDeleted = ValueNotifier(null);
|
2024-01-25 15:37:36 +00:00
|
|
|
|
2022-09-22 05:08:48 +00:00
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
isDeleted.dispose();
|
|
|
|
_viewListener?.stop();
|
|
|
|
}
|
|
|
|
}
|