Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
feat: on enter exit editing property field #1295 (#1747)
Mohammad Zolfagharic9166137be32
diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_editor.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_editor.dartindex f2099be7b5..bdffd8a59b 100644--- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_editor.dart+++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_editor.dart@@ -6,7 +6,7 @@ import 'package:dartz/dartz.dart' show none;import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra_ui/style_widget/button.dart';import 'package:flowy_infra_ui/style_widget/text.dart';-import 'package:flowy_infra_ui/widget/rounded_input_field.dart';+import 'package:flowy_infra_ui/style_widget/text_field.dart';import 'package:flowy_infra_ui/widget/spacing.dart';import 'package:appflowy_backend/log.dart';import 'package:flutter/material.dart';@@ -135,11 +135,9 @@ class _FieldNameTextField extends StatefulWidget {class _FieldNameTextFieldState extends State<_FieldNameTextField> {FocusNode focusNode = FocusNode();- late TextEditingController controller;@overridevoid initState() {- controller = TextEditingController();focusNode.addListener(() {if (focusNode.hasFocus) {widget.popoverMutex.close();@@ -157,33 +155,23 @@ class _FieldNameTextFieldState extends State<_FieldNameTextField> {@overrideWidget build(BuildContext context) {- return MultiBlocListener(- listeners: [- BlocListener<FieldEditorBloc, FieldEditorState>(- listenWhen: (p, c) => p.field == none(),- listener: (context, state) {- focusNode.requestFocus();- },- ),- BlocListener<FieldEditorBloc, FieldEditorState>(- listenWhen: (p, c) => controller.text != c.name,- listener: (context, state) {- controller.text = state.name;- },- ),- ],+ return BlocListener<FieldEditorBloc, FieldEditorState>(+ listenWhen: (p, c) => p.field == none(),+ listener: (context, state) {+ focusNode.requestFocus();+ },child: BlocBuilder<FieldEditorBloc, FieldEditorState>(buildWhen: (previous, current) =>previous.errorText != current.errorText,builder: (context, state) {return Padding(padding: const EdgeInsets.symmetric(horizontal: 12.0),- child: RoundedInputField(- height: 36,+ child: FlowyTextField(focusNode: focusNode,- style: Theme.of(context).textTheme.bodyMedium,- controller: controller,- errorText: context.read<FieldEditorBloc>().state.errorText,+ onSubmitted: (String _) => PopoverContainer.of(context).close(),+ text: context.read<FieldEditorBloc>().state.name,+ errorText: context.read<FieldEditorBloc>().state.errorText.isEmpty ?+ null : context.read<FieldEditorBloc>().state.errorText,onChanged: (newName) {context.read<FieldEditorBloc>()diff --git a/frontend/app_flowy/packages/flowy_infra_ui/lib/style_widget/text_field.dart b/frontend/app_flowy/packages/flowy_infra_ui/lib/style_widget/text_field.dartindex b34864064e..067c3cc64c 100644--- a/frontend/app_flowy/packages/flowy_infra_ui/lib/style_widget/text_field.dart+++ b/frontend/app_flowy/packages/flowy_infra_ui/lib/style_widget/text_field.dart@@ -19,6 +19,7 @@ class FlowyTextField extends StatefulWidget {final bool autoClearWhenDone;final bool submitOnLeave;final Duration? debounceDuration;+ final String? errorText;const FlowyTextField({this.hintText = "",@@ -34,6 +35,7 @@ class FlowyTextField extends StatefulWidget {this.autoClearWhenDone = false,this.submitOnLeave = false,this.debounceDuration,+ this.errorText,Key? key,}) : super(key: key);@@ -117,6 +119,7 @@ class FlowyTextFieldState extends State<FlowyTextField> {),isDense: true,hintText: widget.hintText,+ errorText: widget.errorText,hintStyle: Theme.of(context).textTheme.bodySmall!@@ -128,7 +131,21 @@ class FlowyTextFieldState extends State<FlowyTextField> {color: Theme.of(context).colorScheme.primary,width: 1.0,),- borderRadius: Corners.s8Border,+ borderRadius: Corners.s10Border,+ ),+ errorBorder: OutlineInputBorder(+ borderSide: BorderSide(+ color: Theme.of(context).colorScheme.error,+ width: 1.0,+ ),+ borderRadius: Corners.s10Border,+ ),+ focusedErrorBorder: OutlineInputBorder(+ borderSide: BorderSide(+ color: Theme.of(context).colorScheme.error,+ width: 1.0,+ ),+ borderRadius: Corners.s10Border,),),);diff --git a/frontend/app_flowy/packages/flowy_infra_ui/lib/widget/rounded_input_field.dart b/frontend/app_flowy/packages/flowy_infra_ui/lib/widget/rounded_input_field.dartindex 727eff52c4..e6ab0810b1 100644--- a/frontend/app_flowy/packages/flowy_infra_ui/lib/widget/rounded_input_field.dart+++ b/frontend/app_flowy/packages/flowy_infra_ui/lib/widget/rounded_input_field.dart@@ -27,6 +27,7 @@ class RoundedInputField extends StatefulWidget {final TextEditingController? controller;final bool autoFocus;final int? maxLength;+ final Function(String)? onFieldSubmitted;const RoundedInputField({Key? key,@@ -51,6 +52,7 @@ class RoundedInputField extends StatefulWidget {this.controller,this.autoFocus = false,this.maxLength,+ this.onFieldSubmitted,}) : super(key: key);@override@@ -106,6 +108,7 @@ class _RoundedInputFieldState extends State<RoundedInputField> {maxLength: widget.maxLength,maxLengthEnforcement:MaxLengthEnforcement.truncateAfterCompositionEnds,+ onFieldSubmitted: widget.onFieldSubmitted,onChanged: (value) {inputText = value;if (widget.onChanged != null) {