fix: can't find overlay exists above editabletext

This commit is contained in:
appflowy 2022-03-20 22:38:57 +08:00
parent 1f30a77f1d
commit 475d511829
16 changed files with 66 additions and 76 deletions

View File

@ -81,7 +81,6 @@ class MenuAppHeader extends StatelessWidget {
onSecondaryTap: () { onSecondaryTap: () {
final actionList = AppDisclosureActionSheet(onSelected: (action) => _handleAction(context, action)); final actionList = AppDisclosureActionSheet(onSelected: (action) => _handleAction(context, action));
actionList.show( actionList.show(
context,
context, context,
anchorDirection: AnchorDirection.bottomWithCenterAligned, anchorDirection: AnchorDirection.bottomWithCenterAligned,
); );

View File

@ -32,7 +32,7 @@ class ViewDisclosureButton extends StatelessWidget
width: 26, width: 26,
onPressed: () { onPressed: () {
onTap(); onTap();
show(context, context); show(context);
}, },
icon: svg("editor/details", color: theme.iconColor), icon: svg("editor/details", color: theme.iconColor),
); );

View File

@ -9,7 +9,6 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:styled_widget/styled_widget.dart'; import 'package:styled_widget/styled_widget.dart';
import 'item.dart'; import 'item.dart';
import 'package:async/async.dart';
class ViewSection extends StatelessWidget { class ViewSection extends StatelessWidget {
final AppDataNotifier appData; final AppDataNotifier appData;

View File

@ -188,7 +188,6 @@ class DocumentShareButton extends StatelessWidget {
}); });
}); });
actionList.show( actionList.show(
context,
context, context,
anchorDirection: AnchorDirection.bottomWithCenterAligned, anchorDirection: AnchorDirection.bottomWithCenterAligned,
anchorOffset: offset, anchorOffset: offset,

View File

@ -117,15 +117,6 @@ class _FlowyColorButtonState extends State<FlowyColorButton> {
} }
void _showColorPicker() { void _showColorPicker() {
// FlowyPoppuWindow.show(
// context,
// size: Size(600, 200),
// child: MaterialPicker(
// pickerColor: const Color(0x00000000),
// onColorChanged: (color) => _changeColor(context, color),
// ),
// );
final style = widget.controller.getSelectionStyle(); final style = widget.controller.getSelectionStyle();
final values = style.values.where((v) => v.key == Attribute.background.key).map((v) => v.value); final values = style.values.where((v) => v.key == Attribute.background.key).map((v) => v.value);
int initialColor = 0; int initialColor = 0;

View File

@ -8,13 +8,13 @@ class GridSize {
static double get footerHeight => 40 * scale; static double get footerHeight => 40 * scale;
static double get leadingHeaderPadding => 30 * scale; static double get leadingHeaderPadding => 30 * scale;
static double get trailHeaderPadding => 140 * scale; static double get trailHeaderPadding => 140 * scale;
static double get headerContentPadding => 8 * scale; static double get headerContainerPadding => 0 * scale;
static double get cellContentPadding => 8 * scale; static double get cellContentPadding => 10 * scale;
// //
static EdgeInsets get headerContentInsets => EdgeInsets.symmetric( static EdgeInsets get headerContentInsets => EdgeInsets.symmetric(
horizontal: GridSize.headerContentPadding, horizontal: GridSize.headerContainerPadding,
vertical: GridSize.headerContentPadding, vertical: GridSize.headerContainerPadding,
); );
static EdgeInsets get cellContentInsets => EdgeInsets.symmetric( static EdgeInsets get cellContentInsets => EdgeInsets.symmetric(
horizontal: GridSize.cellContentPadding, horizontal: GridSize.cellContentPadding,
@ -23,8 +23,8 @@ class GridSize {
static EdgeInsets get footerContentInsets => EdgeInsets.fromLTRB( static EdgeInsets get footerContentInsets => EdgeInsets.fromLTRB(
0, 0,
GridSize.headerContentPadding, GridSize.headerContainerPadding,
GridSize.headerContentPadding, GridSize.headerContainerPadding,
GridSize.headerContentPadding, GridSize.headerContainerPadding,
); );
} }

View File

@ -39,7 +39,7 @@ class _AddRowButton extends StatelessWidget {
text: const FlowyText.medium('New row', fontSize: 12), text: const FlowyText.medium('New row', fontSize: 12),
hoverColor: theme.hover, hoverColor: theme.hover,
onTap: () => context.read<GridBloc>().add(const GridEvent.createRow()), onTap: () => context.read<GridBloc>().add(const GridEvent.createRow()),
icon: svg("home/add"), leftIcon: svg("home/add"),
); );
} }
} }

View File

