Skip to content

Commit

Permalink
feat: display no access page (AppFlowy-IO#5941)
Browse files Browse the repository at this point in the history
* feat: display no access page

* fix: optimize the primary rounded button
  • Loading branch information
LucasXu0 authored Aug 13, 2024
1 parent 4b71052 commit 93f9a2c
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/mobile/application/mobile_router.dart';
import 'package:appflowy/plugins/base/emoji/emoji_text.dart';
import 'package:appflowy/plugins/document/application/document_bloc.dart';
Expand All @@ -21,6 +22,7 @@ import 'package:appflowy_editor/appflowy_editor.dart'
TextTransaction,
paragraphNode;
import 'package:collection/collection.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flowy_infra_ui/style_widget/hover.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -105,57 +107,69 @@ class _MentionPageBlockState extends State<MentionPageBlock> {
// memorize the result
pageMemorizer[widget.pageId] = view;
if (view == null) {
return const SizedBox.shrink();
}

final iconSize = widget.textStyle?.fontSize ?? 16.0;
final child = GestureDetector(
onTap: handleTap,
onDoubleTap: handleDoubleTap,
behavior: HitTestBehavior.translucent,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const HSpace(4),
view.icon.value.isNotEmpty
? EmojiText(
emoji: view.icon.value,
fontSize: 12,
textAlign: TextAlign.center,
lineHeight: 1.3,
)
: FlowySvg(
view.layout.icon,
size: Size.square(iconSize + 2.0),
),
const HSpace(2),
FlowyText(
view.name,
return FlowyHover(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: FlowyText(
LocaleKeys.document_mention_noAccess.tr(),
color: Theme.of(context).disabledColor,
decoration: TextDecoration.underline,
fontSize: widget.textStyle?.fontSize,
fontWeight: widget.textStyle?.fontWeight,
),
const HSpace(2),
],
),
),
);
}

final iconSize = widget.textStyle?.fontSize ?? 16.0;
Widget child = Row(
mainAxisSize: MainAxisSize.min,
children: [
const HSpace(4),
view.icon.value.isNotEmpty
? EmojiText(
emoji: view.icon.value,
fontSize: 12,
textAlign: TextAlign.center,
lineHeight: 1.3,
)
: FlowySvg(
view.layout.icon,
size: Size.square(iconSize + 2.0),
),
const HSpace(2),
FlowyText(
view.name,
decoration: TextDecoration.underline,
fontSize: widget.textStyle?.fontSize,
fontWeight: widget.textStyle?.fontWeight,
),
const HSpace(4),
],
);

if (PlatformExtension.isMobile) {
return child;
if (PlatformExtension.isDesktop) {
child = Padding(
padding: const EdgeInsets.symmetric(horizontal: 2),
child: FlowyHover(
cursor: SystemMouseCursors.click,
child: child,
),
);
}

return Padding(
padding: const EdgeInsets.symmetric(horizontal: 2),
child: FlowyHover(
cursor: SystemMouseCursors.click,
child: child,
),
return GestureDetector(
onTap: handleTap,
onDoubleTap: PlatformExtension.isMobile ? handleDoubleTap : null,
behavior: HitTestBehavior.opaque,
child: child,
);
},
);
}

Future<void> handleTap() async {
debugPrint('handleTap');
final view = await fetchView(widget.pageId);
if (view == null) {
Log.error('Page(${widget.pageId}) not found');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ShareMenuButton extends StatelessWidget {
),
child: PrimaryRoundedButton(
text: LocaleKeys.shareAction_buttonText.tr(),
figmaLineHeight: 16,
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ class _PublishButton extends StatelessWidget {
text: LocaleKeys.shareAction_publish.tr(),
useIntrinsicWidth: false,
margin: const EdgeInsets.symmetric(vertical: 9.0),
fontSize: 14.0,
figmaLineHeight: 18.0,
onTap: onPublish,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ class _WorkspaceInfo extends StatelessWidget {
FlowyText.medium(
workspace.name,
fontSize: 14.0,
figmaLineHeight: 17.0,
overflow: TextOverflow.ellipsis,
withTooltip: true,
),
Expand All @@ -260,6 +261,7 @@ class _WorkspaceInfo extends StatelessWidget {
members.length,
),
fontSize: 10.0,
figmaLineHeight: 12.0,
color: Theme.of(context).hintColor,
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class SingleSettingAction extends StatelessWidget {
fontSize: 12,
isDangerous: buttonType.isDangerous,
onPressed: onPressed,
lineHeight: 1.0,
),
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ class FlowyTextButton extends StatelessWidget {
this.fontFamily,
this.isDangerous = false,
this.borderColor,
this.lineHeight,
});

factory FlowyTextButton.primary({
Expand Down Expand Up @@ -362,6 +363,7 @@ class FlowyTextButton extends StatelessWidget {
final String? fontFamily;
final bool isDangerous;
final Color? borderColor;
final double? lineHeight;

@override
Widget build(BuildContext context) {
Expand All @@ -375,6 +377,7 @@ class FlowyTextButton extends StatelessWidget {
overflow: overflow,
color: textColor,
textAlign: TextAlign.center,
lineHeight: lineHeight,
));

Widget child = Row(
Expand Down Expand Up @@ -411,7 +414,7 @@ class FlowyTextButton extends StatelessWidget {
fontSize: fontSize,
decoration: decoration,
fontFamily: fontFamily,
height: 1.1,
height: lineHeight ?? 1.1,
),
),
backgroundColor: WidgetStateProperty.resolveWith(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class PrimaryRoundedButton extends StatelessWidget {
this.hoverColor,
this.backgroundColor,
this.useIntrinsicWidth = true,
this.lineHeight,
this.figmaLineHeight,
});

final String text;
Expand All @@ -27,6 +29,8 @@ class PrimaryRoundedButton extends StatelessWidget {
final Color? hoverColor;
final Color? backgroundColor;
final bool useIntrinsicWidth;
final double? lineHeight;
final double? figmaLineHeight;

@override
Widget build(BuildContext context) {
Expand All @@ -36,6 +40,8 @@ class PrimaryRoundedButton extends StatelessWidget {
text,
fontSize: fontSize ?? 14.0,
fontWeight: fontWeight ?? FontWeight.w500,
lineHeight: lineHeight ?? 1.0,
figmaLineHeight: figmaLineHeight,
color: Theme.of(context).colorScheme.onPrimary,
textAlign: TextAlign.center,
),
Expand Down
3 changes: 2 additions & 1 deletion frontend/resources/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,8 @@
"tooltip": "Click to open page"
},
"deleted": "Deleted",
"deletedContent": "This content does not exist or has been deleted"
"deletedContent": "This content does not exist or has been deleted",
"noAccess": "No Access"
},
"toolbar": {
"resetToDefaultFont": "Reset to default"
Expand Down

0 comments on commit 93f9a2c

Please sign in to comment.