Skip to content

Commit

Permalink
fix: board popover rebuilds
Browse files Browse the repository at this point in the history
  • Loading branch information
squidrye committed Nov 15, 2023
1 parent 6c7e917 commit 057e6fe
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class HomeStack extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocBuilder<PanesBloc, PanesState>(
buildWhen: (previous, current) =>
previous.count != current.count ||
previous.root != current.root ||
previous.allowPaneDrag != current.allowPaneDrag ||
previous.firstLeafNode != current.firstLeafNode,
builder: (context, state) {
return BlocBuilder<HomeSettingBloc, HomeSettingState>(
builder: (context, homeState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/workspace/application/favorite/favorite_bloc.dart';
import 'package:appflowy/workspace/application/panes/panes_bloc/panes_bloc.dart';
import 'package:appflowy/workspace/application/sidebar/folder/folder_bloc.dart';
import 'package:appflowy/workspace/application/view/view_bloc.dart';
import 'package:appflowy/workspace/application/view/prelude.dart';
import 'package:appflowy/workspace/application/view/view_ext.dart';
import 'package:appflowy/workspace/presentation/home/menu/menu_shared_state.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ class _DraggablePaneItemState extends State<DraggablePaneItem> {
data: widget.pane,
enableAutoScroll: false,
feedback: Material(
child: IntrinsicWidth(
child: Opacity(
opacity: 0.5,
child: widget.feedback?.call(context) ?? widget.child,
),
child: Opacity(
opacity: 0.5,
child: widget.feedback?.call(context) ?? widget.child,
),
),
child: widget.child,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/workspace/application/panes/panes.dart';
import 'package:appflowy/workspace/application/panes/panes_bloc/panes_bloc.dart';
import 'package:appflowy/workspace/application/tabs/tabs_controller.dart';
import 'package:appflowy/workspace/presentation/home/home_draggables.dart';
import 'package:appflowy/workspace/presentation/home/home_layout.dart';
Expand Down Expand Up @@ -178,14 +176,6 @@ class _FlowyPaneState extends State<FlowyPane> {
pageController.dispose();
super.dispose();
}

@override
void didChangeDependencies() {
if (widget.node != getIt<PanesBloc>().state.activePane) {
FocusScope.of(widget.paneContext).unfocus();
}
super.didChangeDependencies();
}
}

class _StickyHeaderDelegate extends SliverPersistentHeaderDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:appflowy/workspace/presentation/home/home_stack.dart';
import 'package:appflowy/workspace/presentation/home/panes/panes_layout.dart';
import 'package:flowy_infra_ui/style_widget/extension.dart';
import 'package:flowy_infra_ui/style_widget/hover.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

Expand All @@ -31,12 +32,21 @@ class FlowyPaneGroup extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (node.children.isEmpty) {
return Listener(
final activePaneGestureRecognizerFactory =
GestureRecognizerFactoryWithHandlers<AllowMultipleTap>(
() => AllowMultipleTap(),
(AllowMultipleTap instance) {
instance.onTap = () =>
context.read<PanesBloc>().add(SetActivePane(activePane: node));
},
);
return RawGestureDetector(
behavior: HitTestBehavior.translucent,
onPointerDown: (_) =>
context.read<PanesBloc>().add(SetActivePane(activePane: node)),
gestures: {
AllowMultipleTap: activePaneGestureRecognizerFactory,
},
child: FlowyPane(
key: ValueKey(node.tabsController.tabId),
key: ValueKey(node.paneId + node.tabsController.tabId),
node: node,
allowPaneDrag: allowPaneDrag,
delegate: delegate,
Expand All @@ -48,7 +58,7 @@ class FlowyPaneGroup extends StatelessWidget {
}

return BlocProvider(
key: ValueKey(node.paneId),
key: ValueKey(node.paneId + node.tabsController.tabId),
create: (context) => PaneNodeCubit(
node.children.length,
node.axis == Axis.horizontal
Expand Down Expand Up @@ -159,3 +169,8 @@ class FlowyPaneGroup extends StatelessWidget {
);
}
}

class AllowMultipleTap extends TapGestureRecognizer {
@override
void rejectGesture(int pointer) => acceptGesture(pointer);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:appflowy/plugins/document/presentation/editor_plugins/base/emoji_picker_button.dart';
import 'package:appflowy/startup/tasks/app_window_size_manager.dart';
import 'package:appflowy/workspace/application/tabs/tabs_bloc.dart';
import 'package:appflowy/workspace/application/panes/panes_bloc/panes_bloc.dart';
import 'package:appflowy/workspace/application/view/view_ext.dart';
import 'package:appflowy/workspace/application/view/view_listener.dart';
import 'package:appflowy/workspace/application/view/view_service.dart';
Expand Down Expand Up @@ -210,7 +210,9 @@ class _ViewTitleState extends State<_ViewTitle> {
return FlowyButton(
useIntrinsicWidth: true,
onTap: () {
context.read<TabsBloc>().openPlugin(widget.view);
context
.read<PanesBloc>()
.add(OpenPluginInActivePane(plugin: widget.view.plugin()));
},
text: child,
);
Expand Down

0 comments on commit 057e6fe

Please sign in to comment.