Skip to content

Commit 1de3999

Browse files
committed
chore: fix bugs
1 parent 97eab3b commit 1de3999

File tree

16 files changed

+160
-82
lines changed

16 files changed

+160
-82
lines changed

frontend/app_flowy/lib/plugins/doc/document.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ class DocumentShareButton extends StatelessWidget {
186186
'Exported to: ${LocaleKeys.notifications_export_path.tr()}');
187187
break;
188188
case ShareAction.copyLink:
189-
FlowyAlertDialog(title: LocaleKeys.shareAction_workInProgress.tr())
189+
NavigatorAlertDialog(
190+
title: LocaleKeys.shareAction_workInProgress.tr())
190191
.show(context);
191192
break;
192193
}

frontend/app_flowy/lib/plugins/doc/presentation/toolbar/link_button.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class FlowyLinkStyleButtonState extends State<FlowyLinkStyleButton> {
8484
value = values.first;
8585
}
8686

87-
TextFieldDialog(
87+
NavigatorTextFieldDialog(
8888
title: 'URL',
8989
value: value,
9090
confirm: (newValue) {

frontend/app_flowy/lib/plugins/grid/application/row/row_detail_bloc.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart';
2+
import 'package:app_flowy/plugins/grid/application/field/field_service.dart';
23
import 'package:flutter_bloc/flutter_bloc.dart';
34
import 'package:freezed_annotation/freezed_annotation.dart';
45
import 'dart:async';
@@ -24,6 +25,13 @@ class RowDetailBloc extends Bloc<RowDetailEvent, RowDetailState> {
2425
didReceiveCellDatas: (_DidReceiveCellDatas value) {
2526
emit(state.copyWith(gridCells: value.gridCells));
2627
},
28+
deleteField: (_DeleteField value) {
29+
final fieldService = FieldService(
30+
gridId: dataController.rowInfo.gridId,
31+
fieldId: value.fieldId,
32+
);
33+
fieldService.deleteField();
34+
},
2735
);
2836
},
2937
);
@@ -49,6 +57,7 @@ class RowDetailBloc extends Bloc<RowDetailEvent, RowDetailState> {
4957
@freezed
5058
class RowDetailEvent with _$RowDetailEvent {
5159
const factory RowDetailEvent.initial() = _Initial;
60+
const factory RowDetailEvent.deleteField(String fieldId) = _DeleteField;
5261
const factory RowDetailEvent.didReceiveCellDatas(
5362
List<GridCellIdentifier> gridCells) = _DidReceiveCellDatas;
5463
}

frontend/app_flowy/lib/plugins/grid/presentation/grid_page.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,7 @@ class _GridFooter extends StatelessWidget {
317317
height: GridSize.footerHeight,
318318
child: Padding(
319319
padding: GridSize.footerContentInsets,
320-
child: const Expanded(
321-
child: SizedBox(height: 40, child: GridAddRowButton()),
322-
),
320+
child: const SizedBox(height: 40, child: GridAddRowButton()),
323321
),
324322
),
325323
),

frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell_action_sheet.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class FieldActionCell extends StatelessWidget {
169169
}
170170
},
171171
leftIcon: svgWidget(action.iconName(),
172-
color: enable ? theme.iconColor : theme.disableIconColor),
172+
color: enable ? theme.iconColor : theme.disableIconColor),
173173
);
174174
}
175175
}
@@ -216,7 +216,7 @@ extension _FieldActionExtension on FieldAction {
216216
.add(const FieldActionSheetEvent.duplicateField());
217217
break;
218218
case FieldAction.delete:
219-
FlowyAlertDialog(
219+
NavigatorAlertDialog(
220220
title: LocaleKeys.grid_field_deleteFieldPromptMessage.tr(),
221221
confirm: () {
222222
context

frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_editor.dart

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ import 'package:app_flowy/plugins/grid/application/field/field_editor_bloc.dart'
22
import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_context.dart';
33
import 'package:appflowy_popover/popover.dart';
44
import 'package:easy_localization/easy_localization.dart';
5-
import 'package:app_flowy/plugins/grid/presentation/layout/sizes.dart';
65
import 'package:app_flowy/workspace/presentation/widgets/dialogs.dart';
7-
import 'package:easy_localization/easy_localization.dart';
8-
import 'package:flowy_infra/image.dart';
96
import 'package:flowy_infra/theme.dart';
107
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
118
import 'package:flowy_infra_ui/style_widget/button.dart';
129
import 'package:flowy_infra_ui/style_widget/text.dart';
1310
import 'package:flowy_infra_ui/widget/spacing.dart';
11+
import 'package:flowy_sdk/log.dart';
1412
import 'package:flutter/material.dart';
1513
import 'package:flutter_bloc/flutter_bloc.dart';
1614
import 'package:app_flowy/generated/locale_keys.g.dart';
@@ -21,15 +19,15 @@ class FieldEditor extends StatefulWidget {
2119
final String gridId;
2220
final String fieldName;
2321
final bool isGroupField;
24-
final VoidCallback? onRemoved;
22+
final Function(String)? onDeleted;
2523

2624
final IFieldTypeOptionLoader typeOptionLoader;
2725
const FieldEditor({
2826
required this.gridId,
2927
this.fieldName = "",
3028
required this.typeOptionLoader,
3129
this.isGroupField = false,
32-
this.onRemoved,
30+
this.onDeleted,
3331
Key? key,
3432
}) : super(key: key);
3533

@@ -56,7 +54,6 @@ class _FieldEditorState extends State<FieldEditor> {
5654
loader: widget.typeOptionLoader,
5755
)..add(const FieldEditorEvent.initial()),
5856
child: BlocBuilder<FieldEditorBloc, FieldEditorState>(
59-
buildWhen: (p, c) => false,
6057
builder: (context, state) {
6158
return ListView(
6259
shrinkWrap: true,
@@ -66,7 +63,15 @@ class _FieldEditorState extends State<FieldEditor> {
6663
const VSpace(10),
6764
const _FieldNameCell(),
6865
const VSpace(10),
69-
_DeleteFieldButton(popoverMutex: popoverMutex),
66+
_DeleteFieldButton(
67+
popoverMutex: popoverMutex,
68+
onDeleted: () {
69+
state.field.fold(
70+
() => Log.error('Can not delete the field'),
71+
(field) => widget.onDeleted?.call(field.id),
72+
);
73+
},
74+
),
7075
const VSpace(10),
7176
_FieldTypeOptionCell(popoverMutex: popoverMutex),
7277
],
@@ -129,48 +134,54 @@ class _FieldNameCell extends StatelessWidget {
129134

130135
class _DeleteFieldButton extends StatelessWidget {
131136
final PopoverMutex popoverMutex;
137+
final VoidCallback? onDeleted;
132138

133139
const _DeleteFieldButton({
134140
required this.popoverMutex,
141+
required this.onDeleted,
135142
Key? key,
136143
}) : super(key: key);
137144

138145
@override
139146
Widget build(BuildContext context) {
140147
final theme = context.watch<AppTheme>();
141148
return BlocBuilder<FieldEditorBloc, FieldEditorState>(
149+
buildWhen: (previous, current) => previous != current,
142150
builder: (context, state) {
143151
final enable = !state.canDelete && !state.isGroupField;
152+
Widget button = FlowyButton(
153+
text: FlowyText.medium(
154+
LocaleKeys.grid_field_delete.tr(),
155+
fontSize: 12,
156+
color: enable ? null : theme.shader4,
157+
),
158+
);
159+
if (enable) button = _wrapPopover(button);
160+
return button;
161+
},
162+
);
163+
}
144164

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-
},
165-
child: FlowyButton(
166-
text: FlowyText.medium(
167-
LocaleKeys.grid_field_delete.tr(),
168-
fontSize: 12,
169-
color: enable ? null : theme.shader4,
170-
),
165+
Widget _wrapPopover(Widget widget) {
166+
return Popover(
167+
triggerActions: PopoverTriggerActionFlags.click,
168+
mutex: popoverMutex,
169+
direction: PopoverDirection.center,
170+
popupBuilder: (popupContext) {
171+
return OverlayContainer(
172+
constraints: BoxConstraints.loose(const Size(400, 240)),
173+
child: PopoverAlertView(
174+
title: LocaleKeys.grid_field_deleteFieldPromptMessage.tr(),
175+
cancel: () => popoverMutex.state?.close(),
176+
confirm: () {
177+
onDeleted?.call();
178+
popoverMutex.state?.close();
179+
},
180+
popoverMutex: popoverMutex,
171181
),
172182
);
173183
},
184+
child: widget,
174185
);
175186
}
176187
}

frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_option_editor.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ class FieldTypeOptionEditor extends StatelessWidget {
6565
return SizedBox(
6666
height: GridSize.typeOptionItemHeight,
6767
child: Popover(
68-
triggerActions:
69-
PopoverTriggerActionFlags.hover | PopoverTriggerActionFlags.click,
68+
triggerActions: PopoverTriggerActionFlags.click,
7069
mutex: popoverMutex,
7170
offset: const Offset(20, 0),
7271
popupBuilder: (context) {

frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/builder.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ Widget? makeTypeOptionWidget({
5454
return builder.build(context);
5555
}
5656

57-
TypeOptionWidgetBuilder makeTypeOptionWidgetBuilder(
58-
{required TypeOptionDataController dataController,
59-
required PopoverMutex popoverMutex}) {
57+
TypeOptionWidgetBuilder makeTypeOptionWidgetBuilder({
58+
required TypeOptionDataController dataController,
59+
required PopoverMutex popoverMutex,
60+
}) {
6061
final gridId = dataController.gridId;
6162
final fieldType = dataController.field.fieldType;
6263

frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/row_action_sheet.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ extension _RowActionExtension on _RowAction {
151151
.add(const RowActionSheetEvent.duplicateRow());
152152
break;
153153
case _RowAction.delete:
154-
FlowyAlertDialog(
154+
NavigatorAlertDialog(
155155
title: LocaleKeys.grid_field_deleteFieldPromptMessage.tr(),
156156
confirm: () {
157157
context

frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/row_detail.dart

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,18 @@ class _PropertyList extends StatelessWidget {
145145
);
146146
});
147147
},
148-
onOpened: () {
148+
onOpened: (controller) {
149149
return OverlayContainer(
150150
constraints: BoxConstraints.loose(const Size(240, 200)),
151151
child: FieldEditor(
152152
gridId: viewId,
153153
typeOptionLoader: NewFieldTypeOptionLoader(gridId: viewId),
154+
onDeleted: (fieldId) {
155+
controller.close();
156+
context
157+
.read<RowDetailBloc>()
158+
.add(RowDetailEvent.deleteField(fieldId));
159+
},
154160
),
155161
);
156162
},
@@ -164,9 +170,11 @@ class _PropertyList extends StatelessWidget {
164170

165171
class _CreateFieldButton extends StatelessWidget {
166172
final String viewId;
167-
final Widget Function() onOpened;
173+
final Widget Function(PopoverController) onOpened;
168174
final VoidCallback onClosed;
169-
const _CreateFieldButton({
175+
final PopoverController popoverController = PopoverController();
176+
177+
_CreateFieldButton({
170178
required this.viewId,
171179
required this.onOpened,
172180
required this.onClosed,
@@ -178,8 +186,9 @@ class _CreateFieldButton extends StatelessWidget {
178186
final theme = context.read<AppTheme>();
179187

180188
return Popover(
189+
controller: popoverController,
181190
triggerActions: PopoverTriggerActionFlags.click,
182-
direction: PopoverDirection.bottomWithLeftAligned,
191+
direction: PopoverDirection.topWithLeftAligned,
183192
onClose: onClosed,
184193
child: Container(
185194
height: 40,
@@ -194,7 +203,7 @@ class _CreateFieldButton extends StatelessWidget {
194203
leftIcon: svgWidget("home/add"),
195204
),
196205
),
197-
popupBuilder: (BuildContext context) => onOpened(),
206+
popupBuilder: (BuildContext context) => onOpened(popoverController),
198207
);
199208
}
200209

@@ -252,7 +261,7 @@ class _RowDetailCellState extends State<_RowDetailCell> {
252261
child: Popover(
253262
controller: popover,
254263
offset: const Offset(20, 0),
255-
popupBuilder: (context) {
264+
popupBuilder: (popoverContext) {
256265
return OverlayContainer(
257266
constraints: BoxConstraints.loose(const Size(240, 200)),
258267
child: FieldEditor(
@@ -263,6 +272,12 @@ class _RowDetailCellState extends State<_RowDetailCell> {
263272
gridId: widget.cellId.gridId,
264273
field: widget.cellId.fieldContext.field,
265274
),
275+
onDeleted: (fieldId) {
276+
popover.close();
277+
context
278+
.read<RowDetailBloc>()
279+
.add(RowDetailEvent.deleteField(fieldId));
280+
},
266281
),
267282
);
268283
},

0 commit comments

Comments
 (0)