mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-12-11 23:21:57 +00:00
fix: icon and emoji doesn't align in mention page menu (#7673)
This commit is contained in:
parent
7d0f6c9deb
commit
13028c6cfe
@ -102,7 +102,7 @@ class MobileInlineActionsWidget extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final hasIcon = item.icon != null;
|
final hasIcon = item.iconBuilder != null;
|
||||||
return Container(
|
return Container(
|
||||||
height: 36,
|
height: 36,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -119,7 +119,7 @@ class MobileInlineActionsWidget extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
if (hasIcon) ...[
|
if (hasIcon) ...[
|
||||||
item.icon!.call(isSelected),
|
item.iconBuilder!.call(isSelected),
|
||||||
SizedBox(width: 12),
|
SizedBox(width: 12),
|
||||||
],
|
],
|
||||||
Flexible(
|
Flexible(
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import 'package:appflowy/shared/icon_emoji_picker/icon_picker.dart';
|
|||||||
import 'package:appflowy/user/application/user_service.dart';
|
import 'package:appflowy/user/application/user_service.dart';
|
||||||
import 'package:appflowy_backend/log.dart';
|
import 'package:appflowy_backend/log.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pb.dart';
|
||||||
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
||||||
import 'package:flowy_svg/flowy_svg.dart';
|
import 'package:flowy_svg/flowy_svg.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:string_validator/string_validator.dart';
|
import 'package:string_validator/string_validator.dart';
|
||||||
@ -113,24 +114,21 @@ class _RawEmojiIconWidgetState extends State<RawEmojiIconWidget> {
|
|||||||
try {
|
try {
|
||||||
switch (widget.emoji.type) {
|
switch (widget.emoji.type) {
|
||||||
case FlowyIconType.emoji:
|
case FlowyIconType.emoji:
|
||||||
return EmojiText(
|
return FlowyText.emoji(
|
||||||
emoji: widget.emoji.emoji,
|
widget.emoji.emoji,
|
||||||
fontSize: widget.emojiSize,
|
fontSize: widget.emojiSize,
|
||||||
textAlign: TextAlign.justify,
|
textAlign: TextAlign.justify,
|
||||||
lineHeight: widget.lineHeight,
|
lineHeight: widget.lineHeight,
|
||||||
);
|
);
|
||||||
case FlowyIconType.icon:
|
case FlowyIconType.icon:
|
||||||
IconsData iconData =
|
IconsData iconData = IconsData.fromJson(
|
||||||
IconsData.fromJson(jsonDecode(widget.emoji.emoji));
|
jsonDecode(widget.emoji.emoji),
|
||||||
|
);
|
||||||
if (!widget.enableColor) {
|
if (!widget.enableColor) {
|
||||||
iconData = iconData.noColor();
|
iconData = iconData.noColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Under the same width conditions, icons on macOS seem to appear
|
final iconSize = widget.emojiSize;
|
||||||
/// larger than emojis, so 0.9 is used here to slightly reduce the
|
|
||||||
/// size of the icons
|
|
||||||
final iconSize =
|
|
||||||
Platform.isMacOS ? widget.emojiSize * 0.9 : widget.emojiSize;
|
|
||||||
return IconWidget(
|
return IconWidget(
|
||||||
iconsData: iconData,
|
iconsData: iconData,
|
||||||
size: iconSize,
|
size: iconSize,
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class InlineChildPageService extends InlineActionsDelegate {
|
|||||||
results.add(
|
results.add(
|
||||||
InlineActionsMenuItem(
|
InlineActionsMenuItem(
|
||||||
label: LocaleKeys.inlineActions_createPage.tr(args: [search]),
|
label: LocaleKeys.inlineActions_createPage.tr(args: [search]),
|
||||||
icon: (_) => const FlowySvg(FlowySvgs.add_s),
|
iconBuilder: (_) => const FlowySvg(FlowySvgs.add_s),
|
||||||
onSelected: (context, editorState, service, replacement) =>
|
onSelected: (context, editorState, service, replacement) =>
|
||||||
_onSelected(context, editorState, service, replacement, search),
|
_onSelected(context, editorState, service, replacement, search),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -234,12 +234,19 @@ class InlinePageReferenceService extends InlineActionsDelegate {
|
|||||||
InlineActionsMenuItem _fromView(ViewPB view) => InlineActionsMenuItem(
|
InlineActionsMenuItem _fromView(ViewPB view) => InlineActionsMenuItem(
|
||||||
keywords: [view.nameOrDefault.toLowerCase()],
|
keywords: [view.nameOrDefault.toLowerCase()],
|
||||||
label: view.nameOrDefault,
|
label: view.nameOrDefault,
|
||||||
icon: (onSelected) => view.icon.value.isNotEmpty
|
iconBuilder: (onSelected) {
|
||||||
? RawEmojiIconWidget(
|
final child = view.icon.value.isNotEmpty
|
||||||
emoji: view.icon.toEmojiIconData(),
|
? RawEmojiIconWidget(
|
||||||
emojiSize: 14,
|
emoji: view.icon.toEmojiIconData(),
|
||||||
)
|
emojiSize: 16.0,
|
||||||
: view.defaultIcon(),
|
lineHeight: 18.0 / 16.0,
|
||||||
|
)
|
||||||
|
: view.defaultIcon(size: const Size(16, 16));
|
||||||
|
return SizedBox(
|
||||||
|
width: 16,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
},
|
||||||
onSelected: (context, editorState, menu, replace) => insertPage
|
onSelected: (context, editorState, menu, replace) => insertPage
|
||||||
? _onInsertPageRef(view, context, editorState, replace)
|
? _onInsertPageRef(view, context, editorState, replace)
|
||||||
: _onInsertLinkRef(view, context, editorState, menu, replace),
|
: _onInsertLinkRef(view, context, editorState, menu, replace),
|
||||||
|
|||||||
@ -12,13 +12,13 @@ typedef SelectItemHandler = void Function(
|
|||||||
class InlineActionsMenuItem {
|
class InlineActionsMenuItem {
|
||||||
InlineActionsMenuItem({
|
InlineActionsMenuItem({
|
||||||
required this.label,
|
required this.label,
|
||||||
this.icon,
|
this.iconBuilder,
|
||||||
this.keywords,
|
this.keywords,
|
||||||
this.onSelected,
|
this.onSelected,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String label;
|
final String label;
|
||||||
final Widget Function(bool onSelected)? icon;
|
final Widget Function(bool onSelected)? iconBuilder;
|
||||||
final List<String>? keywords;
|
final List<String>? keywords;
|
||||||
final SelectItemHandler? onSelected;
|
final SelectItemHandler? onSelected;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,8 +92,8 @@ class InlineActionsWidget extends StatefulWidget {
|
|||||||
class _InlineActionsWidgetState extends State<InlineActionsWidget> {
|
class _InlineActionsWidgetState extends State<InlineActionsWidget> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final icon = widget.item.icon;
|
final iconBuilder = widget.item.iconBuilder;
|
||||||
final hasIcon = icon != null;
|
final hasIcon = iconBuilder != null;
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 2),
|
padding: const EdgeInsets.symmetric(vertical: 2),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
@ -104,7 +104,7 @@ class _InlineActionsWidgetState extends State<InlineActionsWidget> {
|
|||||||
text: Row(
|
text: Row(
|
||||||
children: [
|
children: [
|
||||||
if (hasIcon) ...[
|
if (hasIcon) ...[
|
||||||
icon.call(widget.isSelected),
|
iconBuilder.call(widget.isSelected),
|
||||||
SizedBox(width: 12),
|
SizedBox(width: 12),
|
||||||
],
|
],
|
||||||
Flexible(
|
Flexible(
|
||||||
|
|||||||
@ -632,7 +632,11 @@ class _SingleInnerViewItemState extends State<SingleInnerViewItem> {
|
|||||||
Widget _buildViewIconButton() {
|
Widget _buildViewIconButton() {
|
||||||
final iconData = widget.view.icon.toEmojiIconData();
|
final iconData = widget.view.icon.toEmojiIconData();
|
||||||
final icon = iconData.isNotEmpty
|
final icon = iconData.isNotEmpty
|
||||||
? RawEmojiIconWidget(emoji: iconData, emojiSize: 16.0)
|
? RawEmojiIconWidget(
|
||||||
|
emoji: iconData,
|
||||||
|
emojiSize: 16.0,
|
||||||
|
lineHeight: 18.0 / 16.0,
|
||||||
|
)
|
||||||
: Opacity(opacity: 0.6, child: widget.view.defaultIcon());
|
: Opacity(opacity: 0.6, child: widget.view.defaultIcon());
|
||||||
|
|
||||||
final Widget child = AppFlowyPopover(
|
final Widget child = AppFlowyPopover(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user