Skip to content

Commit

Permalink
Merge branch 'chan150-master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
bosskmk committed Mar 1, 2024
2 parents 3b6f423 + 73898d4 commit 5049e4d
Show file tree
Hide file tree
Showing 35 changed files with 615 additions and 183 deletions.
4 changes: 2 additions & 2 deletions lib/src/helper/filter_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -504,11 +504,11 @@ class PlutoGridFilterPopupHeader extends StatelessWidget {
final SetFilterPopupHandler? handleAddNewFilter;

const PlutoGridFilterPopupHeader({
Key? key,
super.key,
this.stateManager,
this.configuration,
this.handleAddNewFilter,
}) : super(key: key);
});

void handleAddButton() {
handleAddNewFilter!(stateManager);
Expand Down
13 changes: 7 additions & 6 deletions lib/src/helper/pluto_key_manager_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/services.dart';

class PlutoKeyManagerEvent {
FocusNode focusNode;
RawKeyEvent event;
KeyEvent event;

PlutoKeyManagerEvent({
required this.focusNode,
Expand All @@ -12,9 +12,9 @@ class PlutoKeyManagerEvent {

bool get needsThrottle => isMoving || isTab || isPageUp || isPageDown;

bool get isKeyDownEvent => event.runtimeType == RawKeyDownEvent;
bool get isKeyDownEvent => event.runtimeType == KeyDownEvent;

bool get isKeyUpEvent => event.runtimeType == RawKeyUpEvent;
bool get isKeyUpEvent => event.runtimeType == KeyUpEvent;

bool get isMoving => isHorizontal || isVertical;

Expand Down Expand Up @@ -94,15 +94,16 @@ class PlutoKeyManagerEvent {
}

bool get isShiftPressed {
return event.isShiftPressed;
return HardwareKeyboard.instance.isShiftPressed;
}

bool get isCtrlPressed {
return event.isMetaPressed || event.isControlPressed;
return HardwareKeyboard.instance.isMetaPressed ||
HardwareKeyboard.instance.isControlPressed;
}

bool get isAltPressed {
return event.isAltPressed;
return HardwareKeyboard.instance.isAltPressed;
}

bool get isModifierPressed {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/manager/pluto_grid_key_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class PlutoGridKeyManager {
if (stateManager.configuration.shortcut.handle(
keyEvent: keyEvent,
stateManager: stateManager,
state: RawKeyboard.instance,
state: HardwareKeyboard.instance,
)) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/manager/pluto_grid_state_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ class PlutoGridStateChangeNotifier extends PlutoChangeNotifier
/// stateManager.refRows.addAll(FilteredList(initialList: value));
/// stateManager.notifyListeners();
/// });
/// {@endtemplate}
/// ```
/// {@endtemplate}
class PlutoGridStateManager extends PlutoGridStateChangeNotifier {
PlutoGridStateManager({
required super.columns,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/manager/shortcut/pluto_grid_shortcut.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class PlutoGridShortcut {
bool handle({
required PlutoKeyManagerEvent keyEvent,
required PlutoGridStateManager stateManager,
required RawKeyboard state,
required HardwareKeyboard state,
}) {
for (final action in actions.entries) {
if (action.key.accepts(keyEvent.event, state)) {
Expand Down
6 changes: 3 additions & 3 deletions lib/src/manager/shortcut/pluto_grid_shortcut_action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class PlutoGridActionDefaultTab extends PlutoGridShortcutAction {

final saveIsEditing = stateManager.isEditing;

keyEvent.event.isShiftPressed
HardwareKeyboard.instance.isShiftPressed
? _moveCellPrevious(stateManager)
: _moveCellNext(stateManager);

Expand Down Expand Up @@ -408,7 +408,7 @@ class PlutoGridActionDefaultEnterKey extends PlutoGridShortcutAction {
}

if (enterKeyAction.isEditingAndMoveDown) {
if (keyEvent.event.isShiftPressed) {
if (HardwareKeyboard.instance.isShiftPressed) {
stateManager.moveCurrentCell(
PlutoMoveDirection.up,
notify: false,
Expand All @@ -420,7 +420,7 @@ class PlutoGridActionDefaultEnterKey extends PlutoGridShortcutAction {
);
}
} else if (enterKeyAction.isEditingAndMoveRight) {
if (keyEvent.event.isShiftPressed) {
if (HardwareKeyboard.instance.isShiftPressed) {
stateManager.moveCurrentCell(
PlutoMoveDirection.left,
force: true,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/manager/state/column_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,12 @@ mixin ColumnState implements IPlutoGridState {

@override
PlutoColumn? get currentColumn {
return currentCell == null ? null : currentCell!.column;
return currentCell?.column;
}

@override
String? get currentColumnField {
return currentCell == null ? null : currentCell!.column.field;
return currentCell?.column.field;
}

@override
Expand Down
4 changes: 1 addition & 3 deletions lib/src/plugin/pluto_lazy_pagination.dart
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,7 @@ class _PaginationWidgetState extends State<_PaginationWidget> {
? SystemMouseCursors.basic
: SystemMouseCursors.click,
),
..._pageNumbers
.map(_makeNumberButton)
.toList(growable: false),
..._pageNumbers.map(_makeNumberButton),
IconButton(
onPressed: _isLastPage ? null : _nextPage,
icon: const Icon(Icons.navigate_next),
Expand Down
4 changes: 1 addition & 3 deletions lib/src/plugin/pluto_pagination.dart
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,7 @@ class PlutoPaginationState extends _PlutoPaginationStateWithChange {
? SystemMouseCursors.basic
: SystemMouseCursors.click,
),
..._pageNumbers
.map(_makeNumberButton)
.toList(growable: false),
..._pageNumbers.map(_makeNumberButton),
IconButton(
onPressed: _isLastPage ? null : _nextPage,
icon: const Icon(Icons.navigate_next),
Expand Down
8 changes: 4 additions & 4 deletions lib/src/pluto_dual_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ class PlutoDualGrid extends StatefulWidget {
this.onSelected,
this.display,
this.divider = const PlutoDualGridDivider(),
Key? key,
}) : super(key: key);
super.key,
});

static const double dividerWidth = 10;

Expand Down Expand Up @@ -262,8 +262,8 @@ class PlutoDualGridDividerWidget extends StatefulWidget {
required this.indicatorColor,
required this.draggingColor,
required this.dragCallback,
Key? key,
}) : super(key: key);
super.key,
});

@override
State<PlutoDualGridDividerWidget> createState() =>
Expand Down
23 changes: 11 additions & 12 deletions lib/src/pluto_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ typedef PlutoRowColorCallback = Color Function(
/// Also, the popup to set the filter or column inside the grid is implemented through the setting of [PlutoGrid].
class PlutoGrid extends PlutoStatefulWidget {
const PlutoGrid({
Key? key,
super.key,
required this.columns,
required this.rows,
this.columnGroups,
Expand All @@ -76,7 +76,7 @@ class PlutoGrid extends PlutoStatefulWidget {
this.configuration = const PlutoGridConfiguration(),
this.notifierFilterResolver,
this.mode = PlutoGridMode.normal,
}) : super(key: key);
});

/// {@template pluto_grid_property_columns}
/// The [PlutoColumn] column is delivered as a list and can be added or deleted after grid creation.
Expand Down Expand Up @@ -593,7 +593,7 @@ class PlutoGridState extends PlutoStateWithChange<PlutoGrid> {
}
}

KeyEventResult _handleGridFocusOnKey(FocusNode focusNode, RawKeyEvent event) {
KeyEventResult _handleGridFocusOnKey(FocusNode focusNode, KeyEvent event) {
if (_keyManager.eventResult.isSkip == false) {
_keyManager.subject.add(PlutoKeyManagerEvent(
focusNode: focusNode,
Expand All @@ -608,7 +608,7 @@ class PlutoGridState extends PlutoStateWithChange<PlutoGrid> {
Widget build(BuildContext context) {
return FocusScope(
onFocusChange: _stateManager.setKeepFocus,
onKey: _handleGridFocusOnKey,
onKeyEvent: _handleGridFocusOnKey,
child: _GridContainer(
stateManager: _stateManager,
child: LayoutBuilder(
Expand Down Expand Up @@ -1204,8 +1204,7 @@ class _GridContainer extends StatelessWidget {
const _GridContainer({
required this.stateManager,
required this.child,
Key? key,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -1368,17 +1367,17 @@ abstract class PlutoGridOnRowCheckedEvent {
/// Argument of [PlutoGrid.onRowChecked] callback when the checkbox of the row is tapped.
class PlutoGridOnRowCheckedOneEvent extends PlutoGridOnRowCheckedEvent {
const PlutoGridOnRowCheckedOneEvent({
required PlutoRow row,
required int rowIdx,
required bool? isChecked,
}) : super(row: row, rowIdx: rowIdx, isChecked: isChecked);
required PlutoRow super.row,
required int super.rowIdx,
required super.isChecked,
});
}

/// Argument of [PlutoGrid.onRowChecked] callback when all checkboxes of the column are tapped.
class PlutoGridOnRowCheckedAllEvent extends PlutoGridOnRowCheckedEvent {
const PlutoGridOnRowCheckedAllEvent({
bool? isChecked,
}) : super(row: null, rowIdx: null, isChecked: isChecked);
super.isChecked,
}) : super(row: null, rowIdx: null);
}

/// The argument of the [PlutoGrid.onRowDoubleTap] callback
Expand Down
4 changes: 2 additions & 2 deletions lib/src/ui/cells/pluto_currency_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class PlutoCurrencyCell extends StatefulWidget implements TextCell {
required this.cell,
required this.column,
required this.row,
Key? key,
}) : super(key: key);
super.key,
});

@override
PlutoCurrencyCellState createState() => PlutoCurrencyCellState();
Expand Down
4 changes: 2 additions & 2 deletions lib/src/ui/cells/pluto_date_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class PlutoDateCell extends StatefulWidget implements PopupCell {
required this.cell,
required this.column,
required this.row,
Key? key,
}) : super(key: key);
super.key,
});

@override
PlutoDateCellState createState() => PlutoDateCellState();
Expand Down
10 changes: 4 additions & 6 deletions lib/src/ui/cells/pluto_default_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class PlutoDefaultCell extends PlutoStatefulWidget {
required this.rowIdx,
required this.row,
required this.stateManager,
Key? key,
}) : super(key: key);
super.key,
});

@override
State<PlutoDefaultCell> createState() => _PlutoDefaultCellState();
Expand Down Expand Up @@ -219,8 +219,7 @@ class _RowDragIconWidget extends StatelessWidget {
required this.stateManager,
required this.dragIcon,
required this.feedbackWidget,
Key? key,
}) : super(key: key);
});

List<PlutoRow> get _draggingRows {
if (stateManager.currentSelectingRows.isEmpty) {
Expand Down Expand Up @@ -422,8 +421,7 @@ class _DefaultCellWidget extends StatelessWidget {
required this.row,
required this.column,
required this.cell,
Key? key,
}) : super(key: key);
});

bool get _showText {
if (!stateManager.enabledRowGroups) {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/ui/cells/pluto_number_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class PlutoNumberCell extends StatefulWidget implements TextCell {
required this.cell,
required this.column,
required this.row,
Key? key,
}) : super(key: key);
super.key,
});

@override
PlutoNumberCellState createState() => PlutoNumberCellState();
Expand Down
4 changes: 2 additions & 2 deletions lib/src/ui/cells/pluto_select_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class PlutoSelectCell extends StatefulWidget implements PopupCell {
required this.cell,
required this.column,
required this.row,
Key? key,
}) : super(key: key);
super.key,
});

@override
PlutoSelectCellState createState() => PlutoSelectCellState();
Expand Down
4 changes: 2 additions & 2 deletions lib/src/ui/cells/pluto_text_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class PlutoTextCell extends StatefulWidget implements TextCell {
required this.cell,
required this.column,
required this.row,
Key? key,
}) : super(key: key);
super.key,
});

@override
PlutoTextCellState createState() => PlutoTextCellState();
Expand Down
4 changes: 2 additions & 2 deletions lib/src/ui/cells/pluto_time_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class PlutoTimeCell extends StatefulWidget implements PopupCell {
required this.cell,
required this.column,
required this.row,
Key? key,
}) : super(key: key);
super.key,
});

@override
PlutoTimeCellState createState() => PlutoTimeCellState();
Expand Down
8 changes: 4 additions & 4 deletions lib/src/ui/cells/popup_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ abstract class PopupCell extends StatefulWidget {
required this.cell,
required this.column,
required this.row,
Key? key,
}) : super(key: key);
super.key,
});
}

abstract class GridPopupProps {
Expand Down Expand Up @@ -62,7 +62,7 @@ mixin PopupCellState<T extends PopupCell> on State<T>
..text =
widget.column.formattedValueForDisplayInEditing(widget.cell.value);

textFocus = FocusNode(onKey: _handleKeyboardFocusOnKey);
textFocus = FocusNode(onKeyEvent: _handleKeyboardFocusOnKey);
}

@override
Expand Down Expand Up @@ -175,7 +175,7 @@ mixin PopupCellState<T extends PopupCell> on State<T>
}
}

