diff --git a/frontend/app_flowy/lib/workspace/application/appearance.dart b/frontend/app_flowy/lib/workspace/application/appearance.dart index ffd7e18c92..06473729a8 100644 --- a/frontend/app_flowy/lib/workspace/application/appearance.dart +++ b/frontend/app_flowy/lib/workspace/application/appearance.dart @@ -7,7 +7,6 @@ import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_setting.pb.dart'; import 'package:flutter/material.dart'; import 'package:easy_localization/easy_localization.dart'; -import 'package:async/async.dart'; class AppearanceSettingModel extends ChangeNotifier with EquatableMixin { AppearanceSettings setting; diff --git a/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_context.dart b/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_context.dart index cd52bc7f11..571461b365 100644 --- a/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_context.dart +++ b/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_context.dart @@ -5,19 +5,8 @@ abstract class EditPannelContext extends Equatable { final String identifier; final String title; final Widget child; - const EditPannelContext( - {required this.child, required this.identifier, required this.title}); + const EditPannelContext({required this.child, required this.identifier, required this.title}); @override List get props => [identifier]; } - -class BlankEditPannelContext extends EditPannelContext { - const BlankEditPannelContext() - : super(child: const Text('Blank'), identifier: '1', title: ''); -} - -class CellEditPannelContext extends EditPannelContext { - const CellEditPannelContext() - : super(child: const Text('shit'), identifier: 'test', title: 'test'); -} diff --git a/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.dart b/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.dart index 0ae2e8326a..e1f2f5835d 100644 --- a/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.dart +++ b/frontend/app_flowy/lib/workspace/application/edit_pannel/edit_pannel_bloc.dart @@ -1,7 +1,6 @@ import 'package:app_flowy/workspace/application/edit_pannel/edit_context.dart'; import 'package:dartz/dartz.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; -// ignore: import_of_legacy_library_into_null_safe import 'package:flutter_bloc/flutter_bloc.dart'; part 'edit_pannel_bloc.freezed.dart'; diff --git a/frontend/app_flowy/lib/workspace/application/home/home_bloc.dart b/frontend/app_flowy/lib/workspace/application/home/home_bloc.dart index e4b0482989..5ed7ce959d 100644 --- a/frontend/app_flowy/lib/workspace/application/home/home_bloc.dart +++ b/frontend/app_flowy/lib/workspace/application/home/home_bloc.dart @@ -12,10 +12,10 @@ class HomeBloc extends Bloc { emit(state.copyWith(isLoading: e.isLoading)); }, setEditPannel: (e) async { - emit(state.copyWith(editContext: some(e.editContext))); + emit(state.copyWith(pannelContext: some(e.editContext))); }, dismissEditPannel: (value) async { - emit(state.copyWith(editContext: none())); + emit(state.copyWith(pannelContext: none())); }, forceCollapse: (e) async { emit(state.copyWith(forceCollapse: e.forceCollapse)); @@ -43,12 +43,12 @@ class HomeState with _$HomeState { const factory HomeState({ required bool isLoading, required bool forceCollapse, - required Option editContext, + required Option pannelContext, }) = _HomeState; factory HomeState.initial() => HomeState( isLoading: false, forceCollapse: false, - editContext: none(), + pannelContext: none(), ); } diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart index f0192a846b..0405279851 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart @@ -20,7 +20,7 @@ class HomeLayout { HomeLayout(BuildContext context, BoxConstraints homeScreenConstraint, bool forceCollapse) { final homeBlocState = context.read().state; - showEditPannel = homeBlocState.editContext.isSome(); + showEditPannel = homeBlocState.pannelContext.isSome(); menuWidth = Sizes.sideBarMed; if (context.widthPx >= PageBreaks.desktop) { diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart index 88ec0f5ad6..e9bb80dd30 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart @@ -126,13 +126,22 @@ class _HomeScreenState extends State { Widget _buildEditPannel({required HomeState homeState, required BuildContext context, required HomeLayout layout}) { final homeBloc = context.read(); - Widget editPannel = EditPannel( - context: homeState.editContext, - onEndEdit: () => homeBloc.add(const HomeEvent.dismissEditPannel()), + return BlocBuilder( + buildWhen: (previous, current) => previous.pannelContext != current.pannelContext, + builder: (context, state) { + return state.pannelContext.fold( + () => const SizedBox(), + (pannelContext) => FocusTraversalGroup( + child: RepaintBoundary( + child: EditPannel( + pannelContext: pannelContext, + onEndEdit: () => homeBloc.add(const HomeEvent.dismissEditPannel()), + ), + ), + ), + ); + }, ); - // editPannel = RepaintBoundary(child: editPannel); - // editPannel = FocusTraversalGroup(child: editPannel); - return editPannel; } Widget _layoutWidgets({ diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_editor.dart b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_editor.dart new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/field_editor.dart @@ -0,0 +1 @@ + diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/header_cell.dart b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/header_cell.dart index 2f9b0b2fd2..4e870ae27d 100755 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/header_cell.dart +++ b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/header_cell.dart @@ -4,7 +4,6 @@ import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.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/dialog/styled_dialogs.dart'; import 'package:flowy_sdk/protobuf/flowy-grid-data-model/grid.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -23,13 +22,7 @@ class HeaderCell extends StatelessWidget { FlowyPoppuWindow.show( context, size: Size(300, 100), - child: Container( - color: Colors.red, - child: TextField( - decoration: InputDecoration(hintText: 'Please enter a text'), - onSubmitted: print, - ), - ), + child: CusTextField(), ); // StyledDialog( @@ -46,6 +39,21 @@ class HeaderCell extends StatelessWidget { } } +class CusTextField extends StatelessWidget { + const CusTextField({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + final theme = context.watch(); + return Container( + color: theme.bg3, + child: TextField( + decoration: InputDecoration(hintText: 'Please enter a text'), + onSubmitted: print, + )); + } +} + class HeaderCellContainer extends StatelessWidget { final HeaderCell child; final double width; diff --git a/frontend/app_flowy/lib/workspace/presentation/widgets/edit_pannel/edit_pannel.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/edit_pannel/edit_pannel.dart index b892a8e49d..f9e5e0e6b5 100644 --- a/frontend/app_flowy/lib/workspace/presentation/widgets/edit_pannel/edit_pannel.dart +++ b/frontend/app_flowy/lib/workspace/presentation/widgets/edit_pannel/edit_pannel.dart @@ -2,7 +2,6 @@ import 'package:app_flowy/workspace/application/edit_pannel/edit_pannel_bloc.dar import 'package:app_flowy/workspace/application/edit_pannel/edit_context.dart'; import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/workspace/presentation/home/home_sizes.dart'; -import 'package:dartz/dartz.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra_ui/style_widget/bar_title.dart'; import 'package:flowy_infra_ui/style_widget/close_button.dart'; @@ -11,15 +10,13 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:app_flowy/generated/locale_keys.g.dart'; class EditPannel extends StatelessWidget { - late final EditPannelContext editContext; + final EditPannelContext pannelContext; final VoidCallback onEndEdit; - EditPannel({ + const EditPannel({ Key? key, - required Option context, + required this.pannelContext, required this.onEndEdit, - }) : super(key: key) { - editContext = context.fold(() => const BlankEditPannelContext(), (c) => c); - } + }) : super(key: key); @override Widget build(BuildContext context) { @@ -34,7 +31,7 @@ class EditPannel extends StatelessWidget { children: [ EditPannelTopBar(onClose: () => onEndEdit()), Expanded( - child: editContext.child, + child: pannelContext.child, ), ], ); diff --git a/frontend/app_flowy/lib/workspace/presentation/widgets/pop_up_window.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/pop_up_window.dart index bad7eb2da6..bea342747b 100644 --- a/frontend/app_flowy/lib/workspace/presentation/widgets/pop_up_window.dart +++ b/frontend/app_flowy/lib/workspace/presentation/widgets/pop_up_window.dart @@ -21,7 +21,6 @@ class FlowyPoppuWindow extends StatelessWidget { required Size size, }) async { final window = await getWindowInfo(); - FlowyOverlay.of(context).insertWithRect( widget: SizedBox.fromSize( size: size, diff --git a/frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/flowy_overlay.dart b/frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/flowy_overlay.dart index 4732374372..11ec524ed4 100644 --- a/frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/flowy_overlay.dart +++ b/frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/flowy_overlay.dart @@ -279,6 +279,17 @@ class FlowyOverlayState extends State { children.add(child); } + // Try to fix there is no overlay for editabletext widget. e.g. TextField. + // // Check out the TextSelectionOverlay class in text_selection.dart. + // // ... + // // final OverlayState? overlay = Overlay.of(context, rootOverlay: true); + // // assert( + // // overlay != null, + // // 'No Overlay widget exists above $context.\n' + // // 'Usually the Navigator created by WidgetsApp provides the overlay. Perhaps your ' + // // 'app content was created above the Navigator with the WidgetsApp builder parameter.', + // // ); + // // ... return MaterialApp( debugShowCheckedModeBanner: false, home: Stack(