fix: some UI issues

This commit is contained in:
Morn 2025-04-10 09:59:12 +08:00
parent add9f16717
commit 05b0160b80
4 changed files with 39 additions and 32 deletions

View file

@ -73,8 +73,10 @@ extension PasteFromPlainText on EditorState {
}
void checkToShowPasteAsMenu(Node node) {
if (selection == null || !selection!.isCollapsed) return;
if (UniversalPlatform.isMobile) return;
final href = _getLinkFromNode(node);
if (href != null && !UniversalPlatform.isMobile) {
if (href != null) {
final context = document.root.context;
if (context != null && context.mounted) {
PasteAsMenuService(context: context, editorState: this).show(href);

View file

@ -64,10 +64,10 @@ class LinkEmbedBlockComponentState extends State<LinkEmbedBlockComponent>
parser.addLinkInfoListener((v) {
if (mounted) {
setState(() {
linkInfo = v;
if (v.isEmpty()) {
if (v.isEmpty() && linkInfo.isEmpty()) {
status = EmbedLoadingStatus.error;
} else {
linkInfo = v;
status = EmbedLoadingStatus.idle;
}
});
@ -197,27 +197,29 @@ class LinkEmbedBlockComponentState extends State<LinkEmbedBlockComponent>
),
),
HSpace(12),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
FlowyText(
linkInfo.siteName ?? '',
color: textScheme.primary,
fontSize: 14,
figmaLineHeight: 20,
fontWeight: FontWeight.w600,
overflow: TextOverflow.ellipsis,
),
VSpace(4),
FlowyText.regular(
url,
color: textScheme.secondary,
fontSize: 12,
figmaLineHeight: 16,
overflow: TextOverflow.ellipsis,
),
],
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
FlowyText(
linkInfo.siteName ?? '',
color: textScheme.primary,
fontSize: 14,
figmaLineHeight: 20,
fontWeight: FontWeight.w600,
overflow: TextOverflow.ellipsis,
),
VSpace(4),
FlowyText.regular(
url,
color: textScheme.secondary,
fontSize: 12,
figmaLineHeight: 16,
overflow: TextOverflow.ellipsis,
),
],
),
),
],
),

View file

@ -32,11 +32,12 @@ class LinkParser {
imageUrl: previewData.image?.url,
faviconUrl: favicon?.url,
);
await _cache.set(url, linkInfo);
if (!linkInfo.isEmpty()) await _cache.set(url, linkInfo);
refreshLinkInfo(linkInfo);
return linkInfo;
} catch (e, s) {
Log.error('get link info error: ', e, s);
refreshLinkInfo(LinkInfo());
return null;
}
}
@ -99,6 +100,7 @@ class LinkInfo {
return FlowyNetworkSvg(
iconUrl,
height: size.height,
width: size.width,
errorWidget: const FlowySvg(FlowySvgs.toolbar_link_earth_m),
);
}
@ -106,6 +108,7 @@ class LinkInfo {
url: iconUrl,
fit: BoxFit.contain,
height: size.height,
width: size.width,
errorWidgetBuilder: (context, error, stackTrace) =>
const FlowySvg(FlowySvgs.toolbar_link_earth_m),
);

View file

@ -43,7 +43,7 @@ class _MentionLinkBlockState extends State<MentionLinkBlock> {
final parser = LinkParser();
_LoadingStatus status = _LoadingStatus.loading;
final previewController = PopoverController();
LinkInfo? linkInfo;
LinkInfo linkInfo = LinkInfo();
bool isHovering = false;
int previewFocusNum = 0;
bool isPreviewHovering = false;
@ -60,7 +60,7 @@ class _MentionLinkBlockState extends State<MentionLinkBlock> {
int get index => widget.index;
bool get readyForPreview =>
status == _LoadingStatus.idle && !(linkInfo?.isEmpty() ?? true);
status == _LoadingStatus.idle && !linkInfo.isEmpty();
@override
void initState() {
@ -69,10 +69,10 @@ class _MentionLinkBlockState extends State<MentionLinkBlock> {
parser.addLinkInfoListener((v) {
if (mounted) {
setState(() {
linkInfo = v;
if (v.isEmpty()) {
if (v.isEmpty() && linkInfo.isEmpty()) {
status = _LoadingStatus.error;
} else {
linkInfo = v;
status = _LoadingStatus.idle;
}
});
@ -112,7 +112,7 @@ class _MentionLinkBlockState extends State<MentionLinkBlock> {
borderRadius: BorderRadius.circular(16),
popupBuilder: (context) => readyForPreview
? MentionLinkPreview(
linkInfo: linkInfo ?? LinkInfo(),
linkInfo: linkInfo,
showAtBottom: showAtBottom,
triggerSize: getSizeFromKey(),
onEnter: (e) {
@ -170,7 +170,7 @@ class _MentionLinkBlockState extends State<MentionLinkBlock> {
HSpace(4),
Flexible(
child: FlowyText(
linkInfo?.siteName ?? url,
linkInfo.siteName ?? url,
color: theme.textColorScheme.primary,
fontSize: 14,
figmaLineHeight: 20,
@ -194,7 +194,7 @@ class _MentionLinkBlockState extends State<MentionLinkBlock> {
child: const CircularProgressIndicator(strokeWidth: 1),
);
} else {
icon = linkInfo?.buildIconWidget() ?? defaultWidget;
icon = linkInfo.buildIconWidget();
}
return SizedBox(
height: 20,