mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: config edit pannel
This commit is contained in:
parent
475d511829
commit
2bbcfaf3ce
@ -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;
|
||||
|
@ -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<Object> 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');
|
||||
}
|
||||
|
@ -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';
|
||||
|
@ -12,10 +12,10 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
||||
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<EditPannelContext> editContext,
|
||||
required Option<EditPannelContext> pannelContext,
|
||||
}) = _HomeState;
|
||||
|
||||
factory HomeState.initial() => HomeState(
|
||||
isLoading: false,
|
||||
forceCollapse: false,
|
||||
editContext: none(),
|
||||
pannelContext: none(),
|
||||
);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class HomeLayout {
|
||||
HomeLayout(BuildContext context, BoxConstraints homeScreenConstraint, bool forceCollapse) {
|
||||
final homeBlocState = context.read<HomeBloc>().state;
|
||||
|
||||
showEditPannel = homeBlocState.editContext.isSome();
|
||||
showEditPannel = homeBlocState.pannelContext.isSome();
|
||||
|
||||
menuWidth = Sizes.sideBarMed;
|
||||
if (context.widthPx >= PageBreaks.desktop) {
|
||||
|
@ -126,13 +126,22 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
|
||||
Widget _buildEditPannel({required HomeState homeState, required BuildContext context, required HomeLayout layout}) {
|
||||
final homeBloc = context.read<HomeBloc>();
|
||||
Widget editPannel = EditPannel(
|
||||
context: homeState.editContext,
|
||||
onEndEdit: () => homeBloc.add(const HomeEvent.dismissEditPannel()),
|
||||
return BlocBuilder<HomeBloc, HomeState>(
|
||||
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({
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -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<AppTheme>();
|
||||
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;
|
||||
|
@ -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<EditPannelContext> 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,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
@ -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,
|
||||
|
@ -279,6 +279,17 @@ class FlowyOverlayState extends State<FlowyOverlay> {
|
||||
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(
|
||||
|
Loading…
Reference in New Issue
Block a user