|
@@ -1,7 +1,12 @@
|
|
import 'package:app_flowy/plugins/grid/application/field/field_editor_bloc.dart';
|
|
import 'package:app_flowy/plugins/grid/application/field/field_editor_bloc.dart';
|
|
import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_context.dart';
|
|
import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_context.dart';
|
|
|
|
+import 'package:app_flowy/plugins/grid/presentation/layout/sizes.dart';
|
|
|
|
+import 'package:app_flowy/workspace/presentation/widgets/dialogs.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
+import 'package:flowy_infra/image.dart';
|
|
|
|
+import 'package:flowy_infra/theme.dart';
|
|
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
|
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
|
|
|
+import 'package:flowy_infra_ui/style_widget/button.dart';
|
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
|
import 'package:flowy_infra_ui/widget/spacing.dart';
|
|
import 'package:flowy_infra_ui/widget/spacing.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/material.dart';
|
|
@@ -13,6 +18,7 @@ import 'field_type_option_editor.dart';
|
|
class FieldEditor extends StatelessWidget with FlowyOverlayDelegate {
|
|
class FieldEditor extends StatelessWidget with FlowyOverlayDelegate {
|
|
final String gridId;
|
|
final String gridId;
|
|
final String fieldName;
|
|
final String fieldName;
|
|
|
|
+ final bool isGroupField;
|
|
final VoidCallback? onRemoved;
|
|
final VoidCallback? onRemoved;
|
|
|
|
|
|
final IFieldTypeOptionLoader typeOptionLoader;
|
|
final IFieldTypeOptionLoader typeOptionLoader;
|
|
@@ -20,6 +26,7 @@ class FieldEditor extends StatelessWidget with FlowyOverlayDelegate {
|
|
required this.gridId,
|
|
required this.gridId,
|
|
this.fieldName = "",
|
|
this.fieldName = "",
|
|
required this.typeOptionLoader,
|
|
required this.typeOptionLoader,
|
|
|
|
+ this.isGroupField = false,
|
|
this.onRemoved,
|
|
this.onRemoved,
|
|
Key? key,
|
|
Key? key,
|
|
}) : super(key: key);
|
|
}) : super(key: key);
|
|
@@ -30,6 +37,7 @@ class FieldEditor extends StatelessWidget with FlowyOverlayDelegate {
|
|
create: (context) => FieldEditorBloc(
|
|
create: (context) => FieldEditorBloc(
|
|
gridId: gridId,
|
|
gridId: gridId,
|
|
fieldName: fieldName,
|
|
fieldName: fieldName,
|
|
|
|
+ isGroupField: isGroupField,
|
|
loader: typeOptionLoader,
|
|
loader: typeOptionLoader,
|
|
)..add(const FieldEditorEvent.initial()),
|
|
)..add(const FieldEditorEvent.initial()),
|
|
child: BlocBuilder<FieldEditorBloc, FieldEditorState>(
|
|
child: BlocBuilder<FieldEditorBloc, FieldEditorState>(
|
|
@@ -43,6 +51,8 @@ class FieldEditor extends StatelessWidget with FlowyOverlayDelegate {
|
|
const VSpace(10),
|
|
const VSpace(10),
|
|
const _FieldNameCell(),
|
|
const _FieldNameCell(),
|
|
const VSpace(10),
|
|
const VSpace(10),
|
|
|
|
+ const _DeleteFieldButton(),
|
|
|
|
+ const VSpace(10),
|
|
const _FieldTypeOptionCell(),
|
|
const _FieldTypeOptionCell(),
|
|
],
|
|
],
|
|
);
|
|
);
|
|
@@ -121,3 +131,47 @@ class _FieldNameCell extends StatelessWidget {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+class _DeleteFieldButton extends StatelessWidget {
|
|
|
|
+ const _DeleteFieldButton({Key? key}) : super(key: key);
|
|
|
|
+
|
|
|
|
+ @override
|
|
|
|
+ Widget build(BuildContext context) {
|
|
|
|
+ final theme = context.watch<AppTheme>();
|
|
|
|
+ return BlocBuilder<FieldEditorBloc, FieldEditorState>(
|
|
|
|
+ builder: (context, state) {
|
|
|
|
+ final enable = !state.canDelete && !state.isGroupField;
|
|
|
|
+ return SizedBox(
|
|
|
|
+ height: GridSize.typeOptionItemHeight,
|
|
|
|
+ child: FlowyButton(
|
|
|
|
+ text: FlowyText.medium(
|
|
|
|
+ LocaleKeys.grid_field_delete.tr(),
|
|
|
|
+ fontSize: 12,
|
|
|
|
+ color: enable ? null : theme.shader4,
|
|
|
|
+ ),
|
|
|
|
+ hoverColor: theme.hover,
|
|
|
|
+ onTap: () {
|
|
|
|
+ if (enable) {
|
|
|
|
+ FlowyAlertDialog(
|
|
|
|
+ title: LocaleKeys.grid_field_deleteFieldPromptMessage.tr(),
|
|
|
|
+ cancel: () {
|
|
|
|
+ FlowyOverlay.of(context).remove(FieldEditor.identifier());
|
|
|
|
+ },
|
|
|
|
+ confirm: () {
|
|
|
|
+ context
|
|
|
|
+ .read<FieldEditorBloc>()
|
|
|
|
+ .add(const FieldEditorEvent.deleteField());
|
|
|
|
+ FlowyOverlay.of(context).remove(FieldEditor.identifier());
|
|
|
|
+ },
|
|
|
|
+ ).show(context);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ leftIcon: svgWidget('grid/delete', color: theme.iconColor),
|
|
|
|
+ ),
|
|
|
|
+ );
|
|
|
|
+ },
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void so() {}
|
|
|
|
+}
|