@@ -50,10 +50,10 @@ class _FieldEditorState extends State<FieldEditor> {
5050 Widget build (BuildContext context) {
5151 return BlocProvider (
5252 create: (context) => FieldEditorBloc (
53- gridId: gridId,
54- fieldName: fieldName,
55- isGroupField: isGroupField,
56- loader: typeOptionLoader,
53+ gridId: widget. gridId,
54+ fieldName: widget. fieldName,
55+ isGroupField: widget. isGroupField,
56+ loader: widget. typeOptionLoader,
5757 )..add (const FieldEditorEvent .initial ()),
5858 child: BlocBuilder <FieldEditorBloc , FieldEditorState >(
5959 buildWhen: (p, c) => false ,
@@ -66,7 +66,7 @@ class _FieldEditorState extends State<FieldEditor> {
6666 const VSpace (10 ),
6767 const _FieldNameCell (),
6868 const VSpace (10 ),
69- const _DeleteFieldButton (),
69+ _DeleteFieldButton (popoverMutex : popoverMutex ),
7070 const VSpace (10 ),
7171 _FieldTypeOptionCell (popoverMutex: popoverMutex),
7272 ],
@@ -128,45 +128,49 @@ class _FieldNameCell extends StatelessWidget {
128128}
129129
130130class _DeleteFieldButton extends StatelessWidget {
131- const _DeleteFieldButton ({Key ? key}) : super (key: key);
131+ final PopoverMutex popoverMutex;
132+
133+ const _DeleteFieldButton ({
134+ required this .popoverMutex,
135+ Key ? key,
136+ }) : super (key: key);
132137
133138 @override
134139 Widget build (BuildContext context) {
135140 final theme = context.watch <AppTheme >();
136141 return BlocBuilder <FieldEditorBloc , FieldEditorState >(
137142 builder: (context, state) {
138143 final enable = ! state.canDelete && ! state.isGroupField;
139- return SizedBox (
140- height: GridSize .typeOptionItemHeight,
144+
145+ return Popover (
146+ triggerActions: PopoverTriggerActionFlags .click,
147+ mutex: popoverMutex,
148+ direction: PopoverDirection .center,
149+ popupBuilder: (context) {
150+ return FlowyAlertDialog (
151+ title: LocaleKeys .grid_field_deleteFieldPromptMessage.tr (),
152+ cancel: () {
153+ // FlowyOverlay.of(context).remove(FieldEditor.identifier())
154+ // popoverMutex.state?.close();
155+ },
156+ confirm: () {
157+ context
158+ .read <FieldEditorBloc >()
159+ .add (const FieldEditorEvent .deleteField ());
160+
161+ // FlowyOverlay.of(context).remove(FieldEditor.identifier());
162+ },
163+ );
164+ },
141165 child: FlowyButton (
142166 text: FlowyText .medium (
143167 LocaleKeys .grid_field_delete.tr (),
144168 fontSize: 12 ,
145169 color: enable ? null : theme.shader4,
146170 ),
147- hoverColor: theme.hover,
148- onTap: () {
149- if (enable) {
150- FlowyAlertDialog (
151- title: LocaleKeys .grid_field_deleteFieldPromptMessage.tr (),
152- cancel: () {
153- FlowyOverlay .of (context).remove (FieldEditor .identifier ());
154- },
155- confirm: () {
156- context
157- .read <FieldEditorBloc >()
158- .add (const FieldEditorEvent .deleteField ());
159- FlowyOverlay .of (context).remove (FieldEditor .identifier ());
160- },
161- ).show (context);
162- }
163- },
164- leftIcon: svgWidget ('grid/delete' , color: theme.iconColor),
165171 ),
166172 );
167173 },
168174 );
169175 }
170-
171- void so () {}
172176}
0 commit comments