|
@@ -1,7 +1,9 @@
|
|
import 'package:app_flowy/startup/startup.dart';
|
|
import 'package:app_flowy/startup/startup.dart';
|
|
import 'package:app_flowy/plugins/grid/application/prelude.dart';
|
|
import 'package:app_flowy/plugins/grid/application/prelude.dart';
|
|
|
|
+import 'package:appflowy_popover/popover.dart';
|
|
|
|
|
|
import 'package:flowy_infra/theme.dart';
|
|
import 'package:flowy_infra/theme.dart';
|
|
|
|
+import 'package:flowy_infra_ui/flowy_infra_ui_web.dart';
|
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
|
// ignore: unused_import
|
|
// ignore: unused_import
|
|
import 'package:flowy_sdk/log.dart';
|
|
import 'package:flowy_sdk/log.dart';
|
|
@@ -133,7 +135,7 @@ class _MultiSelectCellState extends State<GridMultiSelectCell> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-class SelectOptionWrap extends StatelessWidget {
|
|
|
|
|
|
+class SelectOptionWrap extends StatefulWidget {
|
|
final List<SelectOptionPB> selectOptions;
|
|
final List<SelectOptionPB> selectOptions;
|
|
final void Function(bool)? onFocus;
|
|
final void Function(bool)? onFocus;
|
|
final SelectOptionCellStyle? cellStyle;
|
|
final SelectOptionCellStyle? cellStyle;
|
|
@@ -146,15 +148,28 @@ class SelectOptionWrap extends StatelessWidget {
|
|
Key? key,
|
|
Key? key,
|
|
}) : super(key: key);
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
+ @override
|
|
|
|
+ State<StatefulWidget> createState() => _SelectOptionWrapState();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+class _SelectOptionWrapState extends State<SelectOptionWrap> {
|
|
|
|
+ late PopoverController _popover;
|
|
|
|
+
|
|
|
|
+ @override
|
|
|
|
+ void initState() {
|
|
|
|
+ _popover = PopoverController();
|
|
|
|
+ super.initState();
|
|
|
|
+ }
|
|
|
|
+
|
|
@override
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
final theme = context.watch<AppTheme>();
|
|
final theme = context.watch<AppTheme>();
|
|
final Widget child;
|
|
final Widget child;
|
|
- if (selectOptions.isEmpty && cellStyle != null) {
|
|
|
|
|
|
+ if (widget.selectOptions.isEmpty && widget.cellStyle != null) {
|
|
child = Align(
|
|
child = Align(
|
|
alignment: Alignment.centerLeft,
|
|
alignment: Alignment.centerLeft,
|
|
child: FlowyText.medium(
|
|
child: FlowyText.medium(
|
|
- cellStyle!.placeholder,
|
|
|
|
|
|
+ widget.cellStyle!.placeholder,
|
|
fontSize: 14,
|
|
fontSize: 14,
|
|
color: theme.shader3,
|
|
color: theme.shader3,
|
|
),
|
|
),
|
|
@@ -163,7 +178,7 @@ class SelectOptionWrap extends StatelessWidget {
|
|
child = Align(
|
|
child = Align(
|
|
alignment: Alignment.centerLeft,
|
|
alignment: Alignment.centerLeft,
|
|
child: Wrap(
|
|
child: Wrap(
|
|
- children: selectOptions
|
|
|
|
|
|
+ children: widget.selectOptions
|
|
.map((option) => SelectOptionTag.fromOption(
|
|
.map((option) => SelectOptionTag.fromOption(
|
|
context: context,
|
|
context: context,
|
|
option: option,
|
|
option: option,
|
|
@@ -179,14 +194,37 @@ class SelectOptionWrap extends StatelessWidget {
|
|
alignment: AlignmentDirectional.center,
|
|
alignment: AlignmentDirectional.center,
|
|
fit: StackFit.expand,
|
|
fit: StackFit.expand,
|
|
children: [
|
|
children: [
|
|
- child,
|
|
|
|
|
|
+ Popover(
|
|
|
|
+ controller: _popover,
|
|
|
|
+ child: child,
|
|
|
|
+ targetAnchor: Alignment.bottomCenter,
|
|
|
|
+ followerAnchor: Alignment.topCenter,
|
|
|
|
+ offset: const Offset(0, 20),
|
|
|
|
+ popupBuilder: (BuildContext context) {
|
|
|
|
+ WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
|
|
|
+ widget.onFocus?.call(true);
|
|
|
|
+ });
|
|
|
|
+ return OverlayContainer(
|
|
|
|
+ constraints: BoxConstraints.loose(
|
|
|
|
+ Size(SelectOptionCellEditor.editorPanelWidth, 300)),
|
|
|
|
+ child: SizedBox(
|
|
|
|
+ width: SelectOptionCellEditor.editorPanelWidth,
|
|
|
|
+ child: SelectOptionCellEditor(
|
|
|
|
+ cellController: widget.cellControllerBuilder.build()
|
|
|
|
+ as GridSelectOptionCellController,
|
|
|
|
+ onDismissed: () {
|
|
|
|
+ widget.onFocus?.call(false);
|
|
|
|
+ },
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
|
|
+ );
|
|
|
|
+ },
|
|
|
|
+ onClose: () {
|
|
|
|
+ widget.onFocus?.call(false);
|
|
|
|
+ },
|
|
|
|
+ ),
|
|
InkWell(onTap: () {
|
|
InkWell(onTap: () {
|
|
- onFocus?.call(true);
|
|
|
|
- SelectOptionCellEditor.show(
|
|
|
|
- context,
|
|
|
|
- cellControllerBuilder.build() as GridSelectOptionCellController,
|
|
|
|
- () => onFocus?.call(false),
|
|
|
|
- );
|
|
|
|
|
|
+ _popover.show();
|
|
}),
|
|
}),
|
|
],
|
|
],
|
|
);
|
|
);
|