@ -61,9 +61,9 @@ class GridHeader extends StatelessWidget {
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
const LeadingHeaderCell(), const _HeaderLeading(),
...headers, ...headers,
const TrailingHeaderCell(), const _HeaderTrailing(),
], ],
), ),
); );
@ -73,8 +73,8 @@ class GridHeader extends StatelessWidget {
} }
} }
class LeadingHeaderCell extends StatelessWidget { class _HeaderLeading extends StatelessWidget {
const LeadingHeaderCell({Key? key}) : super(key: key); const _HeaderLeading({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -84,8 +84,8 @@ class LeadingHeaderCell extends StatelessWidget {
} }
} }
class TrailingHeaderCell extends StatelessWidget { class _HeaderTrailing extends StatelessWidget {
const TrailingHeaderCell({Key? key}) : super(key: key); const _HeaderTrailing({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -112,7 +112,7 @@ class CreateColumnButton extends StatelessWidget {
text: const FlowyText.medium('New column', fontSize: 12), text: const FlowyText.medium('New column', fontSize: 12),
hoverColor: theme.hover, hoverColor: theme.hover,
onTap: () => context.read<ColumnBloc>().add(const ColumnEvent.createColumn()), onTap: () => context.read<ColumnBloc>().add(const ColumnEvent.createColumn()),
icon: svg("home/add"), leftIcon: svg("home/add"),
); );
} }
} }

View File

@ -1,7 +1,10 @@
import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart'; import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart';
import 'package:app_flowy/workspace/presentation/widgets/pop_up_window.dart';
import 'package:flowy_infra/image.dart';
import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra/theme.dart';
import 'package:flowy_infra_ui/style_widget/button.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/dialog/styled_dialogs.dart';
import 'package:flowy_sdk/protobuf/flowy-grid-data-model/grid.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-grid-data-model/grid.pb.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
@ -14,9 +17,31 @@ class HeaderCell extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = context.watch<AppTheme>(); final theme = context.watch<AppTheme>();
return FlowyButton( return FlowyButton(
text: FlowyText.medium(field.name, fontSize: 12), text: Padding(padding: GridSize.cellContentInsets, child: FlowyText.medium(field.name, fontSize: 12)),
hoverColor: theme.hover, hoverColor: theme.hover,
onTap: () {}, onTap: () {
FlowyPoppuWindow.show(
context,
size: Size(300, 100),
child: Container(
color: Colors.red,
child: TextField(
decoration: InputDecoration(hintText: 'Please enter a text'),
onSubmitted: print,
),
),
);
// StyledDialog(
// child: SingleChildScrollView(
// child: Container(
// color: Colors.red,
// child: TextField(),
// ),
// ),
// ).show(context);
},
rightIcon: svg("editor/details", color: theme.iconColor),
); );
} }
} }

View File

