Skip to content

Commit

Permalink
Merge branch 'feature/refactor' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
bosskmk committed Dec 8, 2022
2 parents ca7b6d3 + 0ceb0a6 commit c7df807
Show file tree
Hide file tree
Showing 18 changed files with 726 additions and 324 deletions.
10 changes: 5 additions & 5 deletions lib/src/manager/pluto_change_notifier_filter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ abstract class PlutoChangeNotifierFilterResolver {
stateManager.setShowColumnFooter.hashCode: 'setShowColumnFooter',
stateManager.setShowColumnFilter.hashCode: 'setShowColumnFilter',
stateManager.setShowLoading.hashCode: 'setShowLoading',
stateManager.performLayoutOnPostFrame.hashCode:
'performLayoutOnPostFrame',
stateManager.notifyChangedShowFrozenColumn.hashCode:
'notifyChangedShowFrozenColumn',

/// pagination_state
stateManager.setPageSize.hashCode: 'setPageSize',
Expand Down Expand Up @@ -197,7 +197,7 @@ class PlutoNotifierFilterResolverDefault
stateManager.removeColumns.hashCode,
stateManager.moveColumn.hashCode,
stateManager.hideColumn.hashCode,
stateManager.performLayoutOnPostFrame.hashCode,
stateManager.notifyChangedShowFrozenColumn.hashCode,
};
}

Expand All @@ -210,7 +210,7 @@ class PlutoNotifierFilterResolverDefault
stateManager.hideColumn.hashCode,
stateManager.setShowColumnGroups.hashCode,
stateManager.removeColumnsInColumnGroup.hashCode,
stateManager.performLayoutOnPostFrame.hashCode,
stateManager.notifyChangedShowFrozenColumn.hashCode,
};
}

Expand All @@ -237,7 +237,7 @@ class PlutoNotifierFilterResolverDefault
stateManager.moveRowsByIndex.hashCode,
stateManager.setRowGroup.hashCode,
stateManager.toggleExpandedRowGroup.hashCode,
stateManager.performLayoutOnPostFrame.hashCode,
stateManager.notifyChangedShowFrozenColumn.hashCode,
stateManager.setPage.hashCode,
stateManager.setPageSize.hashCode,
};
Expand Down
66 changes: 47 additions & 19 deletions lib/src/manager/state/layout_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ abstract class ILayoutState {

void notifyResizingListeners();

void setTextDirection(TextDirection textDirection);
void notifyChangedShowFrozenColumn();

void performLayoutOnPostFrame();
void setTextDirection(TextDirection textDirection);

@visibleForTesting
void setGridGlobalOffset(Offset offset);
Expand Down Expand Up @@ -396,22 +396,22 @@ mixin LayoutState implements IPlutoGridState {

@override
void setLayout(BoxConstraints size) {
final showFrozenColumn = shouldShowFrozenColumns(size.maxWidth);
final bool changedShowFrozenColumn = showFrozenColumn != showFrozenColumn;
final bool changedMaxWidth = maxWidth != size.maxWidth;
final firstLayout = maxWidth == null;
final changedSize = _updateSize(size, firstLayout);
final changedShowFrozen = _updateShowFrozenColumn(
size: size,
firstLayout: firstLayout,
changedSize: changedSize,
);
final bool updateVisibility =
changedShowFrozen || firstLayout || changedSize;
final bool notifyResizing = !firstLayout && changedSize;

_state._maxWidth = size.maxWidth;
_state._maxHeight = size.maxHeight;
_state._showFrozenColumn = showFrozenColumn;
_state._gridGlobalOffset = null;
if (updateVisibility) updateVisibilityLayout();

if (changedShowFrozenColumn || changedMaxWidth) {
updateVisibilityLayout();
if (notifyResizing) notifyResizingListeners();

WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
notifyResizingListeners();
});
}
if (changedShowFrozen) notifyChangedShowFrozenColumn();

if (enableColumnsAutoSize && !activatedColumnsAutoSize) {
activateColumnsAutoSize();
Expand Down Expand Up @@ -498,18 +498,46 @@ mixin LayoutState implements IPlutoGridState {
}

@override
void setTextDirection(TextDirection textDirection) {
_state._textDirection = textDirection;
void notifyChangedShowFrozenColumn() {
notifyListeners(true, notifyChangedShowFrozenColumn.hashCode);
}

@override
void performLayoutOnPostFrame() {
notifyListenersOnPostFrame(true, performLayoutOnPostFrame.hashCode);
void setTextDirection(TextDirection textDirection) {
_state._textDirection = textDirection;
}

@override
@visibleForTesting
void setGridGlobalOffset(Offset offset) {
_state._gridGlobalOffset = offset;
}

bool _updateSize(BoxConstraints size, bool firstLayout) {
final changedMaxWidth = !firstLayout && maxWidth != size.maxWidth;

_state._maxWidth = size.maxWidth;
_state._maxHeight = size.maxHeight;

return changedMaxWidth;
}

bool _updateShowFrozenColumn({
required BoxConstraints size,
required bool firstLayout,
required bool changedSize,
}) {
final updateShowFrozen = firstLayout || changedSize;

final showFrozen = updateShowFrozen
? shouldShowFrozenColumns(size.maxWidth)
: _state._showFrozenColumn!;

final changedShowFrozen =
!firstLayout && _state._showFrozenColumn != showFrozen;

_state._showFrozenColumn = showFrozen;

return changedShowFrozen;
}
}
Loading

0 comments on commit c7df807

Please sign in to comment.