From 8ee9857cf23907a71c5192575da5e2c376ab0621 Mon Sep 17 00:00:00 2001 From: Yeikel Uriarte Arteaga Date: Tue, 26 Nov 2024 15:13:00 -0500 Subject: [PATCH 1/7] feat: allow disable row checkbox under a condition --- .fvm/fvm_config.json | 5 ++--- .gitignore | 11 +++++++++-- lib/src/model/pluto_column.dart | 9 ++++++--- lib/src/ui/cells/pluto_default_cell.dart | 5 ++++- lib/src/widgets/pluto_scaled_checkbox.dart | 2 +- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json index 41959e974..722fd1f83 100644 --- a/.fvm/fvm_config.json +++ b/.fvm/fvm_config.json @@ -1,4 +1,3 @@ { - "flutterSdkVersion": "stable", - "flavors": {} -} + "flutterSdkVersion": "3.24.2" +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index b28e1b84a..8b7e51baa 100644 --- a/.gitignore +++ b/.gitignore @@ -76,8 +76,15 @@ coverage/ !**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages -# FVM Support - https://fvm.app/ -.fvm/flutter_sdk example/windows/flutter/generated_plugin_registrant.cc example/windows/flutter/generated_plugin_registrant.h example/windows/flutter/generated_plugins.cmake + +example/windows/flutter/generated_plugin_registrant.cc +example/windows/flutter/generated_plugin_registrant.h +example/windows/flutter/generated_plugins.cmake + +# FVM Support - https://fvm.app/ +.fvm/flutter_sdk +# FVM Version Cache +.fvm/ diff --git a/lib/src/model/pluto_column.dart b/lib/src/model/pluto_column.dart index 5dc568165..b0e382ec3 100644 --- a/lib/src/model/pluto_column.dart +++ b/lib/src/model/pluto_column.dart @@ -147,9 +147,13 @@ class PlutoColumn { /// A checkbox appears in the cell of the column. bool enableRowChecked; - int rowCheckBoxGroupDepth; // + + int rowCheckBoxGroupDepth; + bool enableTitleChecked; + bool Function(PlutoRow row)? disableRowCheckWhen; + /// Sort rows by tapping on the column heading. bool enableSorting; @@ -258,8 +262,7 @@ class PlutoColumn { this.enableAutoEditing = false, this.enableEditingMode = true, this.hide = false, - this.backgroundGradient, - this.filterWidgetBuilder, + this.disableRowCheckWhen, }) : _key = UniqueKey(), _checkReadOnly = checkReadOnly; diff --git a/lib/src/ui/cells/pluto_default_cell.dart b/lib/src/ui/cells/pluto_default_cell.dart index d68b955fd..b93d9d923 100644 --- a/lib/src/ui/cells/pluto_default_cell.dart +++ b/lib/src/ui/cells/pluto_default_cell.dart @@ -410,9 +410,12 @@ class CheckboxSelectionWidgetState @override Widget build(BuildContext context) { + final disable = + widget.column.disableRowCheckWhen?.call(widget.row) ?? false; + return PlutoScaledCheckbox( value: _checked, - handleOnChanged: _handleOnChanged, + handleOnChanged: disable ? null : _handleOnChanged, tristate: _tristate, scale: 0.86, unselectedColor: stateManager.configuration.style.cellUnselectedColor, diff --git a/lib/src/widgets/pluto_scaled_checkbox.dart b/lib/src/widgets/pluto_scaled_checkbox.dart index e98308546..1c3b00362 100644 --- a/lib/src/widgets/pluto_scaled_checkbox.dart +++ b/lib/src/widgets/pluto_scaled_checkbox.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; class PlutoScaledCheckbox extends StatelessWidget { final bool? value; - final Function(bool? changed) handleOnChanged; + final Function(bool? changed)? handleOnChanged; final bool tristate; From 058fec69e4d2ecbb5c7d5ad45f2e3f0ab7d90f53 Mon Sep 17 00:00:00 2001 From: Yeikel Uriarte Arteaga Date: Tue, 26 Nov 2024 16:23:22 -0500 Subject: [PATCH 2/7] fix: handle a pure value for checkbox when is disable --- lib/src/ui/cells/pluto_default_cell.dart | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/src/ui/cells/pluto_default_cell.dart b/lib/src/ui/cells/pluto_default_cell.dart index b93d9d923..a5d7a4b67 100644 --- a/lib/src/ui/cells/pluto_default_cell.dart +++ b/lib/src/ui/cells/pluto_default_cell.dart @@ -100,6 +100,10 @@ class _PlutoDefaultCellState extends PlutoStateWithChange { @override void updateState(PlutoNotifierEvent event) { + final disable = + widget.column.disableRowCheckWhen?.call(widget.row) ?? false; + if (disable) return; + _hasFocus = update( _hasFocus, stateManager.hasFocus, @@ -354,6 +358,7 @@ class CheckboxSelectionWidgetState bool _tristate = false; bool? _checked; + bool _pureValue = false; @override PlutoGridStateManager get stateManager => widget.stateManager; @@ -361,12 +366,19 @@ class CheckboxSelectionWidgetState @override void initState() { super.initState(); - updateState(PlutoNotifierEventForceUpdate.instance); + _pureValue = widget.row.checked ?? false; } @override void updateState(PlutoNotifierEvent event) { + final disable = + widget.column.disableRowCheckWhen?.call(widget.row) ?? false; + if (disable) { + _checked = _pureValue; + return; + } + _tristate = update( _tristate, stateManager.enabledRowGroups && widget.row.type.isGroup, From 386a4e6c020d2a8a882db48b5cae17305db2036c Mon Sep 17 00:00:00 2001 From: Yeikel Uriarte Arteaga Date: Tue, 10 Dec 2024 22:05:39 -0500 Subject: [PATCH 3/7] fix: remove change in file unrelated with PR --- .fvm/fvm_config.json | 3 ++- .gitignore | 7 ++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json index 722fd1f83..b3db758e4 100644 --- a/.fvm/fvm_config.json +++ b/.fvm/fvm_config.json @@ -1,3 +1,4 @@ { - "flutterSdkVersion": "3.24.2" + "flutterSdkVersion": "stable", + "flavors": {} } \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8b7e51baa..92fc76786 100644 --- a/.gitignore +++ b/.gitignore @@ -76,6 +76,8 @@ coverage/ !**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +# FVM Support - https://fvm.app/ +.fvm/flutter_sdk example/windows/flutter/generated_plugin_registrant.cc example/windows/flutter/generated_plugin_registrant.h example/windows/flutter/generated_plugins.cmake @@ -83,8 +85,3 @@ example/windows/flutter/generated_plugins.cmake example/windows/flutter/generated_plugin_registrant.cc example/windows/flutter/generated_plugin_registrant.h example/windows/flutter/generated_plugins.cmake - -# FVM Support - https://fvm.app/ -.fvm/flutter_sdk -# FVM Version Cache -.fvm/ From b5d2cd70b9fa2cd915caa4317ca02abb8212367a Mon Sep 17 00:00:00 2001 From: Yeikel Uriarte Arteaga Date: Tue, 10 Dec 2024 22:07:25 -0500 Subject: [PATCH 4/7] fix: remove change in file unrelated with PR --- .fvm/fvm_config.json | 2 +- .gitignore | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json index b3db758e4..41959e974 100644 --- a/.fvm/fvm_config.json +++ b/.fvm/fvm_config.json @@ -1,4 +1,4 @@ { "flutterSdkVersion": "stable", "flavors": {} -} \ No newline at end of file +} diff --git a/.gitignore b/.gitignore index 92fc76786..92f3f9a64 100644 --- a/.gitignore +++ b/.gitignore @@ -80,8 +80,4 @@ coverage/ .fvm/flutter_sdk example/windows/flutter/generated_plugin_registrant.cc example/windows/flutter/generated_plugin_registrant.h -example/windows/flutter/generated_plugins.cmake - -example/windows/flutter/generated_plugin_registrant.cc -example/windows/flutter/generated_plugin_registrant.h -example/windows/flutter/generated_plugins.cmake +example/windows/flutter/generated_plugins.cmake \ No newline at end of file From 34aacde0080769b898ea9e4cfb51588c8ec363c9 Mon Sep 17 00:00:00 2001 From: Yeikel Uriarte Arteaga Date: Tue, 10 Dec 2024 22:09:32 -0500 Subject: [PATCH 5/7] fix: remove change in file unrelated with PR --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 92f3f9a64..ac480b7b4 100644 --- a/.gitignore +++ b/.gitignore @@ -79,5 +79,4 @@ coverage/ # FVM Support - https://fvm.app/ .fvm/flutter_sdk example/windows/flutter/generated_plugin_registrant.cc -example/windows/flutter/generated_plugin_registrant.h -example/windows/flutter/generated_plugins.cmake \ No newline at end of file +example/windows/flutter/generated_plugin_registrant.h \ No newline at end of file From 8d4bf347cf51337fd5a7a1b37847d3358193f1b6 Mon Sep 17 00:00:00 2001 From: Yeikel Uriarte Arteaga Date: Tue, 10 Dec 2024 22:12:23 -0500 Subject: [PATCH 6/7] fix: remove change in file unrelated with PR --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ac480b7b4..b28e1b84a 100644 --- a/.gitignore +++ b/.gitignore @@ -79,4 +79,5 @@ coverage/ # FVM Support - https://fvm.app/ .fvm/flutter_sdk example/windows/flutter/generated_plugin_registrant.cc -example/windows/flutter/generated_plugin_registrant.h \ No newline at end of file +example/windows/flutter/generated_plugin_registrant.h +example/windows/flutter/generated_plugins.cmake From f3c055b5bae4d2937a15d3fb0995cc4a27d424c2 Mon Sep 17 00:00:00 2001 From: Yeikel Uriarte Arteaga Date: Wed, 11 Dec 2024 13:10:12 -0500 Subject: [PATCH 7/7] fix: rename new method to avoid confusion --- lib/src/model/pluto_column.dart | 4 ++-- lib/src/ui/cells/pluto_default_cell.dart | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/src/model/pluto_column.dart b/lib/src/model/pluto_column.dart index b0e382ec3..d0cadebc6 100644 --- a/lib/src/model/pluto_column.dart +++ b/lib/src/model/pluto_column.dart @@ -152,7 +152,7 @@ class PlutoColumn { bool enableTitleChecked; - bool Function(PlutoRow row)? disableRowCheckWhen; + bool Function(PlutoRow row)? disableRowCheckboxWhen; /// Sort rows by tapping on the column heading. bool enableSorting; @@ -262,7 +262,7 @@ class PlutoColumn { this.enableAutoEditing = false, this.enableEditingMode = true, this.hide = false, - this.disableRowCheckWhen, + this.disableRowCheckboxWhen, }) : _key = UniqueKey(), _checkReadOnly = checkReadOnly; diff --git a/lib/src/ui/cells/pluto_default_cell.dart b/lib/src/ui/cells/pluto_default_cell.dart index a5d7a4b67..1d584edde 100644 --- a/lib/src/ui/cells/pluto_default_cell.dart +++ b/lib/src/ui/cells/pluto_default_cell.dart @@ -101,7 +101,7 @@ class _PlutoDefaultCellState extends PlutoStateWithChange { @override void updateState(PlutoNotifierEvent event) { final disable = - widget.column.disableRowCheckWhen?.call(widget.row) ?? false; + widget.column.disableRowCheckboxWhen?.call(widget.row) ?? false; if (disable) return; _hasFocus = update( @@ -373,7 +373,7 @@ class CheckboxSelectionWidgetState @override void updateState(PlutoNotifierEvent event) { final disable = - widget.column.disableRowCheckWhen?.call(widget.row) ?? false; + widget.column.disableRowCheckboxWhen?.call(widget.row) ?? false; if (disable) { _checked = _pureValue; return; @@ -423,7 +423,7 @@ class CheckboxSelectionWidgetState @override Widget build(BuildContext context) { final disable = - widget.column.disableRowCheckWhen?.call(widget.row) ?? false; + widget.column.disableRowCheckboxWhen?.call(widget.row) ?? false; return PlutoScaledCheckbox( value: _checked,