Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
feat: optimize shared section logic (#7957)
Lucasc8acd0227a7c
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/data/models/share_access_level.dart b/frontend/appflowy_flutter/lib/features/share_tab/data/models/share_access_level.dartindex c5e4d34f20..141b58d9c7 100644--- a/frontend/appflowy_flutter/lib/features/share_tab/data/models/share_access_level.dart+++ b/frontend/appflowy_flutter/lib/features/share_tab/data/models/share_access_level.dart@@ -1,3 +1,6 @@+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:easy_localization/easy_localization.dart';+/// The access level a user can have on a shared page.enum ShareAccessLevel {/// Can view the page only.@@ -15,13 +18,13 @@ enum ShareAccessLevel {String get i18n {switch (this) {case ShareAccessLevel.readOnly:- return 'View';+ return LocaleKeys.shareTab_accessLevel_view.tr();case ShareAccessLevel.readAndComment:- return 'Comment';+ return LocaleKeys.shareTab_accessLevel_comment.tr();case ShareAccessLevel.readAndWrite:- return 'Edit';+ return LocaleKeys.shareTab_accessLevel_edit.tr();case ShareAccessLevel.fullAccess:- return 'Full access';+ return LocaleKeys.shareTab_accessLevel_fullAccess.tr();}}}diff --git a/frontend/appflowy_flutter/lib/features/share_tab/data/models/shared_user.dart b/frontend/appflowy_flutter/lib/features/share_tab/data/models/shared_user.dartindex 1597c2c3c5..432ff65187 100644--- a/frontend/appflowy_flutter/lib/features/share_tab/data/models/shared_user.dart+++ b/frontend/appflowy_flutter/lib/features/share_tab/data/models/shared_user.dart@@ -26,4 +26,20 @@ class SharedUser {////// if the avatar is not set, it will be the first letter of the name.final String? avatarUrl;++ SharedUser copyWith({+ String? email,+ String? name,+ ShareRole? role,+ ShareAccessLevel? accessLevel,+ String? avatarUrl,+ }) {+ return SharedUser(+ email: email ?? this.email,+ name: name ?? this.name,+ role: role ?? this.role,+ accessLevel: accessLevel ?? this.accessLevel,+ avatarUrl: avatarUrl ?? this.avatarUrl,+ );+ }}diff --git a/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/local_share_with_user_repository.dart b/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/local_share_with_user_repository.dartindex b08b2f524c..d73e1a01c4 100644--- a/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/local_share_with_user_repository.dart+++ b/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/local_share_with_user_repository.dart@@ -142,4 +142,18 @@ class LocalShareWithUserRepository extends ShareWithUserRepository {..._availableSharedUsers,]);}++ @override+ Future<FlowyResult<void, FlowyError>> changeRole({+ required String pageId,+ required String email,+ required ShareRole role,+ }) async {+ final index = _sharedUsers.indexWhere((user) => user.email == email);+ if (index != -1) {+ _sharedUsers[index] = _sharedUsers[index].copyWith(role: role);+ }++ return FlowySuccess(null);+ }}diff --git a/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/rust_share_with_user_repository.dart b/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/rust_share_with_user_repository.dartindex b02cfb6b63..8334d55e1e 100644--- a/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/rust_share_with_user_repository.dart+++ b/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/rust_share_with_user_repository.dart@@ -1,9 +1,10 @@import 'package:appflowy/features/share_tab/data/models/models.dart';-import 'package:appflowy/features/shared_section/util/extensions.dart';+import 'package:appflowy/features/util/extensions.dart';import 'package:appflowy_backend/dispatch/dispatch.dart';import 'package:appflowy_backend/log.dart';import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';import 'package:appflowy_backend/protobuf/flowy-folder/protobuf.dart';+import 'package:appflowy_backend/protobuf/flowy-user/workspace.pb.dart';import 'package:appflowy_result/appflowy_result.dart';import 'share_with_user_repository.dart';@@ -95,4 +96,31 @@ class RustShareWithUserRepository extends ShareWithUserRepository {// TODO: Implement thisreturn FlowySuccess([]);}++ @override+ Future<FlowyResult<void, FlowyError>> changeRole({+ required String pageId,+ required String email,+ required ShareRole role,+ }) async {+ final request = UpdateWorkspaceMemberPB(+ workspaceId: pageId,+ email: email,+ role: role.userRole,+ );+ final result = await UserEventUpdateWorkspaceMember(request).send();+ return result.fold(+ (success) {+ Log.info('change role($role) for user($email) in page($pageId)');+ return FlowySuccess(success);+ },+ (failure) {+ Log.error(+ 'failed to change role($role) for user($email) in page($pageId)',+ failure,+ );+ return FlowyFailure(failure);+ },+ );+ }}diff --git a/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/share_with_user_repository.dart b/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/share_with_user_repository.dartindex d9bcce07af..ad94a39f3d 100644--- a/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/share_with_user_repository.dart+++ b/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/share_with_user_repository.dart@@ -1,5 +1,4 @@-import 'package:appflowy/features/share_tab/data/models/share_access_level.dart';-import 'package:appflowy/features/share_tab/data/models/shared_user.dart';+import 'package:appflowy/features/share_tab/data/models/models.dart';import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';import 'package:appflowy_result/appflowy_result.dart';@@ -32,4 +31,11 @@ abstract class ShareWithUserRepository {required ShareAccessLevel accessLevel,required List<String> emails,});++ /// Change the role of a user in a shared page.+ Future<FlowyResult<void, FlowyError>> changeRole({+ required String pageId,+ required String email,+ required ShareRole role,+ });}diff --git a/frontend/appflowy_flutter/lib/features/share_tab/presentation/share_tab.dart b/frontend/appflowy_flutter/lib/features/share_tab/presentation/share_tab.dartindex ee49c7be75..c6c625c6e2 100644--- a/frontend/appflowy_flutter/lib/features/share_tab/presentation/share_tab.dart+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/share_tab.dart@@ -1,9 +1,9 @@import 'package:appflowy/features/share_tab/data/models/share_access_level.dart';import 'package:appflowy/features/share_tab/logic/share_with_user_bloc.dart';import 'package:appflowy/features/share_tab/presentation/widgets/copy_link_widget.dart';-import 'package:appflowy/features/share_tab/presentation/widgets/general_access_section.dart';-import 'package:appflowy/features/share_tab/presentation/widgets/people_with_acess_section.dart';+import 'package:appflowy/features/share_tab/presentation/widgets/people_with_access_section.dart';import 'package:appflowy/features/share_tab/presentation/widgets/share_with_user_widget.dart';+import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';import 'package:appflowy_ui/appflowy_ui.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flutter/material.dart';@@ -23,7 +23,10 @@ class ShareTab extends StatelessWidget {Widget build(BuildContext context) {final theme = AppFlowyTheme.of(context);- return BlocBuilder<ShareWithUserBloc, ShareWithUserState>(+ return BlocConsumer<ShareWithUserBloc, ShareWithUserState>(+ listener: (context, state) {+ _onShareWithUserError(context, state);+ },builder: (context, state) {if (state.isLoading) {return const SizedBox.shrink();@@ -44,18 +47,20 @@ class ShareTab extends StatelessWidget {),// shared users- VSpace(theme.spacing.l),- state.errorMessage.isNotEmpty- ? Center(child: Text(state.errorMessage))- : PeopleWithAccessSection(- currentUserEmail: state.currentUser?.email ?? '',- users: state.users,- callbacks: _buildPeopleWithAccessSectionCallbacks(context),- ),++ if (state.users.isNotEmpty) ...[+ VSpace(theme.spacing.l),+ PeopleWithAccessSection(+ currentUserEmail: state.currentUser?.email ?? '',+ users: state.users,+ callbacks: _buildPeopleWithAccessSectionCallbacks(context),+ ),+ ],// general access- VSpace(theme.spacing.m),- GeneralAccessSection(),+ // enable it when the backend support general access features.+ // VSpace(theme.spacing.m),+ // GeneralAccessSection(),// copy linkVSpace(theme.spacing.l),@@ -96,4 +101,20 @@ class ShareTab extends StatelessWidget {},);}++ void _onShareWithUserError(+ BuildContext context,+ ShareWithUserState state,+ ) {+ final shareResult = state.shareResult;+ if (shareResult != null) {+ shareResult.onFailure((error) {+ // TODO: handle the limiation error+ showToastNotification(+ message: error.msg,+ type: ToastificationType.error,+ );+ });+ }+ }}diff --git a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/access_level_list_widget.dart b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/access_level_list_widget.dartindex 17bec3a02c..e54937fd0b 100644--- a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/access_level_list_widget.dart+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/access_level_list_widget.dart@@ -1,6 +1,8 @@import 'package:appflowy/features/share_tab/data/models/models.dart';import 'package:appflowy/generated/flowy_svgs.g.dart';+import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy_ui/appflowy_ui.dart';+import 'package:easy_localization/easy_localization.dart';import 'package:flutter/material.dart';class AccessLevelListCallbacks {@@ -99,11 +101,11 @@ class AccessLevelListWidget extends StatelessWidget {// Additional user management optionsAFTextMenuItem(- title: 'Turn into Member',+ title: LocaleKeys.shareTab_turnIntoMember.tr(),onTap: callbacks.onTurnIntoMember,),AFTextMenuItem(- title: 'Remove access',+ title: LocaleKeys.shareTab_removeAccess.tr(),titleColor: theme.textColorScheme.error,onTap: callbacks.onRemoveAccess,),diff --git a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/copy_link_widget.dart b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/copy_link_widget.dartindex 2abda4e3c2..62d426b4f9 100644--- a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/copy_link_widget.dart+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/copy_link_widget.dart@@ -1,7 +1,9 @@import 'package:appflowy/features/share_tab/logic/share_with_user_bloc.dart';import 'package:appflowy/generated/flowy_svgs.g.dart';+import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';import 'package:appflowy_ui/appflowy_ui.dart';+import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flutter/material.dart';import 'package:flutter_bloc/flutter_bloc.dart';@@ -28,7 +30,7 @@ class CopyLinkWidget extends StatelessWidget {),HSpace(theme.spacing.s),AFOutlinedIconTextButton.normal(- text: 'Copy link',+ text: LocaleKeys.shareTab_copyLink.tr(),size: AFButtonSize.l,padding: EdgeInsets.symmetric(horizontal: theme.spacing.l,@@ -43,7 +45,7 @@ class CopyLinkWidget extends StatelessWidget {);showToastNotification(- message: 'Copied link to clipboard',+ message: LocaleKeys.shareTab_copiedLinkToClipboard.tr(),);},),diff --git a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/people_with_acess_section.dart b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/people_with_access_section.dartsimilarity index 95%rename from frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/people_with_acess_section.dartrename to frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/people_with_access_section.dartindex ced7a8a501..ffb41901f7 100644--- a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/people_with_acess_section.dart+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/people_with_access_section.dart@@ -50,19 +50,19 @@ class PeopleWithAccessSection extends StatelessWidget {(user) => user.email == currentUserEmail,);- if (currentUser == null) {- return const SizedBox.shrink();- }-return AFMenuSection(title: 'People with access',constraints: BoxConstraints(maxHeight: 240,),padding: EdgeInsets.symmetric(- vertical: theme.spacing.s,+ vertical: theme.spacing.xs,),children: users.map((user) {+ if (currentUser == null) {+ return const SizedBox.shrink();+ }+return SharedUserWidget(user: user,currentUser: currentUser,diff --git a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/share_with_user_widget.dart b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/share_with_user_widget.dartindex d0e5ffd275..3a0fb779a6 100644--- a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/share_with_user_widget.dart+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/share_with_user_widget.dart@@ -1,4 +1,6 @@+import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy_ui/appflowy_ui.dart';+import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra_ui/widget/spacing.dart';import 'package:flutter/material.dart';import 'package:string_validator/string_validator.dart';@@ -43,12 +45,12 @@ class _ShareWithUserWidgetState extends State<ShareWithUserWidget> {child: AFTextField(controller: controller,size: AFTextFieldSize.m,- hintText: 'Invite by email',+ hintText: LocaleKeys.shareTab_inviteByEmail.tr(),),),HSpace(theme.spacing.s),AFFilledTextButton.primary(- text: 'Invite',+ text: LocaleKeys.shareTab_invite.tr(),disabled: !isButtonEnabled,onTap: () {widget.onInvite(controller.text.trim().split(','));diff --git a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/shared_group_widget.dart b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/shared_group_widget.dartindex 785dd0151e..6672143804 100644--- a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/shared_group_widget.dart+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/shared_group_widget.dart@@ -2,7 +2,9 @@ import 'package:appflowy/features/share_tab/data/models/share_access_level.dart'import 'package:appflowy/features/share_tab/presentation/widgets/access_level_list_widget.dart';import 'package:appflowy/features/share_tab/presentation/widgets/edit_access_level_widget.dart';import 'package:appflowy/generated/flowy_svgs.g.dart';+import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy_ui/appflowy_ui.dart';+import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra_ui/widget/spacing.dart';import 'package:flutter/material.dart';@@ -40,10 +42,13 @@ class SharedGroupWidget extends StatelessWidget {final theme = AppFlowyTheme.of(context);return Row(children: [- Text(- 'Anyone at AppFlowy', // replace it with group name- style: theme.textStyle.body.standard(- color: theme.textColorScheme.primary,+ Flexible(+ child: Text(+ LocaleKeys.shareTab_anyoneAtWorkspace.tr(),+ style: theme.textStyle.body.standard(+ color: theme.textColorScheme.primary,+ ),+ overflow: TextOverflow.ellipsis,),),HSpace(theme.spacing.xs),@@ -58,7 +63,7 @@ class SharedGroupWidget extends StatelessWidget {Widget _buildSubtitle(BuildContext context) {final theme = AppFlowyTheme.of(context);return Text(- 'Anyone in this group with the link can edit', // replace it with group description+ LocaleKeys.shareTab_anyoneInGroupWithLinkCanEdit.tr(),textAlign: TextAlign.left,style: theme.textStyle.caption.standard(color: theme.textColorScheme.secondary,diff --git a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/shared_user_widget.dart b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/shared_user_widget.dartindex 556e6dba0f..0d7ddef6a3 100644--- a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/shared_user_widget.dart+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/shared_user_widget.dart@@ -1,7 +1,9 @@import 'package:appflowy/features/share_tab/data/models/models.dart';import 'package:appflowy/features/share_tab/presentation/widgets/access_level_list_widget.dart';import 'package:appflowy/features/share_tab/presentation/widgets/edit_access_level_widget.dart';+import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy_ui/appflowy_ui.dart';+import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flutter/material.dart';@@ -29,7 +31,6 @@ class SharedUserWidget extends StatelessWidget {leading: AFAvatar(name: user.name,url: user.avatarUrl,- colorHash: user.email,),title: _buildTitle(context),subtitle: _buildSubtitle(context),@@ -45,17 +46,20 @@ class SharedUserWidget extends StatelessWidget {return Row(children: [- Text(- user.name,- style: theme.textStyle.body.standard(- color: theme.textColorScheme.primary,+ Flexible(+ child: Text(+ user.name,+ style: theme.textStyle.body.standard(+ color: theme.textColorScheme.primary,+ ),+ overflow: TextOverflow.ellipsis,),),// if the user is the current user, show '(You)'if (isCurrentUser) ...[HSpace(theme.spacing.xs),Text(- '(You)',+ LocaleKeys.shareTab_you.tr(),style: theme.textStyle.body.standard(color: theme.textColorScheme.secondary,),@@ -65,7 +69,7 @@ class SharedUserWidget extends StatelessWidget {if (user.role == ShareRole.guest) ...[HSpace(theme.spacing.xs),Text(- 'Guest',+ LocaleKeys.shareTab_guest.tr(),style: theme.textStyle.body.standard(color: theme.textColorScheme.warning,),diff --git a/frontend/appflowy_flutter/lib/features/shared_section/data/rust_share_pagers_repository.dart b/frontend/appflowy_flutter/lib/features/shared_section/data/rust_share_pagers_repository.dartindex efdd204443..811801acd5 100644--- a/frontend/appflowy_flutter/lib/features/shared_section/data/rust_share_pagers_repository.dart+++ b/frontend/appflowy_flutter/lib/features/shared_section/data/rust_share_pagers_repository.dart@@ -1,6 +1,6 @@import 'package:appflowy/features/shared_section/data/share_pages_repository.dart';import 'package:appflowy/features/shared_section/models/shared_page.dart';-import 'package:appflowy/features/shared_section/util/extensions.dart';+import 'package:appflowy/features/util/extensions.dart';import 'package:appflowy_backend/dispatch/dispatch.dart';import 'package:appflowy_backend/log.dart';import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';diff --git a/frontend/appflowy_flutter/lib/features/shared_section/logic/shared_section_bloc.dart b/frontend/appflowy_flutter/lib/features/shared_section/logic/shared_section_bloc.dartindex 95bfb00f9d..0865b163fd 100644--- a/frontend/appflowy_flutter/lib/features/shared_section/logic/shared_section_bloc.dart+++ b/frontend/appflowy_flutter/lib/features/shared_section/logic/shared_section_bloc.dart@@ -3,7 +3,7 @@ import 'dart:async';import 'package:appflowy/core/notification/folder_notification.dart';import 'package:appflowy/features/shared_section/data/share_pages_repository.dart';import 'package:appflowy/features/shared_section/models/shared_page.dart';-import 'package:appflowy/features/shared_section/util/extensions.dart';+import 'package:appflowy/features/util/extensions.dart';import 'package:appflowy_backend/log.dart';import 'package:appflowy_backend/protobuf/flowy-folder/protobuf.dart';import 'package:bloc/bloc.dart';diff --git a/frontend/appflowy_flutter/lib/features/shared_section/presentation/shared_section.dart b/frontend/appflowy_flutter/lib/features/shared_section/presentation/shared_section.dartindex fad0c5a748..735e1d9e56 100644--- a/frontend/appflowy_flutter/lib/features/shared_section/presentation/shared_section.dart+++ b/frontend/appflowy_flutter/lib/features/shared_section/presentation/shared_section.dart@@ -23,6 +23,7 @@ class SharedSection extends StatelessWidget {create: (_) => SharedSectionBloc(workspaceId: workspaceId,repository: RustSharePagesRepository(),+ enablePolling: true,)..add(const SharedSectionEvent.init()),child: BlocBuilder<SharedSectionBloc, SharedSectionState>(builder: (context, state) {diff --git a/frontend/appflowy_flutter/lib/features/shared_section/presentation/widgets/refresh_button.dart b/frontend/appflowy_flutter/lib/features/shared_section/presentation/widgets/refresh_button.dartindex efd087e25a..2bb4ee2f7c 100644--- a/frontend/appflowy_flutter/lib/features/shared_section/presentation/widgets/refresh_button.dart+++ b/frontend/appflowy_flutter/lib/features/shared_section/presentation/widgets/refresh_button.dart@@ -1,5 +1,7 @@+import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy_ui/appflowy_ui.dart';import 'package:flutter/material.dart';+import 'package:easy_localization/easy_localization.dart';class RefreshSharedSectionButton extends StatelessWidget {const RefreshSharedSectionButton({@@ -18,7 +20,7 @@ class RefreshSharedSectionButton extends StatelessWidget {size: 20,color: theme.iconColorScheme.secondary,),- title: 'Refresh',+ title: LocaleKeys.shareSection_refresh.tr(),onTap: onTap,);}diff --git a/frontend/appflowy_flutter/lib/features/shared_section/presentation/widgets/shared_pages_list.dart b/frontend/appflowy_flutter/lib/features/shared_section/presentation/widgets/shared_pages_list.dartindex bf1beded18..5203fb6229 100644--- a/frontend/appflowy_flutter/lib/features/shared_section/presentation/widgets/shared_pages_list.dart+++ b/frontend/appflowy_flutter/lib/features/shared_section/presentation/widgets/shared_pages_list.dart@@ -27,6 +27,7 @@ class SharedPagesList extends StatelessWidget {isFirstChild: view.id == sharedPages.first.view.id,view: view,level: 0,+ isDraggable: false, // disable draggable for shared pagesleftPadding: HomeSpaceViewSizes.leftPadding,isFeedback: false,onSelected: (context, view) {diff --git a/frontend/appflowy_flutter/lib/features/shared_section/presentation/widgets/shared_section_header.dart b/frontend/appflowy_flutter/lib/features/shared_section/presentation/widgets/shared_section_header.dartindex a93a74d8f1..203b72d8c5 100644--- a/frontend/appflowy_flutter/lib/features/shared_section/presentation/widgets/shared_section_header.dart+++ b/frontend/appflowy_flutter/lib/features/shared_section/presentation/widgets/shared_section_header.dart@@ -1,4 +1,6 @@+import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy_ui/appflowy_ui.dart';+import 'package:easy_localization/easy_localization.dart';import 'package:flutter/material.dart';class SharedSectionHeader extends StatelessWidget {@@ -13,7 +15,7 @@ class SharedSectionHeader extends StatelessWidget {bottom: theme.spacing.s,),child: Text(- 'Shared', // TODO: i18n+ LocaleKeys.shareSection_shared.tr(),style: theme.textStyle.caption.enhanced(color: theme.textColorScheme.tertiary,),diff --git a/frontend/appflowy_flutter/lib/features/shared_section/util/extensions.dart b/frontend/appflowy_flutter/lib/features/util/extensions.dartsimilarity index 78%rename from frontend/appflowy_flutter/lib/features/shared_section/util/extensions.dartrename to frontend/appflowy_flutter/lib/features/util/extensions.dartindex e6a2692511..cf24a7157e 100644--- a/frontend/appflowy_flutter/lib/features/shared_section/util/extensions.dart+++ b/frontend/appflowy_flutter/lib/features/util/extensions.dart@@ -1,7 +1,9 @@import 'package:appflowy/features/share_tab/data/models/models.dart';import 'package:appflowy/features/shared_section/models/shared_page.dart';-import 'package:appflowy_backend/protobuf/flowy-folder/protobuf.dart';+import 'package:appflowy_backend/protobuf/flowy-folder/protobuf.dart' as folder;import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';+import 'package:appflowy_backend/protobuf/flowy-user/workspace.pbenum.dart'+ as user;extension RepeatedSharedViewResponsePBExtensionon RepeatedSharedViewResponsePB {@@ -83,3 +85,27 @@ extension AFRolePBExtension on AFRolePB {}}}++extension ShareRoleExtension on ShareRole {+ user.AFRolePB get userRole {+ switch (this) {+ case ShareRole.guest:+ return user.AFRolePB.Guest;+ case ShareRole.member:+ return user.AFRolePB.Member;+ case ShareRole.owner:+ return user.AFRolePB.Owner;+ }+ }++ folder.AFRolePB get folderRole {+ switch (this) {+ case ShareRole.guest:+ return folder.AFRolePB.Guest;+ case ShareRole.member:+ return folder.AFRolePB.Member;+ case ShareRole.owner:+ return folder.AFRolePB.Owner;+ }+ }+}diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/add_members_screen.dart b/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/add_members_screen.dartindex 68d603ab60..eaff37e868 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/add_members_screen.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/add_members_screen.dart@@ -5,7 +5,7 @@ import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_pimport 'package:appflowy/shared/af_role_pb_extension.dart';import 'package:appflowy/startup/startup.dart';import 'package:appflowy/user/application/user_service.dart';-import 'package:appflowy/workspace/presentation/settings/widgets/members/inivitation/m_invite_member_by_email.dart';+import 'package:appflowy/workspace/presentation/settings/widgets/members/invitation/m_invite_member_by_email.dart';import 'package:appflowy/workspace/presentation/settings/widgets/members/workspace_member_bloc.dart';import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';import 'package:appflowy_backend/log.dart';diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/invite_members_screen.dart b/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/invite_members_screen.dartindex d4806decdc..78eed9ae34 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/invite_members_screen.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/invite_members_screen.dart@@ -7,7 +7,7 @@ import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_pimport 'package:appflowy/shared/af_role_pb_extension.dart';import 'package:appflowy/startup/startup.dart';import 'package:appflowy/user/application/user_service.dart';-import 'package:appflowy/workspace/presentation/settings/widgets/members/inivitation/m_invite_member_by_link.dart';+import 'package:appflowy/workspace/presentation/settings/widgets/members/invitation/m_invite_member_by_link.dart';import 'package:appflowy/workspace/presentation/settings/widgets/members/workspace_member_bloc.dart';import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';import 'package:appflowy_backend/log.dart';diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/collaborator_avater_stack.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/collaborator_avatar_stack.dartsimilarity index 100%rename from frontend/appflowy_flutter/lib/plugins/document/presentation/collaborator_avater_stack.dartrename to frontend/appflowy_flutter/lib/plugins/document/presentation/collaborator_avatar_stack.dartdiff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/document_collaborators.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/document_collaborators.dartindex d4a6815e32..fa46fd46d0 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/document_collaborators.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/document_collaborators.dart@@ -1,13 +1,13 @@import 'package:appflowy/plugins/document/application/document_awareness_metadata.dart';import 'package:appflowy/plugins/document/application/document_collaborators_bloc.dart';-import 'package:appflowy/plugins/document/presentation/collaborator_avater_stack.dart';+import 'package:appflowy/plugins/document/presentation/collaborator_avatar_stack.dart';import 'package:appflowy/workspace/presentation/widgets/user_avatar.dart';import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';+import 'package:appflowy_ui/appflowy_ui.dart';import 'package:avatar_stack/avatar_stack.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flutter/material.dart';import 'package:flutter_bloc/flutter_bloc.dart';-import 'package:universal_platform/universal_platform.dart';class DocumentCollaborators extends StatelessWidget {const DocumentCollaborators({@@ -99,8 +99,7 @@ class _UserAvatar extends StatelessWidget {child: UserAvatar(iconUrl: user.userAvatar,name: user.userName,- size: 30.0,- fontSize: fontSize ?? (UniversalPlatform.isMobile ? 14 : 12),+ size: AFAvatarSize.m,),),);diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/footer/sidebar_upgarde_application_button.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/footer/sidebar_upgrade_application_button.dartsimilarity index 100%rename from frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/footer/sidebar_upgarde_application_button.dartrename to frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/footer/sidebar_upgrade_application_button.dartdiff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/header/sidebar_user.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/header/sidebar_user.dartindex 82260e8118..0b70dd88c7 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/header/sidebar_user.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/header/sidebar_user.dart@@ -6,6 +6,7 @@ import 'package:appflowy/workspace/presentation/notifications/widgets/notificatiimport 'package:appflowy/workspace/presentation/widgets/user_avatar.dart';import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart'show UserProfilePB;+import 'package:appflowy_ui/appflowy_ui.dart';import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra_ui/style_widget/text.dart';import 'package:flowy_infra_ui/widget/spacing.dart';@@ -35,8 +36,7 @@ class SidebarUser extends StatelessWidget {UserAvatar(iconUrl: state.userProfile.iconUrl,name: state.userProfile.name,- size: 24.0,- fontSize: 16.0,+ size: AFAvatarSize.s,decoration: ShapeDecoration(color: const Color(0xFFFBE8FB),shape: RoundedRectangleBorder(diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/sidebar.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/sidebar.dartindex 1341c344e8..6904521914 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/sidebar.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/sidebar.dart@@ -25,7 +25,7 @@ import 'package:appflowy/workspace/application/view/view_ext.dart';import 'package:appflowy/workspace/presentation/command_palette/command_palette.dart';import 'package:appflowy/workspace/presentation/home/home_sizes.dart';import 'package:appflowy/workspace/presentation/home/menu/sidebar/footer/sidebar_footer.dart';-import 'package:appflowy/workspace/presentation/home/menu/sidebar/footer/sidebar_upgarde_application_button.dart';+import 'package:appflowy/workspace/presentation/home/menu/sidebar/footer/sidebar_upgrade_application_button.dart';import 'package:appflowy/workspace/presentation/home/menu/sidebar/header/sidebar_top_menu.dart';import 'package:appflowy/workspace/presentation/home/menu/sidebar/header/sidebar_user.dart';import 'package:appflowy/workspace/presentation/home/menu/sidebar/shared/sidebar_folder.dart';diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/sidebar_space.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/sidebar_space.dartindex 06204e82d7..dab2c977f9 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/sidebar_space.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/sidebar_space.dart@@ -11,7 +11,8 @@ import 'package:appflowy/workspace/presentation/home/menu/sidebar/favorites/favoimport 'package:appflowy/workspace/presentation/home/menu/sidebar/space/create_space_popup.dart';import 'package:appflowy/workspace/presentation/home/menu/sidebar/space/shared_widget.dart';import 'package:appflowy/workspace/presentation/home/menu/sidebar/space/sidebar_space_header.dart';-import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';+import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'+ hide AFRolePB;import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';import 'package:appflowy_editor/appflowy_editor.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';@@ -35,6 +36,14 @@ class SidebarSpace extends StatelessWidget {final currentWorkspace =context.watch<UserWorkspaceBloc>().state.currentWorkspace;final currentWorkspaceId = currentWorkspace?.workspaceId ?? '';++ // only show spaces if the user role is member or owner+ final currentUserRole = currentWorkspace?.role;+ final shouldShowSpaces = [+ AFRolePB.Member,+ AFRolePB.Owner,+ ].contains(currentUserRole);+return ValueListenableBuilder(valueListenable: getIt<MenuSharedState>().notifier,builder: (_, __, ___) => Provider.value(@@ -54,14 +63,18 @@ class SidebarSpace extends StatelessWidget {},),- const VSpace(16.0),// spaces- const _Space(),+ if (shouldShowSpaces) ...[+ const VSpace(16.0),+ // spaces+ const _Space(),+ ],// sharedif (FeatureFlag.sharedSection.isOn) ...[const VSpace(16.0),SharedSection(+ key: ValueKey(currentWorkspaceId),workspaceId: currentWorkspaceId,),],diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/account/account_user_profile.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/account/account_user_profile.dartindex 62a6232c4a..eb6d8da1e3 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/account/account_user_profile.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/account/account_user_profile.dart@@ -3,7 +3,6 @@ import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/shared/icon_emoji_picker/flowy_icon_emoji_picker.dart';import 'package:appflowy/workspace/application/user/settings_user_bloc.dart';import 'package:appflowy/workspace/presentation/settings/shared/settings_input_field.dart';-import 'package:appflowy/workspace/presentation/widgets/user_avatar.dart';import 'package:appflowy_ui/appflowy_ui.dart';import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';@@ -84,12 +83,11 @@ class _AccountUserProfileState extends State<AccountUserProfile> {child: FlowyTooltip(message:LocaleKeys.settings_accountPage_general_changeProfilePicture.tr(),- child: UserAvatar(- iconUrl: widget.iconUrl,+ verticalOffset: 28,+ child: AFAvatar(+ url: widget.iconUrl,name: widget.name,- size: 48,- fontSize: 20,- isHovering: isHovering,+ size: AFAvatarSize.l,),),),diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/inivitation/invite_member_by_email.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/invitation/invite_member_by_email.dartsimilarity index 100%rename from frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/inivitation/invite_member_by_email.dartrename to frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/invitation/invite_member_by_email.dartdiff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/inivitation/inivite_member_by_link.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/invitation/invite_member_by_link.dartsimilarity index 100%rename from frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/inivitation/inivite_member_by_link.dartrename to frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/invitation/invite_member_by_link.dartdiff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/inivitation/m_invite_member_by_email.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/invitation/m_invite_member_by_email.dartsimilarity index 100%rename from frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/inivitation/m_invite_member_by_email.dartrename to frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/invitation/m_invite_member_by_email.dartdiff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/inivitation/m_invite_member_by_link.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/invitation/m_invite_member_by_link.dartsimilarity index 100%rename from frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/inivitation/m_invite_member_by_link.dartrename to frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/invitation/m_invite_member_by_link.dartdiff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/inivitation/member_http_service.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/invitation/member_http_service.dartsimilarity index 100%rename from frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/inivitation/member_http_service.dartrename to frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/invitation/member_http_service.dartdiff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/workspace_member_bloc.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/workspace_member_bloc.dartindex 3cd6a68b38..2a4137b6b0 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/workspace_member_bloc.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/workspace_member_bloc.dart@@ -5,7 +5,7 @@ import 'package:appflowy/env/cloud_env.dart';import 'package:appflowy/shared/af_role_pb_extension.dart';import 'package:appflowy/shared/af_user_profile_extension.dart';import 'package:appflowy/user/application/user_service.dart';-import 'package:appflowy/workspace/presentation/settings/widgets/members/inivitation/member_http_service.dart';+import 'package:appflowy/workspace/presentation/settings/widgets/members/invitation/member_http_service.dart';import 'package:appflowy_backend/dispatch/dispatch.dart';import 'package:appflowy_backend/log.dart';import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/workspace_member_page.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/workspace_member_page.dartindex 348575d1ab..b2921a1521 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/workspace_member_page.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/workspace_member_page.dart@@ -5,8 +5,8 @@ import 'package:appflowy/shared/af_role_pb_extension.dart';import 'package:appflowy/startup/startup.dart';import 'package:appflowy/workspace/presentation/settings/shared/settings_body.dart';import 'package:appflowy/workspace/presentation/settings/shared/settings_category_spacer.dart';-import 'package:appflowy/workspace/presentation/settings/widgets/members/inivitation/inivite_member_by_link.dart';-import 'package:appflowy/workspace/presentation/settings/widgets/members/inivitation/invite_member_by_email.dart';+import 'package:appflowy/workspace/presentation/settings/widgets/members/invitation/invite_member_by_email.dart';+import 'package:appflowy/workspace/presentation/settings/widgets/members/invitation/invite_member_by_link.dart';import 'package:appflowy/workspace/presentation/settings/widgets/members/workspace_member_bloc.dart';import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';import 'package:appflowy/workspace/presentation/widgets/pop_up_action.dart';@@ -420,9 +420,7 @@ class _MemberItem extends StatelessWidget {UserAvatar(iconUrl: member.avatarUrl,name: member.name,- size: 24,- fontSize: 12,- emojiFontSize: 20,+ size: AFAvatarSize.s,),HSpace(8),Flexible(diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/user_avatar.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/user_avatar.dartindex e1b6f747b4..fe634b559e 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/user_avatar.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/user_avatar.dart@@ -1,13 +1,5 @@-import 'package:appflowy/generated/flowy_svgs.g.dart';-import 'package:appflowy/generated/locale_keys.g.dart';-import 'package:appflowy/util/built_in_svgs.dart';-import 'package:appflowy/util/color_generator/color_generator.dart';import 'package:appflowy_ui/appflowy_ui.dart';-import 'package:easy_localization/easy_localization.dart';-import 'package:flowy_infra/size.dart';-import 'package:flowy_infra_ui/style_widget/text.dart';import 'package:flutter/material.dart';-import 'package:string_validator/string_validator.dart';class UserAvatar extends StatelessWidget {const UserAvatar({@@ -15,17 +7,14 @@ class UserAvatar extends StatelessWidget {required this.iconUrl,required this.name,required this.size,- required this.fontSize,this.isHovering = false,this.decoration,- this.emojiFontSize,});final String iconUrl;final String name;- final double size;- final double fontSize;- final double? emojiFontSize;++ final AFAvatarSize size;final Decoration? decoration;// If true, a border will be applied on top of the avatar@@ -33,126 +22,26 @@ class UserAvatar extends StatelessWidget {@overrideWidget build(BuildContext context) {- if (iconUrl.isEmpty) {- return _buildEmptyAvatar(context);- } else if (isURL(iconUrl)) {- return _buildUrlAvatar(context);- } else {- return _buildEmojiAvatar(context);- }- }-- Widget _buildEmptyAvatar(BuildContext context) {final theme = AppFlowyTheme.of(context);- final String nameOrDefault = _userName(name);- final Color color = ColorGenerator(name).toColor();- const initialsCount = 2;-- // Taking the first letters of the name components and limiting to 2 elements- final nameInitials = nameOrDefault- .split(' ')- .where((element) => element.isNotEmpty)- .take(initialsCount)- .map((element) => element[0].toUpperCase())- .join();-- return Container(- width: size,- height: size,- alignment: Alignment.center,- decoration: decoration ??- BoxDecoration(- color: color,- shape: BoxShape.circle,- border: isHovering- ? Border.all(- color: _darken(color),- width: 4,- )- : null,- ),- child: Text(- nameInitials,- style: theme.textStyle.caption- .standard(color: AppFlowyPrimitiveTokens.subtleColorIron600)- .copyWith(fontSize: fontSize),- ),- );- }-- Widget _buildUrlAvatar(BuildContext context) {- return SizedBox.square(- dimension: size,- child: DecoratedBox(- decoration: decoration ??- BoxDecoration(- shape: BoxShape.circle,- border: isHovering- ? Border.all(- color: Theme.of(context).colorScheme.primary,- width: 4,- )- : null,- ),- child: ClipRRect(- borderRadius: BorderRadius.circular(size / 2),- child: Image.network(- iconUrl,- width: size,- height: size,- fit: BoxFit.cover,- errorBuilder: (context, error, stackTrace) =>- _buildEmptyAvatar(context),- ),- ),- ),- );- }-- Widget _buildEmojiAvatar(BuildContext context) {return SizedBox.square(- dimension: size,+ dimension: size.size,child: DecoratedBox(decoration: decoration ??BoxDecoration(shape: BoxShape.circle,border: isHovering? Border.all(- color: Theme.of(context).colorScheme.primary,+ color: theme.iconColorScheme.primary,width: 4,): null,),- child: ClipRRect(- borderRadius: Corners.s5Border,- child: CircleAvatar(- backgroundColor: Colors.transparent,- child: builtInSVGIcons.contains(iconUrl)- ? FlowySvg(- FlowySvgData('emoji/$iconUrl'),- blendMode: null,- )- : FlowyText.emoji(- iconUrl,- fontSize: emojiFontSize ?? fontSize,- ),- ),+ child: AFAvatar(+ url: iconUrl,+ name: name,+ size: size,),),);}-- /// Return the user name, if the user name is empty,- /// return the default user name.- ///- String _userName(String name) =>- name.isEmpty ? LocaleKeys.defaultUsername.tr() : name;-- /// Used to darken the generated color for the hover border effect.- /// The color is darkened by 15% - Hence the 0.15 value.- ///- Color _darken(Color color) {- final hsl = HSLColor.fromColor(color);- return hsl.withLightness((hsl.lightness - 0.15).clamp(0.0, 1.0)).toColor();- }}diff --git a/frontend/appflowy_flutter/test/widget_test/date_picker_test.dart b/frontend/appflowy_flutter/test/widget_test/date_picker_test.dartindex 8e9e916aa7..fc93fdeda0 100644--- a/frontend/appflowy_flutter/test/widget_test/date_picker_test.dart+++ b/frontend/appflowy_flutter/test/widget_test/date_picker_test.dart@@ -721,7 +721,7 @@ void main() {await tester.pumpAndSettle();await tester.pumpAndSettle();- final bday = DateTime(2024, 11, 30, 1);+ final day = DateTime(2024, 11, 30, 1);expect(find.descendant(@@ -737,7 +737,7 @@ void main() {find.descendant(of: find.byKey(const ValueKey('end_date_time_text_field')),matching: find.text(- DateFormat(DateFormatPB.Friendly.pattern).format(bday),+ DateFormat(DateFormatPB.Friendly.pattern).format(day),),),findsOneWidget,@@ -745,7 +745,7 @@ void main() {final mockState = getMockState(tester);expect(mockState.data.dateTime, fourteenth);- expect(mockState.data.endDateTime, bday);+ expect(mockState.data.endDateTime, day);});testWidgets(diff --git a/frontend/appflowy_flutter/test/widget_test/lib/features/share_section/shared_section_header_test.dart b/frontend/appflowy_flutter/test/widget_test/lib/features/share_section/shared_section_header_test.dartindex b1a2983dd6..180b1f92c6 100644--- a/frontend/appflowy_flutter/test/widget_test/lib/features/share_section/shared_section_header_test.dart+++ b/frontend/appflowy_flutter/test/widget_test/lib/features/share_section/shared_section_header_test.dart@@ -1,4 +1,6 @@import 'package:appflowy/features/shared_section/presentation/widgets/shared_section_header.dart';+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:easy_localization/easy_localization.dart';import 'package:flutter_test/flutter_test.dart';import '../../../widget_test_wrapper.dart';@@ -11,7 +13,7 @@ void main() {child: const SharedSectionHeader(),),);- expect(find.text('Shared'), findsOneWidget);+ expect(find.text(LocaleKeys.shareSection_shared.tr()), findsOneWidget);expect(find.byType(SharedSectionHeader), findsOneWidget);});});diff --git a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/access_level_list_widget_test.dart b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/access_level_list_widget_test.dartindex f3379206ae..495983547b 100644--- a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/access_level_list_widget_test.dart+++ b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/access_level_list_widget_test.dart@@ -1,6 +1,8 @@import 'package:appflowy/features/share_tab/data/models/models.dart';import 'package:appflowy/features/share_tab/presentation/widgets/access_level_list_widget.dart';+import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy_ui/appflowy_ui.dart';+import 'package:easy_localization/easy_localization.dart';import 'package:flutter_test/flutter_test.dart';import '../../../widget_test_wrapper.dart';@@ -47,12 +49,12 @@ void main() {expect(selectedLevel, ShareAccessLevel.readOnly);// Tap on Turn into Member- await tester.tap(find.text('Turn into Member'));+ await tester.tap(find.text(LocaleKeys.shareTab_turnIntoMember.tr()));await tester.pumpAndSettle();expect(turnedIntoMember, isTrue);// Tap on Remove access- await tester.tap(find.text('Remove access'));+ await tester.tap(find.text(LocaleKeys.shareTab_removeAccess.tr()));await tester.pumpAndSettle();expect(removedAccess, isTrue);});@@ -75,8 +77,11 @@ void main() {expect(find.text(ShareAccessLevel.readOnly.i18n), findsNothing);// Management options should be present- expect(find.text('Turn into Member'), findsOneWidget);- expect(find.text('Remove access'), findsOneWidget);+ expect(+ find.text(LocaleKeys.shareTab_turnIntoMember.tr()),+ findsOneWidget,+ );+ expect(find.text(LocaleKeys.shareTab_removeAccess.tr()), findsOneWidget);});});}diff --git a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/copy_link_widget_test.dart b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/copy_link_widget_test.dartindex 97d5beb8c9..5a7f6541f0 100644--- a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/copy_link_widget_test.dart+++ b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/copy_link_widget_test.dart@@ -1,8 +1,10 @@import 'package:appflowy/features/share_tab/data/repositories/local_share_with_user_repository.dart';import 'package:appflowy/features/share_tab/logic/share_with_user_bloc.dart';import 'package:appflowy/features/share_tab/presentation/widgets/copy_link_widget.dart';+import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/clipboard_service.dart';import 'package:appflowy/startup/startup.dart';+import 'package:easy_localization/easy_localization.dart';import 'package:flutter_bloc/flutter_bloc.dart';import 'package:flutter_test/flutter_test.dart';import 'package:mocktail/mocktail.dart';@@ -42,8 +44,8 @@ void main() {);expect(find.text(testLink), findsOneWidget);- expect(find.text('Copy link'), findsOneWidget);- await tester.tap(find.text('Copy link'));+ expect(find.text(LocaleKeys.shareTab_copyLink.tr()), findsOneWidget);+ await tester.tap(find.text(LocaleKeys.shareTab_copyLink.tr()));await tester.pumpAndSettle();// Timer (duration: 0:00:03.000000, periodic: false), created:// #0 new FakeTimer._ (package:fake_async/fake_async.dart:308:62)diff --git a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/people_with_access_section_test.dart b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/people_with_access_section_test.dartindex f646e24985..db5577590a 100644--- a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/people_with_access_section_test.dart+++ b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/people_with_access_section_test.dart@@ -1,5 +1,5 @@import 'package:appflowy/features/share_tab/data/models/models.dart';-import 'package:appflowy/features/share_tab/presentation/widgets/people_with_acess_section.dart';+import 'package:appflowy/features/share_tab/presentation/widgets/people_with_access_section.dart';import 'package:flutter_test/flutter_test.dart';import '../../../widget_test_wrapper.dart';diff --git a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/share_with_user_widget_test.dart b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/share_with_user_widget_test.dartindex 4931e1051f..4a49bf32c0 100644--- a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/share_with_user_widget_test.dart+++ b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/share_with_user_widget_test.dart@@ -1,4 +1,6 @@import 'package:appflowy/features/share_tab/presentation/widgets/share_with_user_widget.dart';+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:easy_localization/easy_localization.dart';import 'package:flutter/material.dart';import 'package:flutter_test/flutter_test.dart';@@ -17,10 +19,10 @@ void main() {),);expect(find.byType(TextField), findsOneWidget);- expect(find.text('Invite'), findsOneWidget);+ expect(find.text(LocaleKeys.shareTab_invite.tr()), findsOneWidget);await tester.enterText(find.byType(TextField), '[email protected]');await tester.pumpAndSettle();- await tester.tap(find.text('Invite'));+ await tester.tap(find.text(LocaleKeys.shareTab_invite.tr()));await tester.pumpAndSettle();expect(invited, isNotNull);expect(invited, contains('[email protected]'));diff --git a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/shared_group_widget_test.dart b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/shared_group_widget_test.dartindex b71f8da708..26b0f1143a 100644--- a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/shared_group_widget_test.dart+++ b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/shared_group_widget_test.dart@@ -1,4 +1,6 @@import 'package:appflowy/features/share_tab/presentation/widgets/shared_group_widget.dart';+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:easy_localization/easy_localization.dart';import 'package:flutter_test/flutter_test.dart';import '../../../widget_test_wrapper.dart';@@ -12,9 +14,12 @@ void main() {child: SharedGroupWidget(),),);- expect(find.text('Anyone at AppFlowy'), findsOneWidget);expect(- find.text('Anyone in this group with the link can edit'),+ find.text(LocaleKeys.shareTab_anyoneAtWorkspace.tr()),+ findsOneWidget,+ );+ expect(+ find.text(LocaleKeys.shareTab_anyoneInGroupWithLinkCanEdit.tr()),findsOneWidget,);// Trailing widget: EditAccessLevelWidget (disabled)diff --git a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/shared_user_widget_test.dart b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/shared_user_widget_test.dartindex f5178236ee..84944eb6cb 100644--- a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/shared_user_widget_test.dart+++ b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/shared_user_widget_test.dart@@ -1,5 +1,7 @@import 'package:appflowy/features/share_tab/data/models/models.dart';import 'package:appflowy/features/share_tab/presentation/widgets/shared_user_widget.dart';+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:easy_localization/easy_localization.dart';import 'package:flutter_test/flutter_test.dart';import '../../../widget_test_wrapper.dart';@@ -24,7 +26,7 @@ void main() {);expect(find.text('Test User'), findsOneWidget);expect(find.text('[email protected]'), findsOneWidget);- expect(find.text('(You)'), findsOneWidget);+ expect(find.text(LocaleKeys.shareTab_you.tr()), findsOneWidget);});testWidgets('shows Guest label for guest user',@@ -43,7 +45,7 @@ void main() {),),);- expect(find.text('Guest'), findsOneWidget);+ expect(find.text(LocaleKeys.shareTab_guest.tr()), findsOneWidget);});});}diff --git a/frontend/resources/translations/en-US.json b/frontend/resources/translations/en-US.jsonindex 5c65fd37c2..6bd2318e19 100644--- a/frontend/resources/translations/en-US.json+++ b/frontend/resources/translations/en-US.json@@ -3410,5 +3410,27 @@"tryAgain": "Try again","rewrite": "Rewrite","insertBelow": "Insert below"+ },+ "shareTab": {+ "accessLevel": {+ "view": "View",+ "comment": "Comment",+ "edit": "Edit",+ "fullAccess": "Full access"+ },+ "inviteByEmail": "Invite by email",+ "invite": "Invite",+ "anyoneAtWorkspace": "Anyone at {workspace}",+ "anyoneInGroupWithLinkCanEdit": "Anyone in this group with the link can edit",+ "copyLink": "Copy link",+ "copiedLinkToClipboard": "Copied link to clipboard",+ "removeAccess": "Remove access",+ "turnIntoMember": "Turn into Member",+ "you": "(You)",+ "guest": "Guest"+ },+ "shareSection": {+ "shared": "Shared",+ "refresh": "Refresh"}-}+}\ No newline at end of file