diff --git a/frontend/app_flowy/lib/plugins/board/presentation/board_page.dart b/frontend/app_flowy/lib/plugins/board/presentation/board_page.dart index d40a2f5ea9..a771d84c36 100644 --- a/frontend/app_flowy/lib/plugins/board/presentation/board_page.dart +++ b/frontend/app_flowy/lib/plugins/board/presentation/board_page.dart @@ -14,6 +14,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/text.dart'; +import 'package:flowy_infra_ui/flowy_infra_ui_web.dart'; import 'package:flowy_infra_ui/widget/error_page.dart'; import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/block_entities.pb.dart'; @@ -285,10 +286,15 @@ class _BoardContentState extends State { rowCache: rowCache, ); - RowDetailPage( - cellBuilder: GridCellBuilder(delegate: dataController), - dataController: dataController, - ).show(context); + FlowyOverlay.show( + context: context, + builder: (BuildContext context) { + return RowDetailPage( + cellBuilder: GridCellBuilder(delegate: dataController), + dataController: dataController, + ); + }, + ); } } diff --git a/frontend/app_flowy/lib/plugins/board/presentation/toolbar/board_setting.dart b/frontend/app_flowy/lib/plugins/board/presentation/toolbar/board_setting.dart index 86beac6830..6bf06c39b9 100644 --- a/frontend/app_flowy/lib/plugins/board/presentation/toolbar/board_setting.dart +++ b/frontend/app_flowy/lib/plugins/board/presentation/toolbar/board_setting.dart @@ -2,7 +2,6 @@ import 'package:app_flowy/generated/locale_keys.g.dart'; import 'package:app_flowy/plugins/board/application/toolbar/board_setting_bloc.dart'; import 'package:app_flowy/plugins/grid/application/field/field_controller.dart'; import 'package:app_flowy/plugins/grid/presentation/layout/sizes.dart'; -import 'package:app_flowy/plugins/grid/presentation/widgets/toolbar/grid_group.dart'; import 'package:app_flowy/plugins/grid/presentation/widgets/toolbar/grid_property.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra/image.dart'; @@ -50,7 +49,7 @@ class BoardSettingList extends StatelessWidget { previous.selectedAction != current.selectedAction, listener: (context, state) { state.selectedAction.foldLeft(null, (_, action) { - FlowyOverlay.of(context).remove(identifier()); + // FlowyOverlay.of(context).remove(identifier()); onAction(action, settingContext); }); }, @@ -84,43 +83,6 @@ class BoardSettingList extends StatelessWidget { ), ); } - - static void show(BuildContext context, BoardSettingContext settingContext) { - final list = BoardSettingList( - settingContext: settingContext, - onAction: (action, settingContext) { - switch (action) { - case BoardSettingAction.properties: - GridPropertyList( - gridId: settingContext.viewId, - fieldController: settingContext.fieldController) - .show(context); - break; - case BoardSettingAction.groups: - GridGroupList( - viewId: settingContext.viewId, - fieldController: settingContext.fieldController) - .show(context); - break; - } - }, - ); - - FlowyOverlay.of(context).insertWithAnchor( - widget: OverlayContainer( - constraints: BoxConstraints.loose(const Size(140, 400)), - child: list, - ), - identifier: identifier(), - anchorContext: context, - anchorDirection: AnchorDirection.bottomRight, - style: FlowyOverlayStyle(blur: false), - ); - } - - static String identifier() { - return (BoardSettingList).toString(); - } } class _SettingItem extends StatelessWidget { @@ -177,3 +139,50 @@ extension _GridSettingExtension on BoardSettingAction { } } } + +class BoardSettingListPopover extends StatefulWidget { + final BoardSettingContext settingContext; + + const BoardSettingListPopover({ + Key? key, + required this.settingContext, + }) : super(key: key); + + @override + State createState() => _BoardSettingListPopoverState(); +} + +class _BoardSettingListPopoverState extends State { + bool _showGridPropertyList = false; + + @override + Widget build(BuildContext context) { + if (_showGridPropertyList) { + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(260, 400)), + child: GridPropertyList( + gridId: widget.settingContext.viewId, + fieldController: widget.settingContext.fieldController, + ), + ); + } + + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(140, 400)), + child: BoardSettingList( + settingContext: widget.settingContext, + onAction: (action, settingContext) { + switch (action) { + case BoardSettingAction.groups: + break; + case BoardSettingAction.properties: + setState(() { + _showGridPropertyList = true; + }); + break; + } + }, + ), + ); + } +} diff --git a/frontend/app_flowy/lib/plugins/board/presentation/toolbar/board_toolbar.dart b/frontend/app_flowy/lib/plugins/board/presentation/toolbar/board_toolbar.dart index 8bc4dcb0c7..ce3bd188d0 100644 --- a/frontend/app_flowy/lib/plugins/board/presentation/toolbar/board_toolbar.dart +++ b/frontend/app_flowy/lib/plugins/board/presentation/toolbar/board_toolbar.dart @@ -1,4 +1,5 @@ import 'package:app_flowy/plugins/grid/application/field/field_controller.dart'; +import 'package:appflowy_popover/popover.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/icon_button.dart'; @@ -47,14 +48,22 @@ class _SettingButton extends StatelessWidget { @override Widget build(BuildContext context) { final theme = context.read(); - return FlowyIconButton( - hoverColor: theme.hover, - width: 22, - onPressed: () => BoardSettingList.show(context, settingContext), - icon: Padding( - padding: const EdgeInsets.symmetric(vertical: 3.0, horizontal: 3.0), - child: svgWidget("grid/setting/setting"), + return Popover( + triggerActions: PopoverTriggerActionFlags.click, + child: FlowyIconButton( + hoverColor: theme.hover, + width: 22, + onPressed: () {}, + icon: Padding( + padding: const EdgeInsets.symmetric(vertical: 3.0, horizontal: 3.0), + child: svgWidget("grid/setting/setting"), + ), ), + popupBuilder: (BuildContext popoverContext) { + return BoardSettingListPopover( + settingContext: settingContext, + ); + }, ); } } diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/grid_page.dart b/frontend/app_flowy/lib/plugins/grid/presentation/grid_page.dart index be9d2fe4e3..2432c0bfc2 100755 --- a/frontend/app_flowy/lib/plugins/grid/presentation/grid_page.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/grid_page.dart @@ -3,6 +3,7 @@ import 'package:app_flowy/plugins/grid/application/row/row_data_controller.dart' import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/plugins/grid/application/grid_bloc.dart'; import 'package:flowy_infra/theme.dart'; +import 'package:flowy_infra_ui/flowy_infra_ui_web.dart'; import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart'; import 'package:flowy_infra_ui/style_widget/scrolling/styled_scroll_bar.dart'; import 'package:flowy_infra_ui/style_widget/scrolling/styled_scrollview.dart'; @@ -290,10 +291,14 @@ class _GridRowsState extends State<_GridRows> { rowCache: rowCache, ); - RowDetailPage( - cellBuilder: cellBuilder, - dataController: dataController, - ).show(context); + FlowyOverlay.show( + context: context, + builder: (BuildContext context) { + return RowDetailPage( + cellBuilder: cellBuilder, + dataController: dataController, + ); + }); } } diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_accessory.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_accessory.dart index 8a88316473..341d4095b0 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_accessory.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_accessory.dart @@ -20,14 +20,36 @@ class GridCellAccessoryBuildContext { }); } -abstract class GridCellAccessory implements Widget { +class GridCellAccessoryBuilder { + final GlobalKey _key = GlobalKey(); + + final Widget Function(Key key) _builder; + + GridCellAccessoryBuilder({required Widget Function(Key key) builder}) + : _builder = builder; + + Widget build() => _builder(_key); + + void onTap() { + (_key.currentState as GridCellAccessoryState).onTap(); + } + + bool enable() { + if (_key.currentState == null) { + return true; + } + return (_key.currentState as GridCellAccessoryState).enable(); + } +} + +abstract class GridCellAccessoryState { void onTap(); // The accessory will be hidden if enable() return false; bool enable() => true; } -class PrimaryCellAccessory extends StatelessWidget with GridCellAccessory { +class PrimaryCellAccessory extends StatefulWidget { final VoidCallback onTapCallback; final bool isCellEditing; const PrimaryCellAccessory({ @@ -36,9 +58,15 @@ class PrimaryCellAccessory extends StatelessWidget with GridCellAccessory { Key? key, }) : super(key: key); + @override + State createState() => _PrimaryCellAccessoryState(); +} + +class _PrimaryCellAccessoryState extends State + with GridCellAccessoryState { @override Widget build(BuildContext context) { - if (isCellEditing) { + if (widget.isCellEditing) { return const SizedBox(); } else { final theme = context.watch(); @@ -53,10 +81,10 @@ class PrimaryCellAccessory extends StatelessWidget with GridCellAccessory { } @override - void onTap() => onTapCallback(); + void onTap() => widget.onTapCallback(); @override - bool enable() => !isCellEditing; + bool enable() => !widget.isCellEditing; } class AccessoryHover extends StatefulWidget { @@ -170,7 +198,7 @@ class _Background extends StatelessWidget { } class CellAccessoryContainer extends StatelessWidget { - final List accessories; + final List accessories; const CellAccessoryContainer({required this.accessories, Key? key}) : super(key: key); @@ -186,7 +214,7 @@ class CellAccessoryContainer extends StatelessWidget { width: 26, height: 26, padding: const EdgeInsets.all(3), - child: accessory, + child: accessory.build(), ), ); return GestureDetector( diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_builder.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_builder.dart index 0a7c3a48a7..1f885c3821 100755 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_builder.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_builder.dart @@ -94,7 +94,7 @@ abstract class CellEditable { ValueNotifier get onCellEditing; } -typedef AccessoryBuilder = List Function( +typedef AccessoryBuilder = List Function( GridCellAccessoryBuildContext buildContext); abstract class CellAccessory extends Widget { @@ -125,8 +125,8 @@ abstract class GridCellWidget extends StatefulWidget final ValueNotifier onCellEditing = ValueNotifier(false); @override - List Function(GridCellAccessoryBuildContext buildContext)? - get accessoryBuilder => null; + List Function( + GridCellAccessoryBuildContext buildContext)? get accessoryBuilder => null; @override final GridCellFocusListener beginFocus = GridCellFocusListener(); diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_container.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_container.dart index eea58775dd..bbe22ffe8f 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_container.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/cell_container.dart @@ -80,7 +80,7 @@ class CellContainer extends StatelessWidget { class _GridCellEnterRegion extends StatelessWidget { final Widget child; - final List accessories; + final List accessories; const _GridCellEnterRegion( {required this.child, required this.accessories, Key? key}) : super(key: key); diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_cell.dart index fa5be5f9bd..2b7ef9b6ab 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_cell.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_cell.dart @@ -3,6 +3,7 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/plugins/grid/application/prelude.dart'; +import 'package:appflowy_popover/popover.dart'; import '../cell_builder.dart'; import 'date_editor.dart'; @@ -39,10 +40,12 @@ class GridDateCell extends GridCellWidget { } class _DateCellState extends GridCellState { + late PopoverController _popover; late DateCellBloc _cellBloc; @override void initState() { + _popover = PopoverController(); final cellController = widget.cellControllerBuilder.build(); _cellBloc = getIt(param1: cellController) ..add(const DateCellEvent.initial()); @@ -58,19 +61,34 @@ class _DateCellState extends GridCellState { value: _cellBloc, child: BlocBuilder( builder: (context, state) { - return SizedBox.expand( - child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () => _showCalendar(context), - child: MouseRegion( - opaque: false, - cursor: SystemMouseCursors.click, - child: Align( - alignment: alignment, - child: FlowyText.medium(state.dateStr, fontSize: 12), + return Popover( + controller: _popover, + offset: const Offset(0, 20), + direction: PopoverDirection.bottomWithLeftAligned, + child: SizedBox.expand( + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () => _showCalendar(context), + child: MouseRegion( + opaque: false, + cursor: SystemMouseCursors.click, + child: Align( + alignment: alignment, + child: FlowyText.medium(state.dateStr, fontSize: 12), + ), ), ), ), + popupBuilder: (BuildContext popoverContent) { + final bloc = context.read(); + return DateCellEditor( + cellController: bloc.cellController.clone(), + onDismissed: () => widget.onCellEditing.value = false, + ); + }, + onClose: () { + widget.onCellEditing.value = false; + }, ); }, ), @@ -78,14 +96,7 @@ class _DateCellState extends GridCellState { } void _showCalendar(BuildContext context) { - final bloc = context.read(); - widget.onCellEditing.value = true; - final calendar = - DateCellEditor(onDismissed: () => widget.onCellEditing.value = false); - calendar.show( - context, - cellController: bloc.cellController.clone(), - ); + _popover.show(); } @override diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_editor.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_editor.dart index d1289b93f2..9c57e7ed3b 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_editor.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/date_cell/date_editor.dart @@ -1,6 +1,7 @@ import 'package:app_flowy/generated/locale_keys.g.dart'; import 'package:app_flowy/plugins/grid/application/cell/date_cal_bloc.dart'; import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_context.dart'; +import 'package:appflowy_popover/popover.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; @@ -23,58 +24,54 @@ final kFirstDay = DateTime(kToday.year, kToday.month - 3, kToday.day); final kLastDay = DateTime(kToday.year, kToday.month + 3, kToday.day); const kMargin = EdgeInsets.symmetric(horizontal: 6, vertical: 10); -class DateCellEditor with FlowyOverlayDelegate { +class DateCellEditor extends StatefulWidget { final VoidCallback onDismissed; + final GridDateCellController cellController; const DateCellEditor({ + Key? key, required this.onDismissed, - }); + required this.cellController, + }) : super(key: key); - Future show( - BuildContext context, { - required GridDateCellController cellController, - }) async { - DateCellEditor.remove(context); + @override + State createState() => _DateCellEditor(); +} - final result = - await cellController.getFieldTypeOption(DateTypeOptionDataParser()); +class _DateCellEditor extends State { + DateTypeOptionPB? _dateTypeOptionPB; - result.fold( - (dateTypeOptionPB) { - final calendar = _CellCalendarWidget( - cellContext: cellController, - dateTypeOptionPB: dateTypeOptionPB, - ); + @override + void initState() { + super.initState(); + _fetchData(); + } - FlowyOverlay.of(context).insertWithAnchor( - widget: OverlayContainer( - constraints: BoxConstraints.loose(const Size(320, 500)), - child: calendar, - ), - identifier: DateCellEditor.identifier(), - anchorContext: context, - anchorDirection: AnchorDirection.leftWithCenterAligned, - style: FlowyOverlayStyle(blur: false), - delegate: this, - ); - }, - (err) => Log.error(err), + _fetchData() async { + final result = await widget.cellController + .getFieldTypeOption(DateTypeOptionDataParser()); + + result.fold((dateTypeOptionPB) { + setState(() { + _dateTypeOptionPB = dateTypeOptionPB; + }); + }, (err) => Log.error(err)); + } + + @override + Widget build(BuildContext context) { + if (_dateTypeOptionPB == null) { + return Container(); + } + + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(320, 500)), + child: _CellCalendarWidget( + cellContext: widget.cellController, + dateTypeOptionPB: _dateTypeOptionPB!, + ), ); } - - static void remove(BuildContext context) { - FlowyOverlay.of(context).remove(identifier()); - } - - static String identifier() { - return (DateCellEditor).toString(); - } - - @override - void didRemove() => onDismissed(); - - @override - bool asBarrier() => true; } class _CellCalendarWidget extends StatelessWidget { @@ -169,17 +166,14 @@ class _CellCalendarWidget extends StatelessWidget { ); }, onDaySelected: (selectedDay, focusedDay) { - _CalDateTimeSetting.hide(context); context .read() .add(DateCalEvent.selectDay(selectedDay)); }, onFormatChanged: (format) { - _CalDateTimeSetting.hide(context); context.read().add(DateCalEvent.setCalFormat(format)); }, onPageChanged: (focusedDay) { - _CalDateTimeSetting.hide(context); context .read() .add(DateCalEvent.setFocusedDay(focusedDay)); @@ -247,7 +241,6 @@ class _TimeTextFieldState extends State<_TimeTextField> { if (widget.bloc.state.dateTypeOptionPB.includeTime) { _focusNode.addListener(() { if (mounted) { - _CalDateTimeSetting.hide(context); widget.bloc.add(DateCalEvent.setTime(_controller.text)); } }); @@ -304,29 +297,34 @@ class _DateTypeOptionButton extends StatelessWidget { @override Widget build(BuildContext context) { final theme = context.watch(); - final title = "${LocaleKeys.grid_field_dateFormat.tr()} &${LocaleKeys.grid_field_timeFormat.tr()}"; + final title = + "${LocaleKeys.grid_field_dateFormat.tr()} &${LocaleKeys.grid_field_timeFormat.tr()}"; return BlocSelector( selector: (state) => state.dateTypeOptionPB, builder: (context, dateTypeOptionPB) { - return FlowyButton( - text: FlowyText.medium(title, fontSize: 12), - hoverColor: theme.hover, - margin: kMargin, - onTap: () => _showTimeSetting(dateTypeOptionPB, context), - rightIcon: svgWidget("grid/more", color: theme.iconColor), + return Popover( + triggerActions: + PopoverTriggerActionFlags.hover | PopoverTriggerActionFlags.click, + offset: const Offset(20, 0), + child: FlowyButton( + text: FlowyText.medium(title, fontSize: 12), + hoverColor: theme.hover, + margin: kMargin, + rightIcon: svgWidget("grid/more", color: theme.iconColor), + ), + popupBuilder: (BuildContext popContext) { + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(140, 100)), + child: _CalDateTimeSetting( + dateTypeOptionPB: dateTypeOptionPB, + onEvent: (event) => context.read().add(event), + ), + ); + }, ); }, ); } - - void _showTimeSetting( - DateTypeOptionPB dateTypeOptionPB, BuildContext context) { - final setting = _CalDateTimeSetting( - dateTypeOptionPB: dateTypeOptionPB, - onEvent: (event) => context.read().add(event), - ); - setting.show(context); - } } class _CalDateTimeSetting extends StatefulWidget { @@ -338,54 +336,48 @@ class _CalDateTimeSetting extends StatefulWidget { @override State<_CalDateTimeSetting> createState() => _CalDateTimeSettingState(); - - static String identifier() { - return (_CalDateTimeSetting).toString(); - } - - void show(BuildContext context) { - hide(context); - FlowyOverlay.of(context).insertWithAnchor( - widget: OverlayContainer( - constraints: BoxConstraints.loose(const Size(140, 100)), - child: this, - ), - identifier: _CalDateTimeSetting.identifier(), - anchorContext: context, - anchorDirection: AnchorDirection.rightWithCenterAligned, - anchorOffset: const Offset(20, 0), - ); - } - - static void hide(BuildContext context) { - FlowyOverlay.of(context).remove(identifier()); - } } class _CalDateTimeSettingState extends State<_CalDateTimeSetting> { String? overlayIdentifier; + final _popoverMutex = PopoverMutex(); @override Widget build(BuildContext context) { List children = [ - DateFormatButton(onTap: () { - final list = DateFormatList( - selectedFormat: widget.dateTypeOptionPB.dateFormat, - onSelected: (format) => - widget.onEvent(DateCalEvent.setDateFormat(format)), - ); - _showOverlay(context, list); - }), - TimeFormatButton( - timeFormat: widget.dateTypeOptionPB.timeFormat, - onTap: () { - final list = TimeFormatList( - selectedFormat: widget.dateTypeOptionPB.timeFormat, - onSelected: (format) => - widget.onEvent(DateCalEvent.setTimeFormat(format)), + Popover( + mutex: _popoverMutex, + triggerActions: + PopoverTriggerActionFlags.hover | PopoverTriggerActionFlags.click, + offset: const Offset(20, 0), + popupBuilder: (BuildContext context) { + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(460, 440)), + child: DateFormatList( + selectedFormat: widget.dateTypeOptionPB.dateFormat, + onSelected: (format) => + widget.onEvent(DateCalEvent.setDateFormat(format)), + ), ); - _showOverlay(context, list); }, + child: const DateFormatButton(), + ), + Popover( + mutex: _popoverMutex, + triggerActions: + PopoverTriggerActionFlags.hover | PopoverTriggerActionFlags.click, + offset: const Offset(20, 0), + popupBuilder: (BuildContext context) { + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(460, 440)), + child: TimeFormatList( + selectedFormat: widget.dateTypeOptionPB.timeFormat, + onSelected: (format) => + widget.onEvent(DateCalEvent.setTimeFormat(format)), + ), + ); + }, + child: TimeFormatButton(timeFormat: widget.dateTypeOptionPB.timeFormat), ), ]; @@ -404,23 +396,4 @@ class _CalDateTimeSettingState extends State<_CalDateTimeSetting> { ), ); } - - void _showOverlay(BuildContext context, Widget child) { - if (overlayIdentifier != null) { - FlowyOverlay.of(context).remove(overlayIdentifier!); - } - - overlayIdentifier = child.toString(); - FlowyOverlay.of(context).insertWithAnchor( - widget: OverlayContainer( - constraints: BoxConstraints.loose(const Size(460, 440)), - child: child, - ), - identifier: overlayIdentifier!, - anchorContext: context, - anchorDirection: AnchorDirection.rightWithCenterAligned, - style: FlowyOverlayStyle(blur: false), - anchorOffset: const Offset(20, 0), - ); - } } diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_cell.dart index c771586e70..df7ddb0d9e 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_cell.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_cell.dart @@ -1,7 +1,9 @@ import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/plugins/grid/application/prelude.dart'; +import 'package:appflowy_popover/popover.dart'; import 'package:flowy_infra/theme.dart'; +import 'package:flowy_infra_ui/flowy_infra_ui_web.dart'; import 'package:flowy_infra_ui/style_widget/text.dart'; // ignore: unused_import import 'package:flowy_sdk/log.dart'; @@ -133,7 +135,7 @@ class _MultiSelectCellState extends State { } } -class SelectOptionWrap extends StatelessWidget { +class SelectOptionWrap extends StatefulWidget { final List selectOptions; final void Function(bool)? onFocus; final SelectOptionCellStyle? cellStyle; @@ -146,15 +148,28 @@ class SelectOptionWrap extends StatelessWidget { Key? key, }) : super(key: key); + @override + State createState() => _SelectOptionWrapState(); +} + +class _SelectOptionWrapState extends State { + late PopoverController _popover; + + @override + void initState() { + _popover = PopoverController(); + super.initState(); + } + @override Widget build(BuildContext context) { final theme = context.watch(); final Widget child; - if (selectOptions.isEmpty && cellStyle != null) { + if (widget.selectOptions.isEmpty && widget.cellStyle != null) { child = Align( alignment: Alignment.centerLeft, child: FlowyText.medium( - cellStyle!.placeholder, + widget.cellStyle!.placeholder, fontSize: 14, color: theme.shader3, ), @@ -165,7 +180,7 @@ class SelectOptionWrap extends StatelessWidget { child: Wrap( spacing: 4, runSpacing: 2, - children: selectOptions + children: widget.selectOptions .map((option) => SelectOptionTag.fromOption( context: context, option: option, @@ -179,14 +194,37 @@ class SelectOptionWrap extends StatelessWidget { alignment: AlignmentDirectional.center, fit: StackFit.expand, children: [ - child, + Popover( + controller: _popover, + offset: const Offset(0, 20), + direction: PopoverDirection.bottomWithLeftAligned, + // triggerActions: PopoverTriggerActionFlags.c, + popupBuilder: (BuildContext context) { + WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + widget.onFocus?.call(true); + }); + return OverlayContainer( + constraints: BoxConstraints.loose( + Size(SelectOptionCellEditor.editorPanelWidth, 300)), + child: SizedBox( + width: SelectOptionCellEditor.editorPanelWidth, + child: SelectOptionCellEditor( + cellController: widget.cellControllerBuilder.build() + as GridSelectOptionCellController, + onDismissed: () { + widget.onFocus?.call(false); + }, + ), + ), + ); + }, + onClose: () { + widget.onFocus?.call(false); + }, + child: child, + ), InkWell(onTap: () { - onFocus?.call(true); - SelectOptionCellEditor.show( - context, - cellControllerBuilder.build() as GridSelectOptionCellController, - () => onFocus?.call(false), - ); + _popover.show(); }), ], ); diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_editor.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_editor.dart index ef0dab83c9..04252ed987 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_editor.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_editor.dart @@ -1,6 +1,7 @@ import 'dart:collection'; import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart'; import 'package:app_flowy/plugins/grid/application/cell/select_option_editor_bloc.dart'; +import 'package:appflowy_popover/popover.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; @@ -28,6 +29,8 @@ class SelectOptionCellEditor extends StatelessWidget with FlowyOverlayDelegate { final GridSelectOptionCellController cellController; final VoidCallback onDismissed; + static double editorPanelWidth = 300; + const SelectOptionCellEditor({ required this.cellController, required this.onDismissed, @@ -226,76 +229,82 @@ class _CreateOptionCell extends StatelessWidget { } } -class _SelectOptionCell extends StatelessWidget { +class _SelectOptionCell extends StatefulWidget { final SelectOptionPB option; final bool isSelected; const _SelectOptionCell(this.option, this.isSelected, {Key? key}) : super(key: key); @override - Widget build(BuildContext context) { - final theme = context.watch(); - return SizedBox( - height: GridSize.typeOptionItemHeight, - child: Row( - children: [ - Flexible( - fit: FlexFit.loose, - child: SelectOptionTagCell( - option: option, - onSelected: (option) { - context - .read() - .add(SelectOptionEditorEvent.selectOption(option.id)); - }, - children: [ - if (isSelected) - Padding( - padding: const EdgeInsets.only(right: 6), - child: svgWidget("grid/checkmark"), - ), - ], - ), - ), - FlowyIconButton( - width: 30, - onPressed: () => _showEditPannel(context), - iconPadding: const EdgeInsets.fromLTRB(4, 4, 4, 4), - icon: svgWidget("editor/details", color: theme.iconColor), - ) - ], - ), - ); + State<_SelectOptionCell> createState() => _SelectOptionCellState(); +} + +class _SelectOptionCellState extends State<_SelectOptionCell> { + late PopoverController _popoverController; + + @override + void initState() { + _popoverController = PopoverController(); + super.initState(); } - void _showEditPannel(BuildContext context) { - final pannel = SelectOptionTypeOptionEditor( - option: option, - onDeleted: () { - context - .read() - .add(SelectOptionEditorEvent.deleteOption(option)); - }, - onUpdated: (updatedOption) { - context - .read() - .add(SelectOptionEditorEvent.updateOption(updatedOption)); - }, - key: ValueKey(option - .id), // Use ValueKey to refresh the UI, otherwise, it will remain the old value. - ); - final overlayIdentifier = (SelectOptionTypeOptionEditor).toString(); - - FlowyOverlay.of(context).remove(overlayIdentifier); - FlowyOverlay.of(context).insertWithAnchor( - widget: OverlayContainer( - constraints: BoxConstraints.loose(const Size(200, 300)), - child: pannel, + @override + Widget build(BuildContext context) { + final theme = context.watch(); + return Popover( + controller: _popoverController, + offset: const Offset(20, 0), + child: SizedBox( + height: GridSize.typeOptionItemHeight, + child: Row( + children: [ + Flexible( + fit: FlexFit.loose, + child: SelectOptionTagCell( + option: widget.option, + onSelected: (option) { + context + .read() + .add(SelectOptionEditorEvent.selectOption(option.id)); + }, + children: [ + if (widget.isSelected) + Padding( + padding: const EdgeInsets.only(right: 6), + child: svgWidget("grid/checkmark"), + ), + ], + ), + ), + FlowyIconButton( + width: 30, + onPressed: () => _popoverController.show(), + iconPadding: const EdgeInsets.fromLTRB(4, 4, 4, 4), + icon: svgWidget("editor/details", color: theme.iconColor), + ) + ], + ), ), - identifier: overlayIdentifier, - anchorContext: context, - anchorDirection: AnchorDirection.rightWithCenterAligned, - anchorOffset: Offset(2 * overlayContainerPadding.left, 0), + popupBuilder: (BuildContext popoverContext) { + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(200, 300)), + child: SelectOptionTypeOptionEditor( + option: widget.option, + onDeleted: () { + context + .read() + .add(SelectOptionEditorEvent.deleteOption(widget.option)); + }, + onUpdated: (updatedOption) { + context + .read() + .add(SelectOptionEditorEvent.updateOption(updatedOption)); + }, + key: ValueKey(widget.option + .id), // Use ValueKey to refresh the UI, otherwise, it will remain the old value. + ), + ); + }, ); } } diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/cell_editor.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/cell_editor.dart index b9e0f1ef48..e390104187 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/cell_editor.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/cell_editor.dart @@ -6,56 +6,13 @@ import 'dart:async'; import 'package:flutter_bloc/flutter_bloc.dart'; -class URLCellEditor extends StatefulWidget with FlowyOverlayDelegate { +class URLCellEditor extends StatefulWidget { final GridURLCellController cellController; - final VoidCallback completed; - const URLCellEditor( - {required this.cellController, required this.completed, Key? key}) + const URLCellEditor({required this.cellController, Key? key}) : super(key: key); @override State createState() => _URLCellEditorState(); - - static void show( - BuildContext context, - GridURLCellController cellContext, - VoidCallback completed, - ) { - FlowyOverlay.of(context).remove(identifier()); - final editor = URLCellEditor( - cellController: cellContext, - completed: completed, - ); - - // - FlowyOverlay.of(context).insertWithAnchor( - widget: OverlayContainer( - constraints: BoxConstraints.loose(const Size(300, 160)), - child: SizedBox( - width: 200, - child: Padding(padding: const EdgeInsets.all(6), child: editor), - ), - ), - identifier: URLCellEditor.identifier(), - anchorContext: context, - anchorDirection: AnchorDirection.bottomWithCenterAligned, - delegate: editor, - ); - } - - static String identifier() { - return (URLCellEditor).toString(); - } - - @override - bool asBarrier() { - return true; - } - - @override - void didRemove() { - completed(); - } } class _URLCellEditorState extends State { @@ -114,3 +71,25 @@ class _URLCellEditorState extends State { } } } + +class URLEditorPopover extends StatelessWidget { + final GridURLCellController cellController; + const URLEditorPopover({required this.cellController, Key? key}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(300, 160)), + child: SizedBox( + width: 200, + child: Padding( + padding: const EdgeInsets.all(6), + child: URLCellEditor( + cellController: cellController, + ), + ), + ), + ); + } +} diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/url_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/url_cell.dart index 102595e166..27e7d4433c 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/url_cell.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/url_cell/url_cell.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:app_flowy/generated/locale_keys.g.dart'; import 'package:app_flowy/plugins/grid/application/cell/url_cell_bloc.dart'; import 'package:app_flowy/workspace/presentation/home/toast.dart'; +import 'package:appflowy_popover/popover.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; @@ -48,27 +49,37 @@ class GridURLCell extends GridCellWidget { @override GridCellState createState() => _GridURLCellState(); - GridCellAccessory accessoryFromType( + GridCellAccessoryBuilder accessoryFromType( GridURLCellAccessoryType ty, GridCellAccessoryBuildContext buildContext) { switch (ty) { case GridURLCellAccessoryType.edit: final cellController = cellControllerBuilder.build() as GridURLCellController; - return _EditURLAccessory( + return GridCellAccessoryBuilder( + builder: (Key key) => _EditURLAccessory( + key: key, cellContext: cellController, - anchorContext: buildContext.anchorContext); + anchorContext: buildContext.anchorContext, + ), + ); case GridURLCellAccessoryType.copyURL: final cellContext = cellControllerBuilder.build() as GridURLCellController; - return _CopyURLAccessory(cellContext: cellContext); + return GridCellAccessoryBuilder( + builder: (Key key) => _CopyURLAccessory( + key: key, + cellContext: cellContext, + ), + ); } } @override - List Function(GridCellAccessoryBuildContext buildContext) + List Function( + GridCellAccessoryBuildContext buildContext) get accessoryBuilder => (buildContext) { - final List accessories = []; + final List accessories = []; if (cellStyle != null) { accessories.addAll(cellStyle!.accessoryTypes.map((ty) { return accessoryFromType(ty, buildContext); @@ -86,6 +97,8 @@ class GridURLCell extends GridCellWidget { } class _GridURLCellState extends GridCellState { + final _popoverController = PopoverController(); + GridURLCellController? _cellContext; late URLCellBloc _cellBloc; @override @@ -116,14 +129,28 @@ class _GridURLCellState extends GridCellState { ), ); - return SizedBox.expand( + return Popover( + controller: _popoverController, + direction: PopoverDirection.bottomWithLeftAligned, + offset: const Offset(0, 20), + child: SizedBox.expand( child: GestureDetector( - child: Align(alignment: Alignment.centerLeft, child: richText), - onTap: () async { - final url = context.read().state.url; - await _openUrlOrEdit(url); + child: Align(alignment: Alignment.centerLeft, child: richText), + onTap: () async { + final url = context.read().state.url; + await _openUrlOrEdit(url); + }, + ), + ), + popupBuilder: (BuildContext popoverContext) { + return URLEditorPopover( + cellController: _cellContext!, + ); }, - )); + onClose: () { + widget.onCellEditing.value = false; + }, + ); }, ), ); @@ -140,12 +167,10 @@ class _GridURLCellState extends GridCellState { if (url.isNotEmpty && await canLaunchUrl(uri)) { await launchUrl(uri); } else { - final cellContext = + _cellContext = widget.cellControllerBuilder.build() as GridURLCellController; widget.onCellEditing.value = true; - URLCellEditor.show(context, cellContext, () { - widget.onCellEditing.value = false; - }); + _popoverController.show(); } } @@ -163,7 +188,7 @@ class _GridURLCellState extends GridCellState { } } -class _EditURLAccessory extends StatelessWidget with GridCellAccessory { +class _EditURLAccessory extends StatefulWidget { final GridURLCellController cellContext; final BuildContext anchorContext; const _EditURLAccessory({ @@ -172,24 +197,55 @@ class _EditURLAccessory extends StatelessWidget with GridCellAccessory { Key? key, }) : super(key: key); + @override + State createState() => _EditURLAccessoryState(); +} + +class _EditURLAccessoryState extends State<_EditURLAccessory> + with GridCellAccessoryState { + late PopoverController _popoverController; + + @override + void initState() { + _popoverController = PopoverController(); + super.initState(); + } + @override Widget build(BuildContext context) { final theme = context.watch(); - return svgWidget("editor/edit", color: theme.iconColor); + return Popover( + controller: _popoverController, + direction: PopoverDirection.bottomWithLeftAligned, + triggerActions: PopoverTriggerActionFlags.click, + offset: const Offset(0, 20), + child: svgWidget("editor/edit", color: theme.iconColor), + popupBuilder: (BuildContext popoverContext) { + return URLEditorPopover( + cellController: widget.cellContext.clone(), + ); + }, + ); } @override void onTap() { - URLCellEditor.show(anchorContext, cellContext, () {}); + _popoverController.show(); } } -class _CopyURLAccessory extends StatelessWidget with GridCellAccessory { +class _CopyURLAccessory extends StatefulWidget { final GridURLCellController cellContext; const _CopyURLAccessory({required this.cellContext, Key? key}) : super(key: key); @override + State createState() => _CopyURLAccessoryState(); +} + +class _CopyURLAccessoryState extends State<_CopyURLAccessory> + with GridCellAccessoryState { + @override Widget build(BuildContext context) { final theme = context.watch(); return svgWidget("editor/copy", color: theme.iconColor); @@ -198,7 +254,7 @@ class _CopyURLAccessory extends StatelessWidget with GridCellAccessory { @override void onTap() { final content = - cellContext.getCellData(loadIfNotExist: false)?.content ?? ""; + widget.cellContext.getCellData(loadIfNotExist: false)?.content ?? ""; Clipboard.setData(ClipboardData(text: content)); showMessageToast(LocaleKeys.grid_row_copyProperty.tr()); } diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell.dart index c1de0eca31..4436e61fb6 100755 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell.dart @@ -1,6 +1,6 @@ import 'package:app_flowy/plugins/grid/application/field/field_cell_bloc.dart'; import 'package:app_flowy/plugins/grid/application/field/field_service.dart'; -import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_context.dart'; +import 'package:appflowy_popover/popover.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/style_widget/button.dart'; @@ -13,23 +13,35 @@ import '../../layout/sizes.dart'; import 'field_type_extension.dart'; import 'field_cell_action_sheet.dart'; -import 'field_editor.dart'; class GridFieldCell extends StatelessWidget { final GridFieldCellContext cellContext; - const GridFieldCell(this.cellContext, {Key? key}) : super(key: key); + const GridFieldCell({ + Key? key, + required this.cellContext, + }) : super(key: key); @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => FieldCellBloc(cellContext: cellContext) - ..add(const FieldCellEvent.initial()), + create: (context) { + return FieldCellBloc(cellContext: cellContext); + }, child: BlocBuilder( - // buildWhen: (p, c) => p.field != c.field, builder: (context, state) { - final button = FieldCellButton( - field: state.field, - onTap: () => _showActionSheet(context), + final button = Popover( + direction: PopoverDirection.bottomWithLeftAligned, + triggerActions: PopoverTriggerActionFlags.click, + offset: const Offset(0, 10), + popupBuilder: (BuildContext context) { + return GridFieldCellActionSheet( + cellContext: cellContext, + ); + }, + child: FieldCellButton( + field: cellContext.field, + onTap: () {}, + ), ); const line = Positioned( @@ -51,29 +63,6 @@ class GridFieldCell extends StatelessWidget { ), ); } - - void _showActionSheet(BuildContext context) { - final state = context.read().state; - GridFieldCellActionSheet( - cellContext: - GridFieldCellContext(gridId: state.gridId, field: state.field), - onEdited: () => _showFieldEditor(context), - ).show(context); - } - - void _showFieldEditor(BuildContext context) { - final state = context.read().state; - final field = state.field; - - FieldEditor( - gridId: state.gridId, - fieldName: field.name, - typeOptionLoader: FieldTypeOptionLoader( - gridId: state.gridId, - field: field, - ), - ).show(context); - } } class _GridHeaderCellContainer extends StatelessWidget { @@ -119,6 +108,7 @@ class _DragToExpandLine extends StatelessWidget { child: GestureDetector( behavior: HitTestBehavior.opaque, onHorizontalDragUpdate: (value) { + debugPrint("update new width: ${value.delta.dx}"); context .read() .add(FieldCellEvent.startUpdateWidth(value.delta.dx)); diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell_action_sheet.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell_action_sheet.dart index 9ea8b56b77..3991b841b8 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell_action_sheet.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell_action_sheet.dart @@ -1,3 +1,5 @@ +import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_context.dart'; +import 'package:app_flowy/plugins/grid/presentation/widgets/header/field_editor.dart'; import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:flowy_infra/image.dart'; @@ -13,75 +15,81 @@ import 'package:app_flowy/generated/locale_keys.g.dart'; import '../../layout/sizes.dart'; -class GridFieldCellActionSheet extends StatelessWidget - with FlowyOverlayDelegate { +class GridFieldCellActionSheet extends StatefulWidget { final GridFieldCellContext cellContext; - final VoidCallback onEdited; - const GridFieldCellActionSheet( - {required this.cellContext, required this.onEdited, Key? key}) + const GridFieldCellActionSheet({required this.cellContext, Key? key}) : super(key: key); - void show(BuildContext overlayContext) { - FlowyOverlay.of(overlayContext).insertWithAnchor( - widget: OverlayContainer( - constraints: BoxConstraints.loose(const Size(240, 200)), - child: this, - ), - identifier: GridFieldCellActionSheet.identifier(), - anchorContext: overlayContext, - anchorDirection: AnchorDirection.bottomWithLeftAligned, - delegate: this, - ); - } + @override + State createState() => _GridFieldCellActionSheetState(); +} + +class _GridFieldCellActionSheetState extends State { + bool _showFieldEditor = false; @override Widget build(BuildContext context) { + if (_showFieldEditor) { + final field = widget.cellContext.field; + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(240, 200)), + child: FieldEditor( + gridId: widget.cellContext.gridId, + fieldName: field.name, + typeOptionLoader: FieldTypeOptionLoader( + gridId: widget.cellContext.gridId, + field: field, + ), + ), + ); + } return BlocProvider( - create: (context) => getIt(param1: cellContext), - child: SingleChildScrollView( - child: Column( - children: [ - _EditFieldButton( - onEdited: () { - FlowyOverlay.of(context).remove(identifier()); - onEdited(); - }, - ), - const VSpace(6), - _FieldOperationList(cellContext, - () => FlowyOverlay.of(context).remove(identifier())), - ], + create: (context) => + getIt(param1: widget.cellContext), + child: OverlayContainer( + constraints: BoxConstraints.loose(const Size(240, 200)), + child: SingleChildScrollView( + child: Column( + children: [ + _EditFieldButton( + cellContext: widget.cellContext, + onTap: () { + setState(() { + _showFieldEditor = true; + }); + }, + ), + const VSpace(6), + _FieldOperationList(widget.cellContext, () {}), + ], + ), ), ), ); } - - static String identifier() { - return (GridFieldCellActionSheet).toString(); - } - - @override - bool asBarrier() { - return true; - } } class _EditFieldButton extends StatelessWidget { - final Function() onEdited; - const _EditFieldButton({required this.onEdited, Key? key}) : super(key: key); + final GridFieldCellContext cellContext; + final void Function()? onTap; + const _EditFieldButton({required this.cellContext, Key? key, this.onTap}) + : super(key: key); @override Widget build(BuildContext context) { final theme = context.watch(); + return BlocBuilder( builder: (context, state) { return SizedBox( height: GridSize.typeOptionItemHeight, child: FlowyButton( - text: FlowyText.medium(LocaleKeys.grid_field_editProperty.tr(), - fontSize: 12), + text: FlowyText.medium( + LocaleKeys.grid_field_editProperty.tr(), + fontSize: 12, + ), hoverColor: theme.hover, - onTap: onEdited, + onTap: onTap, ), ); }, 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.dart index 3f497d3304..83a6a27fda 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 @@ -1,7 +1,7 @@ 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:appflowy_popover/popover.dart'; import 'package:easy_localization/easy_localization.dart'; -import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flutter/material.dart'; @@ -10,7 +10,7 @@ import 'package:app_flowy/generated/locale_keys.g.dart'; import 'field_name_input.dart'; import 'field_type_option_editor.dart'; -class FieldEditor extends StatelessWidget with FlowyOverlayDelegate { +class FieldEditor extends StatefulWidget { final String gridId; final String fieldName; @@ -22,13 +22,26 @@ class FieldEditor extends StatelessWidget with FlowyOverlayDelegate { Key? key, }) : super(key: key); + @override + State createState() => _FieldEditorState(); +} + +class _FieldEditorState extends State { + late PopoverMutex popoverMutex; + + @override + void initState() { + popoverMutex = PopoverMutex(); + super.initState(); + } + @override Widget build(BuildContext context) { return BlocProvider( create: (context) => FieldEditorBloc( - gridId: gridId, - fieldName: fieldName, - loader: typeOptionLoader, + gridId: widget.gridId, + fieldName: widget.fieldName, + loader: widget.typeOptionLoader, )..add(const FieldEditorEvent.initial()), child: BlocBuilder( buildWhen: (p, c) => false, @@ -41,42 +54,22 @@ class FieldEditor extends StatelessWidget with FlowyOverlayDelegate { const VSpace(10), const _FieldNameCell(), const VSpace(10), - const _FieldTypeOptionCell(), + _FieldTypeOptionCell(popoverMutex: popoverMutex), ], ); }, ), ); } - - void show( - BuildContext context, { - AnchorDirection anchorDirection = AnchorDirection.bottomWithLeftAligned, - }) { - FlowyOverlay.of(context).remove(identifier()); - FlowyOverlay.of(context).insertWithAnchor( - widget: OverlayContainer( - constraints: BoxConstraints.loose(const Size(280, 400)), - child: this, - ), - identifier: identifier(), - anchorContext: context, - anchorDirection: anchorDirection, - style: FlowyOverlayStyle(blur: false), - delegate: this, - ); - } - - static String identifier() { - return (FieldEditor).toString(); - } - - @override - bool asBarrier() => true; } class _FieldTypeOptionCell extends StatelessWidget { - const _FieldTypeOptionCell({Key? key}) : super(key: key); + final PopoverMutex popoverMutex; + + const _FieldTypeOptionCell({ + Key? key, + required this.popoverMutex, + }) : super(key: key); @override Widget build(BuildContext context) { @@ -88,7 +81,10 @@ class _FieldTypeOptionCell extends StatelessWidget { (fieldContext) { final dataController = context.read().dataController; - return FieldTypeOptionEditor(dataController: dataController); + return FieldTypeOptionEditor( + dataController: dataController, + popoverMutex: popoverMutex, + ); }, ); }, diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_option_editor.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_option_editor.dart index d9e5eb4f38..4827a5ac6d 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_option_editor.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_option_editor.dart @@ -1,5 +1,6 @@ import 'dart:typed_data'; import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_data_controller.dart'; +import 'package:appflowy_popover/popover.dart'; import 'package:dartz/dartz.dart' show Either; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; @@ -23,30 +24,25 @@ typedef SwitchToFieldCallback FieldType fieldType, ); -class FieldTypeOptionEditor extends StatefulWidget { +class FieldTypeOptionEditor extends StatelessWidget { final TypeOptionDataController dataController; + final PopoverMutex popoverMutex; const FieldTypeOptionEditor({ required this.dataController, + required this.popoverMutex, Key? key, }) : super(key: key); - @override - State createState() => _FieldTypeOptionEditorState(); -} - -class _FieldTypeOptionEditorState extends State { - String? currentOverlayIdentifier; - @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => FieldTypeOptionEditBloc(widget.dataController) + create: (context) => FieldTypeOptionEditBloc(dataController) ..add(const FieldTypeOptionEditEvent.initial()), child: BlocBuilder( builder: (context, state) { List children = [ - _switchFieldTypeButton(context, widget.dataController.field) + _switchFieldTypeButton(context, dataController.field) ]; final typeOptionWidget = _typeOptionWidget(context: context, state: state); @@ -68,18 +64,28 @@ class _FieldTypeOptionEditorState extends State { final theme = context.watch(); return SizedBox( height: GridSize.typeOptionItemHeight, - child: FlowyButton( - text: FlowyText.medium(field.fieldType.title(), fontSize: 12), - margin: const EdgeInsets.symmetric(horizontal: 6, vertical: 2), - hoverColor: theme.hover, - onTap: () { + child: Popover( + triggerActions: + PopoverTriggerActionFlags.hover | PopoverTriggerActionFlags.click, + mutex: popoverMutex, + offset: const Offset(20, 0), + popupBuilder: (context) { final list = FieldTypeList(onSelectField: (newFieldType) { - widget.dataController.switchToField(newFieldType); + dataController.switchToField(newFieldType); }); - _showOverlay(context, list); + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(460, 440)), + child: list, + ); }, - leftIcon: svgWidget(field.fieldType.iconName(), color: theme.iconColor), - rightIcon: svgWidget("grid/more", color: theme.iconColor), + child: FlowyButton( + text: FlowyText.medium(field.fieldType.title(), fontSize: 12), + margin: const EdgeInsets.symmetric(horizontal: 6, vertical: 2), + hoverColor: theme.hover, + leftIcon: + svgWidget(field.fieldType.iconName(), color: theme.iconColor), + rightIcon: svgWidget("grid/more", color: theme.iconColor), + ), ), ); } @@ -88,44 +94,12 @@ class _FieldTypeOptionEditorState extends State { required BuildContext context, required FieldTypeOptionEditState state, }) { - final overlayDelegate = TypeOptionOverlayDelegate( - showOverlay: _showOverlay, - hideOverlay: _hideOverlay, - ); - return makeTypeOptionWidget( context: context, - overlayDelegate: overlayDelegate, - dataController: widget.dataController, + dataController: dataController, + popoverMutex: popoverMutex, ); } - - void _showOverlay(BuildContext context, Widget child, - {VoidCallback? onRemoved}) { - final identifier = child.toString(); - if (currentOverlayIdentifier != null) { - FlowyOverlay.of(context).remove(currentOverlayIdentifier!); - } - - currentOverlayIdentifier = identifier; - FlowyOverlay.of(context).insertWithAnchor( - widget: OverlayContainer( - constraints: BoxConstraints.loose(const Size(460, 440)), - child: child, - ), - identifier: identifier, - anchorContext: context, - anchorDirection: AnchorDirection.leftWithCenterAligned, - style: FlowyOverlayStyle(blur: false), - anchorOffset: const Offset(-20, 0), - ); - } - - void _hideOverlay(BuildContext context) { - if (currentOverlayIdentifier != null) { - FlowyOverlay.of(context).remove(currentOverlayIdentifier!); - } - } } abstract class TypeOptionWidget extends StatelessWidget { diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/grid_header.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/grid_header.dart index 05c1faec08..909a799554 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/grid_header.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/grid_header.dart @@ -4,8 +4,10 @@ import 'package:app_flowy/plugins/grid/application/field/type_option/type_option import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/plugins/grid/application/prelude.dart'; import 'package:easy_localization/easy_localization.dart'; +import 'package:appflowy_popover/popover.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; +import 'package:flowy_infra_ui/flowy_infra_ui_web.dart'; import 'package:flowy_infra_ui/style_widget/button.dart'; import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; @@ -75,6 +77,21 @@ class _GridHeader extends StatefulWidget { } class _GridHeaderState extends State<_GridHeader> { + final Map> _gridMap = {}; + + /// This is a workaround for [ReorderableRow]. + /// [ReorderableRow] warps the child's key with a [GlobalKey]. + /// It will trigger the child's widget's to recreate. + /// The state will lose. + _getKeyById(String id) { + if (_gridMap.containsKey(id)) { + return _gridMap[id]; + } + final newKey = ValueKey(id); + _gridMap[id] = newKey; + return newKey; + } + @override Widget build(BuildContext context) { final theme = context.watch(); @@ -85,7 +102,10 @@ class _GridHeaderState extends State<_GridHeader> { .where((field) => field.visibility) .map((field) => GridFieldCellContext(gridId: widget.gridId, field: field.field)) - .map((ctx) => GridFieldCell(ctx, key: ValueKey(ctx.field.id))) + .map((ctx) => GridFieldCell( + key: _getKeyById(ctx.field.id), + cellContext: ctx, + )) .toList(); return Container( @@ -156,18 +176,28 @@ class CreateFieldButton extends StatelessWidget { Widget build(BuildContext context) { final theme = context.watch(); - return FlowyButton( - text: FlowyText.medium( - LocaleKeys.grid_field_newColumn.tr(), - fontSize: 12, + return Popover( + triggerActions: PopoverTriggerActionFlags.click, + direction: PopoverDirection.bottomWithRightAligned, + child: FlowyButton( + text: FlowyText.medium( + LocaleKeys.grid_field_newColumn.tr(), + fontSize: 12, + ), + hoverColor: theme.shader6, + onTap: () {}, + leftIcon: svgWidget("home/add"), ), - hoverColor: theme.shader6, - onTap: () => FieldEditor( - gridId: gridId, - fieldName: "", - typeOptionLoader: NewFieldTypeOptionLoader(gridId: gridId), - ).show(context), - leftIcon: svgWidget("home/add"), + popupBuilder: (BuildContext popover) { + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(240, 200)), + child: FieldEditor( + gridId: gridId, + fieldName: "", + typeOptionLoader: NewFieldTypeOptionLoader(gridId: gridId), + ), + ); + }, ); } } diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/builder.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/builder.dart index cfa2f9291f..02350f3a5e 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/builder.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/builder.dart @@ -3,6 +3,7 @@ import 'dart:typed_data'; import 'package:app_flowy/plugins/grid/application/field/field_controller.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_data_controller.dart'; +import 'package:appflowy_popover/popover.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/checkbox_type_option.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/date_type_option.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/multi_select_type_option.pb.dart'; @@ -46,19 +47,16 @@ abstract class TypeOptionWidgetBuilder { Widget? makeTypeOptionWidget({ required BuildContext context, required TypeOptionDataController dataController, - required TypeOptionOverlayDelegate overlayDelegate, + required PopoverMutex popoverMutex, }) { final builder = makeTypeOptionWidgetBuilder( - dataController: dataController, - overlayDelegate: overlayDelegate, - ); + dataController: dataController, popoverMutex: popoverMutex); return builder.build(context); } -TypeOptionWidgetBuilder makeTypeOptionWidgetBuilder({ - required TypeOptionDataController dataController, - required TypeOptionOverlayDelegate overlayDelegate, -}) { +TypeOptionWidgetBuilder makeTypeOptionWidgetBuilder( + {required TypeOptionDataController dataController, + required PopoverMutex popoverMutex}) { final gridId = dataController.gridId; final fieldType = dataController.field.fieldType; @@ -73,13 +71,12 @@ TypeOptionWidgetBuilder makeTypeOptionWidgetBuilder({ ); case FieldType.DateTime: return DateTypeOptionWidgetBuilder( - makeTypeOptionContextWithDataController( - gridId: gridId, - fieldType: fieldType, - dataController: dataController, - ), - overlayDelegate, - ); + makeTypeOptionContextWithDataController( + gridId: gridId, + fieldType: fieldType, + dataController: dataController, + ), + popoverMutex); case FieldType.SingleSelect: return SingleSelectTypeOptionWidgetBuilder( makeTypeOptionContextWithDataController( @@ -87,7 +84,7 @@ TypeOptionWidgetBuilder makeTypeOptionWidgetBuilder({ fieldType: fieldType, dataController: dataController, ), - overlayDelegate, + popoverMutex, ); case FieldType.MultiSelect: return MultiSelectTypeOptionWidgetBuilder( @@ -96,7 +93,7 @@ TypeOptionWidgetBuilder makeTypeOptionWidgetBuilder({ fieldType: fieldType, dataController: dataController, ), - overlayDelegate, + popoverMutex, ); case FieldType.Number: return NumberTypeOptionWidgetBuilder( @@ -105,7 +102,7 @@ TypeOptionWidgetBuilder makeTypeOptionWidgetBuilder({ fieldType: fieldType, dataController: dataController, ), - overlayDelegate, + popoverMutex, ); case FieldType.RichText: return RichTextTypeOptionWidgetBuilder( diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/date.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/date.dart index 51433037a3..ae3dcf8682 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/date.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/date.dart @@ -11,6 +11,7 @@ import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/date_type_option_entities.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:appflowy_popover/popover.dart'; import '../../../layout/sizes.dart'; import '../field_type_option_editor.dart'; import 'builder.dart'; @@ -20,10 +21,10 @@ class DateTypeOptionWidgetBuilder extends TypeOptionWidgetBuilder { DateTypeOptionWidgetBuilder( DateTypeOptionContext typeOptionContext, - TypeOptionOverlayDelegate overlayDelegate, + PopoverMutex popoverMutex, ) : _widget = DateTypeOptionWidget( typeOptionContext: typeOptionContext, - overlayDelegate: overlayDelegate, + popoverMutex: popoverMutex, ); @override @@ -34,11 +35,10 @@ class DateTypeOptionWidgetBuilder extends TypeOptionWidgetBuilder { class DateTypeOptionWidget extends TypeOptionWidget { final DateTypeOptionContext typeOptionContext; - final TypeOptionOverlayDelegate overlayDelegate; - + final PopoverMutex popoverMutex; const DateTypeOptionWidget({ required this.typeOptionContext, - required this.overlayDelegate, + required this.popoverMutex, Key? key, }) : super(key: key); @@ -62,39 +62,58 @@ class DateTypeOptionWidget extends TypeOptionWidget { } Widget _renderDateFormatButton(BuildContext context, DateFormat dataFormat) { - return DateFormatButton(onTap: () { - final list = DateFormatList( - selectedFormat: dataFormat, - onSelected: (format) { - context - .read() - .add(DateTypeOptionEvent.didSelectDateFormat(format)); - }, - ); - overlayDelegate.showOverlay(context, list); - }); - } - - Widget _renderTimeFormatButton(BuildContext context, TimeFormat timeFormat) { - return TimeFormatButton( - timeFormat: timeFormat, - onTap: () { - final list = TimeFormatList( - selectedFormat: timeFormat, + return Popover( + mutex: popoverMutex, + triggerActions: + PopoverTriggerActionFlags.hover | PopoverTriggerActionFlags.click, + offset: const Offset(20, 0), + popupBuilder: (popoverContext) { + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(460, 440)), + child: DateFormatList( + selectedFormat: dataFormat, onSelected: (format) { context .read() - .add(DateTypeOptionEvent.didSelectTimeFormat(format)); - }); - overlayDelegate.showOverlay(context, list); + .add(DateTypeOptionEvent.didSelectDateFormat(format)); + PopoverContainerState.of(popoverContext).closeAll(); + }, + ), + ); }, + child: const DateFormatButton(), + ); + } + + Widget _renderTimeFormatButton(BuildContext context, TimeFormat timeFormat) { + return Popover( + mutex: popoverMutex, + triggerActions: + PopoverTriggerActionFlags.hover | PopoverTriggerActionFlags.click, + offset: const Offset(20, 0), + popupBuilder: (BuildContext popoverContext) { + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(460, 440)), + child: TimeFormatList( + selectedFormat: timeFormat, + onSelected: (format) { + context + .read() + .add(DateTypeOptionEvent.didSelectTimeFormat(format)); + PopoverContainerState.of(popoverContext).closeAll(); + }), + ); + }, + child: TimeFormatButton(timeFormat: timeFormat), ); } } class DateFormatButton extends StatelessWidget { - final VoidCallback onTap; - const DateFormatButton({required this.onTap, Key? key}) : super(key: key); + final VoidCallback? onTap; + final void Function(bool)? onHover; + const DateFormatButton({this.onTap, this.onHover, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { @@ -107,6 +126,7 @@ class DateFormatButton extends StatelessWidget { margin: GridSize.typeOptionContentInsets, hoverColor: theme.hover, onTap: onTap, + onHover: onHover, rightIcon: svgWidget("grid/more", color: theme.iconColor), ), ); @@ -115,9 +135,10 @@ class DateFormatButton extends StatelessWidget { class TimeFormatButton extends StatelessWidget { final TimeFormat timeFormat; - final VoidCallback onTap; + final VoidCallback? onTap; + final void Function(bool)? onHover; const TimeFormatButton( - {required this.timeFormat, required this.onTap, Key? key}) + {required this.timeFormat, this.onTap, this.onHover, Key? key}) : super(key: key); @override @@ -131,6 +152,7 @@ class TimeFormatButton extends StatelessWidget { margin: GridSize.typeOptionContentInsets, hoverColor: theme.hover, onTap: onTap, + onHover: onHover, rightIcon: svgWidget("grid/more", color: theme.iconColor), ), ); diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/multi_select.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/multi_select.dart index ab8a628146..75ac6eeaa0 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/multi_select.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/multi_select.dart @@ -1,6 +1,7 @@ import 'package:app_flowy/plugins/grid/application/field/type_option/multi_select_type_option.dart'; import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_context.dart'; import 'package:flutter/material.dart'; +import 'package:appflowy_popover/popover.dart'; import '../field_type_option_editor.dart'; import 'builder.dart'; @@ -11,14 +12,14 @@ class MultiSelectTypeOptionWidgetBuilder extends TypeOptionWidgetBuilder { MultiSelectTypeOptionWidgetBuilder( MultiSelectTypeOptionContext typeOptionContext, - TypeOptionOverlayDelegate overlayDelegate, + PopoverMutex popoverMutex, ) : _widget = MultiSelectTypeOptionWidget( selectOptionAction: MultiSelectAction( fieldId: typeOptionContext.fieldId, gridId: typeOptionContext.gridId, typeOptionContext: typeOptionContext, ), - overlayDelegate: overlayDelegate, + popoverMutex: popoverMutex, ); @override @@ -27,20 +28,22 @@ class MultiSelectTypeOptionWidgetBuilder extends TypeOptionWidgetBuilder { class MultiSelectTypeOptionWidget extends TypeOptionWidget { final MultiSelectAction selectOptionAction; - final TypeOptionOverlayDelegate overlayDelegate; + final PopoverMutex? popoverMutex; const MultiSelectTypeOptionWidget({ - required this.selectOptionAction, - required this.overlayDelegate, Key? key, + required this.selectOptionAction, + this.popoverMutex, }) : super(key: key); @override Widget build(BuildContext context) { return SelectOptionTypeOptionWidget( options: selectOptionAction.typeOption.options, - beginEdit: () => overlayDelegate.hideOverlay(context), - overlayDelegate: overlayDelegate, + beginEdit: () { + PopoverContainerState.of(context).closeAll(); + }, + popoverMutex: popoverMutex, typeOptionAction: selectOptionAction, // key: ValueKey(state.typeOption.hashCode), ); diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/number.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/number.dart index 590a025a41..cdc69eb4e6 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/number.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/number.dart @@ -1,6 +1,7 @@ import 'package:app_flowy/plugins/grid/application/field/type_option/number_bloc.dart'; import 'package:app_flowy/plugins/grid/application/field/type_option/number_format_bloc.dart'; import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_context.dart'; +import 'package:appflowy_popover/popover.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; @@ -23,10 +24,10 @@ class NumberTypeOptionWidgetBuilder extends TypeOptionWidgetBuilder { NumberTypeOptionWidgetBuilder( NumberTypeOptionContext typeOptionContext, - TypeOptionOverlayDelegate overlayDelegate, + PopoverMutex popoverMutex, ) : _widget = NumberTypeOptionWidget( typeOptionContext: typeOptionContext, - overlayDelegate: overlayDelegate, + popoverMutex: popoverMutex, ); @override @@ -34,11 +35,11 @@ class NumberTypeOptionWidgetBuilder extends TypeOptionWidgetBuilder { } class NumberTypeOptionWidget extends TypeOptionWidget { - final TypeOptionOverlayDelegate overlayDelegate; final NumberTypeOptionContext typeOptionContext; + final PopoverMutex popoverMutex; const NumberTypeOptionWidget({ required this.typeOptionContext, - required this.overlayDelegate, + required this.popoverMutex, Key? key, }) : super(key: key); @@ -54,34 +55,40 @@ class NumberTypeOptionWidget extends TypeOptionWidget { listener: (context, state) => typeOptionContext.typeOption = state.typeOption, builder: (context, state) { - return FlowyButton( - text: Row( - children: [ - FlowyText.medium(LocaleKeys.grid_field_numberFormat.tr(), - fontSize: 12), - // const HSpace(6), - const Spacer(), - FlowyText.regular(state.typeOption.format.title(), - fontSize: 12), - ], + return Popover( + mutex: popoverMutex, + triggerActions: PopoverTriggerActionFlags.hover | + PopoverTriggerActionFlags.click, + offset: const Offset(20, 0), + child: FlowyButton( + margin: GridSize.typeOptionContentInsets, + hoverColor: theme.hover, + rightIcon: svgWidget("grid/more", color: theme.iconColor), + text: Row( + children: [ + FlowyText.medium(LocaleKeys.grid_field_numberFormat.tr(), + fontSize: 12), + // const HSpace(6), + const Spacer(), + FlowyText.regular(state.typeOption.format.title(), + fontSize: 12), + ], + ), ), - margin: GridSize.typeOptionContentInsets, - hoverColor: theme.hover, - onTap: () { - final list = NumberFormatList( - onSelected: (format) { - context - .read() - .add(NumberTypeOptionEvent.didSelectFormat(format)); - }, - selectedFormat: state.typeOption.format, - ); - overlayDelegate.showOverlay( - context, - list, + popupBuilder: (BuildContext popoverContext) { + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(460, 440)), + child: NumberFormatList( + onSelected: (format) { + context + .read() + .add(NumberTypeOptionEvent.didSelectFormat(format)); + PopoverContainerState.of(popoverContext).closeAll(); + }, + selectedFormat: state.typeOption.format, + ), ); }, - rightIcon: svgWidget("grid/more", color: theme.iconColor), ); }, ), diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option.dart index d36df1fea7..7b0be75515 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option.dart @@ -1,6 +1,8 @@ import 'package:app_flowy/plugins/grid/application/field/type_option/select_option_type_option_bloc.dart'; +import 'package:appflowy_popover/popover.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; +import 'package:flowy_infra_ui/flowy_infra_ui_web.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/spacing.dart'; @@ -13,20 +15,19 @@ import 'package:app_flowy/generated/locale_keys.g.dart'; import '../../../layout/sizes.dart'; import '../../cell/select_option_cell/extension.dart'; import '../../common/text_field.dart'; -import 'builder.dart'; import 'select_option_editor.dart'; class SelectOptionTypeOptionWidget extends StatelessWidget { final List options; final VoidCallback beginEdit; - final TypeOptionOverlayDelegate overlayDelegate; final ISelectOptionAction typeOptionAction; + final PopoverMutex? popoverMutex; const SelectOptionTypeOptionWidget({ required this.options, required this.beginEdit, - required this.overlayDelegate, required this.typeOptionAction, + this.popoverMutex, Key? key, }) : super(key: key); @@ -50,7 +51,7 @@ class SelectOptionTypeOptionWidget extends StatelessWidget { ), if (state.options.isEmpty && !state.isEditingOption) const _AddOptionButton(), - _OptionList(overlayDelegate) + _OptionList(popoverMutex: popoverMutex) ]; return Column(children: children); @@ -111,8 +112,8 @@ class _OptionTitleButton extends StatelessWidget { } class _OptionList extends StatelessWidget { - final TypeOptionOverlayDelegate delegate; - const _OptionList(this.delegate, {Key? key}) : super(key: key); + final PopoverMutex? popoverMutex; + const _OptionList({Key? key, this.popoverMutex}) : super(key: key); @override Widget build(BuildContext context) { @@ -122,7 +123,11 @@ class _OptionList extends StatelessWidget { }, builder: (context, state) { final cells = state.options.map((option) { - return _makeOptionCell(context, option); + return _makeOptionCell( + context: context, + option: option, + popoverMutex: popoverMutex, + ); }).toList(); return ListView.separated( @@ -140,57 +145,81 @@ class _OptionList extends StatelessWidget { ); } - _OptionCell _makeOptionCell(BuildContext context, SelectOptionPB option) { + _OptionCell _makeOptionCell({ + required BuildContext context, + required SelectOptionPB option, + PopoverMutex? popoverMutex, + }) { return _OptionCell( option: option, - onSelected: (option) { - final pannel = SelectOptionTypeOptionEditor( - option: option, - onDeleted: () { - delegate.hideOverlay(context); - context - .read() - .add(SelectOptionTypeOptionEvent.deleteOption(option)); - }, - onUpdated: (updatedOption) { - delegate.hideOverlay(context); - context - .read() - .add(SelectOptionTypeOptionEvent.updateOption(updatedOption)); - }, - key: ValueKey(option.id), - ); - delegate.showOverlay(context, pannel); - }, + popoverMutex: popoverMutex, ); } } -class _OptionCell extends StatelessWidget { +class _OptionCell extends StatefulWidget { final SelectOptionPB option; - final Function(SelectOptionPB) onSelected; - const _OptionCell({ - required this.option, - required this.onSelected, - Key? key, - }) : super(key: key); + final PopoverMutex? popoverMutex; + const _OptionCell({required this.option, Key? key, this.popoverMutex}) + : super(key: key); + + @override + State<_OptionCell> createState() => _OptionCellState(); +} + +class _OptionCellState extends State<_OptionCell> { + late PopoverController _popoverController; + + @override + void initState() { + _popoverController = PopoverController(); + super.initState(); + } @override Widget build(BuildContext context) { final theme = context.watch(); - return SizedBox( - height: GridSize.typeOptionItemHeight, - child: SelectOptionTagCell( - option: option, - onSelected: onSelected, - children: [ - svgWidget( - "grid/details", - color: theme.iconColor, - ), - ], + return Popover( + controller: _popoverController, + mutex: widget.popoverMutex, + offset: const Offset(20, 0), + child: SizedBox( + height: GridSize.typeOptionItemHeight, + child: SelectOptionTagCell( + option: widget.option, + onSelected: (SelectOptionPB pb) { + _popoverController.show(); + }, + children: [ + svgWidget( + "grid/details", + color: theme.iconColor, + ), + ], + ), ), + popupBuilder: (BuildContext popoverContext) { + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(460, 440)), + child: SelectOptionTypeOptionEditor( + option: widget.option, + onDeleted: () { + context + .read() + .add(SelectOptionTypeOptionEvent.deleteOption(widget.option)); + PopoverContainerState.of(popoverContext).closeAll(); + }, + onUpdated: (updatedOption) { + context + .read() + .add(SelectOptionTypeOptionEvent.updateOption(updatedOption)); + PopoverContainerState.of(popoverContext).closeAll(); + }, + key: ValueKey(widget.option.id), + ), + ); + }, ); } } diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/single_select.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/single_select.dart index d9d699fdff..27ffabb286 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/single_select.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/single_select.dart @@ -2,6 +2,7 @@ import 'package:app_flowy/plugins/grid/application/field/type_option/single_sele import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_context.dart'; import 'package:flutter/material.dart'; import '../field_type_option_editor.dart'; +import 'package:appflowy_popover/popover.dart'; import 'builder.dart'; import 'select_option.dart'; @@ -10,14 +11,14 @@ class SingleSelectTypeOptionWidgetBuilder extends TypeOptionWidgetBuilder { SingleSelectTypeOptionWidgetBuilder( SingleSelectTypeOptionContext singleSelectTypeOption, - TypeOptionOverlayDelegate overlayDelegate, + PopoverMutex popoverMutex, ) : _widget = SingleSelectTypeOptionWidget( selectOptionAction: SingleSelectAction( fieldId: singleSelectTypeOption.fieldId, gridId: singleSelectTypeOption.gridId, typeOptionContext: singleSelectTypeOption, ), - overlayDelegate: overlayDelegate, + popoverMutex: popoverMutex, ); @override @@ -26,20 +27,22 @@ class SingleSelectTypeOptionWidgetBuilder extends TypeOptionWidgetBuilder { class SingleSelectTypeOptionWidget extends TypeOptionWidget { final SingleSelectAction selectOptionAction; - final TypeOptionOverlayDelegate overlayDelegate; + final PopoverMutex? popoverMutex; const SingleSelectTypeOptionWidget({ - required this.selectOptionAction, - required this.overlayDelegate, Key? key, + required this.selectOptionAction, + this.popoverMutex, }) : super(key: key); @override Widget build(BuildContext context) { return SelectOptionTypeOptionWidget( options: selectOptionAction.typeOption.options, - beginEdit: () => overlayDelegate.hideOverlay(context), - overlayDelegate: overlayDelegate, + beginEdit: () { + PopoverContainerState.of(context).closeAll(); + }, + popoverMutex: popoverMutex, typeOptionAction: selectOptionAction, // key: ValueKey(state.typeOption.hashCode), ); diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/grid_row.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/grid_row.dart index 621f53cf1a..ebe2a41db2 100755 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/grid_row.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/grid_row.dart @@ -194,12 +194,17 @@ class RowContent extends StatelessWidget { Provider.of(context, listen: false), accessoryBuilder: (buildContext) { final builder = child.accessoryBuilder; - List accessories = []; + List accessories = []; if (cellId.fieldContext.isPrimary) { - accessories.add(PrimaryCellAccessory( - onTapCallback: onExpand, - isCellEditing: buildContext.isCellEditing, - )); + accessories.add( + GridCellAccessoryBuilder( + builder: (key) => PrimaryCellAccessory( + key: key, + onTapCallback: onExpand, + isCellEditing: buildContext.isCellEditing, + ), + ), + ); } if (builder != null) { diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/row_detail.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/row_detail.dart index 266be35a36..4965fb5407 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/row_detail.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/row/row_detail.dart @@ -15,6 +15,7 @@ import 'package:app_flowy/generated/locale_keys.g.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:appflowy_popover/popover.dart'; import '../../layout/sizes.dart'; import '../cell/cell_accessory.dart'; @@ -35,23 +36,6 @@ class RowDetailPage extends StatefulWidget with FlowyOverlayDelegate { @override State createState() => _RowDetailPageState(); - void show(BuildContext context) async { - final windowSize = MediaQuery.of(context).size; - final size = windowSize * 0.5; - FlowyOverlay.of(context).insertWithRect( - widget: OverlayContainer( - constraints: BoxConstraints.tight(size), - child: this, - ), - identifier: RowDetailPage.identifier(), - anchorPosition: Offset(-size.width / 2.0, -size.height / 2.0), - anchorSize: windowSize, - anchorDirection: AnchorDirection.center, - style: FlowyOverlayStyle(blur: false), - delegate: this, - ); - } - static String identifier() { return (RowDetailPage).toString(); } @@ -60,31 +44,33 @@ class RowDetailPage extends StatefulWidget with FlowyOverlayDelegate { class _RowDetailPageState extends State { @override Widget build(BuildContext context) { - return BlocProvider( - create: (context) { - final bloc = RowDetailBloc( - dataController: widget.dataController, - ); - bloc.add(const RowDetailEvent.initial()); - return bloc; - }, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 20), - child: Column( - children: [ - SizedBox( - height: 30, - child: Row( - children: const [Spacer(), _CloseButton()], + return FlowyDialog( + child: BlocProvider( + create: (context) { + final bloc = RowDetailBloc( + dataController: widget.dataController, + ); + bloc.add(const RowDetailEvent.initial()); + return bloc; + }, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 40, vertical: 20), + child: Column( + children: [ + SizedBox( + height: 40, + child: Row( + children: const [Spacer(), _CloseButton()], + ), ), - ), - Expanded( - child: _PropertyList( - cellBuilder: widget.cellBuilder, - viewId: widget.dataController.rowInfo.gridId, + Expanded( + child: _PropertyList( + cellBuilder: widget.cellBuilder, + viewId: widget.dataController.rowInfo.gridId, + ), ), - ), - ], + ], + ), ), ), ); @@ -99,8 +85,9 @@ class _CloseButton extends StatelessWidget { final theme = context.watch(); return FlowyIconButton( width: 24, - onPressed: () => - FlowyOverlay.of(context).remove(RowDetailPage.identifier()), + onPressed: () { + FlowyOverlay.pop(context); + }, iconPadding: const EdgeInsets.fromLTRB(2, 2, 2, 2), icon: svgWidget("home/close", color: theme.iconColor), ); @@ -161,26 +148,35 @@ class _CreateFieldButton extends StatelessWidget { Widget build(BuildContext context) { final theme = context.read(); - return SizedBox( - height: 40, - child: FlowyButton( - text: FlowyText.medium( - LocaleKeys.grid_field_newColumn.tr(), - fontSize: 12, + return Popover( + triggerActions: PopoverTriggerActionFlags.click, + child: SizedBox( + height: 40, + child: FlowyButton( + text: FlowyText.medium( + LocaleKeys.grid_field_newColumn.tr(), + fontSize: 12, + ), + hoverColor: theme.shader6, + onTap: () {}, + leftIcon: svgWidget("home/add"), ), - hoverColor: theme.shader6, - onTap: () => FieldEditor( - gridId: viewId, - fieldName: "", - typeOptionLoader: NewFieldTypeOptionLoader(gridId: viewId), - ).show(context), - leftIcon: svgWidget("home/add"), ), + popupBuilder: (BuildContext context) { + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(240, 200)), + child: FieldEditor( + gridId: viewId, + fieldName: "", + typeOptionLoader: NewFieldTypeOptionLoader(gridId: viewId), + ), + ); + }, ); } } -class _RowDetailCell extends StatelessWidget { +class _RowDetailCell extends StatefulWidget { final GridCellIdentifier cellId; final GridCellBuilder cellBuilder; const _RowDetailCell({ @@ -189,11 +185,18 @@ class _RowDetailCell extends StatelessWidget { Key? key, }) : super(key: key); + @override + State createState() => _RowDetailCellState(); +} + +class _RowDetailCellState extends State<_RowDetailCell> { + final PopoverController popover = PopoverController(); + @override Widget build(BuildContext context) { final theme = context.watch(); - final style = _customCellStyle(theme, cellId.fieldType); - final cell = cellBuilder.build(cellId, style: style); + final style = _customCellStyle(theme, widget.cellId.fieldType); + final cell = widget.cellBuilder.build(widget.cellId, style: style); final gesture = GestureDetector( behavior: HitTestBehavior.translucent, @@ -214,9 +217,26 @@ class _RowDetailCell extends StatelessWidget { children: [ SizedBox( width: 150, - child: FieldCellButton( - field: cellId.fieldContext.field, - onTap: () => _showFieldEditor(context), + child: Popover( + controller: popover, + offset: const Offset(20, 0), + popupBuilder: (context) { + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(240, 200)), + child: FieldEditor( + gridId: widget.cellId.gridId, + fieldName: widget.cellId.fieldContext.field.name, + typeOptionLoader: FieldTypeOptionLoader( + gridId: widget.cellId.gridId, + field: widget.cellId.fieldContext.field, + ), + ), + ); + }, + child: FieldCellButton( + field: widget.cellId.fieldContext.field, + onTap: () => popover.show(), + ), ), ), const HSpace(10), @@ -226,17 +246,6 @@ class _RowDetailCell extends StatelessWidget { ), ); } - - void _showFieldEditor(BuildContext context) { - FieldEditor( - gridId: cellId.gridId, - fieldName: cellId.fieldContext.name, - typeOptionLoader: FieldTypeOptionLoader( - gridId: cellId.gridId, - field: cellId.fieldContext.field, - ), - ).show(context); - } } GridCellStyle? _customCellStyle(AppTheme theme, FieldType fieldType) { diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_property.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_property.dart index f5acbcba2a..5e38efd9cb 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_property.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_property.dart @@ -1,7 +1,9 @@ import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_context.dart'; +import 'package:app_flowy/plugins/grid/presentation/widgets/header/field_editor.dart'; import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/plugins/grid/application/setting/property_bloc.dart'; import 'package:app_flowy/plugins/grid/presentation/widgets/header/field_type_extension.dart'; +import 'package:appflowy_popover/popover.dart'; import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; @@ -15,9 +17,8 @@ import 'package:styled_widget/styled_widget.dart'; import '../../../application/field/field_controller.dart'; import '../../layout/sizes.dart'; -import '../header/field_editor.dart'; -class GridPropertyList extends StatelessWidget with FlowyOverlayDelegate { +class GridPropertyList extends StatefulWidget { final String gridId; final GridFieldController fieldController; const GridPropertyList({ @@ -26,34 +27,38 @@ class GridPropertyList extends StatelessWidget with FlowyOverlayDelegate { Key? key, }) : super(key: key); - void show(BuildContext context) { - FlowyOverlay.of(context).insertWithAnchor( - widget: OverlayContainer( - constraints: BoxConstraints.loose(const Size(260, 400)), - child: this, - ), - identifier: identifier(), - anchorContext: context, - anchorDirection: AnchorDirection.bottomRight, - style: FlowyOverlayStyle(blur: false), - delegate: this, - ); + @override + State createState() => _GridPropertyListState(); +} + +class _GridPropertyListState extends State { + late PopoverMutex _popoverMutex; + + @override + void initState() { + _popoverMutex = PopoverMutex(); + super.initState(); } @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => - getIt(param1: gridId, param2: fieldController) - ..add(const GridPropertyEvent.initial()), + create: (context) => getIt( + param1: widget.gridId, param2: widget.fieldController) + ..add(const GridPropertyEvent.initial()), child: BlocBuilder( builder: (context, state) { final cells = state.fieldContexts.map((field) { return _GridPropertyCell( - gridId: gridId, fieldContext: field, key: ValueKey(field.id)); + popoverMutex: _popoverMutex, + gridId: widget.gridId, + fieldContext: field, + key: ValueKey(field.id), + ); }).toList(); return ListView.separated( + controller: ScrollController(), shrinkWrap: true, itemCount: cells.length, itemBuilder: (BuildContext context, int index) { @@ -67,21 +72,18 @@ class GridPropertyList extends StatelessWidget with FlowyOverlayDelegate { ), ); } - - String identifier() { - return (GridPropertyList).toString(); - } - - @override - bool asBarrier() => true; } class _GridPropertyCell extends StatelessWidget { final GridFieldContext fieldContext; final String gridId; - const _GridPropertyCell( - {required this.gridId, required this.fieldContext, Key? key}) - : super(key: key); + final PopoverMutex popoverMutex; + const _GridPropertyCell({ + required this.gridId, + required this.fieldContext, + required this.popoverMutex, + Key? key, + }) : super(key: key); @override Widget build(BuildContext context) { @@ -113,21 +115,27 @@ class _GridPropertyCell extends StatelessWidget { ); } - FlowyButton _editFieldButton(AppTheme theme, BuildContext context) { - return FlowyButton( - text: FlowyText.medium(fieldContext.name, fontSize: 12), - hoverColor: theme.hover, - leftIcon: - svgWidget(fieldContext.fieldType.iconName(), color: theme.iconColor), - onTap: () { - FieldEditor( - gridId: gridId, - fieldName: fieldContext.name, - typeOptionLoader: FieldTypeOptionLoader( + Widget _editFieldButton(AppTheme theme, BuildContext context) { + return Popover( + mutex: popoverMutex, + triggerActions: PopoverTriggerActionFlags.click, + offset: const Offset(20, 0), + child: FlowyButton( + text: FlowyText.medium(fieldContext.name, fontSize: 12), + hoverColor: theme.hover, + leftIcon: svgWidget(fieldContext.fieldType.iconName(), + color: theme.iconColor), + ), + popupBuilder: (BuildContext context) { + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(240, 200)), + child: FieldEditor( gridId: gridId, - field: fieldContext.field, + fieldName: fieldContext.name, + typeOptionLoader: FieldTypeOptionLoader( + gridId: gridId, field: fieldContext.field), ), - ).show(context, anchorDirection: AnchorDirection.bottomRight); + ); }, ); } diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_setting.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_setting.dart index c793d7eef1..9198f54de8 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_setting.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_setting.dart @@ -13,7 +13,6 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:app_flowy/generated/locale_keys.g.dart'; import '../../../application/field/field_controller.dart'; import '../../layout/sizes.dart'; -import 'grid_property.dart'; class GridSettingContext { final String gridId; @@ -32,37 +31,6 @@ class GridSettingList extends StatelessWidget { {required this.settingContext, required this.onAction, Key? key}) : super(key: key); - static void show(BuildContext context, GridSettingContext settingContext) { - final list = GridSettingList( - settingContext: settingContext, - onAction: (action, settingContext) { - switch (action) { - case GridSettingAction.filter: - break; - case GridSettingAction.sortBy: - break; - case GridSettingAction.properties: - GridPropertyList( - gridId: settingContext.gridId, - fieldController: settingContext.fieldController) - .show(context); - break; - } - }, - ); - - FlowyOverlay.of(context).insertWithAnchor( - widget: OverlayContainer( - constraints: BoxConstraints.loose(const Size(140, 400)), - child: list, - ), - identifier: list.identifier(), - anchorContext: context, - anchorDirection: AnchorDirection.bottomRight, - style: FlowyOverlayStyle(blur: false), - ); - } - @override Widget build(BuildContext context) { return BlocProvider( diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_toolbar.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_toolbar.dart index 61ea099f56..88b64a8f25 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_toolbar.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_toolbar.dart @@ -1,5 +1,8 @@ +import 'package:appflowy_popover/popover.dart'; +import 'package:app_flowy/plugins/grid/application/setting/setting_bloc.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/style_widget/extension.dart'; import 'package:flowy_infra_ui/style_widget/icon_button.dart'; import 'package:flutter/material.dart'; @@ -7,6 +10,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import '../../../application/field/field_controller.dart'; import '../../layout/sizes.dart'; +import 'grid_property.dart'; import 'grid_setting.dart'; class GridToolbarContext { @@ -49,12 +53,57 @@ class _SettingButton extends StatelessWidget { @override Widget build(BuildContext context) { final theme = context.watch(); - return FlowyIconButton( - hoverColor: theme.hover, - width: 22, - onPressed: () => GridSettingList.show(context, settingContext), - icon: - svgWidget("grid/setting/setting").padding(horizontal: 3, vertical: 3), + return Popover( + triggerActions: PopoverTriggerActionFlags.click, + offset: const Offset(0, 10), + child: FlowyIconButton( + width: 22, + hoverColor: theme.hover, + icon: svgWidget("grid/setting/setting") + .padding(horizontal: 3, vertical: 3), + ), + popupBuilder: (BuildContext context) { + return _GridSettingListPopover(settingContext: settingContext); + }, + ); + } +} + +class _GridSettingListPopover extends StatefulWidget { + final GridSettingContext settingContext; + + const _GridSettingListPopover({Key? key, required this.settingContext}) + : super(key: key); + + @override + State createState() => _GridSettingListPopoverState(); +} + +class _GridSettingListPopoverState extends State<_GridSettingListPopover> { + GridSettingAction? _action; + + @override + Widget build(BuildContext context) { + if (_action == GridSettingAction.properties) { + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(260, 400)), + child: GridPropertyList( + gridId: widget.settingContext.gridId, + fieldController: widget.settingContext.fieldController, + ), + ); + } + + return OverlayContainer( + constraints: BoxConstraints.loose(const Size(140, 400)), + child: GridSettingList( + settingContext: widget.settingContext, + onAction: (action, settingContext) { + setState(() { + _action = action; + }); + }, + ), ); } } diff --git a/frontend/app_flowy/lib/workspace/presentation/settings/settings_dialog.dart b/frontend/app_flowy/lib/workspace/presentation/settings/settings_dialog.dart index eaf09d770f..6de69029a5 100644 --- a/frontend/app_flowy/lib/workspace/presentation/settings/settings_dialog.dart +++ b/frontend/app_flowy/lib/workspace/presentation/settings/settings_dialog.dart @@ -6,6 +6,7 @@ import 'package:app_flowy/workspace/presentation/settings/widgets/settings_langu import 'package:app_flowy/workspace/presentation/settings/widgets/settings_user_view.dart'; import 'package:app_flowy/workspace/presentation/settings/widgets/settings_menu.dart'; import 'package:app_flowy/workspace/application/settings/settings_dialog_bloc.dart'; +import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; @@ -28,46 +29,50 @@ class SettingsDialog extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => getIt(param1: user)..add(const SettingsDialogEvent.initial()), + create: (context) => getIt(param1: user) + ..add(const SettingsDialogEvent.initial()), child: BlocBuilder( builder: (context, state) => ChangeNotifierProvider.value( - value: Provider.of(context, listen: true), - child: AlertDialog( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - ), + value: Provider.of(context, + listen: true), + child: FlowyDialog( title: Text( LocaleKeys.settings_title.tr(), style: const TextStyle( fontWeight: FontWeight.bold, ), ), - content: ConstrainedBox( - constraints: const BoxConstraints( - maxHeight: 600, - minWidth: 600, - maxWidth: 1000, - ), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: 200, - child: SettingsMenu( - changeSelectedIndex: (index) { - context.read().add(SettingsDialogEvent.setViewIndex(index)); - }, - currentIndex: context.read().state.viewIndex, - ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: 200, + child: SettingsMenu( + changeSelectedIndex: (index) { + context + .read() + .add(SettingsDialogEvent.setViewIndex(index)); + }, + currentIndex: context + .read() + .state + .viewIndex, ), - const VerticalDivider(), - const SizedBox(width: 10), - Expanded( - child: getSettingsView(context.read().state.viewIndex, - context.read().state.userProfile), - ) - ], - ), + ), + const VerticalDivider(), + const SizedBox(width: 10), + Expanded( + child: getSettingsView( + context + .read() + .state + .viewIndex, + context + .read() + .state + .userProfile), + ) + ], ), ), ))); diff --git a/frontend/app_flowy/packages/appflowy_popover/.gitignore b/frontend/app_flowy/packages/appflowy_popover/.gitignore new file mode 100644 index 0000000000..96486fd930 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/.gitignore @@ -0,0 +1,30 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/frontend/app_flowy/packages/appflowy_popover/.metadata b/frontend/app_flowy/packages/appflowy_popover/.metadata new file mode 100644 index 0000000000..e7011f64f3 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + channel: stable + +project_type: package diff --git a/frontend/app_flowy/packages/appflowy_popover/CHANGELOG.md b/frontend/app_flowy/packages/appflowy_popover/CHANGELOG.md new file mode 100644 index 0000000000..41cc7d8192 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +* TODO: Describe initial release. diff --git a/frontend/app_flowy/packages/appflowy_popover/LICENSE b/frontend/app_flowy/packages/appflowy_popover/LICENSE new file mode 100644 index 0000000000..ba75c69f7f --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/LICENSE @@ -0,0 +1 @@ +TODO: Add your license here. diff --git a/frontend/app_flowy/packages/appflowy_popover/README.md b/frontend/app_flowy/packages/appflowy_popover/README.md new file mode 100644 index 0000000000..11b608c860 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/README.md @@ -0,0 +1,107 @@ +# AppFlowy Popover + +A Popover can be used to display some content on top of another. + +It can be used to display a dropdown menu. + +> A popover is a transient view that appears above other content onscreen when you tap a control or in an area. Typically, a popover includes an arrow pointing to the location from which it emerged. Popovers can be nonmodal or modal. A nonmodal popover is dismissed by tapping another part of the screen or a button on the popover. A modal popover is dismissed by tapping a Cancel or other button on the popover. + +Source: [Human Interface Guidelines](https://developer.apple.com/design/human-interface-guidelines/ios/views/popovers/). + +## Features + +- Basic popover style +- Follow the target automatically +- Nested popover support +- Exclusive API + +![](./screenshot.png) + +## Example + +```dart +Popover( + // Define how to trigger the popover + triggerActions: PopoverTriggerActionFlags.click, + child: TextButton(child: Text("Popover"), onPressed: () {}), + // Define the direction of the popover + direction: PopoverDirection.bottomWithLeftAligned, + popupBuilder(BuildContext context) { + return PopoverMenu(); + }, +); +``` + +### Trigger the popover manually + +Sometimes, if you want to trigger the popover manually, you can use a `PopoverController`. + +```dart +class MyWidgetState extends State { + late PopoverController _popover; + + @override + void initState() { + _popover = PopoverController(); + super.initState(); + } + + // triggered by another widget + _onClick() { + _popover.show(); + } + + @override + Widget build(BuildContext context) { + return Popover( + controller: _popover, + ... + ) + } +} +``` + +### Make several popovers exclusive + +The popover has a mechanism to make sure there are only one popover is shown in a group of popovers. +It's called `PopoverMutex`. + +If you pass the same mutex object to the popovers, there will be only one popover is triggered. + +```dart +class MyWidgetState extends State { + final _popoverMutex = PopoverMutex(); + + @override + Widget build(BuildContext context) { + return Row( + children: [ + Popover( + mutex: _popoverMutex, + ... + ), + Popover( + mutex: _popoverMutex, + ... + ), + Popover( + mutex: _popoverMutex, + ... + ), + ] + ) + } +} +``` + +## API + +| Param | Description | Type | +| -------------- | ---------------------------------------------------------------- | --------------------------------------- | +| offset | The offset between the popover and the child | `Offset` | +| popupBuilder | The function used to build the popover | `Widget Function(BuildContext context)` | +| triggerActions | Define the actions about how to trigger the popover | `int` | +| mutex | If multiple popovers are exclusive, pass the same mutex to them. | `PopoverMutex` | +| direction | The direction where the popover should be placed | `PopoverDirection` | +| onClose | The callback will be called after the popover is closed | `void Function()` | +| child | The child to trigger the popover | `Widget` | diff --git a/frontend/app_flowy/packages/appflowy_popover/analysis_options.yaml b/frontend/app_flowy/packages/appflowy_popover/analysis_options.yaml new file mode 100644 index 0000000000..a5744c1cfb --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/frontend/app_flowy/packages/appflowy_popover/example/.gitignore b/frontend/app_flowy/packages/appflowy_popover/example/.gitignore new file mode 100644 index 0000000000..a8e938c083 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/.gitignore @@ -0,0 +1,47 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Web related +lib/generated_plugin_registrant.dart + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/frontend/app_flowy/packages/appflowy_popover/example/.metadata b/frontend/app_flowy/packages/appflowy_popover/example/.metadata new file mode 100644 index 0000000000..39f2501e1f --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/.metadata @@ -0,0 +1,45 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled. + +version: + revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + channel: stable + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + - platform: android + create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + - platform: ios + create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + - platform: linux + create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + - platform: macos + create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + - platform: web + create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + - platform: windows + create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/frontend/app_flowy/packages/appflowy_popover/example/README.md b/frontend/app_flowy/packages/appflowy_popover/example/README.md new file mode 100644 index 0000000000..2b3fce4c86 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/README.md @@ -0,0 +1,16 @@ +# example + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/frontend/app_flowy/packages/appflowy_popover/example/analysis_options.yaml b/frontend/app_flowy/packages/appflowy_popover/example/analysis_options.yaml new file mode 100644 index 0000000000..61b6c4de17 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/frontend/app_flowy/packages/appflowy_popover/example/android/.gitignore b/frontend/app_flowy/packages/appflowy_popover/example/android/.gitignore new file mode 100644 index 0000000000..6f568019d3 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/frontend/app_flowy/packages/appflowy_popover/example/android/app/build.gradle b/frontend/app_flowy/packages/appflowy_popover/example/android/app/build.gradle new file mode 100644 index 0000000000..0833ecfca8 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/android/app/build.gradle @@ -0,0 +1,71 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.example.example" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/debug/AndroidManifest.xml b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000000..45d523a2a2 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/AndroidManifest.xml b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..3f41384dbc --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt new file mode 100644 index 0000000000..e793a000d6 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt @@ -0,0 +1,6 @@ +package com.example.example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/drawable-v21/launch_background.xml b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000000..f74085f3f6 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/drawable/launch_background.xml b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000000..304732f884 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000..db77bb4b7b Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000..17987b79bb Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000..09d4391482 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000..d5f1c8d34e Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000..4d6372eebd Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/values-night/styles.xml b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000000..06952be745 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/values/styles.xml b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000000..cb1ef88056 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/profile/AndroidManifest.xml b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000000..45d523a2a2 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/android/build.gradle b/frontend/app_flowy/packages/appflowy_popover/example/android/build.gradle new file mode 100644 index 0000000000..83ae220041 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/android/build.gradle @@ -0,0 +1,31 @@ +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.1.2' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/android/gradle.properties b/frontend/app_flowy/packages/appflowy_popover/example/android/gradle.properties new file mode 100644 index 0000000000..94adc3a3f9 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/frontend/app_flowy/packages/appflowy_popover/example/android/gradle/wrapper/gradle-wrapper.properties b/frontend/app_flowy/packages/appflowy_popover/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000..cc5527d781 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip diff --git a/frontend/app_flowy/packages/appflowy_popover/example/android/settings.gradle b/frontend/app_flowy/packages/appflowy_popover/example/android/settings.gradle new file mode 100644 index 0000000000..44e62bcf06 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/.gitignore b/frontend/app_flowy/packages/appflowy_popover/example/ios/.gitignore new file mode 100644 index 0000000000..7a7f9873ad --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Flutter/AppFrameworkInfo.plist b/frontend/app_flowy/packages/appflowy_popover/example/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000000..8d4492f977 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 9.0 + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Flutter/Debug.xcconfig b/frontend/app_flowy/packages/appflowy_popover/example/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000000..592ceee85b --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Flutter/Release.xcconfig b/frontend/app_flowy/packages/appflowy_popover/example/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000000..592ceee85b --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcodeproj/project.pbxproj b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..6edd238e7c --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,481 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1300; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000..919434a625 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000000..f9b0d7c5ea --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000000..c87d15a335 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000..1d526a16ed --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000000..f9b0d7c5ea --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/AppDelegate.swift b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000000..70693e4a8c --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000..d36b1fab2d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 0000000000..dc9ada4725 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000000..28c6bf0301 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000000..2ccbfd967d Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000000..f091b6b0bc Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000000..4cde12118d Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000000..d0ef06e7ed Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 0000000000..dcdc2306c2 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 0000000000..2ccbfd967d Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000000..c8f9ed8f5c Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000000..a6d6b8609d Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000000..a6d6b8609d Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000000..75b2d164a5 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000000..c4df70d39d Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 0000000000..6a84f41e14 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000000..d0e1f58536 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 0000000000..0bedcf2fd4 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000000..9da19eacad Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000000..9da19eacad Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000000..9da19eacad Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 0000000000..89c2725b70 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Base.lproj/LaunchScreen.storyboard b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000000..f2e259c7c9 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Base.lproj/Main.storyboard b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000000..f3c28516fb --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Info.plist b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Info.plist new file mode 100644 index 0000000000..907f329fe0 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Example + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + example + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + CADisableMinimumFrameDurationOnPhone + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Runner-Bridging-Header.h b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 0000000000..308a2a560b --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/frontend/app_flowy/packages/appflowy_popover/example/lib/example_button.dart b/frontend/app_flowy/packages/appflowy_popover/example/lib/example_button.dart new file mode 100644 index 0000000000..357941dc7f --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/lib/example_button.dart @@ -0,0 +1,98 @@ +import 'package:flutter/material.dart'; +import 'package:appflowy_popover/popover.dart'; + +class PopoverMenu extends StatefulWidget { + const PopoverMenu({Key? key}) : super(key: key); + + @override + State createState() => _PopoverMenuState(); +} + +class _PopoverMenuState extends State { + final PopoverMutex popOverMutex = PopoverMutex(); + + @override + Widget build(BuildContext context) { + return Material( + type: MaterialType.transparency, + child: Container( + width: 200, + height: 200, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(8)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 5, + blurRadius: 7, + offset: const Offset(0, 3), // changes position of shadow + ), + ], + ), + child: ListView(children: [ + Container( + margin: const EdgeInsets.all(8), + child: const Text("Popover", + style: TextStyle( + fontSize: 14, + color: Colors.black, + fontStyle: null, + decoration: null)), + ), + Popover( + triggerActions: PopoverTriggerActionFlags.hover | + PopoverTriggerActionFlags.click, + mutex: popOverMutex, + offset: const Offset(10, 0), + popupBuilder: (BuildContext context) { + return const PopoverMenu(); + }, + child: TextButton( + onPressed: () {}, + child: const Text("First"), + ), + ), + Popover( + triggerActions: PopoverTriggerActionFlags.hover | + PopoverTriggerActionFlags.click, + mutex: popOverMutex, + offset: const Offset(10, 0), + popupBuilder: (BuildContext context) { + return const PopoverMenu(); + }, + child: TextButton( + onPressed: () {}, + child: const Text("Second"), + ), + ), + ]), + )); + } +} + +class ExampleButton extends StatelessWidget { + final String label; + final Offset? offset; + final PopoverDirection? direction; + + const ExampleButton({ + Key? key, + required this.label, + this.direction, + this.offset = Offset.zero, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Popover( + triggerActions: PopoverTriggerActionFlags.click, + offset: offset, + direction: direction ?? PopoverDirection.rightWithTopAligned, + child: TextButton(child: Text(label), onPressed: () {}), + popupBuilder: (BuildContext context) { + return const PopoverMenu(); + }, + ); + } +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/lib/main.dart b/frontend/app_flowy/packages/appflowy_popover/example/lib/main.dart new file mode 100644 index 0000000000..178b075ee6 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/lib/main.dart @@ -0,0 +1,129 @@ +import 'package:appflowy_popover/popover.dart'; +import 'package:flutter/material.dart'; +import "./example_button.dart"; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatelessWidget { + const MyApp({Key? key}) : super(key: key); + + // This widget is the root of your application. + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + // This is the theme of your application. + // + // Try running your application with "flutter run". You'll see the + // application has a blue toolbar. Then, without quitting the app, try + // changing the primarySwatch below to Colors.green and then invoke + // "hot reload" (press "r" in the console where you ran "flutter run", + // or simply save your changes to "hot reload" in a Flutter IDE). + // Notice that the counter didn't reset back to zero; the application + // is not restarted. + primarySwatch: Colors.blue, + ), + home: const MyHomePage(title: 'AppFlowy Popover Example'), + ); + } +} + +class MyHomePage extends StatefulWidget { + const MyHomePage({Key? key, required this.title}) : super(key: key); + + // This widget is the home page of your application. It is stateful, meaning + // that it has a State object (defined below) that contains fields that affect + // how it looks. + + // This class is the configuration for the state. It holds the values (in this + // case the title) provided by the parent (in this case the App widget) and + // used by the build method of the State. Fields in a Widget subclass are + // always marked "final". + + final String title; + + @override + State createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State { + @override + Widget build(BuildContext context) { + // This method is rerun every time setState is called, for instance as done + // by the _incrementCounter method above. + // + // The Flutter framework has been optimized to make rerunning build methods + // fast, so that you can just rebuild anything that needs updating rather + // than having to individually change instances of widgets. + return Scaffold( + appBar: AppBar( + // Here we take the value from the MyHomePage object that was created by + // the App.build method, and use it to set our appbar title. + title: Text(widget.title), + ), + body: Row(children: [ + Column(children: [ + const ExampleButton( + label: "Left top", + offset: Offset(0, 10), + direction: PopoverDirection.bottomWithLeftAligned, + ), + Expanded(child: Container()), + const ExampleButton( + label: "Left bottom", + offset: Offset(0, -10), + direction: PopoverDirection.topWithLeftAligned, + ), + ]), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const ExampleButton( + label: "Top", + offset: Offset(0, 10), + direction: PopoverDirection.bottomWithCenterAligned, + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: const [ + ExampleButton( + label: "Central", + offset: Offset(0, 10), + direction: PopoverDirection.bottomWithCenterAligned, + ), + ], + ), + ), + const ExampleButton( + label: "Bottom", + offset: Offset(0, -10), + direction: PopoverDirection.topWithCenterAligned, + ), + ], + ), + ), + Column( + children: [ + const ExampleButton( + label: "Right top", + offset: Offset(0, 10), + direction: PopoverDirection.bottomWithRightAligned, + ), + Expanded(child: Container()), + const ExampleButton( + label: "Right bottom", + offset: Offset(0, -10), + direction: PopoverDirection.topWithRightAligned, + ), + ], + ) + ]), + ); + } +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/linux/.gitignore b/frontend/app_flowy/packages/appflowy_popover/example/linux/.gitignore new file mode 100644 index 0000000000..d3896c9844 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/frontend/app_flowy/packages/appflowy_popover/example/linux/CMakeLists.txt b/frontend/app_flowy/packages/appflowy_popover/example/linux/CMakeLists.txt new file mode 100644 index 0000000000..74c66dd446 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/linux/CMakeLists.txt @@ -0,0 +1,138 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.10) +project(runner LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "example") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "com.example.example") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Define the application target. To change its name, change BINARY_NAME above, +# not the value here, or `flutter run` will no longer work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/frontend/app_flowy/packages/appflowy_popover/example/linux/flutter/CMakeLists.txt b/frontend/app_flowy/packages/appflowy_popover/example/linux/flutter/CMakeLists.txt new file mode 100644 index 0000000000..d5bd01648a --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/linux/flutter/CMakeLists.txt @@ -0,0 +1,88 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/frontend/app_flowy/packages/appflowy_popover/example/linux/flutter/generated_plugin_registrant.cc b/frontend/app_flowy/packages/appflowy_popover/example/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000000..e71a16d23d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void fl_register_plugins(FlPluginRegistry* registry) { +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/linux/flutter/generated_plugin_registrant.h b/frontend/app_flowy/packages/appflowy_popover/example/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000000..e0f0a47bc0 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/linux/flutter/generated_plugins.cmake b/frontend/app_flowy/packages/appflowy_popover/example/linux/flutter/generated_plugins.cmake new file mode 100644 index 0000000000..2e1de87a7e --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/linux/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/frontend/app_flowy/packages/appflowy_popover/example/linux/main.cc b/frontend/app_flowy/packages/appflowy_popover/example/linux/main.cc new file mode 100644 index 0000000000..e7c5c54370 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/linux/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/linux/my_application.cc b/frontend/app_flowy/packages/appflowy_popover/example/linux/my_application.cc new file mode 100644 index 0000000000..0ba8f43096 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/linux/my_application.cc @@ -0,0 +1,104 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "example"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "example"); + } + + gtk_window_set_default_size(window, 1280, 720); + gtk_widget_show(GTK_WIDGET(window)); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, + "flags", G_APPLICATION_NON_UNIQUE, + nullptr)); +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/linux/my_application.h b/frontend/app_flowy/packages/appflowy_popover/example/linux/my_application.h new file mode 100644 index 0000000000..72271d5e41 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/linux/my_application.h @@ -0,0 +1,18 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/.gitignore b/frontend/app_flowy/packages/appflowy_popover/example/macos/.gitignore new file mode 100644 index 0000000000..746adbb6b9 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Flutter/Flutter-Debug.xcconfig b/frontend/app_flowy/packages/appflowy_popover/example/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 0000000000..c2efd0b608 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Flutter/Flutter-Release.xcconfig b/frontend/app_flowy/packages/appflowy_popover/example/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 0000000000..c2efd0b608 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Flutter/GeneratedPluginRegistrant.swift b/frontend/app_flowy/packages/appflowy_popover/example/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 0000000000..cccf817a52 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,10 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner.xcodeproj/project.pbxproj b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..c84862c675 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,572 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 51; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* example.app */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* example.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1300; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000000..fb7259e177 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner.xcworkspace/contents.xcworkspacedata b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000..1d526a16ed --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/AppDelegate.swift b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/AppDelegate.swift new file mode 100644 index 0000000000..d53ef64377 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/AppDelegate.swift @@ -0,0 +1,9 @@ +import Cocoa +import FlutterMacOS + +@NSApplicationMain +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000..a2ec33f19f --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 0000000000..3c4935a7ca Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 0000000000..ed4cc16421 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 0000000000..483be61389 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 0000000000..bcbf36df2f Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 0000000000..9c0a652864 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 0000000000..e71a726136 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 0000000000..8a31fe2dd3 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Base.lproj/MainMenu.xib b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 0000000000..80e867a4e0 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Configs/AppInfo.xcconfig b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 0000000000..8b42559e87 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = example + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = com.example.example + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2022 com.example. All rights reserved. diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Configs/Debug.xcconfig b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 0000000000..36b0fd9464 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Configs/Release.xcconfig b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 0000000000..dff4f49561 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Configs/Warnings.xcconfig b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 0000000000..42bcbf4780 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/DebugProfile.entitlements b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/DebugProfile.entitlements new file mode 100644 index 0000000000..dddb8a30c8 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Info.plist b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Info.plist new file mode 100644 index 0000000000..4789daa6a4 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/MainFlutterWindow.swift b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 0000000000..2722837ec9 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,15 @@ +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController.init() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Release.entitlements b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Release.entitlements new file mode 100644 index 0000000000..852fa1a472 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/pubspec.yaml b/frontend/app_flowy/packages/appflowy_popover/example/pubspec.yaml new file mode 100644 index 0000000000..c970983dbc --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/pubspec.yaml @@ -0,0 +1,89 @@ +name: example +description: A new Flutter project. + +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: "none" # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +version: 1.0.0+1 + +environment: + sdk: ">=2.17.6 <3.0.0" + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + appflowy_popover: + path: ../ + +dev_dependencies: + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/frontend/app_flowy/packages/appflowy_popover/example/web/favicon.png b/frontend/app_flowy/packages/appflowy_popover/example/web/favicon.png new file mode 100644 index 0000000000..8aaa46ac1a Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/web/favicon.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/web/icons/Icon-192.png b/frontend/app_flowy/packages/appflowy_popover/example/web/icons/Icon-192.png new file mode 100644 index 0000000000..b749bfef07 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/web/icons/Icon-192.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/web/icons/Icon-512.png b/frontend/app_flowy/packages/appflowy_popover/example/web/icons/Icon-512.png new file mode 100644 index 0000000000..88cfd48dff Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/web/icons/Icon-512.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/web/icons/Icon-maskable-192.png b/frontend/app_flowy/packages/appflowy_popover/example/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000000..eb9b4d76e5 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/web/icons/Icon-maskable-192.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/web/icons/Icon-maskable-512.png b/frontend/app_flowy/packages/appflowy_popover/example/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000000..d69c56691f Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/web/icons/Icon-maskable-512.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/web/index.html b/frontend/app_flowy/packages/appflowy_popover/example/web/index.html new file mode 100644 index 0000000000..41b3bc336f --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/web/index.html @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + example + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/web/manifest.json b/frontend/app_flowy/packages/appflowy_popover/example/web/manifest.json new file mode 100644 index 0000000000..096edf8fe4 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "example", + "short_name": "example", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/windows/.gitignore b/frontend/app_flowy/packages/appflowy_popover/example/windows/.gitignore new file mode 100644 index 0000000000..d492d0d98c --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/windows/CMakeLists.txt b/frontend/app_flowy/packages/appflowy_popover/example/windows/CMakeLists.txt new file mode 100644 index 0000000000..c0270746b1 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/windows/CMakeLists.txt @@ -0,0 +1,101 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(example LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "example") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/frontend/app_flowy/packages/appflowy_popover/example/windows/flutter/CMakeLists.txt b/frontend/app_flowy/packages/appflowy_popover/example/windows/flutter/CMakeLists.txt new file mode 100644 index 0000000000..930d2071a3 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/windows/flutter/CMakeLists.txt @@ -0,0 +1,104 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + windows-x64 $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/frontend/app_flowy/packages/appflowy_popover/example/windows/flutter/generated_plugin_registrant.cc b/frontend/app_flowy/packages/appflowy_popover/example/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000000..8b6d4680af --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void RegisterPlugins(flutter::PluginRegistry* registry) { +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/windows/flutter/generated_plugin_registrant.h b/frontend/app_flowy/packages/appflowy_popover/example/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000000..dc139d85a9 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/windows/flutter/generated_plugins.cmake b/frontend/app_flowy/packages/appflowy_popover/example/windows/flutter/generated_plugins.cmake new file mode 100644 index 0000000000..b93c4c30c1 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/windows/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/CMakeLists.txt b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/CMakeLists.txt new file mode 100644 index 0000000000..b9e550fba8 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/Runner.rc b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/Runner.rc new file mode 100644 index 0000000000..5fdea291cf --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#ifdef FLUTTER_BUILD_NUMBER +#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER +#else +#define VERSION_AS_NUMBER 1,0,0 +#endif + +#ifdef FLUTTER_BUILD_NAME +#define VERSION_AS_STRING #FLUTTER_BUILD_NAME +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "com.example" "\0" + VALUE "FileDescription", "example" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "example" "\0" + VALUE "LegalCopyright", "Copyright (C) 2022 com.example. All rights reserved." "\0" + VALUE "OriginalFilename", "example.exe" "\0" + VALUE "ProductName", "example" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/flutter_window.cpp b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/flutter_window.cpp new file mode 100644 index 0000000000..b43b9095ea --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/flutter_window.cpp @@ -0,0 +1,61 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/flutter_window.h b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/flutter_window.h new file mode 100644 index 0000000000..6da0652f05 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/main.cpp b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/main.cpp new file mode 100644 index 0000000000..bcb57b0e2a --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.CreateAndShow(L"example", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/resource.h b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/resource.h new file mode 100644 index 0000000000..66a65d1e4a --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/resources/app_icon.ico b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/resources/app_icon.ico new file mode 100644 index 0000000000..c04e20caf6 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/resources/app_icon.ico differ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/runner.exe.manifest b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/runner.exe.manifest new file mode 100644 index 0000000000..c977c4a425 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/runner.exe.manifest @@ -0,0 +1,20 @@ + + + + + PerMonitorV2 + + + + + + + + + + + + + + + diff --git a/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/utils.cpp b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/utils.cpp new file mode 100644 index 0000000000..f5bf9fa0f5 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/utils.cpp @@ -0,0 +1,64 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr); + std::string utf8_string; + if (target_length == 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, utf8_string.data(), + target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/utils.h b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/utils.h new file mode 100644 index 0000000000..3879d54755 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/win32_window.cpp b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/win32_window.cpp new file mode 100644 index 0000000000..c10f08dc7d --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/win32_window.cpp @@ -0,0 +1,245 @@ +#include "win32_window.h" + +#include + +#include "resource.h" + +namespace { + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + FreeLibrary(user32_module); + } +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::CreateAndShow(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + return OnCreate(); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} diff --git a/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/win32_window.h b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/win32_window.h new file mode 100644 index 0000000000..17ba431125 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/example/windows/runner/win32_window.h @@ -0,0 +1,98 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates and shows a win32 window with |title| and position and size using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size to will treat the width height passed in to this function + // as logical pixels and scale to appropriate for the default monitor. Returns + // true if the window was created successfully. + bool CreateAndShow(const std::wstring& title, + const Point& origin, + const Size& size); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // OS callback called by message pump. Handles the WM_NCCREATE message which + // is passed when the non-client area is being created and enables automatic + // non-client DPI scaling so that the non-client area automatically + // responsponds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_ diff --git a/frontend/app_flowy/packages/appflowy_popover/lib/follower.dart b/frontend/app_flowy/packages/appflowy_popover/lib/follower.dart new file mode 100644 index 0000000000..ff54eaac61 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/lib/follower.dart @@ -0,0 +1,79 @@ +import 'package:flutter/rendering.dart'; +import 'package:flutter/widgets.dart'; + +class PopoverCompositedTransformFollower extends CompositedTransformFollower { + const PopoverCompositedTransformFollower({ + super.key, + required super.link, + super.showWhenUnlinked = true, + super.offset = Offset.zero, + super.targetAnchor = Alignment.topLeft, + super.followerAnchor = Alignment.topLeft, + super.child, + }); + + @override + PopoverRenderFollowerLayer createRenderObject(BuildContext context) { + final screenSize = MediaQuery.of(context).size; + return PopoverRenderFollowerLayer( + screenSize: screenSize, + link: link, + showWhenUnlinked: showWhenUnlinked, + offset: offset, + leaderAnchor: targetAnchor, + followerAnchor: followerAnchor, + ); + } + + @override + void updateRenderObject( + BuildContext context, PopoverRenderFollowerLayer renderObject) { + final screenSize = MediaQuery.of(context).size; + renderObject + ..screenSize = screenSize + ..link = link + ..showWhenUnlinked = showWhenUnlinked + ..offset = offset + ..leaderAnchor = targetAnchor + ..followerAnchor = followerAnchor; + } +} + +class PopoverRenderFollowerLayer extends RenderFollowerLayer { + Size screenSize; + + PopoverRenderFollowerLayer({ + required super.link, + super.showWhenUnlinked = true, + super.offset = Offset.zero, + super.leaderAnchor = Alignment.topLeft, + super.followerAnchor = Alignment.topLeft, + super.child, + required this.screenSize, + }); + + @override + void paint(PaintingContext context, Offset offset) { + super.paint(context, offset); + + if (link.leader == null) { + return; + } + + if (link.leader!.offset.dx + link.leaderSize!.width + size.width > + screenSize.width) { + debugPrint("over flow"); + } + debugPrint( + "right: ${link.leader!.offset.dx + link.leaderSize!.width + size.width}, screen with: ${screenSize.width}"); + } +} + +class EdgeFollowerLayer extends FollowerLayer { + EdgeFollowerLayer({ + required super.link, + super.showWhenUnlinked = true, + super.unlinkedOffset = Offset.zero, + super.linkedOffset = Offset.zero, + }); +} diff --git a/frontend/app_flowy/packages/appflowy_popover/lib/layout.dart b/frontend/app_flowy/packages/appflowy_popover/lib/layout.dart new file mode 100644 index 0000000000..d589f18723 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/lib/layout.dart @@ -0,0 +1,341 @@ +import 'dart:math' as math; +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import './popover.dart'; + +class PopoverLayoutDelegate extends SingleChildLayoutDelegate { + PopoverLink link; + PopoverDirection direction; + final Offset offset; + + PopoverLayoutDelegate({ + required this.link, + required this.direction, + required this.offset, + }); + + @override + bool shouldRelayout(PopoverLayoutDelegate oldDelegate) { + if (direction != oldDelegate.direction) { + return true; + } + + if (link != oldDelegate.link) { + return true; + } + + if (link.leaderOffset != oldDelegate.link.leaderOffset) { + return true; + } + + if (link.leaderSize != oldDelegate.link.leaderSize) { + return true; + } + + return false; + } + + @override + BoxConstraints getConstraintsForChild(BoxConstraints constraints) { + return constraints.loosen(); + // assert(link.leaderSize != null); + // // if (link.leaderSize == null) { + // // return constraints.loosen(); + // // } + // final anchorRect = Rect.fromLTWH( + // link.leaderOffset!.dx, + // link.leaderOffset!.dy, + // link.leaderSize!.width, + // link.leaderSize!.height, + // ); + // BoxConstraints childConstraints; + // switch (direction) { + // case PopoverDirection.topLeft: + // childConstraints = BoxConstraints.loose(Size( + // anchorRect.left, + // anchorRect.top, + // )); + // break; + // case PopoverDirection.topRight: + // childConstraints = BoxConstraints.loose(Size( + // constraints.maxWidth - anchorRect.right, + // anchorRect.top, + // )); + // break; + // case PopoverDirection.bottomLeft: + // childConstraints = BoxConstraints.loose(Size( + // anchorRect.left, + // constraints.maxHeight - anchorRect.bottom, + // )); + // break; + // case PopoverDirection.bottomRight: + // childConstraints = BoxConstraints.loose(Size( + // constraints.maxWidth - anchorRect.right, + // constraints.maxHeight - anchorRect.bottom, + // )); + // break; + // case PopoverDirection.center: + // childConstraints = BoxConstraints.loose(Size( + // constraints.maxWidth, + // constraints.maxHeight, + // )); + // break; + // case PopoverDirection.topWithLeftAligned: + // childConstraints = BoxConstraints.loose(Size( + // constraints.maxWidth - anchorRect.left, + // anchorRect.top, + // )); + // break; + // case PopoverDirection.topWithCenterAligned: + // childConstraints = BoxConstraints.loose(Size( + // constraints.maxWidth, + // anchorRect.top, + // )); + // break; + // case PopoverDirection.topWithRightAligned: + // childConstraints = BoxConstraints.loose(Size( + // anchorRect.right, + // anchorRect.top, + // )); + // break; + // case PopoverDirection.rightWithTopAligned: + // childConstraints = BoxConstraints.loose(Size( + // constraints.maxWidth - anchorRect.right, + // constraints.maxHeight - anchorRect.top, + // )); + // break; + // case PopoverDirection.rightWithCenterAligned: + // childConstraints = BoxConstraints.loose(Size( + // constraints.maxWidth - anchorRect.right, + // constraints.maxHeight, + // )); + // break; + // case PopoverDirection.rightWithBottomAligned: + // childConstraints = BoxConstraints.loose(Size( + // constraints.maxWidth - anchorRect.right, + // anchorRect.bottom, + // )); + // break; + // case PopoverDirection.bottomWithLeftAligned: + // childConstraints = BoxConstraints.loose(Size( + // anchorRect.left, + // constraints.maxHeight - anchorRect.bottom, + // )); + // break; + // case PopoverDirection.bottomWithCenterAligned: + // childConstraints = BoxConstraints.loose(Size( + // constraints.maxWidth, + // constraints.maxHeight - anchorRect.bottom, + // )); + // break; + // case PopoverDirection.bottomWithRightAligned: + // childConstraints = BoxConstraints.loose(Size( + // anchorRect.right, + // constraints.maxHeight - anchorRect.bottom, + // )); + // break; + // case PopoverDirection.leftWithTopAligned: + // childConstraints = BoxConstraints.loose(Size( + // anchorRect.left, + // constraints.maxHeight - anchorRect.top, + // )); + // break; + // case PopoverDirection.leftWithCenterAligned: + // childConstraints = BoxConstraints.loose(Size( + // anchorRect.left, + // constraints.maxHeight, + // )); + // break; + // case PopoverDirection.leftWithBottomAligned: + // childConstraints = BoxConstraints.loose(Size( + // anchorRect.left, + // anchorRect.bottom, + // )); + // break; + // case PopoverDirection.custom: + // childConstraints = constraints.loosen(); + // break; + // default: + // throw UnimplementedError(); + // } + // return childConstraints; + } + + @override + Offset getPositionForChild(Size size, Size childSize) { + if (link.leaderSize == null) { + return Offset.zero; + } + final anchorRect = Rect.fromLTWH( + link.leaderOffset!.dx + offset.dx, + link.leaderOffset!.dy + offset.dy, + link.leaderSize!.width, + link.leaderSize!.height, + ); + Offset position; + switch (direction) { + case PopoverDirection.topLeft: + position = Offset( + anchorRect.left - childSize.width, + anchorRect.top - childSize.height, + ); + break; + case PopoverDirection.topRight: + position = Offset( + anchorRect.right, + anchorRect.top - childSize.height, + ); + break; + case PopoverDirection.bottomLeft: + position = Offset( + anchorRect.left - childSize.width, + anchorRect.bottom, + ); + break; + case PopoverDirection.bottomRight: + position = Offset( + anchorRect.right, + anchorRect.bottom, + ); + break; + case PopoverDirection.center: + position = anchorRect.center; + break; + case PopoverDirection.topWithLeftAligned: + position = Offset( + anchorRect.left, + anchorRect.top - childSize.height, + ); + break; + case PopoverDirection.topWithCenterAligned: + position = Offset( + anchorRect.left + anchorRect.width / 2.0 - childSize.width / 2.0, + anchorRect.top - childSize.height, + ); + break; + case PopoverDirection.topWithRightAligned: + position = Offset( + anchorRect.right - childSize.width, + anchorRect.top - childSize.height, + ); + break; + case PopoverDirection.rightWithTopAligned: + position = Offset(anchorRect.right, anchorRect.top); + break; + case PopoverDirection.rightWithCenterAligned: + position = Offset( + anchorRect.right, + anchorRect.top + anchorRect.height / 2.0 - childSize.height / 2.0, + ); + break; + case PopoverDirection.rightWithBottomAligned: + position = Offset( + anchorRect.right, + anchorRect.bottom - childSize.height, + ); + break; + case PopoverDirection.bottomWithLeftAligned: + position = Offset( + anchorRect.left, + anchorRect.bottom, + ); + break; + case PopoverDirection.bottomWithCenterAligned: + position = Offset( + anchorRect.left + anchorRect.width / 2.0 - childSize.width / 2.0, + anchorRect.bottom, + ); + break; + case PopoverDirection.bottomWithRightAligned: + position = Offset( + anchorRect.right - childSize.width, + anchorRect.bottom, + ); + break; + case PopoverDirection.leftWithTopAligned: + position = Offset( + anchorRect.left - childSize.width, + anchorRect.top, + ); + break; + case PopoverDirection.leftWithCenterAligned: + position = Offset( + anchorRect.left - childSize.width, + anchorRect.top + anchorRect.height / 2.0 - childSize.height / 2.0, + ); + break; + case PopoverDirection.leftWithBottomAligned: + position = Offset( + anchorRect.left - childSize.width, + anchorRect.bottom - childSize.height, + ); + break; + default: + throw UnimplementedError(); + } + return Offset( + math.max(0.0, math.min(size.width - childSize.width, position.dx)), + math.max(0.0, math.min(size.height - childSize.height, position.dy)), + ); + } +} + +class PopoverTarget extends SingleChildRenderObjectWidget { + final PopoverLink link; + const PopoverTarget({ + super.key, + super.child, + required this.link, + }); + + @override + PopoverTargetRenderBox createRenderObject(BuildContext context) { + return PopoverTargetRenderBox( + link: link, + ); + } + + @override + void updateRenderObject( + BuildContext context, PopoverTargetRenderBox renderObject) { + renderObject.link = link; + } +} + +class PopoverTargetRenderBox extends RenderProxyBox { + PopoverLink link; + PopoverTargetRenderBox({required this.link, RenderBox? child}) : super(child); + + @override + bool get alwaysNeedsCompositing => true; + + @override + void performLayout() { + super.performLayout(); + link.leaderSize = size; + } + + @override + void paint(PaintingContext context, Offset offset) { + link.leaderOffset = localToGlobal(Offset.zero); + super.paint(context, offset); + } + + @override + void detach() { + link.leaderOffset = null; + link.leaderSize = null; + super.detach(); + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(DiagnosticsProperty('link', link)); + } +} + +class PopoverLink { + Offset? leaderOffset; + Size? leaderSize; +} diff --git a/frontend/app_flowy/packages/appflowy_popover/lib/popover.dart b/frontend/app_flowy/packages/appflowy_popover/lib/popover.dart new file mode 100644 index 0000000000..2fc26aeb0c --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/lib/popover.dart @@ -0,0 +1,314 @@ +import 'package:appflowy_popover/layout.dart'; +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +/// If multiple popovers are exclusive, +/// pass the same mutex to them. +class PopoverMutex { + PopoverState? state; +} + +class PopoverController { + PopoverState? state; + + close() { + state?.close(); + } + + show() { + state?.showOverlay(); + } +} + +class PopoverTriggerActionFlags { + static int click = 0x01; + static int hover = 0x02; +} + +enum PopoverDirection { + // Corner aligned with a corner of the SourceWidget + topLeft, + topRight, + bottomLeft, + bottomRight, + center, + + // Edge aligned with a edge of the SourceWidget + topWithLeftAligned, + topWithCenterAligned, + topWithRightAligned, + rightWithTopAligned, + rightWithCenterAligned, + rightWithBottomAligned, + bottomWithLeftAligned, + bottomWithCenterAligned, + bottomWithRightAligned, + leftWithTopAligned, + leftWithCenterAligned, + leftWithBottomAligned, + + custom, +} + +class Popover extends StatefulWidget { + final PopoverController? controller; + + final Offset? offset; + + final Decoration? maskDecoration; + + /// The function used to build the popover. + final Widget Function(BuildContext context) popupBuilder; + + final int triggerActions; + + /// If multiple popovers are exclusive, + /// pass the same mutex to them. + final PopoverMutex? mutex; + + /// The direction of the popover + final PopoverDirection direction; + + final void Function()? onClose; + + /// The content area of the popover. + final Widget child; + + const Popover({ + Key? key, + required this.child, + required this.popupBuilder, + this.controller, + this.offset, + this.maskDecoration, + this.triggerActions = 0, + this.direction = PopoverDirection.rightWithTopAligned, + this.mutex, + this.onClose, + }) : super(key: key); + + @override + State createState() => PopoverState(); +} + +class PopoverState extends State { + final PopoverLink popoverLink = PopoverLink(); + OverlayEntry? _overlayEntry; + bool hasMask = true; + + static PopoverState? _popoverWithMask; + + @override + void initState() { + widget.controller?.state = this; + super.initState(); + } + + showOverlay() { + close(); + + if (widget.mutex != null) { + if (widget.mutex!.state != null && widget.mutex!.state != this) { + widget.mutex!.state!.close(); + } + + widget.mutex!.state = this; + } + + if (_popoverWithMask == null) { + _popoverWithMask = this; + } else { + hasMask = false; + } + + final newEntry = OverlayEntry(builder: (context) { + final children = []; + + if (hasMask) { + children.add(_PopoverMask( + decoration: widget.maskDecoration, + onTap: () => close(), + onExit: () => close(), + )); + } + + children.add(PopoverContainer( + direction: widget.direction, + popoverLink: popoverLink, + offset: widget.offset ?? Offset.zero, + popupBuilder: widget.popupBuilder, + onClose: () => close(), + onCloseAll: () => closeAll(), + )); + + return Stack(children: children); + }); + + _overlayEntry = newEntry; + + Overlay.of(context)?.insert(newEntry); + } + + close() { + if (_overlayEntry != null) { + _overlayEntry!.remove(); + _overlayEntry = null; + if (_popoverWithMask == this) { + _popoverWithMask = null; + } + if (widget.onClose != null) { + widget.onClose!(); + } + } + + if (widget.mutex?.state == this) { + widget.mutex!.state = null; + } + } + + closeAll() { + _popoverWithMask?.close(); + } + + @override + void deactivate() { + close(); + super.deactivate(); + } + + _handleTargetPointerDown(PointerDownEvent event) { + if (widget.triggerActions & PopoverTriggerActionFlags.click != 0) { + showOverlay(); + } + } + + _handleTargetPointerEnter(PointerEnterEvent event) { + if (widget.triggerActions & PopoverTriggerActionFlags.hover != 0) { + showOverlay(); + } + } + + _buildContent(BuildContext context) { + if (widget.triggerActions == 0) { + return widget.child; + } + + return MouseRegion( + onEnter: _handleTargetPointerEnter, + child: Listener( + onPointerDown: _handleTargetPointerDown, + child: widget.child, + ), + ); + } + + @override + Widget build(BuildContext context) { + return PopoverTarget( + link: popoverLink, + child: _buildContent(context), + ); + } +} + +class _PopoverMask extends StatefulWidget { + final void Function() onTap; + final void Function()? onExit; + final Decoration? decoration; + + const _PopoverMask( + {Key? key, required this.onTap, this.onExit, this.decoration}) + : super(key: key); + + @override + State createState() => _PopoverMaskState(); +} + +class _PopoverMaskState extends State<_PopoverMask> { + @override + void initState() { + HardwareKeyboard.instance.addHandler(_handleGlobalKeyEvent); + super.initState(); + } + + bool _handleGlobalKeyEvent(KeyEvent event) { + if (event.logicalKey == LogicalKeyboardKey.escape) { + if (widget.onExit != null) { + widget.onExit!(); + } + + return true; + } + return false; + } + + @override + void deactivate() { + HardwareKeyboard.instance.removeHandler(_handleGlobalKeyEvent); + super.deactivate(); + } + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: widget.onTap, + child: Container( + // decoration: widget.decoration, + decoration: widget.decoration ?? + const BoxDecoration( + color: Color.fromARGB(0, 244, 67, 54), + ), + ), + ); + } +} + +class PopoverContainer extends StatefulWidget { + final Widget Function(BuildContext context) popupBuilder; + final PopoverDirection direction; + final PopoverLink popoverLink; + final Offset offset; + final void Function() onClose; + final void Function() onCloseAll; + + const PopoverContainer({ + Key? key, + required this.popupBuilder, + required this.direction, + required this.popoverLink, + required this.offset, + required this.onClose, + required this.onCloseAll, + }) : super(key: key); + + @override + State createState() => PopoverContainerState(); +} + +class PopoverContainerState extends State { + @override + Widget build(BuildContext context) { + return CustomSingleChildLayout( + delegate: PopoverLayoutDelegate( + direction: widget.direction, + link: widget.popoverLink, + offset: widget.offset, + ), + child: widget.popupBuilder(context), + ); + } + + close() => widget.onClose(); + + closeAll() => widget.onCloseAll(); + + static PopoverContainerState of(BuildContext context) { + if (context is StatefulElement && context.state is PopoverContainerState) { + return context.state as PopoverContainerState; + } + final PopoverContainerState? result = + context.findAncestorStateOfType(); + return result!; + } +} diff --git a/frontend/app_flowy/packages/appflowy_popover/pubspec.yaml b/frontend/app_flowy/packages/appflowy_popover/pubspec.yaml new file mode 100644 index 0000000000..be1e57f009 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/pubspec.yaml @@ -0,0 +1,54 @@ +name: appflowy_popover +description: A new Flutter package project. +version: 0.0.1 +homepage: + +environment: + sdk: ">=2.17.6 <3.0.0" + flutter: ">=1.17.0" + +dependencies: + flutter: + sdk: flutter + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # To add assets to your package, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # + # For details regarding assets in packages, see + # https://flutter.dev/assets-and-images/#from-packages + # + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # To add custom fonts to your package, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts in packages, see + # https://flutter.dev/custom-fonts/#from-packages diff --git a/frontend/app_flowy/packages/appflowy_popover/screenshot.png b/frontend/app_flowy/packages/appflowy_popover/screenshot.png new file mode 100644 index 0000000000..556559d7a2 Binary files /dev/null and b/frontend/app_flowy/packages/appflowy_popover/screenshot.png differ diff --git a/frontend/app_flowy/packages/appflowy_popover/test/popover_test.dart b/frontend/app_flowy/packages/appflowy_popover/test/popover_test.dart new file mode 100644 index 0000000000..9a3bf783f3 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_popover/test/popover_test.dart @@ -0,0 +1,10 @@ +import 'package:flutter_test/flutter_test.dart'; + +void main() { + test('adds one to input values', () { + // final calculator = Calculator(); + // expect(calculator.addOne(2), 3); + // expect(calculator.addOne(-7), -6); + // expect(calculator.addOne(0), 1); + }); +} diff --git a/frontend/app_flowy/packages/flowy_infra_ui/lib/flowy_infra_ui.dart b/frontend/app_flowy/packages/flowy_infra_ui/lib/flowy_infra_ui.dart index 91768bd645..a656077eb5 100644 --- a/frontend/app_flowy/packages/flowy_infra_ui/lib/flowy_infra_ui.dart +++ b/frontend/app_flowy/packages/flowy_infra_ui/lib/flowy_infra_ui.dart @@ -8,3 +8,5 @@ export 'src/keyboard/keyboard_visibility_detector.dart'; export 'src/flowy_overlay/flowy_overlay.dart'; export 'src/flowy_overlay/list_overlay.dart'; export 'src/flowy_overlay/option_overlay.dart'; +export 'src/flowy_overlay/flowy_dialog.dart'; +export 'src/flowy_overlay/flowy_popover.dart'; diff --git a/frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/flowy_dialog.dart b/frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/flowy_dialog.dart new file mode 100644 index 0000000000..e0158d5c0c --- /dev/null +++ b/frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/flowy_dialog.dart @@ -0,0 +1,45 @@ +import 'package:flutter/material.dart'; +import 'dart:math'; + +const _overlayContainerPadding = EdgeInsets.all(12); +const overlayContainerMaxWidth = 760.0; +const overlayContainerMinWidth = 320.0; + +class FlowyDialog extends StatelessWidget { + final Widget? title; + final ShapeBorder? shape; + final Widget child; + final BoxConstraints? constraints; + final EdgeInsets padding; + const FlowyDialog({ + required this.child, + this.title, + this.shape, + this.constraints, + this.padding = _overlayContainerPadding, + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + final windowSize = MediaQuery.of(context).size; + final size = windowSize * 0.7; + return SimpleDialog( + title: title, + shape: shape ?? + RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), + children: [ + Material( + type: MaterialType.transparency, + child: Container( + padding: padding, + height: size.height, + width: max(min(size.width, overlayContainerMaxWidth), + overlayContainerMinWidth), + constraints: constraints, + child: child, + ), + ) + ]); + } +} 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 54f8d3168f..15797453e6 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 @@ -109,6 +109,19 @@ class FlowyOverlay extends StatefulWidget { return state; } + static void show( + {required BuildContext context, + required Widget Function(BuildContext context) builder}) { + showDialog( + context: context, + builder: builder, + ); + } + + static void pop(BuildContext context) { + Navigator.of(context).pop(); + } + @override FlowyOverlayState createState() => FlowyOverlayState(); } diff --git a/frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/flowy_popover.dart b/frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/flowy_popover.dart new file mode 100644 index 0000000000..d1a52e50d9 --- /dev/null +++ b/frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/flowy_popover.dart @@ -0,0 +1,59 @@ +import 'package:flowy_infra_ui/flowy_infra_ui_web.dart'; +import 'package:flowy_infra_ui/style_widget/decoration.dart'; +import 'package:flowy_infra/theme.dart'; +import 'package:provider/provider.dart'; +import 'package:flutter/material.dart'; +import './flowy_popover_layout.dart'; + +const _overlayContainerPadding = EdgeInsets.all(12); + +class FlowyPopover extends StatefulWidget { + final Widget Function(BuildContext context) builder; + final ShapeBorder? shape; + final Rect anchorRect; + final AnchorDirection? anchorDirection; + final EdgeInsets padding; + final BoxConstraints? constraints; + + const FlowyPopover({ + Key? key, + required this.builder, + required this.anchorRect, + this.shape, + this.padding = _overlayContainerPadding, + this.anchorDirection, + this.constraints, + }) : super(key: key); + + @override + State createState() => _FlowyPopoverState(); +} + +class _FlowyPopoverState extends State { + final preRenderKey = GlobalKey(); + Size? size; + + @override + Widget build(BuildContext context) { + final theme = + context.watch() ?? AppTheme.fromType(ThemeType.light); + return Material( + type: MaterialType.transparency, + child: CustomSingleChildLayout( + delegate: PopoverLayoutDelegate( + anchorRect: widget.anchorRect, + anchorDirection: + widget.anchorDirection ?? AnchorDirection.rightWithTopAligned, + overlapBehaviour: OverlapBehaviour.stretch, + ), + child: Container( + padding: widget.padding, + constraints: widget.constraints ?? + BoxConstraints.loose(const Size(280, 400)), + decoration: FlowyDecoration.decoration( + theme.surface, theme.shadowColor.withOpacity(0.15)), + key: preRenderKey, + child: widget.builder(context), + ))); + } +} diff --git a/frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/flowy_popover_layout.dart b/frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/flowy_popover_layout.dart new file mode 100644 index 0000000000..0d4bacde52 --- /dev/null +++ b/frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/flowy_popover_layout.dart @@ -0,0 +1,251 @@ +import 'dart:math' as math; +import 'package:flutter/material.dart'; +import 'flowy_overlay.dart'; + +class PopoverLayoutDelegate extends SingleChildLayoutDelegate { + PopoverLayoutDelegate({ + required this.anchorRect, + required this.anchorDirection, + required this.overlapBehaviour, + }); + + final Rect anchorRect; + final AnchorDirection anchorDirection; + final OverlapBehaviour overlapBehaviour; + + @override + bool shouldRelayout(PopoverLayoutDelegate oldDelegate) { + return anchorRect != oldDelegate.anchorRect || + anchorDirection != oldDelegate.anchorDirection || + overlapBehaviour != oldDelegate.overlapBehaviour; + } + + @override + BoxConstraints getConstraintsForChild(BoxConstraints constraints) { + switch (overlapBehaviour) { + case OverlapBehaviour.none: + return constraints.loosen(); + case OverlapBehaviour.stretch: + BoxConstraints childConstraints; + switch (anchorDirection) { + case AnchorDirection.topLeft: + childConstraints = BoxConstraints.loose(Size( + anchorRect.left, + anchorRect.top, + )); + break; + case AnchorDirection.topRight: + childConstraints = BoxConstraints.loose(Size( + constraints.maxWidth - anchorRect.right, + anchorRect.top, + )); + break; + case AnchorDirection.bottomLeft: + childConstraints = BoxConstraints.loose(Size( + anchorRect.left, + constraints.maxHeight - anchorRect.bottom, + )); + break; + case AnchorDirection.bottomRight: + childConstraints = BoxConstraints.loose(Size( + constraints.maxWidth - anchorRect.right, + constraints.maxHeight - anchorRect.bottom, + )); + break; + case AnchorDirection.center: + childConstraints = BoxConstraints.loose(Size( + constraints.maxWidth, + constraints.maxHeight, + )); + break; + case AnchorDirection.topWithLeftAligned: + childConstraints = BoxConstraints.loose(Size( + constraints.maxWidth - anchorRect.left, + anchorRect.top, + )); + break; + case AnchorDirection.topWithCenterAligned: + childConstraints = BoxConstraints.loose(Size( + constraints.maxWidth, + anchorRect.top, + )); + break; + case AnchorDirection.topWithRightAligned: + childConstraints = BoxConstraints.loose(Size( + anchorRect.right, + anchorRect.top, + )); + break; + case AnchorDirection.rightWithTopAligned: + childConstraints = BoxConstraints.loose(Size( + constraints.maxWidth - anchorRect.right, + constraints.maxHeight - anchorRect.top, + )); + break; + case AnchorDirection.rightWithCenterAligned: + childConstraints = BoxConstraints.loose(Size( + constraints.maxWidth - anchorRect.right, + constraints.maxHeight, + )); + break; + case AnchorDirection.rightWithBottomAligned: + childConstraints = BoxConstraints.loose(Size( + constraints.maxWidth - anchorRect.right, + anchorRect.bottom, + )); + break; + case AnchorDirection.bottomWithLeftAligned: + childConstraints = BoxConstraints.loose(Size( + anchorRect.left, + constraints.maxHeight - anchorRect.bottom, + )); + break; + case AnchorDirection.bottomWithCenterAligned: + childConstraints = BoxConstraints.loose(Size( + constraints.maxWidth, + constraints.maxHeight - anchorRect.bottom, + )); + break; + case AnchorDirection.bottomWithRightAligned: + childConstraints = BoxConstraints.loose(Size( + anchorRect.right, + constraints.maxHeight - anchorRect.bottom, + )); + break; + case AnchorDirection.leftWithTopAligned: + childConstraints = BoxConstraints.loose(Size( + anchorRect.left, + constraints.maxHeight - anchorRect.top, + )); + break; + case AnchorDirection.leftWithCenterAligned: + childConstraints = BoxConstraints.loose(Size( + anchorRect.left, + constraints.maxHeight, + )); + break; + case AnchorDirection.leftWithBottomAligned: + childConstraints = BoxConstraints.loose(Size( + anchorRect.left, + anchorRect.bottom, + )); + break; + case AnchorDirection.custom: + childConstraints = constraints.loosen(); + break; + default: + throw UnimplementedError(); + } + return childConstraints; + } + } + + @override + Offset getPositionForChild(Size size, Size childSize) { + Offset position; + switch (anchorDirection) { + case AnchorDirection.topLeft: + position = Offset( + anchorRect.left - childSize.width, + anchorRect.top - childSize.height, + ); + break; + case AnchorDirection.topRight: + position = Offset( + anchorRect.right, + anchorRect.top - childSize.height, + ); + break; + case AnchorDirection.bottomLeft: + position = Offset( + anchorRect.left - childSize.width, + anchorRect.bottom, + ); + break; + case AnchorDirection.bottomRight: + position = Offset( + anchorRect.right, + anchorRect.bottom, + ); + break; + case AnchorDirection.center: + position = anchorRect.center; + break; + case AnchorDirection.topWithLeftAligned: + position = Offset( + anchorRect.left, + anchorRect.top - childSize.height, + ); + break; + case AnchorDirection.topWithCenterAligned: + position = Offset( + anchorRect.left + anchorRect.width / 2.0 - childSize.width / 2.0, + anchorRect.top - childSize.height, + ); + break; + case AnchorDirection.topWithRightAligned: + position = Offset( + anchorRect.right - childSize.width, + anchorRect.top - childSize.height, + ); + break; + case AnchorDirection.rightWithTopAligned: + position = Offset(anchorRect.right, anchorRect.top); + break; + case AnchorDirection.rightWithCenterAligned: + position = Offset( + anchorRect.right, + anchorRect.top + anchorRect.height / 2.0 - childSize.height / 2.0, + ); + break; + case AnchorDirection.rightWithBottomAligned: + position = Offset( + anchorRect.right, + anchorRect.bottom - childSize.height, + ); + break; + case AnchorDirection.bottomWithLeftAligned: + position = Offset( + anchorRect.left, + anchorRect.bottom, + ); + break; + case AnchorDirection.bottomWithCenterAligned: + position = Offset( + anchorRect.left + anchorRect.width / 2.0 - childSize.width / 2.0, + anchorRect.bottom, + ); + break; + case AnchorDirection.bottomWithRightAligned: + position = Offset( + anchorRect.right - childSize.width, + anchorRect.bottom, + ); + break; + case AnchorDirection.leftWithTopAligned: + position = Offset( + anchorRect.left - childSize.width, + anchorRect.top, + ); + break; + case AnchorDirection.leftWithCenterAligned: + position = Offset( + anchorRect.left - childSize.width, + anchorRect.top + anchorRect.height / 2.0 - childSize.height / 2.0, + ); + break; + case AnchorDirection.leftWithBottomAligned: + position = Offset( + anchorRect.left - childSize.width, + anchorRect.bottom - childSize.height, + ); + break; + default: + throw UnimplementedError(); + } + return Offset( + math.max(0.0, math.min(size.width - childSize.width, position.dx)), + math.max(0.0, math.min(size.height - childSize.height, position.dy)), + ); + } +} diff --git a/frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/overlay_container.dart b/frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/overlay_container.dart index 96b566b308..91206253b1 100644 --- a/frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/overlay_container.dart +++ b/frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/overlay_container.dart @@ -18,12 +18,14 @@ class OverlayContainer extends StatelessWidget { @override Widget build(BuildContext context) { - final theme = context.watch() ?? AppTheme.fromType(ThemeType.light); + final theme = + context.watch() ?? AppTheme.fromType(ThemeType.light); return Material( type: MaterialType.transparency, child: Container( padding: padding, - decoration: FlowyDecoration.decoration(theme.surface, theme.shadowColor.withOpacity(0.15)), + decoration: FlowyDecoration.decoration( + theme.surface, theme.shadowColor.withOpacity(0.15)), constraints: constraints, child: child, ), diff --git a/frontend/app_flowy/packages/flowy_infra_ui/lib/style_widget/button.dart b/frontend/app_flowy/packages/flowy_infra_ui/lib/style_widget/button.dart index 046ee8a0c1..ba2b3049af 100644 --- a/frontend/app_flowy/packages/flowy_infra_ui/lib/style_widget/button.dart +++ b/frontend/app_flowy/packages/flowy_infra_ui/lib/style_widget/button.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; class FlowyButton extends StatelessWidget { final Widget text; final VoidCallback? onTap; + final void Function(bool)? onHover; final EdgeInsets margin; final Widget? leftIcon; final Widget? rightIcon; @@ -15,6 +16,7 @@ class FlowyButton extends StatelessWidget { Key? key, required this.text, this.onTap, + this.onHover, this.margin = const EdgeInsets.symmetric(horizontal: 6, vertical: 2), this.leftIcon, this.rightIcon, @@ -27,7 +29,9 @@ class FlowyButton extends StatelessWidget { return InkWell( onTap: onTap, child: FlowyHover( - style: HoverStyle(borderRadius: BorderRadius.zero, hoverColor: hoverColor), + style: + HoverStyle(borderRadius: BorderRadius.zero, hoverColor: hoverColor), + onHover: onHover, setSelected: () => isSelected, builder: (context, onHover) => _render(), ), @@ -38,14 +42,16 @@ class FlowyButton extends StatelessWidget { List children = List.empty(growable: true); if (leftIcon != null) { - children.add(SizedBox.fromSize(size: const Size.square(16), child: leftIcon!)); + children.add( + SizedBox.fromSize(size: const Size.square(16), child: leftIcon!)); children.add(const HSpace(6)); } children.add(Expanded(child: text)); if (rightIcon != null) { - children.add(SizedBox.fromSize(size: const Size.square(16), child: rightIcon!)); + children.add( + SizedBox.fromSize(size: const Size.square(16), child: rightIcon!)); } return Padding( @@ -121,7 +127,8 @@ class FlowyTextButton extends StatelessWidget { visualDensity: VisualDensity.compact, hoverElevation: 0, highlightElevation: 0, - shape: RoundedRectangleBorder(borderRadius: radius ?? BorderRadius.circular(2)), + shape: RoundedRectangleBorder( + borderRadius: radius ?? BorderRadius.circular(2)), fillColor: fillColor, hoverColor: hoverColor ?? Colors.transparent, focusColor: Colors.transparent, diff --git a/frontend/app_flowy/packages/flowy_infra_ui/lib/style_widget/hover.dart b/frontend/app_flowy/packages/flowy_infra_ui/lib/style_widget/hover.dart index 5a3b305e1e..00e0bb1b3a 100644 --- a/frontend/app_flowy/packages/flowy_infra_ui/lib/style_widget/hover.dart +++ b/frontend/app_flowy/packages/flowy_infra_ui/lib/style_widget/hover.dart @@ -9,6 +9,7 @@ class FlowyHover extends StatefulWidget { final HoverBuilder? builder; final Widget? child; final bool Function()? setSelected; + final void Function(bool)? onHover; final MouseCursor? cursor; const FlowyHover( @@ -17,6 +18,7 @@ class FlowyHover extends StatefulWidget { this.child, required this.style, this.setSelected, + this.onHover, this.cursor}) : super(key: key); @@ -32,8 +34,18 @@ class _FlowyHoverState extends State { return MouseRegion( cursor: widget.cursor != null ? widget.cursor! : SystemMouseCursors.click, opaque: false, - onEnter: (p) => setState(() => _onHover = true), - onExit: (p) => setState(() => _onHover = false), + onEnter: (p) { + setState(() => _onHover = true); + if (widget.onHover != null) { + widget.onHover!(true); + } + }, + onExit: (p) { + setState(() => _onHover = false); + if (widget.onHover != null) { + widget.onHover!(false); + } + }, child: renderWidget(), ); } diff --git a/frontend/app_flowy/pubspec.lock b/frontend/app_flowy/pubspec.lock index 693c6b41e9..ce5a13f5f9 100644 --- a/frontend/app_flowy/pubspec.lock +++ b/frontend/app_flowy/pubspec.lock @@ -36,6 +36,13 @@ packages: relative: true source: path version: "0.0.4" + appflowy_popover: + dependency: "direct main" + description: + path: "packages/appflowy_popover" + relative: true + source: path + version: "0.0.1" args: dependency: transitive description: @@ -1487,5 +1494,5 @@ packages: source: hosted version: "8.1.0" sdks: - dart: ">=2.17.0 <3.0.0" + dart: ">=2.17.6 <3.0.0" flutter: ">=3.0.0" diff --git a/frontend/app_flowy/pubspec.yaml b/frontend/app_flowy/pubspec.yaml index 41fa98d7ea..cfa3e13872 100644 --- a/frontend/app_flowy/pubspec.yaml +++ b/frontend/app_flowy/pubspec.yaml @@ -41,6 +41,8 @@ dependencies: path: packages/appflowy_board appflowy_editor: path: packages/appflowy_editor + appflowy_popover: + path: packages/appflowy_popover flutter_quill: git: url: https://github.com/appflowy/flutter-quill.git