mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: Add new page icon and refactor (#1449)
* refactor: port to popover action list for add new page * feat: add icons to menu items for add new page * chore: change translation for Doc to Document Co-authored-by: nathan <nathan@appflowy.io>
This commit is contained in:
@ -221,7 +221,7 @@
|
|||||||
"menuName": "Grid"
|
"menuName": "Grid"
|
||||||
},
|
},
|
||||||
"document": {
|
"document": {
|
||||||
"menuName": "Doc",
|
"menuName": "Document",
|
||||||
"date": {
|
"date": {
|
||||||
"timeHintTextInTwelveHour": "01:00 PM",
|
"timeHintTextInTwelveHour": "01:00 PM",
|
||||||
"timeHintTextInTwentyFourHour": "13:00"
|
"timeHintTextInTwentyFourHour": "13:00"
|
||||||
|
@ -221,7 +221,7 @@
|
|||||||
"menuName": "Grille"
|
"menuName": "Grille"
|
||||||
},
|
},
|
||||||
"document": {
|
"document": {
|
||||||
"menuName": "Doc",
|
"menuName": "Document",
|
||||||
"date": {
|
"date": {
|
||||||
"timeHintTextInTwelveHour": "01:00 PM",
|
"timeHintTextInTwelveHour": "01:00 PM",
|
||||||
"timeHintTextInTwentyFourHour": "13:00"
|
"timeHintTextInTwentyFourHour": "13:00"
|
||||||
|
@ -209,7 +209,7 @@
|
|||||||
"menuName": "Grid"
|
"menuName": "Grid"
|
||||||
},
|
},
|
||||||
"document": {
|
"document": {
|
||||||
"menuName": "Doc",
|
"menuName": "Dokter",
|
||||||
"date": {
|
"date": {
|
||||||
"timeHintTextInTwelveHour": "01:00 PM",
|
"timeHintTextInTwelveHour": "01:00 PM",
|
||||||
"timeHintTextInTwentyFourHour": "13:00"
|
"timeHintTextInTwentyFourHour": "13:00"
|
||||||
|
@ -220,10 +220,10 @@
|
|||||||
"menuName": "Grade"
|
"menuName": "Grade"
|
||||||
},
|
},
|
||||||
"document": {
|
"document": {
|
||||||
"menuName": "Doc",
|
"menuName": "Documento",
|
||||||
"date": {
|
"date": {
|
||||||
"timeHintTextInTwelveHour": "12:00 AM",
|
"timeHintTextInTwelveHour": "01:00 PM",
|
||||||
"timeHintTextInTwentyFourHour": "12:00"
|
"timeHintTextInTwentyFourHour": "13:00"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"board": {
|
"board": {
|
||||||
|
@ -15,6 +15,9 @@ class BlankPluginBuilder extends PluginBuilder {
|
|||||||
@override
|
@override
|
||||||
String get menuName => "Blank";
|
String get menuName => "Blank";
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get menuIcon => "";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
PluginType get pluginType => PluginType.blank;
|
PluginType get pluginType => PluginType.blank;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,9 @@ class BoardPluginBuilder implements PluginBuilder {
|
|||||||
@override
|
@override
|
||||||
String get menuName => "Board";
|
String get menuName => "Board";
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get menuIcon => "editor/board";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
PluginType get pluginType => PluginType.board;
|
PluginType get pluginType => PluginType.board;
|
||||||
|
|
||||||
|
@ -38,6 +38,9 @@ class DocumentPluginBuilder extends PluginBuilder {
|
|||||||
@override
|
@override
|
||||||
String get menuName => LocaleKeys.document_menuName.tr();
|
String get menuName => LocaleKeys.document_menuName.tr();
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get menuIcon => "editor/documents";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
PluginType get pluginType => PluginType.editor;
|
PluginType get pluginType => PluginType.editor;
|
||||||
|
|
||||||
|
@ -22,6 +22,9 @@ class GridPluginBuilder implements PluginBuilder {
|
|||||||
@override
|
@override
|
||||||
String get menuName => LocaleKeys.grid_menuName.tr();
|
String get menuName => LocaleKeys.grid_menuName.tr();
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get menuIcon => "editor/grid";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
PluginType get pluginType => PluginType.grid;
|
PluginType get pluginType => PluginType.grid;
|
||||||
|
|
||||||
|
@ -20,6 +20,9 @@ class TrashPluginBuilder extends PluginBuilder {
|
|||||||
@override
|
@override
|
||||||
String get menuName => "TrashPB";
|
String get menuName => "TrashPB";
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get menuIcon => "editor/delete";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
PluginType get pluginType => PluginType.trash;
|
PluginType get pluginType => PluginType.trash;
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,8 @@ abstract class PluginBuilder {
|
|||||||
|
|
||||||
String get menuName;
|
String get menuName;
|
||||||
|
|
||||||
|
String get menuIcon;
|
||||||
|
|
||||||
PluginType get pluginType;
|
PluginType get pluginType;
|
||||||
|
|
||||||
ViewDataFormatPB get dataFormatType => ViewDataFormatPB.TreeFormat;
|
ViewDataFormatPB get dataFormatType => ViewDataFormatPB.TreeFormat;
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import 'package:app_flowy/startup/plugin/plugin.dart';
|
import 'package:app_flowy/startup/plugin/plugin.dart';
|
||||||
|
import 'package:app_flowy/workspace/presentation/widgets/pop_up_action.dart';
|
||||||
|
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||||
import 'package:flowy_infra/image.dart';
|
import 'package:flowy_infra/image.dart';
|
||||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
|
||||||
import 'package:flowy_infra_ui/style_widget/hover.dart';
|
|
||||||
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
|
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/text.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
|
||||||
class AddButton extends StatelessWidget {
|
class AddButton extends StatelessWidget {
|
||||||
final Function(PluginBuilder) onSelected;
|
final Function(PluginBuilder) onSelected;
|
||||||
|
|
||||||
const AddButton({
|
const AddButton({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.onSelected,
|
required this.onSelected,
|
||||||
@ -16,91 +16,47 @@ class AddButton extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return FlowyIconButton(
|
final List<PopoverAction> actions = [];
|
||||||
width: 22,
|
actions.addAll(
|
||||||
onPressed: () {
|
pluginBuilders()
|
||||||
ActionList(
|
.map((pluginBuilder) =>
|
||||||
anchorContext: context,
|
AddButtonActionWrapper(pluginBuilder: pluginBuilder))
|
||||||
onSelected: onSelected,
|
.toList(),
|
||||||
).show(context);
|
|
||||||
},
|
|
||||||
icon: svgWidget(
|
|
||||||
"home/add",
|
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
|
||||||
).padding(horizontal: 3, vertical: 3),
|
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ActionList {
|
return PopoverActionList<PopoverAction>(
|
||||||
final Function(PluginBuilder) onSelected;
|
direction: PopoverDirection.bottomWithLeftAligned,
|
||||||
final BuildContext anchorContext;
|
actions: actions,
|
||||||
final String _identifier = 'DisclosureButtonActionList';
|
buildChild: (controller) {
|
||||||
|
return FlowyIconButton(
|
||||||
const ActionList({required this.anchorContext, required this.onSelected});
|
width: 22,
|
||||||
|
onPressed: () => controller.show(),
|
||||||
void show(BuildContext buildContext) {
|
icon: svgWidget(
|
||||||
final items = pluginBuilders().map(
|
"home/add",
|
||||||
(pluginBuilder) {
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
return CreateItem(
|
).padding(horizontal: 3, vertical: 3),
|
||||||
pluginBuilder: pluginBuilder,
|
|
||||||
onSelected: (builder) {
|
|
||||||
onSelected(builder);
|
|
||||||
FlowyOverlay.of(buildContext).remove(_identifier);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
).toList();
|
onSelected: (action, controller) {
|
||||||
|
if (action is AddButtonActionWrapper) {
|
||||||
|
onSelected(action.pluginBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
ListOverlay.showWithAnchor(
|
controller.close();
|
||||||
buildContext,
|
},
|
||||||
identifier: _identifier,
|
|
||||||
itemCount: items.length,
|
|
||||||
itemBuilder: (context, index) => items[index],
|
|
||||||
anchorContext: anchorContext,
|
|
||||||
anchorDirection: AnchorDirection.bottomRight,
|
|
||||||
constraints: BoxConstraints(
|
|
||||||
minWidth: 120,
|
|
||||||
maxWidth: 280,
|
|
||||||
minHeight: items.length * (CreateItem.height),
|
|
||||||
maxHeight: items.length * (CreateItem.height),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CreateItem extends StatelessWidget {
|
class AddButtonActionWrapper extends ActionCell {
|
||||||
static const double height = 30;
|
|
||||||
static const double verticalPadding = 6;
|
|
||||||
|
|
||||||
final PluginBuilder pluginBuilder;
|
final PluginBuilder pluginBuilder;
|
||||||
final Function(PluginBuilder) onSelected;
|
|
||||||
const CreateItem({
|
AddButtonActionWrapper({required this.pluginBuilder});
|
||||||
Key? key,
|
|
||||||
required this.pluginBuilder,
|
|
||||||
required this.onSelected,
|
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget? icon(Color iconColor) =>
|
||||||
return FlowyHover(
|
svgWidget(pluginBuilder.menuIcon, color: iconColor);
|
||||||
child: GestureDetector(
|
|
||||||
behavior: HitTestBehavior.opaque,
|
@override
|
||||||
onTap: () => onSelected(pluginBuilder),
|
String get name => pluginBuilder.menuName;
|
||||||
child: ConstrainedBox(
|
|
||||||
constraints: const BoxConstraints(
|
|
||||||
minWidth: 120,
|
|
||||||
minHeight: CreateItem.height,
|
|
||||||
),
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: FlowyText.medium(
|
|
||||||
pluginBuilder.menuName,
|
|
||||||
fontSize: 12,
|
|
||||||
).padding(horizontal: 10),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user