|
@@ -20,11 +20,11 @@ class SelectOptionCellStyle extends GridCellStyle {
|
|
}
|
|
}
|
|
|
|
|
|
class SingleSelectCell extends GridCellWidget {
|
|
class SingleSelectCell extends GridCellWidget {
|
|
- final GridSelectOptionCellContext cellContext;
|
|
|
|
|
|
+ final GridCellContextBuilder cellContextBuilder;
|
|
late final SelectOptionCellStyle? cellStyle;
|
|
late final SelectOptionCellStyle? cellStyle;
|
|
|
|
|
|
SingleSelectCell({
|
|
SingleSelectCell({
|
|
- required this.cellContext,
|
|
|
|
|
|
+ required this.cellContextBuilder,
|
|
GridCellStyle? style,
|
|
GridCellStyle? style,
|
|
Key? key,
|
|
Key? key,
|
|
}) : super(key: key) {
|
|
}) : super(key: key) {
|
|
@@ -45,7 +45,8 @@ class _SingleSelectCellState extends State<SingleSelectCell> {
|
|
@override
|
|
@override
|
|
void initState() {
|
|
void initState() {
|
|
// Log.trace("init widget $hashCode");
|
|
// Log.trace("init widget $hashCode");
|
|
- _cellBloc = getIt<SelectionCellBloc>(param1: widget.cellContext)..add(const SelectionCellEvent.initial());
|
|
|
|
|
|
+ final cellContext = _buildCellContext();
|
|
|
|
+ _cellBloc = getIt<SelectionCellBloc>(param1: cellContext)..add(const SelectionCellEvent.initial());
|
|
super.initState();
|
|
super.initState();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -69,7 +70,7 @@ class _SingleSelectCellState extends State<SingleSelectCell> {
|
|
widget.onFocus.value = true;
|
|
widget.onFocus.value = true;
|
|
SelectOptionCellEditor.show(
|
|
SelectOptionCellEditor.show(
|
|
context,
|
|
context,
|
|
- widget.cellContext.clone(),
|
|
|
|
|
|
+ _buildCellContext(),
|
|
() => widget.onFocus.value = false,
|
|
() => widget.onFocus.value = false,
|
|
);
|
|
);
|
|
},
|
|
},
|
|
@@ -81,12 +82,8 @@ class _SingleSelectCellState extends State<SingleSelectCell> {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- @override
|
|
|
|
- void didUpdateWidget(covariant SingleSelectCell oldWidget) {
|
|
|
|
- if (oldWidget.cellContext != widget.cellContext) {
|
|
|
|
- // Log.trace("did update widget $hashCode");
|
|
|
|
- }
|
|
|
|
- super.didUpdateWidget(oldWidget);
|
|
|
|
|
|
+ GridSelectOptionCellContext _buildCellContext() {
|
|
|
|
+ return widget.cellContextBuilder.build() as GridSelectOptionCellContext;
|
|
}
|
|
}
|
|
|
|
|
|
@override
|
|
@override
|
|
@@ -99,11 +96,11 @@ class _SingleSelectCellState extends State<SingleSelectCell> {
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
//----------------------------------------------------------------
|
|
class MultiSelectCell extends GridCellWidget {
|
|
class MultiSelectCell extends GridCellWidget {
|
|
- final GridSelectOptionCellContext cellContext;
|
|
|
|
|
|
+ final GridCellContextBuilder cellContextBuilder;
|
|
late final SelectOptionCellStyle? cellStyle;
|
|
late final SelectOptionCellStyle? cellStyle;
|
|
|
|
|
|
MultiSelectCell({
|
|
MultiSelectCell({
|
|
- required this.cellContext,
|
|
|
|
|
|
+ required this.cellContextBuilder,
|
|
GridCellStyle? style,
|
|
GridCellStyle? style,
|
|
Key? key,
|
|
Key? key,
|
|
}) : super(key: key) {
|
|
}) : super(key: key) {
|
|
@@ -123,7 +120,8 @@ class _MultiSelectCellState extends State<MultiSelectCell> {
|
|
|
|
|
|
@override
|
|
@override
|
|
void initState() {
|
|
void initState() {
|
|
- _cellBloc = getIt<SelectionCellBloc>(param1: widget.cellContext)..add(const SelectionCellEvent.initial());
|
|
|
|
|
|
+ final cellContext = _buildCellContext();
|
|
|
|
+ _cellBloc = getIt<SelectionCellBloc>(param1: cellContext)..add(const SelectionCellEvent.initial());
|
|
super.initState();
|
|
super.initState();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -145,7 +143,7 @@ class _MultiSelectCellState extends State<MultiSelectCell> {
|
|
widget.onFocus.value = true;
|
|
widget.onFocus.value = true;
|
|
SelectOptionCellEditor.show(
|
|
SelectOptionCellEditor.show(
|
|
context,
|
|
context,
|
|
- widget.cellContext,
|
|
|
|
|
|
+ _buildCellContext(),
|
|
() => widget.onFocus.value = false,
|
|
() => widget.onFocus.value = false,
|
|
);
|
|
);
|
|
},
|
|
},
|
|
@@ -162,4 +160,8 @@ class _MultiSelectCellState extends State<MultiSelectCell> {
|
|
_cellBloc.close();
|
|
_cellBloc.close();
|
|
super.dispose();
|
|
super.dispose();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ GridSelectOptionCellContext _buildCellContext() {
|
|
|
|
+ return widget.cellContextBuilder.build() as GridSelectOptionCellContext;
|
|
|
|
+ }
|
|
}
|
|
}
|