KeyEventResult _handleKeyboardFocusOnKey(FocusNode node, RawKeyEvent event) {
KeyEventResult _handleKeyboardFocusOnKey(FocusNode node, KeyEvent event) {
var keyManager = PlutoKeyManagerEvent(
focusNode: node,
event: event,
Expand Down
8 changes: 4 additions & 4 deletions lib/src/ui/cells/text_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ abstract class TextCell extends StatefulWidget {
required this.cell,
required this.column,
required this.row,
Key? key,
}) : super(key: key);
super.key,
});
}

abstract class TextFieldProps {
Expand Down Expand Up @@ -52,7 +52,7 @@ mixin TextCellState<T extends TextCell> on State<T> implements TextFieldProps {
void initState() {
super.initState();

cellFocus = FocusNode(onKey: _handleOnKey);
cellFocus = FocusNode(onKeyEvent: _handleOnKey);

widget.stateManager.setTextEditingController(_textController);

Expand Down Expand Up @@ -172,7 +172,7 @@ mixin TextCellState<T extends TextCell> on State<T> implements TextFieldProps {
});
}

KeyEventResult _handleOnKey(FocusNode node, RawKeyEvent event) {
KeyEventResult _handleOnKey(FocusNode node, KeyEvent event) {
var keyManager = PlutoKeyManagerEvent(
focusNode: node,
event: event,
Expand Down
Loading

0 comments on commit 5049e4d

Please sign in to comment.