@ -146,7 +146,7 @@ class _TrashPageState extends State<TrashPage> {
size: const Size(102, 30), size: const Size(102, 30),
child: FlowyButton( child: FlowyButton(
text: FlowyText.medium(LocaleKeys.trash_restoreAll.tr(), fontSize: 12), text: FlowyText.medium(LocaleKeys.trash_restoreAll.tr(), fontSize: 12),
icon: svg('editor/restore', color: theme.iconColor), leftIcon: svg('editor/restore', color: theme.iconColor),
hoverColor: theme.hover, hoverColor: theme.hover,
onTap: () => context.read<TrashBloc>().add(const TrashEvent.restoreAll()), onTap: () => context.read<TrashBloc>().add(const TrashEvent.restoreAll()),
), ),
@ -156,7 +156,7 @@ class _TrashPageState extends State<TrashPage> {
size: const Size(102, 30), size: const Size(102, 30),
child: FlowyButton( child: FlowyButton(
text: FlowyText.medium(LocaleKeys.trash_deleteAll.tr(), fontSize: 12), text: FlowyText.medium(LocaleKeys.trash_deleteAll.tr(), fontSize: 12),
icon: svg('editor/delete', color: theme.iconColor), leftIcon: svg('editor/delete', color: theme.iconColor),
hoverColor: theme.hover, hoverColor: theme.hover,
onTap: () => context.read<TrashBloc>().add(const TrashEvent.deleteAll()), onTap: () => context.read<TrashBloc>().add(const TrashEvent.deleteAll()),
), ),

View File

@ -112,7 +112,6 @@ class QuestionBubble extends StatelessWidget {
}); });
}); });
actionList.show( actionList.show(
context,
context, context,
anchorDirection: AnchorDirection.topWithRightAligned, anchorDirection: AnchorDirection.topWithRightAligned,
anchorOffset: const Offset(0, -10), anchorOffset: const Offset(0, -10),

View File

@ -24,8 +24,8 @@ abstract class ActionList<T extends ActionItem> {
FlowyOverlayDelegate? get delegate; FlowyOverlayDelegate? get delegate;
void show( void show(
BuildContext buildContext, BuildContext buildContext, {
BuildContext anchorContext, { BuildContext? anchorContext,
AnchorDirection anchorDirection = AnchorDirection.bottomRight, AnchorDirection anchorDirection = AnchorDirection.bottomRight,
Offset? anchorOffset, Offset? anchorOffset,
}) { }) {
@ -47,7 +47,7 @@ abstract class ActionList<T extends ActionItem> {
identifier: identifier, identifier: identifier,
itemCount: widgets.length, itemCount: widgets.length,
itemBuilder: (context, index) => widgets[index], itemBuilder: (context, index) => widgets[index],
anchorContext: anchorContext, anchorContext: anchorContext ?? buildContext,
anchorDirection: anchorDirection, anchorDirection: anchorDirection,
width: maxWidth, width: maxWidth,
height: widgets.length * (itemHeight + ActionListSizes.padding * 2), height: widgets.length * (itemHeight + ActionListSizes.padding * 2),

View File

@ -21,6 +21,7 @@ class FlowyPoppuWindow extends StatelessWidget {
required Size size, required Size size,
}) async { }) async {
final window = await getWindowInfo(); final window = await getWindowInfo();
FlowyOverlay.of(context).insertWithRect( FlowyOverlay.of(context).insertWithRect(
widget: SizedBox.fromSize( widget: SizedBox.fromSize(
size: size, size: size,

View File

@ -279,8 +279,11 @@ class FlowyOverlayState extends State<FlowyOverlay> {
children.add(child); children.add(child);
} }
return Stack( return MaterialApp(
children: children..addAll(overlays), debugShowCheckedModeBanner: false,
home: Stack(
children: children..addAll(overlays),
),
); );
} }

View File

@ -103,38 +103,4 @@ class ListOverlay extends StatelessWidget {
style: style, style: style,
); );
} }
static void showWithRect(
BuildContext context, {
required BuildContext anchorContext,
required String identifier,
required IndexedWidgetBuilder itemBuilder,
int? itemCount,
ScrollController? controller,
double maxWidth = double.infinity,
double maxHeight = double.infinity,
required Offset anchorPosition,
required Size anchorSize,
AnchorDirection? anchorDirection,
FlowyOverlayDelegate? delegate,
OverlapBehaviour? overlapBehaviour,
FlowyOverlayStyle? style,
}) {
FlowyOverlay.of(context).insertWithRect(
widget: ListOverlay(
itemBuilder: itemBuilder,
itemCount: itemCount,
controller: controller,
width: maxWidth,
height: maxHeight,
),
identifier: identifier,
anchorPosition: anchorPosition,
anchorSize: anchorSize,
anchorDirection: anchorDirection,
delegate: delegate,
overlapBehaviour: overlapBehaviour,
style: style,
);
}
} }

View File

@ -8,14 +8,16 @@ class FlowyButton extends StatelessWidget {
final Widget text; final Widget text;
final VoidCallback? onTap; final VoidCallback? onTap;
final EdgeInsets padding; final EdgeInsets padding;
final Widget? icon; final Widget? leftIcon;
final Widget? rightIcon;
final Color hoverColor; final Color hoverColor;
const FlowyButton({ const FlowyButton({
Key? key, Key? key,
required this.text, required this.text,
this.onTap, this.onTap,
this.padding = const EdgeInsets.symmetric(horizontal: 3, vertical: 2), this.padding = const EdgeInsets.symmetric(horizontal: 3, vertical: 2),
this.icon, this.leftIcon,
this.rightIcon,
this.hoverColor = Colors.transparent, this.hoverColor = Colors.transparent,
}) : super(key: key); }) : super(key: key);
@ -33,13 +35,19 @@ class FlowyButton extends StatelessWidget {
Widget _render() { Widget _render() {
List<Widget> children = List.empty(growable: true); List<Widget> children = List.empty(growable: true);
if (icon != null) { if (leftIcon != null) {
children.add(SizedBox.fromSize(size: const Size.square(16), child: icon!)); children.add(SizedBox.fromSize(size: const Size.square(16), child: leftIcon!));
children.add(const HSpace(6)); children.add(const HSpace(6));
} }
children.add(Align(child: text)); children.add(Align(child: text));
if (rightIcon != null) {
children.add(const Spacer());
children.add(SizedBox.fromSize(size: const Size.square(16), child: rightIcon!));
children.add(const HSpace(6));
}
return Padding( return Padding(
padding: padding, padding: padding,
child: Row( child: Row(