From 0f40ac2dc009109bb08e79f855a998a2cce75414 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Thu, 18 Jan 2024 10:40:52 +0530 Subject: [PATCH 01/47] initiated --- .../linux/flutter/ephemeral/.plugin_symlinks/url_launcher_linux | 2 +- .../example/macos/Flutter/GeneratedPluginRegistrant.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demo/linux/flutter/ephemeral/.plugin_symlinks/url_launcher_linux b/demo/linux/flutter/ephemeral/.plugin_symlinks/url_launcher_linux index e433ea04f..f2fd81190 120000 --- a/demo/linux/flutter/ephemeral/.plugin_symlinks/url_launcher_linux +++ b/demo/linux/flutter/ephemeral/.plugin_symlinks/url_launcher_linux @@ -1 +1 @@ -C:/Users/manek/AppData/Local/Pub/Cache/hosted/pub.dev/url_launcher_linux-3.0.2/ \ No newline at end of file +C:/Users/Administrator/AppData/Local/Pub/Cache/hosted/pub.dev/url_launcher_linux-3.1.1/ \ No newline at end of file diff --git a/packages/pluto_grid_export/example/macos/Flutter/GeneratedPluginRegistrant.swift b/packages/pluto_grid_export/example/macos/Flutter/GeneratedPluginRegistrant.swift index 416ef8457..9c4efdd9c 100644 --- a/packages/pluto_grid_export/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/packages/pluto_grid_export/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -6,7 +6,7 @@ import FlutterMacOS import Foundation import file_saver -import path_provider_macos +import path_provider_foundation import printing func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { From d2207bf0f93d45df0748749e5a3dc1287fbd63a3 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Thu, 18 Jan 2024 10:48:43 +0530 Subject: [PATCH 02/47] testing changes --- lib/src/helper/show_column_menu.dart | 2 +- lib/src/pluto_grid_configuration.dart | 126 +++++++++----------------- 2 files changed, 42 insertions(+), 86 deletions(-) diff --git a/lib/src/helper/show_column_menu.dart b/lib/src/helper/show_column_menu.dart index 878eab54c..b1a17629e 100644 --- a/lib/src/helper/show_column_menu.dart +++ b/lib/src/helper/show_column_menu.dart @@ -156,7 +156,7 @@ List> _getDefaultColumnMenuItems({ const PopupMenuDivider(), _buildMenuItem( value: PlutoGridColumnMenuItem.setFilter, - text: localeText.setFilter, + text: "changed", textColor: textColor, ), _buildMenuItem( diff --git a/lib/src/pluto_grid_configuration.dart b/lib/src/pluto_grid_configuration.dart index 9b946b169..4b24e413c 100644 --- a/lib/src/pluto_grid_configuration.dart +++ b/lib/src/pluto_grid_configuration.dart @@ -105,8 +105,7 @@ class PlutoGridConfiguration { PlutoFilterTypeStartsWith.name = localeText.filterStartsWith; PlutoFilterTypeEndsWith.name = localeText.filterEndsWith; PlutoFilterTypeGreaterThan.name = localeText.filterGreaterThan; - PlutoFilterTypeGreaterThanOrEqualTo.name = - localeText.filterGreaterThanOrEqualTo; + PlutoFilterTypeGreaterThanOrEqualTo.name = localeText.filterGreaterThanOrEqualTo; PlutoFilterTypeLessThan.name = localeText.filterLessThan; PlutoFilterTypeLessThanOrEqualTo.name = localeText.filterLessThanOrEqualTo; } @@ -141,10 +140,8 @@ class PlutoGridConfiguration { PlutoGridLocaleText? localeText, }) { return PlutoGridConfiguration( - enableMoveDownAfterSelecting: - enableMoveDownAfterSelecting ?? this.enableMoveDownAfterSelecting, - enableMoveHorizontalInEditing: - enableMoveHorizontalInEditing ?? this.enableMoveHorizontalInEditing, + enableMoveDownAfterSelecting: enableMoveDownAfterSelecting ?? this.enableMoveDownAfterSelecting, + enableMoveHorizontalInEditing: enableMoveHorizontalInEditing ?? this.enableMoveHorizontalInEditing, enterKeyAction: enterKeyAction ?? this.enterKeyAction, tabKeyAction: tabKeyAction ?? this.tabKeyAction, shortcut: shortcut ?? this.shortcut, @@ -161,10 +158,8 @@ class PlutoGridConfiguration { return identical(this, other) || other is PlutoGridConfiguration && runtimeType == other.runtimeType && - enableMoveDownAfterSelecting == - other.enableMoveDownAfterSelecting && - enableMoveHorizontalInEditing == - other.enableMoveHorizontalInEditing && + enableMoveDownAfterSelecting == other.enableMoveDownAfterSelecting && + enableMoveHorizontalInEditing == other.enableMoveHorizontalInEditing && enterKeyAction == other.enterKeyAction && tabKeyAction == other.tabKeyAction && shortcut == other.shortcut && @@ -492,67 +487,47 @@ class PlutoGridStyleConfig { BorderRadiusGeometry? gridPopupBorderRadius, }) { return PlutoGridStyleConfig( - enableGridBorderShadow: - enableGridBorderShadow ?? this.enableGridBorderShadow, - enableColumnBorderVertical: - enableColumnBorderVertical ?? this.enableColumnBorderVertical, - enableColumnBorderHorizontal: - enableColumnBorderHorizontal ?? this.enableColumnBorderHorizontal, - enableCellBorderVertical: - enableCellBorderVertical ?? this.enableCellBorderVertical, - enableCellBorderHorizontal: - enableCellBorderHorizontal ?? this.enableCellBorderHorizontal, - enableRowColorAnimation: - enableRowColorAnimation ?? this.enableRowColorAnimation, + enableGridBorderShadow: enableGridBorderShadow ?? this.enableGridBorderShadow, + enableColumnBorderVertical: enableColumnBorderVertical ?? this.enableColumnBorderVertical, + enableColumnBorderHorizontal: enableColumnBorderHorizontal ?? this.enableColumnBorderHorizontal, + enableCellBorderVertical: enableCellBorderVertical ?? this.enableCellBorderVertical, + enableCellBorderHorizontal: enableCellBorderHorizontal ?? this.enableCellBorderHorizontal, + enableRowColorAnimation: enableRowColorAnimation ?? this.enableRowColorAnimation, gridBackgroundColor: gridBackgroundColor ?? this.gridBackgroundColor, rowColor: rowColor ?? this.rowColor, oddRowColor: oddRowColor == null ? this.oddRowColor : oddRowColor.value, - evenRowColor: - evenRowColor == null ? this.evenRowColor : evenRowColor.value, + evenRowColor: evenRowColor == null ? this.evenRowColor : evenRowColor.value, activatedColor: activatedColor ?? this.activatedColor, checkedColor: checkedColor ?? this.checkedColor, cellColorInEditState: cellColorInEditState ?? this.cellColorInEditState, - cellColorInReadOnlyState: - cellColorInReadOnlyState ?? this.cellColorInReadOnlyState, - cellColorGroupedRow: cellColorGroupedRow == null - ? this.cellColorGroupedRow - : cellColorGroupedRow.value, - dragTargetColumnColor: - dragTargetColumnColor ?? this.dragTargetColumnColor, + cellColorInReadOnlyState: cellColorInReadOnlyState ?? this.cellColorInReadOnlyState, + cellColorGroupedRow: cellColorGroupedRow == null ? this.cellColorGroupedRow : cellColorGroupedRow.value, + dragTargetColumnColor: dragTargetColumnColor ?? this.dragTargetColumnColor, iconColor: iconColor ?? this.iconColor, disabledIconColor: disabledIconColor ?? this.disabledIconColor, menuBackgroundColor: menuBackgroundColor ?? this.menuBackgroundColor, gridBorderColor: gridBorderColor ?? this.gridBorderColor, borderColor: borderColor ?? this.borderColor, activatedBorderColor: activatedBorderColor ?? this.activatedBorderColor, - inactivatedBorderColor: - inactivatedBorderColor ?? this.inactivatedBorderColor, + inactivatedBorderColor: inactivatedBorderColor ?? this.inactivatedBorderColor, iconSize: iconSize ?? this.iconSize, rowHeight: rowHeight ?? this.rowHeight, columnHeight: columnHeight ?? this.columnHeight, columnFilterHeight: columnFilterHeight ?? this.columnFilterHeight, - defaultColumnTitlePadding: - defaultColumnTitlePadding ?? this.defaultColumnTitlePadding, - defaultColumnFilterPadding: - defaultColumnFilterPadding ?? this.defaultColumnFilterPadding, + defaultColumnTitlePadding: defaultColumnTitlePadding ?? this.defaultColumnTitlePadding, + defaultColumnFilterPadding: defaultColumnFilterPadding ?? this.defaultColumnFilterPadding, defaultCellPadding: defaultCellPadding ?? this.defaultCellPadding, columnTextStyle: columnTextStyle ?? this.columnTextStyle, cellTextStyle: cellTextStyle ?? this.cellTextStyle, columnContextIcon: columnContextIcon ?? this.columnContextIcon, columnResizeIcon: columnResizeIcon ?? this.columnResizeIcon, - columnAscendingIcon: columnAscendingIcon == null - ? this.columnAscendingIcon - : columnAscendingIcon.value, - columnDescendingIcon: columnDescendingIcon == null - ? this.columnDescendingIcon - : columnDescendingIcon.value, + columnAscendingIcon: columnAscendingIcon == null ? this.columnAscendingIcon : columnAscendingIcon.value, + columnDescendingIcon: columnDescendingIcon == null ? this.columnDescendingIcon : columnDescendingIcon.value, rowGroupExpandedIcon: rowGroupExpandedIcon ?? this.rowGroupExpandedIcon, - rowGroupCollapsedIcon: - rowGroupCollapsedIcon ?? this.rowGroupCollapsedIcon, + rowGroupCollapsedIcon: rowGroupCollapsedIcon ?? this.rowGroupCollapsedIcon, rowGroupEmptyIcon: rowGroupEmptyIcon ?? this.rowGroupEmptyIcon, gridBorderRadius: gridBorderRadius ?? this.gridBorderRadius, - gridPopupBorderRadius: - gridPopupBorderRadius ?? this.gridPopupBorderRadius, + gridPopupBorderRadius: gridPopupBorderRadius ?? this.gridPopupBorderRadius, ); } @@ -563,8 +538,7 @@ class PlutoGridStyleConfig { runtimeType == other.runtimeType && enableGridBorderShadow == other.enableGridBorderShadow && enableColumnBorderVertical == other.enableColumnBorderVertical && - enableColumnBorderHorizontal == - other.enableColumnBorderHorizontal && + enableColumnBorderHorizontal == other.enableColumnBorderHorizontal && enableCellBorderVertical == other.enableCellBorderVertical && enableCellBorderHorizontal == other.enableCellBorderHorizontal && enableRowColorAnimation == other.enableRowColorAnimation && @@ -662,16 +636,14 @@ class PlutoGridScrollbarConfig { this.onlyDraggingThumb = true, this.enableScrollAfterDragEnd = true, this.scrollbarThickness = PlutoScrollbar.defaultThickness, - this.scrollbarThicknessWhileDragging = - PlutoScrollbar.defaultThicknessWhileDragging, + this.scrollbarThicknessWhileDragging = PlutoScrollbar.defaultThicknessWhileDragging, this.hoverWidth = PlutoScrollbar.defaultScrollbarHoverWidth, this.mainAxisMargin, this.crossAxisMargin, this.scrollBarColor, this.scrollBarTrackColor, this.scrollbarRadius = PlutoScrollbar.defaultRadius, - this.scrollbarRadiusWhileDragging = - PlutoScrollbar.defaultRadiusWhileDragging, + this.scrollbarRadiusWhileDragging = PlutoScrollbar.defaultRadiusWhileDragging, this.longPressDuration, this.dragDevices, }); @@ -725,16 +697,14 @@ class PlutoGridScrollbarConfig { onlyDraggingThumb == other.onlyDraggingThumb && enableScrollAfterDragEnd == other.enableScrollAfterDragEnd && scrollbarThickness == other.scrollbarThickness && - scrollbarThicknessWhileDragging == - other.scrollbarThicknessWhileDragging && + scrollbarThicknessWhileDragging == other.scrollbarThicknessWhileDragging && hoverWidth == other.hoverWidth && mainAxisMargin == other.mainAxisMargin && crossAxisMargin == other.crossAxisMargin && scrollBarColor == other.scrollBarColor && scrollBarTrackColor == other.scrollBarTrackColor && scrollbarRadius == other.scrollbarRadius && - scrollbarRadiusWhileDragging == - other.scrollbarRadiusWhileDragging && + scrollbarRadiusWhileDragging == other.scrollbarRadiusWhileDragging && longPressDuration == other.longPressDuration && dragDevices == other.dragDevices; } @@ -835,8 +805,7 @@ class PlutoGridColumnFilterConfig { bool get hasUserFilter => _userFilters != null && _userFilters!.isNotEmpty; - List get filters => - hasUserFilter ? _userFilters! : FilterHelper.defaultFilters; + List get filters => hasUserFilter ? _userFilters! : FilterHelper.defaultFilters; int get debounceMilliseconds => _debounceMilliseconds; @@ -865,8 +834,7 @@ class PlutoGridColumnFilterConfig { other is PlutoGridColumnFilterConfig && runtimeType == other.runtimeType && listEquals(_userFilters, other._userFilters) && - _userResolveDefaultColumnFilter == - other._userResolveDefaultColumnFilter && + _userResolveDefaultColumnFilter == other._userResolveDefaultColumnFilter && _debounceMilliseconds == other._debounceMilliseconds; } @@ -933,16 +901,11 @@ class PlutoGridColumnSizeConfig { return PlutoGridColumnSizeConfig( autoSizeMode: autoSizeMode ?? this.autoSizeMode, resizeMode: resizeMode ?? this.resizeMode, - restoreAutoSizeAfterHideColumn: - restoreAutoSizeAfterHideColumn ?? this.restoreAutoSizeAfterHideColumn, - restoreAutoSizeAfterFrozenColumn: restoreAutoSizeAfterFrozenColumn ?? - this.restoreAutoSizeAfterFrozenColumn, - restoreAutoSizeAfterMoveColumn: - restoreAutoSizeAfterMoveColumn ?? this.restoreAutoSizeAfterMoveColumn, - restoreAutoSizeAfterInsertColumn: restoreAutoSizeAfterInsertColumn ?? - this.restoreAutoSizeAfterInsertColumn, - restoreAutoSizeAfterRemoveColumn: restoreAutoSizeAfterRemoveColumn ?? - this.restoreAutoSizeAfterRemoveColumn, + restoreAutoSizeAfterHideColumn: restoreAutoSizeAfterHideColumn ?? this.restoreAutoSizeAfterHideColumn, + restoreAutoSizeAfterFrozenColumn: restoreAutoSizeAfterFrozenColumn ?? this.restoreAutoSizeAfterFrozenColumn, + restoreAutoSizeAfterMoveColumn: restoreAutoSizeAfterMoveColumn ?? this.restoreAutoSizeAfterMoveColumn, + restoreAutoSizeAfterInsertColumn: restoreAutoSizeAfterInsertColumn ?? this.restoreAutoSizeAfterInsertColumn, + restoreAutoSizeAfterRemoveColumn: restoreAutoSizeAfterRemoveColumn ?? this.restoreAutoSizeAfterRemoveColumn, ); } @@ -953,16 +916,11 @@ class PlutoGridColumnSizeConfig { runtimeType == other.runtimeType && autoSizeMode == other.autoSizeMode && resizeMode == other.resizeMode && - restoreAutoSizeAfterHideColumn == - other.restoreAutoSizeAfterHideColumn && - restoreAutoSizeAfterFrozenColumn == - other.restoreAutoSizeAfterFrozenColumn && - restoreAutoSizeAfterMoveColumn == - other.restoreAutoSizeAfterMoveColumn && - restoreAutoSizeAfterInsertColumn == - other.restoreAutoSizeAfterInsertColumn && - restoreAutoSizeAfterRemoveColumn == - other.restoreAutoSizeAfterRemoveColumn; + restoreAutoSizeAfterHideColumn == other.restoreAutoSizeAfterHideColumn && + restoreAutoSizeAfterFrozenColumn == other.restoreAutoSizeAfterFrozenColumn && + restoreAutoSizeAfterMoveColumn == other.restoreAutoSizeAfterMoveColumn && + restoreAutoSizeAfterInsertColumn == other.restoreAutoSizeAfterInsertColumn && + restoreAutoSizeAfterRemoveColumn == other.restoreAutoSizeAfterRemoveColumn; } @override @@ -1671,11 +1629,9 @@ enum PlutoGridEnterKeyAction { /// Pressing the Enter key does nothing. none; - bool get isEditingAndMoveDown => - this == PlutoGridEnterKeyAction.editingAndMoveDown; + bool get isEditingAndMoveDown => this == PlutoGridEnterKeyAction.editingAndMoveDown; - bool get isEditingAndMoveRight => - this == PlutoGridEnterKeyAction.editingAndMoveRight; + bool get isEditingAndMoveRight => this == PlutoGridEnterKeyAction.editingAndMoveRight; bool get isToggleEditing => this == PlutoGridEnterKeyAction.toggleEditing; From e9fd8fe93131b4dd3796e3f3424f665b29d3869a Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Thu, 18 Jan 2024 10:58:08 +0530 Subject: [PATCH 03/47] changes --- lib/src/helper/show_column_menu.dart | 2 +- lib/src/pluto_grid_configuration.dart | 6 +++--- test/src/ui/columns/pluto_column_title_test.dart | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/src/helper/show_column_menu.dart b/lib/src/helper/show_column_menu.dart index b1a17629e..878eab54c 100644 --- a/lib/src/helper/show_column_menu.dart +++ b/lib/src/helper/show_column_menu.dart @@ -156,7 +156,7 @@ List> _getDefaultColumnMenuItems({ const PopupMenuDivider(), _buildMenuItem( value: PlutoGridColumnMenuItem.setFilter, - text: "changed", + text: localeText.setFilter, textColor: textColor, ), _buildMenuItem( diff --git a/lib/src/pluto_grid_configuration.dart b/lib/src/pluto_grid_configuration.dart index 4b24e413c..ed604c0e0 100644 --- a/lib/src/pluto_grid_configuration.dart +++ b/lib/src/pluto_grid_configuration.dart @@ -981,13 +981,13 @@ class PlutoGridLocaleText { const PlutoGridLocaleText({ // Column menu - this.unfreezeColumn = 'Unfreeze', - this.freezeColumnToStart = 'Freeze to start', + this.unfreezeColumn = 'Unfreeze edited', + this.freezeColumnToStart = 'Freeze to start edited', this.freezeColumnToEnd = 'Freeze to end', this.autoFitColumn = 'Auto fit', this.hideColumn = 'Hide column', this.setColumns = 'Set columns', - this.setFilter = 'Set filter', + this.setFilter = 'Set filter edited', this.resetFilter = 'Reset filter', // SetColumns popup this.setColumnsTitle = 'Column title', diff --git a/test/src/ui/columns/pluto_column_title_test.dart b/test/src/ui/columns/pluto_column_title_test.dart index 6cf9265a1..0dd36cd6d 100644 --- a/test/src/ui/columns/pluto_column_title_test.dart +++ b/test/src/ui/columns/pluto_column_title_test.dart @@ -378,14 +378,14 @@ void main() { }); tapColumn.test('기본 메뉴가 출력 되어야 한다.', (tester) async { - expect(find.text('Freeze to start'), findsOneWidget); + expect(find.text('Freeze to start edited'), findsOneWidget); expect(find.text('Freeze to end'), findsOneWidget); expect(find.text('Auto fit'), findsOneWidget); }); tapColumn.test('Freeze to start 를 탭하면 toggleFrozenColumn 이 호출 되어야 한다.', (tester) async { - await tester.tap(find.text('Freeze to start')); + await tester.tap(find.text('Freeze to start edited')); verify(stateManager.toggleFrozenColumn( column, @@ -444,7 +444,7 @@ void main() { tapColumn.test('고정 컬럼의 기본 메뉴가 출력 되어야 한다.', (tester) async { expect(find.text('Unfreeze'), findsOneWidget); - expect(find.text('Freeze to start'), findsNothing); + expect(find.text('Freeze to start edited'), findsNothing); expect(find.text('Freeze to end'), findsNothing); expect(find.text('Auto fit'), findsOneWidget); }); @@ -496,7 +496,7 @@ void main() { tapColumn.test('고정 컬럼의 기본 메뉴가 출력 되어야 한다.', (tester) async { expect(find.text('Unfreeze'), findsOneWidget); - expect(find.text('Freeze to start'), findsNothing); + expect(find.text('Freeze to start edited'), findsNothing); expect(find.text('Freeze to end'), findsNothing); expect(find.text('Auto fit'), findsOneWidget); }); From 113c62b63086c59b99b29e008bbb2a229a920687 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Thu, 18 Jan 2024 11:00:09 +0530 Subject: [PATCH 04/47] f --- test/src/ui/columns/pluto_column_title_test.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/src/ui/columns/pluto_column_title_test.dart b/test/src/ui/columns/pluto_column_title_test.dart index 0dd36cd6d..6cf9265a1 100644 --- a/test/src/ui/columns/pluto_column_title_test.dart +++ b/test/src/ui/columns/pluto_column_title_test.dart @@ -378,14 +378,14 @@ void main() { }); tapColumn.test('기본 메뉴가 출력 되어야 한다.', (tester) async { - expect(find.text('Freeze to start edited'), findsOneWidget); + expect(find.text('Freeze to start'), findsOneWidget); expect(find.text('Freeze to end'), findsOneWidget); expect(find.text('Auto fit'), findsOneWidget); }); tapColumn.test('Freeze to start 를 탭하면 toggleFrozenColumn 이 호출 되어야 한다.', (tester) async { - await tester.tap(find.text('Freeze to start edited')); + await tester.tap(find.text('Freeze to start')); verify(stateManager.toggleFrozenColumn( column, @@ -444,7 +444,7 @@ void main() { tapColumn.test('고정 컬럼의 기본 메뉴가 출력 되어야 한다.', (tester) async { expect(find.text('Unfreeze'), findsOneWidget); - expect(find.text('Freeze to start edited'), findsNothing); + expect(find.text('Freeze to start'), findsNothing); expect(find.text('Freeze to end'), findsNothing); expect(find.text('Auto fit'), findsOneWidget); }); @@ -496,7 +496,7 @@ void main() { tapColumn.test('고정 컬럼의 기본 메뉴가 출력 되어야 한다.', (tester) async { expect(find.text('Unfreeze'), findsOneWidget); - expect(find.text('Freeze to start edited'), findsNothing); + expect(find.text('Freeze to start'), findsNothing); expect(find.text('Freeze to end'), findsNothing); expect(find.text('Auto fit'), findsOneWidget); }); From 6f37b322625cdc454f4687b0b30899a7a46c366e Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Thu, 18 Jan 2024 11:48:52 +0530 Subject: [PATCH 05/47] fixes made --- lib/src/helper/filter_helper.dart | 47 ++++++++++++++++++--------- lib/src/pluto_grid_configuration.dart | 6 ++-- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/lib/src/helper/filter_helper.dart b/lib/src/helper/filter_helper.dart index 9a47632ba..69f6b0e15 100644 --- a/lib/src/helper/filter_helper.dart +++ b/lib/src/helper/filter_helper.dart @@ -3,8 +3,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:pluto_grid/pluto_grid.dart'; -typedef SetFilterPopupHandler = void Function( - PlutoGridStateManager? stateManager); +typedef SetFilterPopupHandler = void Function(PlutoGridStateManager? stateManager); class FilterHelper { /// A value to identify all column searches when searching filters. @@ -41,10 +40,8 @@ class FilterHelper { }) { return PlutoRow( cells: { - filterFieldColumn: - PlutoCell(value: columnField ?? filterFieldAllColumns), - filterFieldType: - PlutoCell(value: filterType ?? const PlutoFilterTypeContains()), + filterFieldColumn: PlutoCell(value: columnField ?? filterFieldAllColumns), + filterFieldType: PlutoCell(value: filterType ?? const PlutoFilterTypeContains()), filterFieldValue: PlutoCell(value: filterValue ?? ''), }, ); @@ -97,8 +94,7 @@ class FilterHelper { flag, compareByFilterType( filterType: filterType!, - base: row!.cells[e.cells[filterFieldColumn]!.value]!.value - .toString(), + base: row!.cells[e.cells[filterFieldColumn]!.value]!.value.toString(), search: e.cells[filterFieldValue]!.value.toString(), column: foundColumn, ), @@ -139,9 +135,7 @@ class FilterHelper { columnField = allField; } - final String filterType = - (row.cells[FilterHelper.filterFieldType]!.value as PlutoFilterType) - .title; + final String filterType = (row.cells[FilterHelper.filterFieldType]!.value as PlutoFilterType).title; final filterValue = row.cells[FilterHelper.filterFieldValue]!.value; @@ -171,8 +165,7 @@ class FilterHelper { } for (var row in filteredRows) { - if (row!.cells[filterFieldColumn]!.value == filterFieldAllColumns || - row.cells[filterFieldColumn]!.value == column.field) { + if (row!.cells[filterFieldColumn]!.value == filterFieldAllColumns || row.cells[filterFieldColumn]!.value == column.field) { return true; } } @@ -447,8 +440,7 @@ class FilterPopupState { required List columns, }) { Map columnMap = { - FilterHelper.filterFieldAllColumns: - configuration.localeText.filterAllColumns, + FilterHelper.filterFieldAllColumns: configuration.localeText.filterAllColumns, }; columns.where((element) => element.enableFilterMenuItem).forEach((element) { @@ -526,7 +518,30 @@ class PlutoGridFilterPopupHeader extends StatelessWidget { if (stateManager!.rows.isEmpty) { Navigator.of(stateManager!.gridFocusNode.context!).pop(); } else { - stateManager!.removeRows(stateManager!.rows); + showDialog( + context: stateManager!.gridFocusNode.context!, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Confirmation'), + content: const Text('Are you sure you want to clear the rows?'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: const Text('Cancel'), + ), + TextButton( + onPressed: () { + Navigator.of(context).pop(); + stateManager!.removeRows(stateManager!.rows); + }, + child: const Text('Clear'), + ), + ], + ); + }, + ); } } diff --git a/lib/src/pluto_grid_configuration.dart b/lib/src/pluto_grid_configuration.dart index ed604c0e0..4b24e413c 100644 --- a/lib/src/pluto_grid_configuration.dart +++ b/lib/src/pluto_grid_configuration.dart @@ -981,13 +981,13 @@ class PlutoGridLocaleText { const PlutoGridLocaleText({ // Column menu - this.unfreezeColumn = 'Unfreeze edited', - this.freezeColumnToStart = 'Freeze to start edited', + this.unfreezeColumn = 'Unfreeze', + this.freezeColumnToStart = 'Freeze to start', this.freezeColumnToEnd = 'Freeze to end', this.autoFitColumn = 'Auto fit', this.hideColumn = 'Hide column', this.setColumns = 'Set columns', - this.setFilter = 'Set filter edited', + this.setFilter = 'Set filter', this.resetFilter = 'Reset filter', // SetColumns popup this.setColumnsTitle = 'Column title', From 4be9816dd8549a060025aefbcb8253ce28efe4d3 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Fri, 19 Jan 2024 10:15:06 +0530 Subject: [PATCH 06/47] modified package --- lib/src/helper/filter_helper.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/helper/filter_helper.dart b/lib/src/helper/filter_helper.dart index 69f6b0e15..201306c62 100644 --- a/lib/src/helper/filter_helper.dart +++ b/lib/src/helper/filter_helper.dart @@ -534,6 +534,7 @@ class PlutoGridFilterPopupHeader extends StatelessWidget { TextButton( onPressed: () { Navigator.of(context).pop(); + stateManager!.removeRows(stateManager!.rows); }, child: const Text('Clear'), From 8625cad32c9f9468714b1649660aca30f6750424 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Fri, 19 Jan 2024 10:16:50 +0530 Subject: [PATCH 07/47] modified --- lib/src/helper/filter_helper.dart | 10 ++- lib/src/pluto_grid_popup.dart | 87 +++++++++---------- .../lib/src/pdf/generic_pdf_controller.dart | 3 +- 3 files changed, 49 insertions(+), 51 deletions(-) diff --git a/lib/src/helper/filter_helper.dart b/lib/src/helper/filter_helper.dart index 201306c62..11971ca8b 100644 --- a/lib/src/helper/filter_helper.dart +++ b/lib/src/helper/filter_helper.dart @@ -523,21 +523,23 @@ class PlutoGridFilterPopupHeader extends StatelessWidget { builder: (BuildContext context) { return AlertDialog( title: const Text('Confirmation'), - content: const Text('Are you sure you want to clear the rows?'), + content: const Text('Are you sure you want to clear the Filters?'), actions: [ TextButton( onPressed: () { Navigator.of(context).pop(); }, - child: const Text('Cancel'), + child: const Text('No', style: TextStyle(color: Colors.red)), ), TextButton( onPressed: () { Navigator.of(context).pop(); - stateManager!.removeRows(stateManager!.rows); }, - child: const Text('Clear'), + child: const Text( + 'Clear', + style: TextStyle(color: Colors.green), + ), ), ], ); diff --git a/lib/src/pluto_grid_popup.dart b/lib/src/pluto_grid_popup.dart index 710e2c350..33c16ed50 100644 --- a/lib/src/pluto_grid_popup.dart +++ b/lib/src/pluto_grid_popup.dart @@ -109,51 +109,48 @@ class PlutoGridPopup { textDirection, ); - PlutoGridOnSelectedEvent? selected = - await showDialog( - context: context, - builder: (BuildContext ctx) { - return Dialog( - shape: borderRadius == BorderRadius.zero - ? null - : RoundedRectangleBorder(borderRadius: borderRadius), - child: LayoutBuilder( - builder: (ctx, size) { - return SizedBox( - width: (width ?? size.maxWidth) + - PlutoGridSettings.gridInnerSpacing, - height: height ?? size.maxHeight, - child: Directionality( - textDirection: textDirection, - child: PlutoGrid( - columns: columns, - rows: rows, - columnGroups: columnGroups, - onLoaded: onLoaded, - onChanged: onChanged, - onSelected: (PlutoGridOnSelectedEvent event) { - Navigator.pop(ctx, event); - }, - onSorted: onSorted, - onRowChecked: onRowChecked, - onRowDoubleTap: onRowDoubleTap, - onRowSecondaryTap: onRowSecondaryTap, - onRowsMoved: onRowsMoved, - onColumnsMoved: onColumnsMoved, - createHeader: createHeader, - createFooter: createFooter, - noRowsWidget: noRowsWidget, - rowColorCallback: rowColorCallback, - columnMenuDelegate: columnMenuDelegate, - configuration: configuration, - mode: mode, - ), - ), - ); - }, - ), - ); - }); + PlutoGridOnSelectedEvent? selected = await showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext ctx) { + return Dialog( + shape: borderRadius == BorderRadius.zero ? null : RoundedRectangleBorder(borderRadius: borderRadius), + child: LayoutBuilder( + builder: (ctx, size) { + return SizedBox( + width: (width ?? size.maxWidth) + PlutoGridSettings.gridInnerSpacing, + height: height ?? size.maxHeight, + child: Directionality( + textDirection: textDirection, + child: PlutoGrid( + columns: columns, + rows: rows, + columnGroups: columnGroups, + onLoaded: onLoaded, + onChanged: onChanged, + onSelected: (PlutoGridOnSelectedEvent event) { + Navigator.pop(ctx, event); + }, + onSorted: onSorted, + onRowChecked: onRowChecked, + onRowDoubleTap: onRowDoubleTap, + onRowSecondaryTap: onRowSecondaryTap, + onRowsMoved: onRowsMoved, + onColumnsMoved: onColumnsMoved, + createHeader: createHeader, + createFooter: createFooter, + noRowsWidget: noRowsWidget, + rowColorCallback: rowColorCallback, + columnMenuDelegate: columnMenuDelegate, + configuration: configuration, + mode: mode, + ), + ), + ); + }, + ), + ); + }); if (onSelected != null && selected != null) { onSelected!(selected); } diff --git a/packages/pluto_grid_export/lib/src/pdf/generic_pdf_controller.dart b/packages/pluto_grid_export/lib/src/pdf/generic_pdf_controller.dart index 82ea42a9c..150f82bab 100644 --- a/packages/pluto_grid_export/lib/src/pdf/generic_pdf_controller.dart +++ b/packages/pluto_grid_export/lib/src/pdf/generic_pdf_controller.dart @@ -79,10 +79,9 @@ class GenericPdfController extends PdfController { } Widget _table(List columns, List> rows) { - return Table.fromTextArray( + return TableHelper.fromTextArray( border: null, cellAlignment: Alignment.center, - // [Resolved 3.8.1] https://github.com/DavBfr/dart_pdf/pull/1033 to replace "headerDecoration" with "headerCellDecoration" headerCellDecoration: BoxDecoration( color: headerBackground, border: Border.all( From d91b44699cac1909d08ebe3eeb2c70f6e20115ef Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Fri, 19 Jan 2024 11:22:24 +0530 Subject: [PATCH 08/47] modified --- lib/src/helper/filter_helper.dart | 97 ++++++++++++++----------------- 1 file changed, 45 insertions(+), 52 deletions(-) diff --git a/lib/src/helper/filter_helper.dart b/lib/src/helper/filter_helper.dart index 11971ca8b..4f2761039 100644 --- a/lib/src/helper/filter_helper.dart +++ b/lib/src/helper/filter_helper.dart @@ -515,64 +515,57 @@ class PlutoGridFilterPopupHeader extends StatelessWidget { } void handleClearButton() { - if (stateManager!.rows.isEmpty) { - Navigator.of(stateManager!.gridFocusNode.context!).pop(); - } else { - showDialog( - context: stateManager!.gridFocusNode.context!, - builder: (BuildContext context) { - return AlertDialog( - title: const Text('Confirmation'), - content: const Text('Are you sure you want to clear the Filters?'), - actions: [ - TextButton( - onPressed: () { - Navigator.of(context).pop(); - }, - child: const Text('No', style: TextStyle(color: Colors.red)), - ), - TextButton( - onPressed: () { - Navigator.of(context).pop(); - stateManager!.removeRows(stateManager!.rows); - }, - child: const Text( - 'Clear', - style: TextStyle(color: Colors.green), - ), - ), - ], - ); - }, - ); - } + stateManager!.removeRows(stateManager!.rows); } @override Widget build(BuildContext context) { + Size size = MediaQuery.sizeOf(context); + return SingleChildScrollView( scrollDirection: Axis.horizontal, - child: Row( - children: [ - IconButton( - icon: const Icon(Icons.add), - color: configuration!.style.iconColor, - iconSize: configuration!.style.iconSize, - onPressed: handleAddButton, - ), - IconButton( - icon: const Icon(Icons.remove), - color: configuration!.style.iconColor, - iconSize: configuration!.style.iconSize, - onPressed: handleRemoveButton, - ), - IconButton( - icon: const Icon(Icons.clear_sharp), - color: Colors.red, - iconSize: configuration!.style.iconSize, - onPressed: handleClearButton, - ), - ], + child: SizedBox( + width: size.width - 1328, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + IconButton( + icon: const Icon(Icons.add), + color: configuration!.style.iconColor, + iconSize: configuration!.style.iconSize, + onPressed: handleAddButton, + ), + IconButton( + icon: const Icon(Icons.remove), + color: configuration!.style.iconColor, + iconSize: configuration!.style.iconSize, + onPressed: handleRemoveButton, + ), + InkWell( + onTap: handleClearButton, + child: const Text( + 'Clear Filter', + style: TextStyle(color: Colors.red), + ), + ), + ], + ), + ElevatedButton( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all(Colors.redAccent), + ), + onPressed: () { + Navigator.of(stateManager!.gridFocusNode.context!).pop(); + }, + child: const Text( + 'Close', + style: TextStyle(color: Colors.white), + ), + ), + ], + ), ), ); } From 0871508b299fa63bca7cf9958d3da6a70f3d7581 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Fri, 19 Jan 2024 11:25:26 +0530 Subject: [PATCH 09/47] changed color --- lib/src/helper/filter_helper.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/helper/filter_helper.dart b/lib/src/helper/filter_helper.dart index 4f2761039..88a3b7452 100644 --- a/lib/src/helper/filter_helper.dart +++ b/lib/src/helper/filter_helper.dart @@ -547,7 +547,7 @@ class PlutoGridFilterPopupHeader extends StatelessWidget { onTap: handleClearButton, child: const Text( 'Clear Filter', - style: TextStyle(color: Colors.red), + style: TextStyle(color: Colors.blue), ), ), ], From c5aa98dae2993ecfc89f06aa96b74eb26e63af66 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Thu, 25 Jan 2024 12:38:45 +0530 Subject: [PATCH 10/47] add reset filter --- example/windows/runner/Runner.rc | 10 +-- lib/src/helper/filter_helper.dart | 77 ++++++++++------------ lib/src/ui/columns/pluto_column_title.dart | 69 +++++++++---------- 3 files changed, 73 insertions(+), 83 deletions(-) diff --git a/example/windows/runner/Runner.rc b/example/windows/runner/Runner.rc index 51812dcd4..e5666e022 100644 --- a/example/windows/runner/Runner.rc +++ b/example/windows/runner/Runner.rc @@ -60,14 +60,14 @@ IDI_APP_ICON ICON "resources\\app_icon.ico" // Version // -#ifdef FLUTTER_BUILD_NUMBER -#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD #else -#define VERSION_AS_NUMBER 1,0,0 +#define VERSION_AS_NUMBER 1,0,0,0 #endif -#ifdef FLUTTER_BUILD_NAME -#define VERSION_AS_STRING #FLUTTER_BUILD_NAME +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION #else #define VERSION_AS_STRING "1.0.0" #endif diff --git a/lib/src/helper/filter_helper.dart b/lib/src/helper/filter_helper.dart index 88a3b7452..6aca1c0ee 100644 --- a/lib/src/helper/filter_helper.dart +++ b/lib/src/helper/filter_helper.dart @@ -520,52 +520,47 @@ class PlutoGridFilterPopupHeader extends StatelessWidget { @override Widget build(BuildContext context) { - Size size = MediaQuery.sizeOf(context); - return SingleChildScrollView( scrollDirection: Axis.horizontal, - child: SizedBox( - width: size.width - 1328, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - IconButton( - icon: const Icon(Icons.add), - color: configuration!.style.iconColor, - iconSize: configuration!.style.iconSize, - onPressed: handleAddButton, - ), - IconButton( - icon: const Icon(Icons.remove), - color: configuration!.style.iconColor, - iconSize: configuration!.style.iconSize, - onPressed: handleRemoveButton, - ), - InkWell( - onTap: handleClearButton, - child: const Text( - 'Clear Filter', - style: TextStyle(color: Colors.blue), - ), - ), - ], - ), - ElevatedButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all(Colors.redAccent), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + IconButton( + icon: const Icon(Icons.add), + color: configuration!.style.iconColor, + iconSize: configuration!.style.iconSize, + onPressed: handleAddButton, + ), + IconButton( + icon: const Icon(Icons.remove), + color: configuration!.style.iconColor, + iconSize: configuration!.style.iconSize, + onPressed: handleRemoveButton, ), - onPressed: () { - Navigator.of(stateManager!.gridFocusNode.context!).pop(); - }, - child: const Text( - 'Close', - style: TextStyle(color: Colors.white), + InkWell( + onTap: handleClearButton, + child: const Text( + 'Clear Filter', + style: TextStyle(color: Colors.blue), + ), ), + ], + ), + ElevatedButton( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all(Colors.redAccent), + ), + onPressed: () { + Navigator.of(stateManager!.gridFocusNode.context!).pop(); + }, + child: const Text( + 'Close', + style: TextStyle(color: Colors.white), ), - ], - ), + ), + ], ), ); } diff --git a/lib/src/ui/columns/pluto_column_title.dart b/lib/src/ui/columns/pluto_column_title.dart index a9d46cd0f..12d2be2ca 100644 --- a/lib/src/ui/columns/pluto_column_title.dart +++ b/lib/src/ui/columns/pluto_column_title.dart @@ -31,9 +31,7 @@ class PlutoColumnTitleState extends PlutoStateWithChange { PlutoColumnSort _sort = PlutoColumnSort.none; bool get showContextIcon { - return widget.column.enableContextMenu || - widget.column.enableDropToResize || - !_sort.isNone; + return widget.column.enableContextMenu || widget.column.enableDropToResize || !_sort.isNone; } bool get enableGesture { @@ -42,9 +40,7 @@ class PlutoColumnTitleState extends PlutoStateWithChange { MouseCursor get contextMenuCursor { if (enableGesture) { - return widget.column.enableDropToResize - ? SystemMouseCursors.resizeLeftRight - : SystemMouseCursors.click; + return widget.column.enableDropToResize ? SystemMouseCursors.resizeLeftRight : SystemMouseCursors.click; } return SystemMouseCursors.basic; @@ -98,8 +94,7 @@ class PlutoColumnTitleState extends PlutoStateWithChange { void _handleOnPointMove(PointerMoveEvent event) { // if at least one movement event has distanceSquared > 0.5 _isPointMoving will be true - _isPointMoving |= - (_columnRightPosition - event.position).distanceSquared > 0.5; + _isPointMoving |= (_columnRightPosition - event.position).distanceSquared > 0.5; if (!_isPointMoving) return; @@ -144,9 +139,7 @@ class PlutoColumnTitleState extends PlutoStateWithChange { icon: PlutoGridColumnIcon( sort: _sort, color: style.iconColor, - icon: widget.column.enableContextMenu - ? style.columnContextIcon - : style.columnResizeIcon, + icon: widget.column.enableContextMenu ? style.columnContextIcon : style.columnResizeIcon, ascendingIcon: style.columnAscendingIcon, descendingIcon: style.columnDescendingIcon, ), @@ -279,8 +272,7 @@ class _DraggableWidget extends StatelessWidget { alignment: column.titleTextAlign.alignmentValue, width: PlutoGridSettings.minColumnWidth, height: stateManager.columnHeight, - backgroundColor: - stateManager.configuration.style.gridBackgroundColor, + backgroundColor: stateManager.configuration.style.gridBackgroundColor, borderColor: stateManager.configuration.style.gridBorderColor, child: Text( column.title, @@ -346,13 +338,9 @@ class _ColumnWidget extends StatelessWidget { Key? key, }) : super(key: key); - EdgeInsets get padding => - column.titlePadding ?? - stateManager.configuration.style.defaultColumnTitlePadding; + EdgeInsets get padding => column.titlePadding ?? stateManager.configuration.style.defaultColumnTitlePadding; - bool get showSizedBoxForIcon => - column.isShowRightIcon && - (column.titleTextAlign.isRight || stateManager.isRTL); + bool get showSizedBoxForIcon => column.isShowRightIcon && (column.titleTextAlign.isRight || stateManager.isRTL); @override Widget build(BuildContext context) { @@ -380,13 +368,9 @@ class _ColumnWidget extends StatelessWidget { height: height, child: DecoratedBox( decoration: BoxDecoration( - color: noDragTarget - ? column.backgroundColor - : style.dragTargetColumnColor, + color: noDragTarget ? column.backgroundColor : style.dragTargetColumnColor, border: BorderDirectional( - end: style.enableColumnBorderVertical - ? BorderSide(color: style.borderColor, width: 1.0) - : BorderSide.none, + end: style.enableColumnBorderVertical ? BorderSide(color: style.borderColor, width: 1.0) : BorderSide.none, ), ), child: Padding( @@ -395,8 +379,7 @@ class _ColumnWidget extends StatelessWidget { alignment: Alignment.centerLeft, child: Row( children: [ - if (column.enableRowChecked) - CheckboxAllSelectionWidget(stateManager: stateManager), + if (column.enableRowChecked) CheckboxAllSelectionWidget(stateManager: stateManager), Expanded( child: _ColumnTextWidget( column: column, @@ -419,16 +402,13 @@ class _ColumnWidget extends StatelessWidget { class CheckboxAllSelectionWidget extends PlutoStatefulWidget { final PlutoGridStateManager stateManager; - const CheckboxAllSelectionWidget({required this.stateManager, Key? key}) - : super(key: key); + const CheckboxAllSelectionWidget({required this.stateManager, Key? key}) : super(key: key); @override - CheckboxAllSelectionWidgetState createState() => - CheckboxAllSelectionWidgetState(); + CheckboxAllSelectionWidgetState createState() => CheckboxAllSelectionWidgetState(); } -class CheckboxAllSelectionWidgetState - extends PlutoStateWithChange { +class CheckboxAllSelectionWidgetState extends PlutoStateWithChange { bool? _checked; @override @@ -531,8 +511,7 @@ class _ColumnTextWidgetState extends PlutoStateWithChange<_ColumnTextWidget> { ); } - String? get _title => - widget.column.titleSpan == null ? widget.column.title : null; + String? get _title => widget.column.titleSpan == null ? widget.column.title : null; List get _children => [ if (widget.column.titleSpan != null) widget.column.titleSpan!, @@ -547,8 +526,24 @@ class _ColumnTextWidgetState extends PlutoStateWithChange<_ColumnTextWidget> { ), onPressed: _handleOnPressedFilter, constraints: BoxConstraints( - maxHeight: - widget.height + (PlutoGridSettings.rowBorderWidth * 2), + maxHeight: widget.height + (PlutoGridSettings.rowBorderWidth * 2), + ), + ), + ), + if (_isFilteredList) + WidgetSpan( + alignment: PlaceholderAlignment.middle, + child: IconButton( + icon: Icon( + Icons.filter_alt_off, + color: stateManager.configuration.style.iconColor, + size: stateManager.configuration.style.iconSize, + ), + onPressed: () { + stateManager.setFilter(null); + }, + constraints: BoxConstraints( + maxHeight: widget.height + (PlutoGridSettings.rowBorderWidth * 2), ), ), ), From 1da68ad2bf64b500b8d72ad639b27c9fc8cf3c54 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Thu, 25 Jan 2024 12:41:00 +0530 Subject: [PATCH 11/47] fixes --- lib/src/helper/filter_helper.dart | 3 +++ pubspec.yaml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/src/helper/filter_helper.dart b/lib/src/helper/filter_helper.dart index 6aca1c0ee..b3c7664db 100644 --- a/lib/src/helper/filter_helper.dart +++ b/lib/src/helper/filter_helper.dart @@ -548,6 +548,9 @@ class PlutoGridFilterPopupHeader extends StatelessWidget { ), ], ), + const SizedBox( + width: 5, + ), ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.redAccent), diff --git a/pubspec.yaml b/pubspec.yaml index 9ff0f667c..6699f9780 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pluto_grid description: PlutoGrid is a dataGrid that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS. (DataGrid, DataTable, Data Grid, Data Table, Sticky) -version: 7.0.2 +version: 7.0.3 homepage: https://pluto.weblaze.dev repository: https://github.com/bosskmk/pluto_grid From fd365dc5af57bcd940f2ea8379685b0c71c3eb2a Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Mon, 29 Jan 2024 09:44:12 +0530 Subject: [PATCH 12/47] made changes --- lib/src/helper/filter_helper.dart | 81 ++++++++++++---------- lib/src/ui/columns/pluto_column_title.dart | 27 ++++++++ 2 files changed, 70 insertions(+), 38 deletions(-) diff --git a/lib/src/helper/filter_helper.dart b/lib/src/helper/filter_helper.dart index b3c7664db..6f28868e0 100644 --- a/lib/src/helper/filter_helper.dart +++ b/lib/src/helper/filter_helper.dart @@ -520,50 +520,55 @@ class PlutoGridFilterPopupHeader extends StatelessWidget { @override Widget build(BuildContext context) { + Size size = MediaQuery.sizeOf(context); + return SingleChildScrollView( scrollDirection: Axis.horizontal, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - IconButton( - icon: const Icon(Icons.add), - color: configuration!.style.iconColor, - iconSize: configuration!.style.iconSize, - onPressed: handleAddButton, - ), - IconButton( - icon: const Icon(Icons.remove), - color: configuration!.style.iconColor, - iconSize: configuration!.style.iconSize, - onPressed: handleRemoveButton, - ), - InkWell( - onTap: handleClearButton, - child: const Text( - 'Clear Filter', - style: TextStyle(color: Colors.blue), + child: SizedBox( + width: size.width -1330, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + IconButton( + icon: const Icon(Icons.add), + color: configuration!.style.iconColor, + iconSize: configuration!.style.iconSize, + onPressed: handleAddButton, ), - ), - ], - ), - const SizedBox( - width: 5, - ), - ElevatedButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all(Colors.redAccent), + IconButton( + icon: const Icon(Icons.remove), + color: configuration!.style.iconColor, + iconSize: configuration!.style.iconSize, + onPressed: handleRemoveButton, + ), + InkWell( + onTap: handleClearButton, + child: const Text( + 'Clear Filter', + style: TextStyle(color: Colors.blue), + ), + ), + ], ), - onPressed: () { - Navigator.of(stateManager!.gridFocusNode.context!).pop(); - }, - child: const Text( - 'Close', - style: TextStyle(color: Colors.white), + const SizedBox( + width: 5, ), + ElevatedButton( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all(Colors.redAccent), + ), + onPressed: () { + Navigator.of(stateManager!.gridFocusNode.context!).pop(); + }, + child: const Text( + 'Close', + style: TextStyle(color: Colors.white), + ), ), - ], + ], + ), ), ); } diff --git a/lib/src/ui/columns/pluto_column_title.dart b/lib/src/ui/columns/pluto_column_title.dart index 12d2be2ca..7e2dd9f11 100644 --- a/lib/src/ui/columns/pluto_column_title.dart +++ b/lib/src/ui/columns/pluto_column_title.dart @@ -483,6 +483,33 @@ class _ColumnTextWidget extends PlutoStatefulWidget { _ColumnTextWidgetState createState() => _ColumnTextWidgetState(); } +abstract class IFilteringRowState { + List get filterRows; + + bool get hasFilter; + + void setFilter(FilteredListFilter? filter, {bool notify = true}); + + void setFilterWithFilterRows(List rows, {bool notify = true}); + + void setFilterRows(List rows); + + List filterRowsByField(String columnField); + + /// Check if the column is in a state with filtering applied. + bool isFilteredColumn(PlutoColumn column); + + void removeColumnsInFilterRows( + List columns, { + bool notify = true, + }); + + void showFilterPopup( + BuildContext context, { + PlutoColumn? calledColumn, + }); +} + class _ColumnTextWidgetState extends PlutoStateWithChange<_ColumnTextWidget> { bool _isFilteredList = false; From 489de53158758b7f8942dc23d99262121d46ae46 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Mon, 29 Jan 2024 09:54:45 +0530 Subject: [PATCH 13/47] fixes --- lib/src/ui/columns/pluto_column_title.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/ui/columns/pluto_column_title.dart b/lib/src/ui/columns/pluto_column_title.dart index 7e2dd9f11..68056f518 100644 --- a/lib/src/ui/columns/pluto_column_title.dart +++ b/lib/src/ui/columns/pluto_column_title.dart @@ -567,7 +567,9 @@ class _ColumnTextWidgetState extends PlutoStateWithChange<_ColumnTextWidget> { size: stateManager.configuration.style.iconSize, ), onPressed: () { - stateManager.setFilter(null); + setState(() { + stateManager.setFilter(null); + }); }, constraints: BoxConstraints( maxHeight: widget.height + (PlutoGridSettings.rowBorderWidth * 2), From a9e56da867118eed24894cbd798c66feada614bc Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Mon, 29 Jan 2024 10:30:54 +0530 Subject: [PATCH 14/47] fixes --- lib/src/helper/show_column_menu.dart | 8 +-- lib/src/pluto_dual_grid.dart | 59 +++++++--------------- lib/src/pluto_grid.dart | 4 +- lib/src/ui/columns/pluto_column_title.dart | 5 +- 4 files changed, 27 insertions(+), 49 deletions(-) diff --git a/lib/src/helper/show_column_menu.dart b/lib/src/helper/show_column_menu.dart index 878eab54c..0b039ce9d 100644 --- a/lib/src/helper/show_column_menu.dart +++ b/lib/src/helper/show_column_menu.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:pluto_grid/pluto_grid.dart'; +GlobalKey parentKey = GlobalKey(); + abstract class PlutoColumnMenuDelegate { List> buildMenuItems({ required PlutoGridStateManager stateManager, @@ -16,8 +18,7 @@ abstract class PlutoColumnMenuDelegate { }); } -class PlutoColumnMenuDelegateDefault - implements PlutoColumnMenuDelegate { +class PlutoColumnMenuDelegateDefault implements PlutoColumnMenuDelegate { const PlutoColumnMenuDelegateDefault(); @override @@ -81,8 +82,7 @@ Future? showColumnMenu({ required List> items, Color backgroundColor = Colors.white, }) { - final RenderBox overlay = - Overlay.of(context).context.findRenderObject() as RenderBox; + final RenderBox overlay = Overlay.of(context).context.findRenderObject() as RenderBox; return showMenu( context: context, diff --git a/lib/src/pluto_dual_grid.dart b/lib/src/pluto_dual_grid.dart index 167686ba1..200f28289 100644 --- a/lib/src/pluto_dual_grid.dart +++ b/lib/src/pluto_dual_grid.dart @@ -3,8 +3,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:pluto_grid/pluto_grid.dart'; -typedef PlutoDualOnSelectedEventCallback = void Function( - PlutoDualOnSelectedEvent event); +typedef PlutoDualOnSelectedEventCallback = void Function(PlutoDualOnSelectedEvent event); /// In [PlutoDualGrid], set the separation widget between the two grids. class PlutoDualGridDivider { @@ -84,8 +83,7 @@ class PlutoDualGridResizeNotifier extends ChangeNotifier { } class PlutoDualGridState extends State { - final PlutoDualGridResizeNotifier resizeNotifier = - PlutoDualGridResizeNotifier(); + final PlutoDualGridResizeNotifier resizeNotifier = PlutoDualGridResizeNotifier(); late final PlutoDualGridDisplay display; @@ -144,11 +142,9 @@ class PlutoDualGridState extends State { } if (isGridA) { - _streamA = - onLoadedEvent.stateManager.eventManager!.listener(handleEvent); + _streamA = onLoadedEvent.stateManager.eventManager!.listener(handleEvent); } else { - _streamB = - onLoadedEvent.stateManager.eventManager!.listener(handleEvent); + _streamB = onLoadedEvent.stateManager.eventManager!.listener(handleEvent); } if (props.onLoaded != null) { @@ -194,7 +190,7 @@ class PlutoDualGridState extends State { columnMenuDelegate: props.columnMenuDelegate, configuration: props.configuration, mode: mode, - key: props.key, + parentKey: props.key, ), ); } @@ -224,8 +220,7 @@ class PlutoDualGridState extends State { indicatorColor: widget.divider.indicatorColor, draggingColor: widget.divider.draggingColor, dragCallback: (details) { - final RenderBox object = - context.findRenderObject() as RenderBox; + final RenderBox object = context.findRenderObject() as RenderBox; display.offset = object .globalToLocal(Offset( @@ -266,12 +261,10 @@ class PlutoDualGridDividerWidget extends StatefulWidget { }) : super(key: key); @override - State createState() => - PlutoDualGridDividerWidgetState(); + State createState() => PlutoDualGridDividerWidgetState(); } -class PlutoDualGridDividerWidgetState - extends State { +class PlutoDualGridDividerWidgetState extends State { bool isDragging = false; void onHorizontalDragStart(DragStartDetails details) { @@ -355,8 +348,7 @@ class PlutoDualGridLayoutDelegate extends MultiChildLayoutDelegate { maxHeight: size.height, ); - final dividerHalf = - showDraggableDivider ? PlutoDualGrid.dividerWidth / 2 : 0; + final dividerHalf = showDraggableDivider ? PlutoDualGrid.dividerWidth / 2 : 0; final dividerWidth = dividerHalf * 2; @@ -613,33 +605,20 @@ class PlutoDualGridProps { return PlutoDualGridProps( columns: columns ?? this.columns, rows: rows ?? this.rows, - columnGroups: - columnGroups == null ? this.columnGroups : columnGroups.value, + columnGroups: columnGroups == null ? this.columnGroups : columnGroups.value, onLoaded: onLoaded == null ? this.onLoaded : onLoaded.value, onChanged: onChanged == null ? this.onChanged : onChanged.value, onSorted: onSorted == null ? this.onSorted : onSorted.value, - onRowChecked: - onRowChecked == null ? this.onRowChecked : onRowChecked.value, - onRowDoubleTap: - onRowDoubleTap == null ? this.onRowDoubleTap : onRowDoubleTap.value, - onRowSecondaryTap: onRowSecondaryTap == null - ? this.onRowSecondaryTap - : onRowSecondaryTap.value, + onRowChecked: onRowChecked == null ? this.onRowChecked : onRowChecked.value, + onRowDoubleTap: onRowDoubleTap == null ? this.onRowDoubleTap : onRowDoubleTap.value, + onRowSecondaryTap: onRowSecondaryTap == null ? this.onRowSecondaryTap : onRowSecondaryTap.value, onRowsMoved: onRowsMoved == null ? this.onRowsMoved : onRowsMoved.value, - onColumnsMoved: - onColumnsMoved == null ? this.onColumnsMoved : onColumnsMoved.value, - createHeader: - createHeader == null ? this.createHeader : createHeader.value, - createFooter: - createFooter == null ? this.createFooter : createFooter.value, - noRowsWidget: - noRowsWidget == null ? this.noRowsWidget : noRowsWidget.value, - rowColorCallback: rowColorCallback == null - ? this.rowColorCallback - : rowColorCallback.value, - columnMenuDelegate: columnMenuDelegate == null - ? this.columnMenuDelegate - : columnMenuDelegate.value, + onColumnsMoved: onColumnsMoved == null ? this.onColumnsMoved : onColumnsMoved.value, + createHeader: createHeader == null ? this.createHeader : createHeader.value, + createFooter: createFooter == null ? this.createFooter : createFooter.value, + noRowsWidget: noRowsWidget == null ? this.noRowsWidget : noRowsWidget.value, + rowColorCallback: rowColorCallback == null ? this.rowColorCallback : rowColorCallback.value, + columnMenuDelegate: columnMenuDelegate == null ? this.columnMenuDelegate : columnMenuDelegate.value, configuration: configuration ?? this.configuration, mode: mode == null ? this.mode : mode.value, key: key ?? this.key, diff --git a/lib/src/pluto_grid.dart b/lib/src/pluto_grid.dart index 54d8e96ee..dbed5aa21 100644 --- a/lib/src/pluto_grid.dart +++ b/lib/src/pluto_grid.dart @@ -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, + Key? parentKey, required this.columns, required this.rows, this.columnGroups, @@ -76,7 +76,7 @@ class PlutoGrid extends PlutoStatefulWidget { this.configuration = const PlutoGridConfiguration(), this.notifierFilterResolver, this.mode = PlutoGridMode.normal, - }) : super(key: key); + }) : super(key: parentKey); /// {@template pluto_grid_property_columns} /// The [PlutoColumn] column is delivered as a list and can be added or deleted after grid creation. diff --git a/lib/src/ui/columns/pluto_column_title.dart b/lib/src/ui/columns/pluto_column_title.dart index 68056f518..38cc75bac 100644 --- a/lib/src/ui/columns/pluto_column_title.dart +++ b/lib/src/ui/columns/pluto_column_title.dart @@ -567,9 +567,8 @@ class _ColumnTextWidgetState extends PlutoStateWithChange<_ColumnTextWidget> { size: stateManager.configuration.style.iconSize, ), onPressed: () { - setState(() { - stateManager.setFilter(null); - }); + stateManager.setFilter(null); + parentKey.currentState?.stateManager.setFilter(null); }, constraints: BoxConstraints( maxHeight: widget.height + (PlutoGridSettings.rowBorderWidth * 2), From db9ee034c42f98ac5f3b6fd84ee9e9b47ca8ad16 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Mon, 29 Jan 2024 10:56:28 +0530 Subject: [PATCH 15/47] changes --- lib/src/helper/show_column_menu.dart | 2 -- lib/src/ui/columns/pluto_column_title.dart | 11 +++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/src/helper/show_column_menu.dart b/lib/src/helper/show_column_menu.dart index 0b039ce9d..8cc4fbbf0 100644 --- a/lib/src/helper/show_column_menu.dart +++ b/lib/src/helper/show_column_menu.dart @@ -1,8 +1,6 @@ import 'package:flutter/material.dart'; import 'package:pluto_grid/pluto_grid.dart'; -GlobalKey parentKey = GlobalKey(); - abstract class PlutoColumnMenuDelegate { List> buildMenuItems({ required PlutoGridStateManager stateManager, diff --git a/lib/src/ui/columns/pluto_column_title.dart b/lib/src/ui/columns/pluto_column_title.dart index 38cc75bac..dc06fe4e1 100644 --- a/lib/src/ui/columns/pluto_column_title.dart +++ b/lib/src/ui/columns/pluto_column_title.dart @@ -467,7 +467,6 @@ class CheckboxAllSelectionWidgetState extends PlutoStateWithChange { @override PlutoGridStateManager get stateManager => widget.stateManager; - @override void initState() { super.initState(); @@ -538,6 +536,10 @@ class _ColumnTextWidgetState extends PlutoStateWithChange<_ColumnTextWidget> { ); } + void clearFilter() { + stateManager.setFilter(null); + } + String? get _title => widget.column.titleSpan == null ? widget.column.title : null; List get _children => [ @@ -566,10 +568,7 @@ class _ColumnTextWidgetState extends PlutoStateWithChange<_ColumnTextWidget> { color: stateManager.configuration.style.iconColor, size: stateManager.configuration.style.iconSize, ), - onPressed: () { - stateManager.setFilter(null); - parentKey.currentState?.stateManager.setFilter(null); - }, + onPressed: clearFilter, constraints: BoxConstraints( maxHeight: widget.height + (PlutoGridSettings.rowBorderWidth * 2), ), From 24b0abbd7596789332845c6c804efe5674419404 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Mon, 29 Jan 2024 10:57:44 +0530 Subject: [PATCH 16/47] changed key --- lib/src/pluto_grid.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/pluto_grid.dart b/lib/src/pluto_grid.dart index dbed5aa21..54d8e96ee 100644 --- a/lib/src/pluto_grid.dart +++ b/lib/src/pluto_grid.dart @@ -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? parentKey, + Key? key, required this.columns, required this.rows, this.columnGroups, @@ -76,7 +76,7 @@ class PlutoGrid extends PlutoStatefulWidget { this.configuration = const PlutoGridConfiguration(), this.notifierFilterResolver, this.mode = PlutoGridMode.normal, - }) : super(key: parentKey); + }) : 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. From 13f3cba138c219a5738c21d6622974023783d416 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Mon, 29 Jan 2024 11:01:03 +0530 Subject: [PATCH 17/47] parent --- lib/src/pluto_dual_grid.dart | 59 ++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/lib/src/pluto_dual_grid.dart b/lib/src/pluto_dual_grid.dart index 200f28289..167686ba1 100644 --- a/lib/src/pluto_dual_grid.dart +++ b/lib/src/pluto_dual_grid.dart @@ -3,7 +3,8 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:pluto_grid/pluto_grid.dart'; -typedef PlutoDualOnSelectedEventCallback = void Function(PlutoDualOnSelectedEvent event); +typedef PlutoDualOnSelectedEventCallback = void Function( + PlutoDualOnSelectedEvent event); /// In [PlutoDualGrid], set the separation widget between the two grids. class PlutoDualGridDivider { @@ -83,7 +84,8 @@ class PlutoDualGridResizeNotifier extends ChangeNotifier { } class PlutoDualGridState extends State { - final PlutoDualGridResizeNotifier resizeNotifier = PlutoDualGridResizeNotifier(); + final PlutoDualGridResizeNotifier resizeNotifier = + PlutoDualGridResizeNotifier(); late final PlutoDualGridDisplay display; @@ -142,9 +144,11 @@ class PlutoDualGridState extends State { } if (isGridA) { - _streamA = onLoadedEvent.stateManager.eventManager!.listener(handleEvent); + _streamA = + onLoadedEvent.stateManager.eventManager!.listener(handleEvent); } else { - _streamB = onLoadedEvent.stateManager.eventManager!.listener(handleEvent); + _streamB = + onLoadedEvent.stateManager.eventManager!.listener(handleEvent); } if (props.onLoaded != null) { @@ -190,7 +194,7 @@ class PlutoDualGridState extends State { columnMenuDelegate: props.columnMenuDelegate, configuration: props.configuration, mode: mode, - parentKey: props.key, + key: props.key, ), ); } @@ -220,7 +224,8 @@ class PlutoDualGridState extends State { indicatorColor: widget.divider.indicatorColor, draggingColor: widget.divider.draggingColor, dragCallback: (details) { - final RenderBox object = context.findRenderObject() as RenderBox; + final RenderBox object = + context.findRenderObject() as RenderBox; display.offset = object .globalToLocal(Offset( @@ -261,10 +266,12 @@ class PlutoDualGridDividerWidget extends StatefulWidget { }) : super(key: key); @override - State createState() => PlutoDualGridDividerWidgetState(); + State createState() => + PlutoDualGridDividerWidgetState(); } -class PlutoDualGridDividerWidgetState extends State { +class PlutoDualGridDividerWidgetState + extends State { bool isDragging = false; void onHorizontalDragStart(DragStartDetails details) { @@ -348,7 +355,8 @@ class PlutoDualGridLayoutDelegate extends MultiChildLayoutDelegate { maxHeight: size.height, ); - final dividerHalf = showDraggableDivider ? PlutoDualGrid.dividerWidth / 2 : 0; + final dividerHalf = + showDraggableDivider ? PlutoDualGrid.dividerWidth / 2 : 0; final dividerWidth = dividerHalf * 2; @@ -605,20 +613,33 @@ class PlutoDualGridProps { return PlutoDualGridProps( columns: columns ?? this.columns, rows: rows ?? this.rows, - columnGroups: columnGroups == null ? this.columnGroups : columnGroups.value, + columnGroups: + columnGroups == null ? this.columnGroups : columnGroups.value, onLoaded: onLoaded == null ? this.onLoaded : onLoaded.value, onChanged: onChanged == null ? this.onChanged : onChanged.value, onSorted: onSorted == null ? this.onSorted : onSorted.value, - onRowChecked: onRowChecked == null ? this.onRowChecked : onRowChecked.value, - onRowDoubleTap: onRowDoubleTap == null ? this.onRowDoubleTap : onRowDoubleTap.value, - onRowSecondaryTap: onRowSecondaryTap == null ? this.onRowSecondaryTap : onRowSecondaryTap.value, + onRowChecked: + onRowChecked == null ? this.onRowChecked : onRowChecked.value, + onRowDoubleTap: + onRowDoubleTap == null ? this.onRowDoubleTap : onRowDoubleTap.value, + onRowSecondaryTap: onRowSecondaryTap == null + ? this.onRowSecondaryTap + : onRowSecondaryTap.value, onRowsMoved: onRowsMoved == null ? this.onRowsMoved : onRowsMoved.value, - onColumnsMoved: onColumnsMoved == null ? this.onColumnsMoved : onColumnsMoved.value, - createHeader: createHeader == null ? this.createHeader : createHeader.value, - createFooter: createFooter == null ? this.createFooter : createFooter.value, - noRowsWidget: noRowsWidget == null ? this.noRowsWidget : noRowsWidget.value, - rowColorCallback: rowColorCallback == null ? this.rowColorCallback : rowColorCallback.value, - columnMenuDelegate: columnMenuDelegate == null ? this.columnMenuDelegate : columnMenuDelegate.value, + onColumnsMoved: + onColumnsMoved == null ? this.onColumnsMoved : onColumnsMoved.value, + createHeader: + createHeader == null ? this.createHeader : createHeader.value, + createFooter: + createFooter == null ? this.createFooter : createFooter.value, + noRowsWidget: + noRowsWidget == null ? this.noRowsWidget : noRowsWidget.value, + rowColorCallback: rowColorCallback == null + ? this.rowColorCallback + : rowColorCallback.value, + columnMenuDelegate: columnMenuDelegate == null + ? this.columnMenuDelegate + : columnMenuDelegate.value, configuration: configuration ?? this.configuration, mode: mode == null ? this.mode : mode.value, key: key ?? this.key, From d7c307d754af95f74107fd26c31713ae8548778d Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Mon, 29 Jan 2024 11:09:53 +0530 Subject: [PATCH 18/47] state --- lib/src/pluto_dual_grid.dart | 57 +++++++--------------- lib/src/ui/columns/pluto_column_title.dart | 1 + 2 files changed, 19 insertions(+), 39 deletions(-) diff --git a/lib/src/pluto_dual_grid.dart b/lib/src/pluto_dual_grid.dart index 167686ba1..9035ed39b 100644 --- a/lib/src/pluto_dual_grid.dart +++ b/lib/src/pluto_dual_grid.dart @@ -3,8 +3,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:pluto_grid/pluto_grid.dart'; -typedef PlutoDualOnSelectedEventCallback = void Function( - PlutoDualOnSelectedEvent event); +typedef PlutoDualOnSelectedEventCallback = void Function(PlutoDualOnSelectedEvent event); /// In [PlutoDualGrid], set the separation widget between the two grids. class PlutoDualGridDivider { @@ -84,8 +83,7 @@ class PlutoDualGridResizeNotifier extends ChangeNotifier { } class PlutoDualGridState extends State { - final PlutoDualGridResizeNotifier resizeNotifier = - PlutoDualGridResizeNotifier(); + final PlutoDualGridResizeNotifier resizeNotifier = PlutoDualGridResizeNotifier(); late final PlutoDualGridDisplay display; @@ -144,11 +142,9 @@ class PlutoDualGridState extends State { } if (isGridA) { - _streamA = - onLoadedEvent.stateManager.eventManager!.listener(handleEvent); + _streamA = onLoadedEvent.stateManager.eventManager!.listener(handleEvent); } else { - _streamB = - onLoadedEvent.stateManager.eventManager!.listener(handleEvent); + _streamB = onLoadedEvent.stateManager.eventManager!.listener(handleEvent); } if (props.onLoaded != null) { @@ -224,8 +220,7 @@ class PlutoDualGridState extends State { indicatorColor: widget.divider.indicatorColor, draggingColor: widget.divider.draggingColor, dragCallback: (details) { - final RenderBox object = - context.findRenderObject() as RenderBox; + final RenderBox object = context.findRenderObject() as RenderBox; display.offset = object .globalToLocal(Offset( @@ -266,12 +261,10 @@ class PlutoDualGridDividerWidget extends StatefulWidget { }) : super(key: key); @override - State createState() => - PlutoDualGridDividerWidgetState(); + State createState() => PlutoDualGridDividerWidgetState(); } -class PlutoDualGridDividerWidgetState - extends State { +class PlutoDualGridDividerWidgetState extends State { bool isDragging = false; void onHorizontalDragStart(DragStartDetails details) { @@ -355,8 +348,7 @@ class PlutoDualGridLayoutDelegate extends MultiChildLayoutDelegate { maxHeight: size.height, ); - final dividerHalf = - showDraggableDivider ? PlutoDualGrid.dividerWidth / 2 : 0; + final dividerHalf = showDraggableDivider ? PlutoDualGrid.dividerWidth / 2 : 0; final dividerWidth = dividerHalf * 2; @@ -613,33 +605,20 @@ class PlutoDualGridProps { return PlutoDualGridProps( columns: columns ?? this.columns, rows: rows ?? this.rows, - columnGroups: - columnGroups == null ? this.columnGroups : columnGroups.value, + columnGroups: columnGroups == null ? this.columnGroups : columnGroups.value, onLoaded: onLoaded == null ? this.onLoaded : onLoaded.value, onChanged: onChanged == null ? this.onChanged : onChanged.value, onSorted: onSorted == null ? this.onSorted : onSorted.value, - onRowChecked: - onRowChecked == null ? this.onRowChecked : onRowChecked.value, - onRowDoubleTap: - onRowDoubleTap == null ? this.onRowDoubleTap : onRowDoubleTap.value, - onRowSecondaryTap: onRowSecondaryTap == null - ? this.onRowSecondaryTap - : onRowSecondaryTap.value, + onRowChecked: onRowChecked == null ? this.onRowChecked : onRowChecked.value, + onRowDoubleTap: onRowDoubleTap == null ? this.onRowDoubleTap : onRowDoubleTap.value, + onRowSecondaryTap: onRowSecondaryTap == null ? this.onRowSecondaryTap : onRowSecondaryTap.value, onRowsMoved: onRowsMoved == null ? this.onRowsMoved : onRowsMoved.value, - onColumnsMoved: - onColumnsMoved == null ? this.onColumnsMoved : onColumnsMoved.value, - createHeader: - createHeader == null ? this.createHeader : createHeader.value, - createFooter: - createFooter == null ? this.createFooter : createFooter.value, - noRowsWidget: - noRowsWidget == null ? this.noRowsWidget : noRowsWidget.value, - rowColorCallback: rowColorCallback == null - ? this.rowColorCallback - : rowColorCallback.value, - columnMenuDelegate: columnMenuDelegate == null - ? this.columnMenuDelegate - : columnMenuDelegate.value, + onColumnsMoved: onColumnsMoved == null ? this.onColumnsMoved : onColumnsMoved.value, + createHeader: createHeader == null ? this.createHeader : createHeader.value, + createFooter: createFooter == null ? this.createFooter : createFooter.value, + noRowsWidget: noRowsWidget == null ? this.noRowsWidget : noRowsWidget.value, + rowColorCallback: rowColorCallback == null ? this.rowColorCallback : rowColorCallback.value, + columnMenuDelegate: columnMenuDelegate == null ? this.columnMenuDelegate : columnMenuDelegate.value, configuration: configuration ?? this.configuration, mode: mode == null ? this.mode : mode.value, key: key ?? this.key, diff --git a/lib/src/ui/columns/pluto_column_title.dart b/lib/src/ui/columns/pluto_column_title.dart index dc06fe4e1..9640978be 100644 --- a/lib/src/ui/columns/pluto_column_title.dart +++ b/lib/src/ui/columns/pluto_column_title.dart @@ -538,6 +538,7 @@ class _ColumnTextWidgetState extends PlutoStateWithChange<_ColumnTextWidget> { void clearFilter() { stateManager.setFilter(null); + updateState(PlutoNotifierEventForceUpdate.instance); } String? get _title => widget.column.titleSpan == null ? widget.column.title : null; From 99618245a2b70f04076a23b605cba4a8f447a5de Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Mon, 29 Jan 2024 11:32:32 +0530 Subject: [PATCH 19/47] changes --- lib/src/ui/columns/pluto_column_title.dart | 27 ++++++++++------------ 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/src/ui/columns/pluto_column_title.dart b/lib/src/ui/columns/pluto_column_title.dart index 9640978be..db8c55c55 100644 --- a/lib/src/ui/columns/pluto_column_title.dart +++ b/lib/src/ui/columns/pluto_column_title.dart @@ -517,7 +517,6 @@ class _ColumnTextWidgetState extends PlutoStateWithChange<_ColumnTextWidget> { @override void initState() { super.initState(); - updateState(PlutoNotifierEventForceUpdate.instance); } @@ -538,7 +537,6 @@ class _ColumnTextWidgetState extends PlutoStateWithChange<_ColumnTextWidget> { void clearFilter() { stateManager.setFilter(null); - updateState(PlutoNotifierEventForceUpdate.instance); } String? get _title => widget.column.titleSpan == null ? widget.column.title : null; @@ -560,21 +558,20 @@ class _ColumnTextWidgetState extends PlutoStateWithChange<_ColumnTextWidget> { ), ), ), - if (_isFilteredList) - WidgetSpan( - alignment: PlaceholderAlignment.middle, - child: IconButton( - icon: Icon( - Icons.filter_alt_off, - color: stateManager.configuration.style.iconColor, - size: stateManager.configuration.style.iconSize, - ), - onPressed: clearFilter, - constraints: BoxConstraints( - maxHeight: widget.height + (PlutoGridSettings.rowBorderWidth * 2), - ), + WidgetSpan( + alignment: PlaceholderAlignment.middle, + child: IconButton( + icon: Icon( + Icons.filter_alt_off, + color: stateManager.configuration.style.iconColor, + size: stateManager.configuration.style.iconSize, + ), + onPressed: clearFilter, + constraints: BoxConstraints( + maxHeight: widget.height + (PlutoGridSettings.rowBorderWidth * 2), ), ), + ), ]; @override From 7ba7d35ae5a955b7086b97e354a63515e0fc3ae7 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Mon, 29 Jan 2024 11:36:42 +0530 Subject: [PATCH 20/47] revert --- lib/src/ui/columns/pluto_column_title.dart | 26 ++++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/src/ui/columns/pluto_column_title.dart b/lib/src/ui/columns/pluto_column_title.dart index db8c55c55..400e8166b 100644 --- a/lib/src/ui/columns/pluto_column_title.dart +++ b/lib/src/ui/columns/pluto_column_title.dart @@ -537,6 +537,7 @@ class _ColumnTextWidgetState extends PlutoStateWithChange<_ColumnTextWidget> { void clearFilter() { stateManager.setFilter(null); + debugPrint("clear filter called"); } String? get _title => widget.column.titleSpan == null ? widget.column.title : null; @@ -558,20 +559,21 @@ class _ColumnTextWidgetState extends PlutoStateWithChange<_ColumnTextWidget> { ), ), ), - WidgetSpan( - alignment: PlaceholderAlignment.middle, - child: IconButton( - icon: Icon( - Icons.filter_alt_off, - color: stateManager.configuration.style.iconColor, - size: stateManager.configuration.style.iconSize, - ), - onPressed: clearFilter, - constraints: BoxConstraints( - maxHeight: widget.height + (PlutoGridSettings.rowBorderWidth * 2), + if (_isFilteredList) + WidgetSpan( + alignment: PlaceholderAlignment.middle, + child: IconButton( + icon: Icon( + Icons.filter_alt_off, + color: stateManager.configuration.style.iconColor, + size: stateManager.configuration.style.iconSize, + ), + onPressed: clearFilter, + constraints: BoxConstraints( + maxHeight: widget.height + (PlutoGridSettings.rowBorderWidth * 2), + ), ), ), - ), ]; @override From 41c5f4bddc6c14f937c9b0b24642d15f8ed7732b Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Mon, 29 Jan 2024 12:09:51 +0530 Subject: [PATCH 21/47] reset --- lib/src/manager/state/filtering_row_state.dart | 2 +- lib/src/ui/columns/pluto_column_title.dart | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/src/manager/state/filtering_row_state.dart b/lib/src/manager/state/filtering_row_state.dart index 1db515b4d..b7b5b63e1 100644 --- a/lib/src/manager/state/filtering_row_state.dart +++ b/lib/src/manager/state/filtering_row_state.dart @@ -73,7 +73,7 @@ mixin FilteringRowState implements IPlutoGridState { refRows.setFilter(savedFilter); } - resetCurrentState(notify: false); + resetCurrentState(notify: true); notifyListeners(notify, setFilter.hashCode); } diff --git a/lib/src/ui/columns/pluto_column_title.dart b/lib/src/ui/columns/pluto_column_title.dart index 400e8166b..3ec77419f 100644 --- a/lib/src/ui/columns/pluto_column_title.dart +++ b/lib/src/ui/columns/pluto_column_title.dart @@ -536,7 +536,9 @@ class _ColumnTextWidgetState extends PlutoStateWithChange<_ColumnTextWidget> { } void clearFilter() { - stateManager.setFilter(null); + stateManager.setFilter( + null, + ); debugPrint("clear filter called"); } From 566d0f7ef9a4bceec52eb784ebc80ddef3417b47 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Mon, 29 Jan 2024 13:23:05 +0530 Subject: [PATCH 22/47] fixes --- lib/src/ui/columns/pluto_column_title.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/src/ui/columns/pluto_column_title.dart b/lib/src/ui/columns/pluto_column_title.dart index 3ec77419f..b42b70e62 100644 --- a/lib/src/ui/columns/pluto_column_title.dart +++ b/lib/src/ui/columns/pluto_column_title.dart @@ -539,6 +539,8 @@ class _ColumnTextWidgetState extends PlutoStateWithChange<_ColumnTextWidget> { stateManager.setFilter( null, ); + stateManager.setPage(1); + debugPrint("clear filter called"); } From 1f60c2218a73626bfc952f0b8b98b7f6d1f4197f Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Mon, 29 Jan 2024 13:37:07 +0530 Subject: [PATCH 23/47] filter final push --- lib/src/ui/columns/pluto_column_title.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/src/ui/columns/pluto_column_title.dart b/lib/src/ui/columns/pluto_column_title.dart index b42b70e62..08be6f7f8 100644 --- a/lib/src/ui/columns/pluto_column_title.dart +++ b/lib/src/ui/columns/pluto_column_title.dart @@ -540,8 +540,6 @@ class _ColumnTextWidgetState extends PlutoStateWithChange<_ColumnTextWidget> { null, ); stateManager.setPage(1); - - debugPrint("clear filter called"); } String? get _title => widget.column.titleSpan == null ? widget.column.title : null; From 830f439222e2eaf1485b6882b0b3eb7b9ebffae7 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Wed, 7 Feb 2024 17:11:32 +0530 Subject: [PATCH 24/47] updated --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 6699f9780..0cd433205 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pluto_grid description: PlutoGrid is a dataGrid that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS. (DataGrid, DataTable, Data Grid, Data Table, Sticky) -version: 7.0.3 +version: 7.0.4 homepage: https://pluto.weblaze.dev repository: https://github.com/bosskmk/pluto_grid From c7a0e64128129ce6280b15fb68294a5d60ce20fd Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Wed, 7 Feb 2024 17:27:20 +0530 Subject: [PATCH 25/47] made changes --- pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 0cd433205..ad2152c73 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,8 +1,8 @@ name: pluto_grid description: PlutoGrid is a dataGrid that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS. (DataGrid, DataTable, Data Grid, Data Table, Sticky) -version: 7.0.4 +version: 7.0.5 homepage: https://pluto.weblaze.dev -repository: https://github.com/bosskmk/pluto_grid +repository: https://github.com/videalphatech/pluto_grid_modified environment: sdk: ">=2.17.0 <3.0.0" From fa236191e318cfb1a7dd909d6f1444ae2ec60fef Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Wed, 7 Feb 2024 17:35:38 +0530 Subject: [PATCH 26/47] new version --- pubspec.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index ad2152c73..0f98b1783 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,11 +1,12 @@ name: pluto_grid description: PlutoGrid is a dataGrid that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS. (DataGrid, DataTable, Data Grid, Data Table, Sticky) -version: 7.0.5 +version: 7.0.6 + homepage: https://pluto.weblaze.dev repository: https://github.com/videalphatech/pluto_grid_modified environment: - sdk: ">=2.17.0 <3.0.0" + sdk: '>=3.0.3 <4.0.0' flutter: ">=2.5.0" dependencies: From f11947b32735d1f3e8370080c56cee6a80f366d3 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Wed, 7 Feb 2024 18:17:03 +0530 Subject: [PATCH 27/47] changes --- lib/src/helper/filter_helper.dart | 8 ++++---- pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/src/helper/filter_helper.dart b/lib/src/helper/filter_helper.dart index 6f28868e0..858e2bace 100644 --- a/lib/src/helper/filter_helper.dart +++ b/lib/src/helper/filter_helper.dart @@ -525,9 +525,9 @@ class PlutoGridFilterPopupHeader extends StatelessWidget { return SingleChildScrollView( scrollDirection: Axis.horizontal, child: SizedBox( - width: size.width -1330, + width: size.width - 1330, child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ @@ -553,7 +553,7 @@ class PlutoGridFilterPopupHeader extends StatelessWidget { ], ), const SizedBox( - width: 5, + width: 370, ), ElevatedButton( style: ButtonStyle( @@ -566,7 +566,7 @@ class PlutoGridFilterPopupHeader extends StatelessWidget { 'Close', style: TextStyle(color: Colors.white), ), - ), + ), ], ), ), diff --git a/pubspec.yaml b/pubspec.yaml index 0f98b1783..ad8a0b017 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pluto_grid description: PlutoGrid is a dataGrid that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS. (DataGrid, DataTable, Data Grid, Data Table, Sticky) -version: 7.0.6 +version: 7.0.7 homepage: https://pluto.weblaze.dev repository: https://github.com/videalphatech/pluto_grid_modified From 0486b8d23d0dca4fb679c56ac5728b99e735b67c Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Thu, 8 Feb 2024 00:19:10 +0530 Subject: [PATCH 28/47] change --- lib/src/helper/filter_helper.dart | 85 +++++++++++++++---------------- 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/lib/src/helper/filter_helper.dart b/lib/src/helper/filter_helper.dart index 858e2bace..074f4b055 100644 --- a/lib/src/helper/filter_helper.dart +++ b/lib/src/helper/filter_helper.dart @@ -521,54 +521,49 @@ class PlutoGridFilterPopupHeader extends StatelessWidget { @override Widget build(BuildContext context) { Size size = MediaQuery.sizeOf(context); - - return SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: SizedBox( - width: size.width - 1330, - child: Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - IconButton( - icon: const Icon(Icons.add), - color: configuration!.style.iconColor, - iconSize: configuration!.style.iconSize, - onPressed: handleAddButton, - ), - IconButton( - icon: const Icon(Icons.remove), - color: configuration!.style.iconColor, - iconSize: configuration!.style.iconSize, - onPressed: handleRemoveButton, - ), - InkWell( - onTap: handleClearButton, - child: const Text( - 'Clear Filter', - style: TextStyle(color: Colors.blue), - ), - ), - ], - ), - const SizedBox( - width: 370, - ), - ElevatedButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all(Colors.redAccent), + return SizedBox( + width: size.width , + child: Row( + children: [ + Row( + children: [ + IconButton( + icon: const Icon(Icons.add), + color: configuration!.style.iconColor, + iconSize: configuration!.style.iconSize, + onPressed: handleAddButton, + ), + IconButton( + icon: const Icon(Icons.remove), + color: configuration!.style.iconColor, + iconSize: configuration!.style.iconSize, + onPressed: handleRemoveButton, ), - onPressed: () { - Navigator.of(stateManager!.gridFocusNode.context!).pop(); - }, - child: const Text( - 'Close', - style: TextStyle(color: Colors.white), + InkWell( + onTap: handleClearButton, + child: const Text( + 'Clear Filter', + style: TextStyle(color: Colors.blue), + ), ), + ], + ), + const SizedBox( + width: 370, + ), + ElevatedButton( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all(Colors.redAccent), + ), + onPressed: () { + Navigator.of(stateManager!.gridFocusNode.context!).pop(); + }, + child: const Text( + 'Close', + style: TextStyle(color: Colors.white), ), - ], - ), + ), + ], ), ); } From 9f7e2671ae00768b8c18fcc47b3361511effffca Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Thu, 8 Feb 2024 09:49:11 +0530 Subject: [PATCH 29/47] updated version with changes --- lib/src/helper/show_column_menu.dart | 90 +--------------------- lib/src/ui/columns/pluto_column_title.dart | 23 ++---- pubspec.yaml | 2 +- 3 files changed, 9 insertions(+), 106 deletions(-) diff --git a/lib/src/helper/show_column_menu.dart b/lib/src/helper/show_column_menu.dart index 8cc4fbbf0..5fa5d5944 100644 --- a/lib/src/helper/show_column_menu.dart +++ b/lib/src/helper/show_column_menu.dart @@ -39,34 +39,10 @@ class PlutoColumnMenuDelegateDefault implements PlutoColumnMenuDelegate> _getDefaultColumnMenuItems({ required PlutoColumn column, }) { final Color textColor = stateManager.style.cellTextStyle.color!; - - final Color disableTextColor = textColor.withOpacity(0.5); - - final bool enoughFrozenColumnsWidth = stateManager.enoughFrozenColumnsWidth( - stateManager.maxWidth! - column.width, - ); - final localeText = stateManager.localeText; return [ - if (column.frozen.isFrozen == true) - _buildMenuItem( - value: PlutoGridColumnMenuItem.unfreeze, - text: localeText.unfreezeColumn, - textColor: textColor, - ), - if (column.frozen.isFrozen != true) ...[ - _buildMenuItem( - value: PlutoGridColumnMenuItem.freezeToStart, - enabled: enoughFrozenColumnsWidth, - text: localeText.freezeColumnToStart, - textColor: enoughFrozenColumnsWidth ? textColor : disableTextColor, - ), - _buildMenuItem( - value: PlutoGridColumnMenuItem.freezeToEnd, - enabled: enoughFrozenColumnsWidth, - text: localeText.freezeColumnToEnd, - textColor: enoughFrozenColumnsWidth ? textColor : disableTextColor, - ), - ], - const PopupMenuDivider(), _buildMenuItem( - value: PlutoGridColumnMenuItem.autoFit, - text: localeText.autoFitColumn, + value: PlutoGridColumnMenuItem.setFilter, + text: localeText.setFilter, textColor: textColor, ), - if (column.enableHideColumnMenuItem == true) - _buildMenuItem( - value: PlutoGridColumnMenuItem.hideColumn, - text: localeText.hideColumn, - textColor: textColor, - enabled: stateManager.refColumns.length > 1, - ), - if (column.enableSetColumnsMenuItem == true) - _buildMenuItem( - value: PlutoGridColumnMenuItem.setColumns, - text: localeText.setColumns, - textColor: textColor, - ), - if (column.enableFilterMenuItem == true) ...[ - const PopupMenuDivider(), - _buildMenuItem( - value: PlutoGridColumnMenuItem.setFilter, - text: localeText.setFilter, - textColor: textColor, - ), - _buildMenuItem( - value: PlutoGridColumnMenuItem.resetFilter, - text: localeText.resetFilter, - textColor: textColor, - enabled: stateManager.hasFilter, - ), - ], ]; } @@ -189,12 +110,5 @@ PopupMenuItem _buildMenuItem({ /// Items in the context menu on the right side of the column enum PlutoGridColumnMenuItem { - unfreeze, - freezeToStart, - freezeToEnd, - hideColumn, - setColumns, - autoFit, setFilter, - resetFilter, } diff --git a/lib/src/ui/columns/pluto_column_title.dart b/lib/src/ui/columns/pluto_column_title.dart index 08be6f7f8..1d5d6b42c 100644 --- a/lib/src/ui/columns/pluto_column_title.dart +++ b/lib/src/ui/columns/pluto_column_title.dart @@ -65,25 +65,14 @@ class PlutoColumnTitleState extends PlutoStateWithChange { } void _showContextMenu(BuildContext context, Offset position) async { - final selected = await showColumnMenu( + // Execute the action associated with "Set Filter" + stateManager.columnMenuDelegate.onSelected( context: context, - position: position, - backgroundColor: stateManager.style.menuBackgroundColor, - items: stateManager.columnMenuDelegate.buildMenuItems( - stateManager: stateManager, - column: widget.column, - ), + stateManager: stateManager, + column: widget.column, + mounted: mounted, + selected: PlutoGridColumnMenuItem.setFilter, // Directly pass the option ); - - if (context.mounted) { - stateManager.columnMenuDelegate.onSelected( - context: context, - stateManager: stateManager, - column: widget.column, - mounted: mounted, - selected: selected, - ); - } } void _handleOnPointDown(PointerDownEvent event) { diff --git a/pubspec.yaml b/pubspec.yaml index ad8a0b017..58d1ccb65 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pluto_grid description: PlutoGrid is a dataGrid that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS. (DataGrid, DataTable, Data Grid, Data Table, Sticky) -version: 7.0.7 +version: 7.0.8 homepage: https://pluto.weblaze.dev repository: https://github.com/videalphatech/pluto_grid_modified From 7fece6c17f4f6f4499457ac0a3cab71640145179 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Thu, 15 Feb 2024 10:46:14 +0530 Subject: [PATCH 30/47] migrated to latest version --- .fvm/fvm_config.json | 4 +- .vscode/git-commit.js | 2 + .vscode/git-push.js | 2 + .vscode/git-stage.js | 2 + .vscode/settings.json | 11 + example/lib/main.dart | 1 + lib/src/helper/filter_helper.dart | 2 +- lib/src/manager/pluto_grid_state_manager.dart | 1 - lib/src/manager/state/column_state.dart | 2 + lib/src/model/pluto_column_type.dart | 199 +++++++++++++++--- pubspec.yaml | 8 +- 11 files changed, 202 insertions(+), 32 deletions(-) create mode 100644 .vscode/git-commit.js create mode 100644 .vscode/git-push.js create mode 100644 .vscode/git-stage.js create mode 100644 .vscode/settings.json diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json index 41959e974..3e7195748 100644 --- a/.fvm/fvm_config.json +++ b/.fvm/fvm_config.json @@ -1,4 +1,4 @@ { - "flutterSdkVersion": "stable", + "flutterSdkVersion": "3.16.9", "flavors": {} -} +} \ No newline at end of file diff --git a/.vscode/git-commit.js b/.vscode/git-commit.js new file mode 100644 index 000000000..54e8861e2 --- /dev/null +++ b/.vscode/git-commit.js @@ -0,0 +1,2 @@ +const { exec } = require('child_process'); +exec('git commit -m "latest_deployment"'); \ No newline at end of file diff --git a/.vscode/git-push.js b/.vscode/git-push.js new file mode 100644 index 000000000..02b693a1a --- /dev/null +++ b/.vscode/git-push.js @@ -0,0 +1,2 @@ +const { exec } = require('child_process'); +exec('git push origin'); \ No newline at end of file diff --git a/.vscode/git-stage.js b/.vscode/git-stage.js new file mode 100644 index 000000000..77bb6e082 --- /dev/null +++ b/.vscode/git-stage.js @@ -0,0 +1,2 @@ +const { exec } = require('child_process'); +exec('git add .'); diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..1cb16cec3 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,11 @@ +{ + "dart.flutterSdkPath": ".fvm/flutter_sdk", + // Remove .fvm files from search + "search.exclude": { + "**/.fvm": true + }, + // Remove from file watching + "files.watcherExclude": { + "**/.fvm": true + } + } \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index 260b5266f..67403072a 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -13,6 +13,7 @@ class MyApp extends StatelessWidget { return MaterialApp( title: 'PlutoGrid Example', theme: ThemeData( + useMaterial3: false, primarySwatch: Colors.blue, ), home: const PlutoGridExamplePage(), diff --git a/lib/src/helper/filter_helper.dart b/lib/src/helper/filter_helper.dart index 074f4b055..b28e22dbc 100644 --- a/lib/src/helper/filter_helper.dart +++ b/lib/src/helper/filter_helper.dart @@ -522,7 +522,7 @@ class PlutoGridFilterPopupHeader extends StatelessWidget { Widget build(BuildContext context) { Size size = MediaQuery.sizeOf(context); return SizedBox( - width: size.width , + width: size.width, child: Row( children: [ Row( diff --git a/lib/src/manager/pluto_grid_state_manager.dart b/lib/src/manager/pluto_grid_state_manager.dart index 5e0a6f031..fc0dcfa2a 100644 --- a/lib/src/manager/pluto_grid_state_manager.dart +++ b/lib/src/manager/pluto_grid_state_manager.dart @@ -186,7 +186,6 @@ class PlutoGridStateChangeNotifier extends PlutoChangeNotifier /// onLoaded: (PlutoGridOnLoadedEvent event) => stateManager = event.stateManager, /// ) /// ``` -/// {@template initialize_rows_sync_or_async} /// It is created when [PlutoGrid] is first created, /// and the state required for the grid is set for `List rows`. /// [PlutoGridStateManager.initializeRows], which operates at this time, works synchronously, diff --git a/lib/src/manager/state/column_state.dart b/lib/src/manager/state/column_state.dart index 77109320d..04f22ea03 100644 --- a/lib/src/manager/state/column_state.dart +++ b/lib/src/manager/state/column_state.dart @@ -1,3 +1,5 @@ +// ignore_for_file: prefer_null_aware_operators + import 'dart:collection'; import 'package:flutter/material.dart'; diff --git a/lib/src/model/pluto_column_type.dart b/lib/src/model/pluto_column_type.dart index 12203c48b..dae7fa9b0 100644 --- a/lib/src/model/pluto_column_type.dart +++ b/lib/src/model/pluto_column_type.dart @@ -13,6 +13,15 @@ abstract class PlutoColumnType { ); } + /// Set as a boolean column. + factory PlutoColumnType.boolean({ + dynamic defaultValue = false, + }) { + return PlutoColumnTypeBoolean( + defaultValue: defaultValue, + ); + } + /// Set to numeric column. /// /// [format] @@ -31,7 +40,7 @@ abstract class PlutoColumnType { factory PlutoColumnType.number({ dynamic defaultValue = 0, bool negative = true, - String format = '#,###', + String format = '#,###.#######', bool applyFormatOnInit = true, bool allowFirstDot = false, String? locale, @@ -46,6 +55,25 @@ abstract class PlutoColumnType { ); } +//this sorting is custom build for sorting double + factory PlutoColumnType.double({ + dynamic defaultValue = 0.0, + bool negative = true, + String format = '#,###.#######', + bool applyFormatOnInit = true, + bool allowFirstDot = false, + String? locale, + }) { + return PlutoColumnTypeDouble( + defaultValue: defaultValue, + format: format, + negative: negative, + applyFormatOnInit: applyFormatOnInit, + allowFirstDot: allowFirstDot, + locale: locale, + ); + } + /// Set to currency column. /// /// [format] @@ -224,11 +252,37 @@ extension PlutoColumnTypeExtension on PlutoColumnType { bool get hasFormat => this is PlutoColumnTypeHasFormat; - bool get applyFormatOnInit => - hasFormat ? (this as PlutoColumnTypeHasFormat).applyFormatOnInit : false; + bool get applyFormatOnInit => hasFormat ? (this as PlutoColumnTypeHasFormat).applyFormatOnInit : false; + + dynamic applyFormat(dynamic value) => hasFormat ? (this as PlutoColumnTypeHasFormat).applyFormat(value) : value; +} + +class PlutoColumnTypeBoolean implements PlutoColumnType { + @override + final dynamic defaultValue; + + const PlutoColumnTypeBoolean({ + this.defaultValue, + }); + + @override + bool isValid(dynamic value) { + return value is bool; + } + + @override + int compare(dynamic a, dynamic b) { + bool boolA = a == null ? false : a as bool; + bool boolB = b == null ? false : b as bool; + + // Custom sorting for booleans: false first, then true + return boolA == boolB ? 0 : (boolA ? 1 : -1); + } - dynamic applyFormat(dynamic value) => - hasFormat ? (this as PlutoColumnTypeHasFormat).applyFormat(value) : value; + @override + dynamic makeCompareValue(dynamic v) { + return v == null ? false : v as bool; + } } class PlutoColumnTypeText implements PlutoColumnType { @@ -255,9 +309,49 @@ class PlutoColumnTypeText implements PlutoColumnType { } } -class PlutoColumnTypeNumber - with PlutoColumnTypeWithNumberFormat - implements PlutoColumnType, PlutoColumnTypeHasFormat { +class PlutoColumnTypeDouble with PlutoColumnTypeWithDoubleFormat implements PlutoColumnType, PlutoColumnTypeHasFormat { + @override + final dynamic defaultValue; + + @override + final bool negative; + + @override + final String format; + + @override + final bool applyFormatOnInit; + + @override + final bool allowFirstDot; + + @override + final String? locale; + + PlutoColumnTypeDouble({ + this.defaultValue, + required this.negative, + required this.format, + required this.applyFormatOnInit, + required this.allowFirstDot, + required this.locale, + }) : numberFormat = intl.NumberFormat(format, locale), + decimalPoint = _getDecimalPoint(format); + + @override + final intl.NumberFormat numberFormat; + + @override + final int decimalPoint; + + static int _getDecimalPoint(String format) { + final int dotIndex = format.indexOf('.'); + + return dotIndex < 0 ? 0 : format.substring(dotIndex).length - 1; + } +} + +class PlutoColumnTypeNumber with PlutoColumnTypeWithNumberFormat implements PlutoColumnType, PlutoColumnTypeHasFormat { @override final dynamic defaultValue; @@ -299,9 +393,7 @@ class PlutoColumnTypeNumber } } -class PlutoColumnTypeCurrency - with PlutoColumnTypeWithNumberFormat - implements PlutoColumnType, PlutoColumnTypeHasFormat { +class PlutoColumnTypeCurrency with PlutoColumnTypeWithNumberFormat implements PlutoColumnType, PlutoColumnTypeHasFormat { @override final dynamic defaultValue; @@ -351,8 +443,7 @@ class PlutoColumnTypeCurrency late final int decimalPoint; } -class PlutoColumnTypeSelect - implements PlutoColumnType, PlutoColumnTypeHasPopupIcon { +class PlutoColumnTypeSelect implements PlutoColumnType, PlutoColumnTypeHasPopupIcon { @override final dynamic defaultValue; @@ -386,12 +477,7 @@ class PlutoColumnTypeSelect } } -class PlutoColumnTypeDate - implements - PlutoColumnType, - PlutoColumnTypeHasFormat, - PlutoColumnTypeHasDateFormat, - PlutoColumnTypeHasPopupIcon { +class PlutoColumnTypeDate implements PlutoColumnType, PlutoColumnTypeHasFormat, PlutoColumnTypeHasDateFormat, PlutoColumnTypeHasPopupIcon { @override final dynamic defaultValue; @@ -477,8 +563,7 @@ class PlutoColumnTypeDate } } -class PlutoColumnTypeTime - implements PlutoColumnType, PlutoColumnTypeHasPopupIcon { +class PlutoColumnTypeTime implements PlutoColumnType, PlutoColumnTypeHasPopupIcon { @override final dynamic defaultValue; @@ -539,6 +624,74 @@ abstract class PlutoColumnTypeHasPopupIcon { IconData? get popupIcon; } +mixin PlutoColumnTypeWithDoubleFormat { + intl.NumberFormat get numberFormat; + + bool get negative; + + int get decimalPoint; + + bool get allowFirstDot; + + String? get locale; + + bool isValid(dynamic value) { + if (!isNumeric(value)) { + return false; + } + + if (negative == false && num.parse(value.toString()) < 0) { + return false; + } + + return true; + } + + int compare(dynamic a, dynamic b) { + return _compareWithNull( + a, + b, + () => toDouble(a.toString()).compareTo(toDouble(b.toString())), + ); + } + + dynamic makeCompareValue(dynamic v) { + return v.runtimeType != num ? toDouble(v.toString()) : v; + } + + String applyFormat(dynamic value) { + double number = toDouble(value.toString()); + + if (negative == false && number < 0) { + number = 0.0; + } + + return numberFormat.format(number); + } + + /// Convert [String] converted to [applyFormat] to [double]. + double toDouble(String formatted) { + String match = '0-9\\-${numberFormat.symbols.DECIMAL_SEP}'; + + if (negative) { + match += numberFormat.symbols.MINUS_SIGN; + } + + formatted = formatted.replaceAll(RegExp('[^$match]'), '').replaceFirst(numberFormat.symbols.DECIMAL_SEP, '.'); + + final double formattedDouble = double.tryParse(formatted) ?? 0.0; + + return formattedDouble.isFinite ? formattedDouble : 0.0; + } + + bool isNumeric(dynamic s) { + if (s == null) { + return false; + } + return double.tryParse(s.toString()) != null; + } +} + mixin PlutoColumnTypeWithNumberFormat { intl.NumberFormat get numberFormat; @@ -595,9 +748,7 @@ mixin PlutoColumnTypeWithNumberFormat { match += numberFormat.symbols.MINUS_SIGN; } - formatted = formatted - .replaceAll(RegExp('[^$match]'), '') - .replaceFirst(numberFormat.symbols.DECIMAL_SEP, '.'); + formatted = formatted.replaceAll(RegExp('[^$match]'), '').replaceFirst(numberFormat.symbols.DECIMAL_SEP, '.'); final num formattedNumber = num.tryParse(formatted) ?? 0; diff --git a/pubspec.yaml b/pubspec.yaml index 58d1ccb65..e0c1901c6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pluto_grid description: PlutoGrid is a dataGrid that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS. (DataGrid, DataTable, Data Grid, Data Table, Sticky) -version: 7.0.8 +version: 7.1.0 homepage: https://pluto.weblaze.dev repository: https://github.com/videalphatech/pluto_grid_modified @@ -14,9 +14,9 @@ dependencies: sdk: flutter # Follows the intl version included in Flutter. # https://github.com/flutter/flutter/blob/84a1e904f44f9b0e9c4510138010edcc653163f8/packages/flutter_localizations/pubspec.yaml#L11 - intl: ^0.18.0 - rxdart: ^0.27.7 - collection: ^1.17.1 + intl: + rxdart: + collection: dev_dependencies: flutter_test: From 640cba306eddc322573d113a185fd932a96e1207 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Mon, 19 Feb 2024 12:36:01 +0530 Subject: [PATCH 31/47] version updated --- .fvm/fvm_config.json | 2 +- pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json index 3e7195748..ccdae4db8 100644 --- a/.fvm/fvm_config.json +++ b/.fvm/fvm_config.json @@ -1,4 +1,4 @@ { - "flutterSdkVersion": "3.16.9", + "flutterSdkVersion": "3.19.0", "flavors": {} } \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index e0c1901c6..dd5b4ad6f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pluto_grid description: PlutoGrid is a dataGrid that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS. (DataGrid, DataTable, Data Grid, Data Table, Sticky) -version: 7.1.0 +version: 7.1.1 homepage: https://pluto.weblaze.dev repository: https://github.com/videalphatech/pluto_grid_modified From bb94103ceef0a9f6693cbe06b62cf8e2e86e9b81 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Mon, 19 Feb 2024 14:28:49 +0530 Subject: [PATCH 32/47] version downgraded --- .fvm/fvm_config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json index ccdae4db8..88fa31a0a 100644 --- a/.fvm/fvm_config.json +++ b/.fvm/fvm_config.json @@ -1,4 +1,4 @@ { - "flutterSdkVersion": "3.19.0", + "flutterSdkVersion": "3.10.4", "flavors": {} } \ No newline at end of file From ff28cf90a8c5727605c17abb00d78776511ae04f Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Tue, 20 Feb 2024 09:54:21 +0530 Subject: [PATCH 33/47] added stringNumber sorting --- .fvm/fvm_config.json | 2 +- lib/src/model/pluto_column_type.dart | 60 ++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json index 88fa31a0a..3e7195748 100644 --- a/.fvm/fvm_config.json +++ b/.fvm/fvm_config.json @@ -1,4 +1,4 @@ { - "flutterSdkVersion": "3.10.4", + "flutterSdkVersion": "3.16.9", "flavors": {} } \ No newline at end of file diff --git a/lib/src/model/pluto_column_type.dart b/lib/src/model/pluto_column_type.dart index dae7fa9b0..d9273d707 100644 --- a/lib/src/model/pluto_column_type.dart +++ b/lib/src/model/pluto_column_type.dart @@ -55,6 +55,24 @@ abstract class PlutoColumnType { ); } + factory PlutoColumnType.stringAndNumber({ + dynamic defaultValue = 0.0, + bool negative = true, + String format = '#,###.#######', + bool applyFormatOnInit = true, + bool allowFirstDot = false, + String? locale, + }) { + return PlutoColumnTypeStringAndNumber( + defaultValue: defaultValue, + format: format, + negative: negative, + applyFormatOnInit: applyFormatOnInit, + allowFirstDot: allowFirstDot, + locale: locale, + ); + } + //this sorting is custom build for sorting double factory PlutoColumnType.double({ dynamic defaultValue = 0.0, @@ -257,6 +275,48 @@ extension PlutoColumnTypeExtension on PlutoColumnType { dynamic applyFormat(dynamic value) => hasFormat ? (this as PlutoColumnTypeHasFormat).applyFormat(value) : value; } +class PlutoColumnTypeStringAndNumber with PlutoColumnTypeWithDoubleFormat implements PlutoColumnType, PlutoColumnTypeHasFormat { + @override + final dynamic defaultValue; + + @override + final bool negative; + + @override + final String format; + + @override + final bool applyFormatOnInit; + + @override + final bool allowFirstDot; + + @override + final String? locale; + + PlutoColumnTypeStringAndNumber({ + this.defaultValue, + required this.negative, + required this.format, + required this.applyFormatOnInit, + required this.allowFirstDot, + required this.locale, + }) : numberFormat = intl.NumberFormat(format, locale), + decimalPoint = _getDecimalPoint(format); + + @override + final intl.NumberFormat numberFormat; + + @override + final int decimalPoint; + + static int _getDecimalPoint(String format) { + final int dotIndex = format.indexOf('.'); + + return dotIndex < 0 ? 0 : format.substring(dotIndex).length - 1; + } +} + class PlutoColumnTypeBoolean implements PlutoColumnType { @override final dynamic defaultValue; From c68d5c98dbb665562eff56c174c5e6c9832fb324 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Tue, 20 Feb 2024 10:12:18 +0530 Subject: [PATCH 34/47] fixes: plutocolumn sort --- lib/src/model/pluto_column_type.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/src/model/pluto_column_type.dart b/lib/src/model/pluto_column_type.dart index d9273d707..efb53dec3 100644 --- a/lib/src/model/pluto_column_type.dart +++ b/lib/src/model/pluto_column_type.dart @@ -315,6 +315,18 @@ class PlutoColumnTypeStringAndNumber with PlutoColumnTypeWithDoubleFormat implem return dotIndex < 0 ? 0 : format.substring(dotIndex).length - 1; } + + int compareTo(dynamic other) { + String thisValue = defaultValue.toString(); + String otherValue = other.toString(); + double? thisDouble = double.tryParse(thisValue); + double? otherDouble = double.tryParse(otherValue); + if (thisDouble != null && otherDouble != null) { + return thisDouble.compareTo(otherDouble); + } else { + return thisValue.compareTo(otherValue); + } + } } class PlutoColumnTypeBoolean implements PlutoColumnType { From 291caf762ec478938fbcff6ed2527c119d0e38da Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Tue, 20 Feb 2024 10:36:40 +0530 Subject: [PATCH 35/47] changes --- lib/src/model/pluto_column_type.dart | 5 +++++ pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/src/model/pluto_column_type.dart b/lib/src/model/pluto_column_type.dart index efb53dec3..70268f83a 100644 --- a/lib/src/model/pluto_column_type.dart +++ b/lib/src/model/pluto_column_type.dart @@ -321,8 +321,13 @@ class PlutoColumnTypeStringAndNumber with PlutoColumnTypeWithDoubleFormat implem String otherValue = other.toString(); double? thisDouble = double.tryParse(thisValue); double? otherDouble = double.tryParse(otherValue); + if (thisDouble != null && otherDouble != null) { return thisDouble.compareTo(otherDouble); + } else if (thisDouble != null) { + return thisDouble.compareTo(double.tryParse(otherValue) ?? double.nan); + } else if (otherDouble != null) { + return (double.tryParse(thisValue) ?? double.nan).compareTo(otherDouble); } else { return thisValue.compareTo(otherValue); } diff --git a/pubspec.yaml b/pubspec.yaml index dd5b4ad6f..b45c8fee5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pluto_grid description: PlutoGrid is a dataGrid that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS. (DataGrid, DataTable, Data Grid, Data Table, Sticky) -version: 7.1.1 +version: 7.1.2 homepage: https://pluto.weblaze.dev repository: https://github.com/videalphatech/pluto_grid_modified From 54f1a9bd7ef784c6f43d528af24894cf7482eb51 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Thu, 22 Feb 2024 10:53:51 +0530 Subject: [PATCH 36/47] fixes: duration and text --- example/lib/main.dart | 8 ++--- lib/src/model/pluto_column_type.dart | 45 +++++++++++++++++----------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 67403072a..831174d2a 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -36,7 +36,7 @@ class _PlutoGridExamplePageState extends State { PlutoColumn( title: 'Id', field: 'id', - type: PlutoColumnType.text(), + type: PlutoColumnType.stringAndNumber(), ), PlutoColumn( title: 'Name', @@ -96,7 +96,7 @@ class _PlutoGridExamplePageState extends State { final List rows = [ PlutoRow( cells: { - 'id': PlutoCell(value: 'user1'), + 'id': PlutoCell(value: 'user 113'), 'name': PlutoCell(value: 'Mike'), 'age': PlutoCell(value: 20), 'role': PlutoCell(value: 'Programmer'), @@ -107,7 +107,7 @@ class _PlutoGridExamplePageState extends State { ), PlutoRow( cells: { - 'id': PlutoCell(value: 'user2'), + 'id': PlutoCell(value: 'user 212'), 'name': PlutoCell(value: 'Jack'), 'age': PlutoCell(value: 25), 'role': PlutoCell(value: 'Designer'), @@ -118,7 +118,7 @@ class _PlutoGridExamplePageState extends State { ), PlutoRow( cells: { - 'id': PlutoCell(value: 'user3'), + 'id': PlutoCell(value: 'user 312'), 'name': PlutoCell(value: 'Suzi'), 'age': PlutoCell(value: 40), 'role': PlutoCell(value: 'Owner'), diff --git a/lib/src/model/pluto_column_type.dart b/lib/src/model/pluto_column_type.dart index 70268f83a..6e203be53 100644 --- a/lib/src/model/pluto_column_type.dart +++ b/lib/src/model/pluto_column_type.dart @@ -63,7 +63,7 @@ abstract class PlutoColumnType { bool allowFirstDot = false, String? locale, }) { - return PlutoColumnTypeStringAndNumber( + return PlutoColumnTypeDuration( defaultValue: defaultValue, format: format, negative: negative, @@ -275,7 +275,7 @@ extension PlutoColumnTypeExtension on PlutoColumnType { dynamic applyFormat(dynamic value) => hasFormat ? (this as PlutoColumnTypeHasFormat).applyFormat(value) : value; } -class PlutoColumnTypeStringAndNumber with PlutoColumnTypeWithDoubleFormat implements PlutoColumnType, PlutoColumnTypeHasFormat { +class PlutoColumnTypeDuration with PlutoColumnTypeWithDoubleFormat implements PlutoColumnType, PlutoColumnTypeHasFormat { @override final dynamic defaultValue; @@ -294,7 +294,7 @@ class PlutoColumnTypeStringAndNumber with PlutoColumnTypeWithDoubleFormat implem @override final String? locale; - PlutoColumnTypeStringAndNumber({ + PlutoColumnTypeDuration({ this.defaultValue, required this.negative, required this.format, @@ -316,22 +316,31 @@ class PlutoColumnTypeStringAndNumber with PlutoColumnTypeWithDoubleFormat implem return dotIndex < 0 ? 0 : format.substring(dotIndex).length - 1; } - int compareTo(dynamic other) { - String thisValue = defaultValue.toString(); - String otherValue = other.toString(); - double? thisDouble = double.tryParse(thisValue); - double? otherDouble = double.tryParse(otherValue); - - if (thisDouble != null && otherDouble != null) { - return thisDouble.compareTo(otherDouble); - } else if (thisDouble != null) { - return thisDouble.compareTo(double.tryParse(otherValue) ?? double.nan); - } else if (otherDouble != null) { - return (double.tryParse(thisValue) ?? double.nan).compareTo(otherDouble); + String getHumanReadableDuration() { + final int seconds = (defaultValue ?? 0).toInt(); + final Duration duration = Duration(seconds: seconds); + + final int days = duration.inDays; + final int hours = duration.inHours.remainder(24); + final int minutes = duration.inMinutes.remainder(60); + + if (days > 0) { + return '$days days ago'; + } else if (hours > 0) { + return '$hours hours ago'; + } else if (minutes > 0) { + return '$minutes minutes ago'; } else { - return thisValue.compareTo(otherValue); + return 'Just now'; } } + + int compareTo(dynamic other) { + final int thisSeconds = (defaultValue ?? 0).toInt(); + final int otherSeconds = (other ?? 0).toInt(); + + return thisSeconds.compareTo(otherSeconds); + } } class PlutoColumnTypeBoolean implements PlutoColumnType { @@ -377,12 +386,12 @@ class PlutoColumnTypeText implements PlutoColumnType { @override int compare(dynamic a, dynamic b) { - return _compareWithNull(a, b, () => a.toString().compareTo(b.toString())); + return _compareWithNull(a, b, () => a.toString().toLowerCase().compareTo(b.toString().toLowerCase())); } @override dynamic makeCompareValue(dynamic v) { - return v.toString(); + return v.toString().toLowerCase(); } } From 79a238c7062a08720f1e8ab64f0c0cc378ff9759 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Thu, 22 Feb 2024 12:03:12 +0530 Subject: [PATCH 37/47] fixes --- example/lib/main.dart | 2 +- lib/src/model/pluto_column_type.dart | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 831174d2a..359ed09f8 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -36,7 +36,7 @@ class _PlutoGridExamplePageState extends State { PlutoColumn( title: 'Id', field: 'id', - type: PlutoColumnType.stringAndNumber(), + type: PlutoColumnType.duration(), ), PlutoColumn( title: 'Name', diff --git a/lib/src/model/pluto_column_type.dart b/lib/src/model/pluto_column_type.dart index 6e203be53..9b054e930 100644 --- a/lib/src/model/pluto_column_type.dart +++ b/lib/src/model/pluto_column_type.dart @@ -55,7 +55,7 @@ abstract class PlutoColumnType { ); } - factory PlutoColumnType.stringAndNumber({ + factory PlutoColumnType.duration({ dynamic defaultValue = 0.0, bool negative = true, String format = '#,###.#######', @@ -320,15 +320,17 @@ class PlutoColumnTypeDuration with PlutoColumnTypeWithDoubleFormat implements Pl final int seconds = (defaultValue ?? 0).toInt(); final Duration duration = Duration(seconds: seconds); - final int days = duration.inDays; - final int hours = duration.inHours.remainder(24); - final int minutes = duration.inMinutes.remainder(60); + final Duration difference = DateTime.now().difference(DateTime.now().subtract(duration)); - if (days > 0) { + final int days = difference.inDays; + final int hours = difference.inHours.remainder(24); + final int minutes = difference.inMinutes.remainder(60); + + if (days > 1) { return '$days days ago'; - } else if (hours > 0) { + } else if (hours > 1) { return '$hours hours ago'; - } else if (minutes > 0) { + } else if (minutes > 1) { return '$minutes minutes ago'; } else { return 'Just now'; From 2e6bc2e49d510ca8bfa3a41fea21109f252043c5 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Thu, 22 Feb 2024 12:37:57 +0530 Subject: [PATCH 38/47] feature displayValue --- lib/src/model/pluto_cell.dart | 36 ++++++++++++++++++++-------- lib/src/model/pluto_column_type.dart | 7 ++---- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/lib/src/model/pluto_cell.dart b/lib/src/model/pluto_cell.dart index 072ef58b5..6eb398d3b 100644 --- a/lib/src/model/pluto_cell.dart +++ b/lib/src/model/pluto_cell.dart @@ -11,6 +11,31 @@ class PlutoCell { final Key _key; dynamic _value; + dynamic _displayValue; + + dynamic get displayValue { + if (_displayValue != null) { + return _displayValue; + } else { + return value; + } + } + + set displayValue(dynamic changed) { + if (_displayValue == changed) { + return; + } + + _displayValue = changed; + } + + dynamic get value { + if (_needToApplyFormatOnInit) { + _applyFormatOnInit(); + } + + return _value; + } dynamic _valueForSorting; @@ -44,14 +69,6 @@ class PlutoCell { return _row!; } - dynamic get value { - if (_needToApplyFormatOnInit) { - _applyFormatOnInit(); - } - - return _value; - } - set value(dynamic changed) { if (_value == changed) { return; @@ -94,8 +111,7 @@ class PlutoCell { _value = _column!.type.applyFormat(_value); if (_column!.type is PlutoColumnTypeWithNumberFormat) { - _value = - (_column!.type as PlutoColumnTypeWithNumberFormat).toNumber(_value); + _value = (_column!.type as PlutoColumnTypeWithNumberFormat).toNumber(_value); } _needToApplyFormatOnInit = false; diff --git a/lib/src/model/pluto_column_type.dart b/lib/src/model/pluto_column_type.dart index 9b054e930..9f07490a9 100644 --- a/lib/src/model/pluto_column_type.dart +++ b/lib/src/model/pluto_column_type.dart @@ -58,7 +58,7 @@ abstract class PlutoColumnType { factory PlutoColumnType.duration({ dynamic defaultValue = 0.0, bool negative = true, - String format = '#,###.#######', + String format = '', bool applyFormatOnInit = true, bool allowFirstDot = false, String? locale, @@ -77,7 +77,7 @@ abstract class PlutoColumnType { factory PlutoColumnType.double({ dynamic defaultValue = 0.0, bool negative = true, - String format = '#,###.#######', + String format = '#,###.###,###,#', bool applyFormatOnInit = true, bool allowFirstDot = false, String? locale, @@ -312,16 +312,13 @@ class PlutoColumnTypeDuration with PlutoColumnTypeWithDoubleFormat implements Pl static int _getDecimalPoint(String format) { final int dotIndex = format.indexOf('.'); - return dotIndex < 0 ? 0 : format.substring(dotIndex).length - 1; } String getHumanReadableDuration() { final int seconds = (defaultValue ?? 0).toInt(); final Duration duration = Duration(seconds: seconds); - final Duration difference = DateTime.now().difference(DateTime.now().subtract(duration)); - final int days = difference.inDays; final int hours = difference.inHours.remainder(24); final int minutes = difference.inMinutes.remainder(60); From 3d0cb16af0350ca6ba254a4e35fcd2dd2e471904 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Thu, 22 Feb 2024 12:41:46 +0530 Subject: [PATCH 39/47] changes --- lib/src/model/pluto_cell.dart | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/src/model/pluto_cell.dart b/lib/src/model/pluto_cell.dart index 6eb398d3b..28ce9ed71 100644 --- a/lib/src/model/pluto_cell.dart +++ b/lib/src/model/pluto_cell.dart @@ -4,9 +4,11 @@ import 'package:pluto_grid/pluto_grid.dart'; class PlutoCell { PlutoCell({ dynamic value, + dynamic displayValue, Key? key, }) : _key = key ?? UniqueKey(), - _value = value; + _value = value, + _displayValue = displayValue; final Key _key; @@ -39,14 +41,6 @@ class PlutoCell { dynamic _valueForSorting; - /// Set initial value according to [PlutoColumn] setting. - /// - /// [setColumn] is called when [PlutoGridStateManager.initializeRows] is called. - /// When [setColumn] is called, this value is changed to `true` according to the column setting. - /// If this value is `true` when the getter of [PlutoCell.value] is called, - /// it calls [_applyFormatOnInit] to update the value according to the format. - /// [_applyFormatOnInit] is called once, and if [setColumn] is not called again, - /// it is not called anymore. bool _needToApplyFormatOnInit = false; PlutoColumn? _column; @@ -118,7 +112,7 @@ class PlutoCell { } } -_assertUnInitializedCell(bool flag) { +void _assertUnInitializedCell(bool flag) { assert( flag, 'PlutoCell is not initialized.' From 14636744bf6706eeaf816ae6b07430234f91efbe Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Thu, 22 Feb 2024 12:48:26 +0530 Subject: [PATCH 40/47] changes --- lib/src/model/pluto_cell.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/model/pluto_cell.dart b/lib/src/model/pluto_cell.dart index 28ce9ed71..36e5d1a28 100644 --- a/lib/src/model/pluto_cell.dart +++ b/lib/src/model/pluto_cell.dart @@ -4,7 +4,7 @@ import 'package:pluto_grid/pluto_grid.dart'; class PlutoCell { PlutoCell({ dynamic value, - dynamic displayValue, + String? displayValue, Key? key, }) : _key = key ?? UniqueKey(), _value = value, From f9c642e0a9285621a9a6f7690815b4ef0e8e7c23 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Thu, 22 Feb 2024 12:54:33 +0530 Subject: [PATCH 41/47] changed pluto cell --- lib/src/model/pluto_cell.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/src/model/pluto_cell.dart b/lib/src/model/pluto_cell.dart index 36e5d1a28..c113a4214 100644 --- a/lib/src/model/pluto_cell.dart +++ b/lib/src/model/pluto_cell.dart @@ -90,15 +90,18 @@ class PlutoCell { } dynamic _getValueForSorting() { + if (displayValue != null) { + return displayValue; + } if (_column == null) { - return _value; + return displayValue; } if (_needToApplyFormatOnInit) { _applyFormatOnInit(); } - return _column!.type.makeCompareValue(_value); + return _column!.type.makeCompareValue(_value || displayValue); } void _applyFormatOnInit() { From 6a2c7f3ee23abcac6f0b92f28f9f05774f60e695 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Thu, 22 Feb 2024 13:33:34 +0530 Subject: [PATCH 42/47] changes --- lib/src/model/pluto_cell.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/model/pluto_cell.dart b/lib/src/model/pluto_cell.dart index c113a4214..67e5631d8 100644 --- a/lib/src/model/pluto_cell.dart +++ b/lib/src/model/pluto_cell.dart @@ -4,7 +4,7 @@ import 'package:pluto_grid/pluto_grid.dart'; class PlutoCell { PlutoCell({ dynamic value, - String? displayValue, + dynamic displayValue, Key? key, }) : _key = key ?? UniqueKey(), _value = value, @@ -101,7 +101,7 @@ class PlutoCell { _applyFormatOnInit(); } - return _column!.type.makeCompareValue(_value || displayValue); + return _column!.type.makeCompareValue(displayValue); } void _applyFormatOnInit() { From 749af9b3ed69edc39da9a4a8299ec13e4b8ea65e Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Thu, 22 Feb 2024 14:12:15 +0530 Subject: [PATCH 43/47] changes reverted --- lib/src/model/pluto_cell.dart | 57 +++++++++++----------------- lib/src/model/pluto_column_type.dart | 2 +- 2 files changed, 23 insertions(+), 36 deletions(-) diff --git a/lib/src/model/pluto_cell.dart b/lib/src/model/pluto_cell.dart index 67e5631d8..072ef58b5 100644 --- a/lib/src/model/pluto_cell.dart +++ b/lib/src/model/pluto_cell.dart @@ -4,43 +4,24 @@ import 'package:pluto_grid/pluto_grid.dart'; class PlutoCell { PlutoCell({ dynamic value, - dynamic displayValue, Key? key, }) : _key = key ?? UniqueKey(), - _value = value, - _displayValue = displayValue; + _value = value; final Key _key; dynamic _value; - dynamic _displayValue; - - dynamic get displayValue { - if (_displayValue != null) { - return _displayValue; - } else { - return value; - } - } - - set displayValue(dynamic changed) { - if (_displayValue == changed) { - return; - } - - _displayValue = changed; - } - - dynamic get value { - if (_needToApplyFormatOnInit) { - _applyFormatOnInit(); - } - - return _value; - } dynamic _valueForSorting; + /// Set initial value according to [PlutoColumn] setting. + /// + /// [setColumn] is called when [PlutoGridStateManager.initializeRows] is called. + /// When [setColumn] is called, this value is changed to `true` according to the column setting. + /// If this value is `true` when the getter of [PlutoCell.value] is called, + /// it calls [_applyFormatOnInit] to update the value according to the format. + /// [_applyFormatOnInit] is called once, and if [setColumn] is not called again, + /// it is not called anymore. bool _needToApplyFormatOnInit = false; PlutoColumn? _column; @@ -63,6 +44,14 @@ class PlutoCell { return _row!; } + dynamic get value { + if (_needToApplyFormatOnInit) { + _applyFormatOnInit(); + } + + return _value; + } + set value(dynamic changed) { if (_value == changed) { return; @@ -90,32 +79,30 @@ class PlutoCell { } dynamic _getValueForSorting() { - if (displayValue != null) { - return displayValue; - } if (_column == null) { - return displayValue; + return _value; } if (_needToApplyFormatOnInit) { _applyFormatOnInit(); } - return _column!.type.makeCompareValue(displayValue); + return _column!.type.makeCompareValue(_value); } void _applyFormatOnInit() { _value = _column!.type.applyFormat(_value); if (_column!.type is PlutoColumnTypeWithNumberFormat) { - _value = (_column!.type as PlutoColumnTypeWithNumberFormat).toNumber(_value); + _value = + (_column!.type as PlutoColumnTypeWithNumberFormat).toNumber(_value); } _needToApplyFormatOnInit = false; } } -void _assertUnInitializedCell(bool flag) { +_assertUnInitializedCell(bool flag) { assert( flag, 'PlutoCell is not initialized.' diff --git a/lib/src/model/pluto_column_type.dart b/lib/src/model/pluto_column_type.dart index 9f07490a9..e30beaa30 100644 --- a/lib/src/model/pluto_column_type.dart +++ b/lib/src/model/pluto_column_type.dart @@ -77,7 +77,7 @@ abstract class PlutoColumnType { factory PlutoColumnType.double({ dynamic defaultValue = 0.0, bool negative = true, - String format = '#,###.###,###,#', + String format = '#,###.#######', bool applyFormatOnInit = true, bool allowFirstDot = false, String? locale, From 4b5254ffcaebe46bee76c3f081e74a1ca3790d44 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Mon, 11 Mar 2024 12:31:03 +0530 Subject: [PATCH 44/47] fixes: bugs --- lib/src/helper/filter_helper.dart | 3 +++ lib/src/helper/show_column_menu.dart | 19 ++++++++++++------- lib/src/model/pluto_column_type.dart | 10 +++++++--- lib/src/ui/columns/pluto_column_title.dart | 19 +++++++++++-------- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/lib/src/helper/filter_helper.dart b/lib/src/helper/filter_helper.dart index b28e22dbc..2acd4cc1c 100644 --- a/lib/src/helper/filter_helper.dart +++ b/lib/src/helper/filter_helper.dart @@ -3,6 +3,8 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:pluto_grid/pluto_grid.dart'; +import '../ui/columns/pluto_column_title.dart'; + typedef SetFilterPopupHandler = void Function(PlutoGridStateManager? stateManager); class FilterHelper { @@ -557,6 +559,7 @@ class PlutoGridFilterPopupHeader extends StatelessWidget { ), onPressed: () { Navigator.of(stateManager!.gridFocusNode.context!).pop(); + isFiltered = false; }, child: const Text( 'Close', diff --git a/lib/src/helper/show_column_menu.dart b/lib/src/helper/show_column_menu.dart index 5fa5d5944..d978024c3 100644 --- a/lib/src/helper/show_column_menu.dart +++ b/lib/src/helper/show_column_menu.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:pluto_grid/pluto_grid.dart'; +import '../ui/columns/pluto_column_title.dart'; + abstract class PlutoColumnMenuDelegate { List> buildMenuItems({ required PlutoGridStateManager stateManager, @@ -38,13 +40,16 @@ class PlutoColumnMenuDelegateDefault implements PlutoColumnMenuDelegate 1) { - return '$days days ago'; + return '$days ${_pluralize(days, "day")} ago'; } else if (hours > 1) { - return '$hours hours ago'; + return '$hours ${_pluralize(hours, "hour")} ago'; } else if (minutes > 1) { - return '$minutes minutes ago'; + return '$minutes ${_pluralize(minutes, "minute")} ago'; } else { return 'Just now'; } } + String _pluralize(int value, String unit) { + return value == 1 ? unit : '${unit}s'; + } + int compareTo(dynamic other) { final int thisSeconds = (defaultValue ?? 0).toInt(); final int otherSeconds = (other ?? 0).toInt(); diff --git a/lib/src/ui/columns/pluto_column_title.dart b/lib/src/ui/columns/pluto_column_title.dart index 1d5d6b42c..f0995e327 100644 --- a/lib/src/ui/columns/pluto_column_title.dart +++ b/lib/src/ui/columns/pluto_column_title.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:pluto_grid/pluto_grid.dart'; import '../ui.dart'; +bool isFiltered = false; class PlutoColumnTitle extends PlutoStatefulWidget { final PlutoGridStateManager stateManager; @@ -65,14 +66,16 @@ class PlutoColumnTitleState extends PlutoStateWithChange { } void _showContextMenu(BuildContext context, Offset position) async { - // Execute the action associated with "Set Filter" - stateManager.columnMenuDelegate.onSelected( - context: context, - stateManager: stateManager, - column: widget.column, - mounted: mounted, - selected: PlutoGridColumnMenuItem.setFilter, // Directly pass the option - ); + if (context.mounted) { + stateManager.columnMenuDelegate.onSelected( + context: context, + stateManager: stateManager, + column: widget.column, + mounted: mounted, + selected: PlutoGridColumnMenuItem.setFilter, + ); + isFiltered = true; + } } void _handleOnPointDown(PointerDownEvent event) { From ae0cf3a06d2a6996497b491db041307873168784 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Mon, 11 Mar 2024 12:31:19 +0530 Subject: [PATCH 45/47] updated --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index b45c8fee5..ec88f14a8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pluto_grid description: PlutoGrid is a dataGrid that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS. (DataGrid, DataTable, Data Grid, Data Table, Sticky) -version: 7.1.2 +version: 7.1.3 homepage: https://pluto.weblaze.dev repository: https://github.com/videalphatech/pluto_grid_modified From fa3bcc73e255156b3c695e1ad0fd010faa7972d1 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Tue, 19 Mar 2024 16:30:22 +0530 Subject: [PATCH 46/47] type duration added --- example/lib/main.dart | 8 +-- lib/src/model/pluto_column_type.dart | 94 +++++++++------------------- pubspec.yaml | 2 +- 3 files changed, 34 insertions(+), 70 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 359ed09f8..3d974f347 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -41,7 +41,7 @@ class _PlutoGridExamplePageState extends State { PlutoColumn( title: 'Name', field: 'name', - type: PlutoColumnType.text(), + type: PlutoColumnType.duration(), ), PlutoColumn( title: 'Age', @@ -97,7 +97,7 @@ class _PlutoGridExamplePageState extends State { PlutoRow( cells: { 'id': PlutoCell(value: 'user 113'), - 'name': PlutoCell(value: 'Mike'), + 'name': PlutoCell(value: '1111 days'), 'age': PlutoCell(value: 20), 'role': PlutoCell(value: 'Programmer'), 'joined': PlutoCell(value: '2021-01-01'), @@ -108,7 +108,7 @@ class _PlutoGridExamplePageState extends State { PlutoRow( cells: { 'id': PlutoCell(value: 'user 212'), - 'name': PlutoCell(value: 'Jack'), + 'name': PlutoCell(value: '210 days'), 'age': PlutoCell(value: 25), 'role': PlutoCell(value: 'Designer'), 'joined': PlutoCell(value: '2021-02-01'), @@ -119,7 +119,7 @@ class _PlutoGridExamplePageState extends State { PlutoRow( cells: { 'id': PlutoCell(value: 'user 312'), - 'name': PlutoCell(value: 'Suzi'), + 'name': PlutoCell(value: '2111210 days'), 'age': PlutoCell(value: 40), 'role': PlutoCell(value: 'Owner'), 'joined': PlutoCell(value: '2021-03-01'), diff --git a/lib/src/model/pluto_column_type.dart b/lib/src/model/pluto_column_type.dart index 61231d445..3b41f15d6 100644 --- a/lib/src/model/pluto_column_type.dart +++ b/lib/src/model/pluto_column_type.dart @@ -54,22 +54,11 @@ abstract class PlutoColumnType { locale: locale, ); } - factory PlutoColumnType.duration({ dynamic defaultValue = 0.0, - bool negative = true, - String format = '', - bool applyFormatOnInit = true, - bool allowFirstDot = false, - String? locale, }) { return PlutoColumnTypeDuration( defaultValue: defaultValue, - format: format, - negative: negative, - applyFormatOnInit: applyFormatOnInit, - allowFirstDot: allowFirstDot, - locale: locale, ); } @@ -275,74 +264,49 @@ extension PlutoColumnTypeExtension on PlutoColumnType { dynamic applyFormat(dynamic value) => hasFormat ? (this as PlutoColumnTypeHasFormat).applyFormat(value) : value; } -class PlutoColumnTypeDuration with PlutoColumnTypeWithDoubleFormat implements PlutoColumnType, PlutoColumnTypeHasFormat { +class PlutoColumnTypeDuration implements PlutoColumnType { @override final dynamic defaultValue; - @override - final bool negative; - - @override - final String format; - - @override - final bool applyFormatOnInit; - - @override - final bool allowFirstDot; - - @override - final String? locale; - - PlutoColumnTypeDuration({ + const PlutoColumnTypeDuration({ this.defaultValue, - required this.negative, - required this.format, - required this.applyFormatOnInit, - required this.allowFirstDot, - required this.locale, - }) : numberFormat = intl.NumberFormat(format, locale), - decimalPoint = _getDecimalPoint(format); - - @override - final intl.NumberFormat numberFormat; + }); @override - final int decimalPoint; - - static int _getDecimalPoint(String format) { - final int dotIndex = format.indexOf('.'); - return dotIndex < 0 ? 0 : format.substring(dotIndex).length - 1; + bool isValid(dynamic value) { + return value is String || value is num; } - String getHumanReadableDuration() { - final int seconds = (defaultValue ?? 0).toInt(); - final Duration duration = Duration(seconds: seconds); - final Duration difference = DateTime.now().difference(DateTime.now().subtract(duration)); - final int days = difference.inDays; - final int hours = difference.inHours.remainder(24); - final int minutes = difference.inMinutes.remainder(60); - - if (days > 1) { - return '$days ${_pluralize(days, "day")} ago'; - } else if (hours > 1) { - return '$hours ${_pluralize(hours, "hour")} ago'; - } else if (minutes > 1) { - return '$minutes ${_pluralize(minutes, "minute")} ago'; + @override + int compare(dynamic a, dynamic b) { + if (a is num && b is num) { + return a.compareTo(b); + } else if (a is num) { + return 1; // a is considered greater + } else if (b is num) { + return -1; // b is considered greater } else { - return 'Just now'; + // If both are strings containing both numbers and alphabets, + // extract the numeric part for comparison + final num aNum = _extractNumber(a); + final num bNum = _extractNumber(b); + return aNum.compareTo(bNum); } } - String _pluralize(int value, String unit) { - return value == 1 ? unit : '${unit}s'; + num _extractNumber(dynamic value) { + final RegExp regex = RegExp(r'\d+'); + final Iterable matches = regex.allMatches(value.toString()); + if (matches.isNotEmpty) { + return num.parse(matches.first.group(0)!); + } else { + return defaultValue; + } } - int compareTo(dynamic other) { - final int thisSeconds = (defaultValue ?? 0).toInt(); - final int otherSeconds = (other ?? 0).toInt(); - - return thisSeconds.compareTo(otherSeconds); + @override + dynamic makeCompareValue(dynamic v) { + return v; } } diff --git a/pubspec.yaml b/pubspec.yaml index ec88f14a8..25310a9c2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pluto_grid description: PlutoGrid is a dataGrid that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS. (DataGrid, DataTable, Data Grid, Data Table, Sticky) -version: 7.1.3 +version: 8.1 homepage: https://pluto.weblaze.dev repository: https://github.com/videalphatech/pluto_grid_modified From 9c78d7779c0c921b03981b33aff2dd4b4ad4d844 Mon Sep 17 00:00:00 2001 From: kiranpsvidealpha Date: Tue, 19 Mar 2024 16:32:23 +0530 Subject: [PATCH 47/47] new version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 25310a9c2..734e76ec8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pluto_grid description: PlutoGrid is a dataGrid that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS. (DataGrid, DataTable, Data Grid, Data Table, Sticky) -version: 8.1 +version: 7.1.4 homepage: https://pluto.weblaze.dev repository: https://github.com/videalphatech/pluto_grid_modified