chore: make select option cell selectable

This commit is contained in:
appflowy 2022-09-07 14:03:28 +08:00
parent 8894e9c784
commit 9bc2bc82be
3 changed files with 33 additions and 31 deletions

View File

@ -56,23 +56,23 @@ class _BoardSelectOptionCellState extends State<BoardSelectOptionCell> {
(option) => SelectOptionTag.fromOption(
context: context,
option: option,
onSelected: () {
SelectOptionCellEditor.show(
context: context,
cellController: widget.cellControllerBuilder.build()
as GridSelectOptionCellController,
);
},
),
)
.toList();
return IntrinsicHeight(
child: Stack(
alignment: AlignmentDirectional.center,
fit: StackFit.expand,
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 6),
child: Wrap(spacing: 4, runSpacing: 2, children: children),
),
_SelectOptionDialog(
controller: widget.cellControllerBuilder.build(),
),
],
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 6),
child: SizedBox.expand(
child: Wrap(spacing: 4, runSpacing: 2, children: children),
),
),
);
}
@ -98,12 +98,13 @@ class _SelectOptionDialog extends StatelessWidget {
@override
Widget build(BuildContext context) {
return InkWell(onTap: () {
SelectOptionCellEditor.show(
context,
_controller,
() {},
);
});
return SizedBox(
child: InkWell(onTap: () {
SelectOptionCellEditor.show(
context: context,
cellController: _controller,
);
}),
);
}
}

View File

@ -183,9 +183,10 @@ class SelectOptionWrap extends StatelessWidget {
InkWell(onTap: () {
onFocus?.call(true);
SelectOptionCellEditor.show(
context,
cellControllerBuilder.build() as GridSelectOptionCellController,
() => onFocus?.call(false),
context: context,
cellController:
cellControllerBuilder.build() as GridSelectOptionCellController,
onDismissed: () => onFocus?.call(false),
);
}),
],

View File

@ -26,11 +26,11 @@ const double _editorPannelWidth = 300;
class SelectOptionCellEditor extends StatelessWidget with FlowyOverlayDelegate {
final GridSelectOptionCellController cellController;
final VoidCallback onDismissed;
final VoidCallback? onDismissed;
const SelectOptionCellEditor({
required this.cellController,
required this.onDismissed,
this.onDismissed,
Key? key,
}) : super(key: key);
@ -58,14 +58,14 @@ class SelectOptionCellEditor extends StatelessWidget with FlowyOverlayDelegate {
);
}
static void show(
BuildContext context,
GridSelectOptionCellController cellContext,
VoidCallback onDismissed,
) {
static void show({
required BuildContext context,
required GridSelectOptionCellController cellController,
VoidCallback? onDismissed,
}) {
SelectOptionCellEditor.remove(context);
final editor = SelectOptionCellEditor(
cellController: cellContext,
cellController: cellController,
onDismissed: onDismissed,
);
@ -94,7 +94,7 @@ class SelectOptionCellEditor extends StatelessWidget with FlowyOverlayDelegate {
bool asBarrier() => true;
@override
void didRemove() => onDismissed();
void didRemove() => onDismissed?.call();
}
class _OptionList extends StatelessWidget {