Skip to content

Commit

Permalink
fix: size controller gets disposed
Browse files Browse the repository at this point in the history
  • Loading branch information
squidrye committed Sep 19, 2023
1 parent 144ecd1 commit b82a4ae
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class PanesService {
return node.children.first.copyWith(
paneId: nanoid(),
parent: node.parent,
sizeController: PaneSizeController.intial(),
sizeController: PaneSizeController(flex: node.sizeController.flex),
tabs: Tabs(
currentIndex: node.children.first.tabs.currentIndex,
pageManagers: node.children.first.tabs.pageManagers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,6 @@ class Tabs extends ChangeNotifier {
}
}

void transferTab({required PageManager pm}) {
final selectExistingPlugin = _selectPluginIfOpen(pm.plugin.id);

if (!selectExistingPlugin) {
_pageManagers.add(PageManager()..setPlugin(pm.plugin));
}
currentIndex = _pageManagers.length - 1;
notifyListeners();
}

void move({
required PageManager from,
required PageManager to,
Expand Down Expand Up @@ -136,6 +126,7 @@ class Tabs extends ChangeNotifier {
}
}
}
setLatestOpenView();
notifyListeners();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:vector_math/vector_math.dart' as math;
import 'dart:math';
import 'package:flutter/material.dart';

//TODO(squidrye):refactor cross draggables and add edge cases
//TODO(squidrye):refactor cross draggable
enum FlowyDraggableHoverPosition { none, top, left, right, bottom, tab }

class DraggablePaneItem extends StatefulWidget {
Expand Down Expand Up @@ -51,12 +51,7 @@ class _DraggablePaneItemState extends State<DraggablePaneItem> {
},
child: DraggableItem<CrossDraggablesEntity>(
data: widget.pane,
onWillAccept: (data) =>
(data?.crossDraggableType == CrossDraggableType.pane &&
(data?.draggable as PaneNode).paneId ==
(widget.pane.draggable as PaneNode).paneId)
? false
: true,
onWillAccept: (data) => _shouldAccept(data!, position),
onMove: (data) {
final renderBox = widget.paneContext.findRenderObject() as RenderBox;
final offset = renderBox.globalToLocal(data.offset);
Expand Down Expand Up @@ -227,7 +222,7 @@ class _DraggablePaneItemState extends State<DraggablePaneItem> {
fromTab.tabs.closeView(fromTab.pageManager.plugin.id);
(to.draggable as PaneNode)
.tabs
.transferTab(pm: fromTab.pageManager);
.openView(fromTab.pageManager.plugin);
return;
}
default:
Expand Down

0 comments on commit b82a4ae

Please sign in to comment.