Skip to content

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.

feat: refactor share menu (#7935)

Lucas03d35f8fe187
diff --git a/frontend/Makefile.toml b/frontend/Makefile.toml
index 8e0bb5b697..66dc4a5338 100644
--- a/frontend/Makefile.toml
+++ b/frontend/Makefile.toml
@@ -26,7 +26,7 @@ CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
CARGO_MAKE_CRATE_FS_NAME = "dart_ffi"
CARGO_MAKE_CRATE_NAME = "dart-ffi"
LIB_NAME = "dart_ffi"
-APPFLOWY_VERSION = "0.9.2"
+APPFLOWY_VERSION = "0.9.3"
FLUTTER_DESKTOP_FEATURES = "dart"
PRODUCT_NAME = "AppFlowy"
MACOSX_DEPLOYMENT_TARGET = "11.0"
diff --git a/frontend/appflowy_flutter/integration_test/desktop/cloud/workspace/workspace_test_runner.dart b/frontend/appflowy_flutter/integration_test/desktop/cloud/workspace/workspace_test_runner.dart
index 4d2862038e..7fbd55e1ad 100644
--- a/frontend/appflowy_flutter/integration_test/desktop/cloud/workspace/workspace_test_runner.dart
+++ b/frontend/appflowy_flutter/integration_test/desktop/cloud/workspace/workspace_test_runner.dart
@@ -5,12 +5,13 @@ import 'collaborative_workspace_test.dart' as collaborative_workspace_test;
import 'share_menu_test.dart' as share_menu_test;
import 'tabs_test.dart' as tabs_test;
import 'workspace_icon_test.dart' as workspace_icon_test;
-import 'workspace_settings_test.dart' as workspace_settings_test;
+// import 'workspace_settings_test.dart' as workspace_settings_test;
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
- workspace_settings_test.main();
+ // Enable it after implementing the share feature
+ // workspace_settings_test.main();
share_menu_test.main();
collaborative_workspace_test.main();
change_name_and_icon_test.main();
diff --git a/frontend/appflowy_flutter/lib/ai/widgets/ai_prompt_modal/ai_prompt_database_modal.dart b/frontend/appflowy_flutter/lib/ai/widgets/ai_prompt_modal/ai_prompt_database_modal.dart
index cb00ef74c5..a878563cb7 100644
--- a/frontend/appflowy_flutter/lib/ai/widgets/ai_prompt_modal/ai_prompt_database_modal.dart
+++ b/frontend/appflowy_flutter/lib/ai/widgets/ai_prompt_modal/ai_prompt_database_modal.dart
@@ -575,7 +575,7 @@ class _FieldSelectorState extends State<FieldSelector> {
padding: EdgeInsets.all(theme.spacing.m),
itemBuilder: (context, index) {
if (widget.isOptional && index == 0) {
- return AFMenuItem(
+ return AFTextMenuItem(
title: LocaleKeys.ai_customPrompt_selectField.tr(),
onTap: () {
widget.onSelect?.call(null);
@@ -591,7 +591,7 @@ class _FieldSelectorState extends State<FieldSelector> {
);
}
final field = fields[index - (widget.isOptional ? 1 : 0)];
- return AFMenuItem(
+ return AFTextMenuItem(
title: field.name,
trailing: field.id == selectedField?.id
? FlowySvg(
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/data/models/models.dart b/frontend/appflowy_flutter/lib/features/share_tab/data/models/models.dart
new file mode 100644
index 0000000000..93b5234c57
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/data/models/models.dart
@@ -0,0 +1,4 @@
+export 'share_access_level.dart';
+export 'share_popover_group_id.dart';
+export 'share_role.dart';
+export 'shared_user.dart';
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.dart
new file mode 100644
index 0000000000..c5e4d34f20
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/data/models/share_access_level.dart
@@ -0,0 +1,27 @@
+/// The access level a user can have on a shared page.
+enum ShareAccessLevel {
+ /// Can view the page only.
+ readOnly,
+
+ /// Can read and comment on the page.
+ readAndComment,
+
+ /// Can read and write to the page.
+ readAndWrite,
+
+ /// Full access (edit, share, remove, etc.) and can add new users.
+ fullAccess;
+
+ String get i18n {
+ switch (this) {
+ case ShareAccessLevel.readOnly:
+ return 'View';
+ case ShareAccessLevel.readAndComment:
+ return 'Comment';
+ case ShareAccessLevel.readAndWrite:
+ return 'Edit';
+ case ShareAccessLevel.fullAccess:
+ return 'Full access';
+ }
+ }
+}
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/data/models/share_popover_group_id.dart b/frontend/appflowy_flutter/lib/features/share_tab/data/models/share_popover_group_id.dart
new file mode 100644
index 0000000000..a793507df5
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/data/models/share_popover_group_id.dart
@@ -0,0 +1 @@
+class SharePopoverGroupId {}
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/data/models/share_role.dart b/frontend/appflowy_flutter/lib/features/share_tab/data/models/share_role.dart
new file mode 100644
index 0000000000..5a50fd14e7
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/data/models/share_role.dart
@@ -0,0 +1,10 @@
+enum ShareRole {
+ /// The owner of the shared page.
+ owner,
+
+ /// A guest on the shared page.
+ guest,
+
+ /// A member of the shared page.
+ member,
+}
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.dart
new file mode 100644
index 0000000000..1597c2c3c5
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/data/models/shared_user.dart
@@ -0,0 +1,29 @@
+import 'package:appflowy/features/share_tab/data/models/share_access_level.dart';
+import 'package:appflowy/features/share_tab/data/models/share_role.dart';
+
+/// Represents a user with a role on a shared page.
+class SharedUser {
+ SharedUser({
+ required this.email,
+ required this.name,
+ required this.role,
+ required this.accessLevel,
+ this.avatarUrl,
+ });
+
+ final String email;
+
+ /// The name of the user.
+ final String name;
+
+ /// The role of the user.
+ final ShareRole role;
+
+ /// The access level of the user.
+ final ShareAccessLevel accessLevel;
+
+ /// The avatar URL of the user.
+ ///
+ /// if the avatar is not set, it will be the first letter of the name.
+ final String? avatarUrl;
+}
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/mock_share_repository.dart b/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/mock_share_repository.dart
new file mode 100644
index 0000000000..450523efb8
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/mock_share_repository.dart
@@ -0,0 +1,145 @@
+import 'dart:math';
+
+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';
+
+import 'share_repository.dart';
+
+class MockShareRepository extends ShareRepository {
+ MockShareRepository();
+
+ final List<SharedUser> _sharedUsers = [
+ SharedUser(
+ email: '[email protected]',
+ name: 'Lucas Xu',
+ accessLevel: ShareAccessLevel.readOnly,
+ role: ShareRole.guest,
+ avatarUrl: 'https://avatar.iran.liara.run/public',
+ ),
+ SharedUser(
+ email: '[email protected]',
+ name: 'Vivian Wang',
+ accessLevel: ShareAccessLevel.readAndWrite,
+ role: ShareRole.member,
+ avatarUrl: 'https://avatar.iran.liara.run/public/girl',
+ ),
+ SharedUser(
+ email: '[email protected]',
+ name: 'Shuheng',
+ accessLevel: ShareAccessLevel.fullAccess,
+ role: ShareRole.owner,
+ avatarUrl: 'https://avatar.iran.liara.run/public/boy',
+ ),
+ SharedUser(
+ email: '[email protected]',
+ name: 'Guest User 1',
+ accessLevel: ShareAccessLevel.readOnly,
+ role: ShareRole.guest,
+ avatarUrl: 'https://avatar.iran.liara.run/public/boy/10',
+ ),
+ SharedUser(
+ email: '[email protected]',
+ name: 'Guest User 2',
+ accessLevel: ShareAccessLevel.readOnly,
+ role: ShareRole.owner,
+ avatarUrl: 'https://avatar.iran.liara.run/public/boy/11',
+ ),
+ SharedUser(
+ email: '[email protected]',
+ name: 'Member User 1',
+ accessLevel: ShareAccessLevel.readAndWrite,
+ role: ShareRole.member,
+ avatarUrl: 'https://avatar.iran.liara.run/public/boy/12',
+ ),
+ SharedUser(
+ email: '[email protected]',
+ name: 'Member User 2',
+ accessLevel: ShareAccessLevel.readAndWrite,
+ role: ShareRole.member,
+ avatarUrl: 'https://avatar.iran.liara.run/public/boy/13',
+ ),
+ ];
+
+ final List<SharedUser> _availableSharedUsers = [
+ SharedUser(
+ email: '[email protected]',
+ name: 'Guest',
+ accessLevel: ShareAccessLevel.readOnly,
+ role: ShareRole.guest,
+ avatarUrl: 'https://avatar.iran.liara.run/public/boy/28',
+ ),
+ SharedUser(
+ email: '[email protected]',
+ name: 'Richard',
+ accessLevel: ShareAccessLevel.readAndWrite,
+ role: ShareRole.member,
+ avatarUrl: 'https://avatar.iran.liara.run/public/boy/28',
+ ),
+ ];
+
+ @override
+ Future<FlowyResult<List<SharedUser>, FlowyError>> getSharedUsersInPage({
+ required String pageId,
+ }) async {
+ return FlowySuccess(_sharedUsers);
+ }
+
+ @override
+ Future<FlowyResult<void, FlowyError>> removeSharedUserFromPage({
+ required String pageId,
+ required List<String> emails,
+ }) async {
+ for (final email in emails) {
+ _sharedUsers.removeWhere((user) => user.email == email);
+ }
+
+ return FlowySuccess(null);
+ }
+
+ @override
+ Future<FlowyResult<void, FlowyError>> sharePageWithUser({
+ required String pageId,
+ required ShareAccessLevel accessLevel,
+ required List<String> emails,
+ }) async {
+ for (final email in emails) {
+ final index = _sharedUsers.indexWhere((user) => user.email == email);
+ if (index != -1) {
+ // Update access level if user exists
+ final user = _sharedUsers[index];
+ _sharedUsers[index] = SharedUser(
+ name: user.name,
+ email: user.email,
+ accessLevel: accessLevel,
+ role: user.role,
+ avatarUrl: user.avatarUrl,
+ );
+ } else {
+ // Add new user
+ _sharedUsers.add(
+ SharedUser(
+ name: email.split('@').first,
+ email: email,
+ accessLevel: accessLevel,
+ role: ShareRole.guest,
+ avatarUrl:
+ 'https://avatar.iran.liara.run/public/${Random().nextInt(100)}',
+ ),
+ );
+ }
+ }
+
+ return FlowySuccess(null);
+ }
+
+ @override
+ Future<FlowyResult<List<SharedUser>, FlowyError>> getAvailableSharedUsers({
+ required String pageId,
+ }) async {
+ return FlowySuccess([
+ ..._sharedUsers,
+ ..._availableSharedUsers,
+ ]);
+ }
+}
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/rust_share_repository.dart b/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/rust_share_repository.dart
new file mode 100644
index 0000000000..9c400d6360
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/rust_share_repository.dart
@@ -0,0 +1,175 @@
+import 'package:appflowy/features/share_tab/data/models/models.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_result/appflowy_result.dart';
+
+import 'share_repository.dart';
+
+class RustShareRepository extends ShareRepository {
+ RustShareRepository();
+
+ @override
+ Future<FlowyResult<List<SharedUser>, FlowyError>> getSharedUsersInPage({
+ required String pageId,
+ }) async {
+ final request = GetSharedUsersPayloadPB(
+ viewId: pageId,
+ );
+ final result = await FolderEventGetSharedUsers(request).send();
+
+ return result.fold(
+ (success) {
+ Log.info('get shared users: $success');
+
+ return FlowySuccess(success.sharedUsers);
+ },
+ (failure) {
+ Log.error('getUsersInSharedPage: $failure');
+
+ return FlowyFailure(failure);
+ },
+ );
+ }
+
+ @override
+ Future<FlowyResult<void, FlowyError>> removeSharedUserFromPage({
+ required String pageId,
+ required List<String> emails,
+ }) async {
+ final request = RemoveUserFromSharedPagePayloadPB(
+ viewId: pageId,
+ emails: emails,
+ );
+ final result = await FolderEventRemoveUserFromSharedPage(request).send();
+
+ return result.fold(
+ (success) {
+ Log.info('remove users($emails) from shared page($pageId)');
+
+ return FlowySuccess(success);
+ },
+ (failure) {
+ Log.error('removeUserFromPage: $failure');
+
+ return FlowyFailure(failure);
+ },
+ );
+ }
+
+ @override
+ Future<FlowyResult<void, FlowyError>> sharePageWithUser({
+ required String pageId,
+ required ShareAccessLevel accessLevel,
+ required List<String> emails,
+ }) async {
+ final request = SharePageWithUserPayloadPB(
+ viewId: pageId,
+ emails: emails,
+ accessLevel: accessLevel.accessLevel,
+ );
+ final result = await FolderEventSharePageWithUser(request).send();
+
+ return result.fold(
+ (success) {
+ Log.info(
+ 'share page($pageId) with users($emails) with access level($accessLevel)',
+ );
+
+ return FlowySuccess(success);
+ },
+ (failure) {
+ Log.error('sharePageWithUser: $failure');
+
+ return FlowyFailure(failure);
+ },
+ );
+ }
+
+ @override
+ Future<FlowyResult<List<SharedUser>, FlowyError>> getAvailableSharedUsers({
+ required String pageId,
+ }) async {
+ // TODO: Implement this
+ return FlowySuccess([]);
+ }
+}
+
+extension on RepeatedSharedUserPB {
+ List<SharedUser> get sharedUsers {
+ return items.map((e) => e.sharedUser).toList();
+ }
+}
+
+extension on SharedUserPB {
+ SharedUser get sharedUser {
+ return SharedUser(
+ email: email,
+ name: name,
+ accessLevel: accessLevel.shareRole,
+ role: role.shareRole,
+ avatarUrl: avatarUrl,
+ );
+ }
+}
+
+extension on AFAccessLevelPB {
+ ShareAccessLevel get shareRole {
+ switch (this) {
+ case AFAccessLevelPB.ReadOnly:
+ return ShareAccessLevel.readOnly;
+ case AFAccessLevelPB.ReadAndComment:
+ return ShareAccessLevel.readAndComment;
+ case AFAccessLevelPB.ReadAndWrite:
+ return ShareAccessLevel.readAndWrite;
+ case AFAccessLevelPB.FullAccess:
+ return ShareAccessLevel.fullAccess;
+ default:
+ throw Exception('Unknown share role: $this');
+ }
+ }
+}
+
+extension on ShareAccessLevel {
+ AFAccessLevelPB get accessLevel {
+ switch (this) {
+ case ShareAccessLevel.readOnly:
+ return AFAccessLevelPB.ReadOnly;
+ case ShareAccessLevel.readAndComment:
+ return AFAccessLevelPB.ReadAndComment;
+ case ShareAccessLevel.readAndWrite:
+ return AFAccessLevelPB.ReadAndWrite;
+ case ShareAccessLevel.fullAccess:
+ return AFAccessLevelPB.FullAccess;
+ }
+ }
+}
+
+extension on AFRolePB {
+ ShareRole get shareRole {
+ switch (this) {
+ case AFRolePB.Guest:
+ return ShareRole.guest;
+ case AFRolePB.Member:
+ return ShareRole.member;
+ case AFRolePB.Owner:
+ return ShareRole.owner;
+ default:
+ throw Exception('Unknown share role: $this');
+ }
+ }
+}
+
+// extension on ShareRole {
+// AFRolePB get role {
+// switch (this) {
+// case ShareRole.guest:
+// return AFRolePB.Guest;
+// case ShareRole.member:
+// return AFRolePB.Member;
+// case ShareRole.owner:
+// return AFRolePB.Owner;
+// }
+// }
+// }
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/share_repository.dart b/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/share_repository.dart
new file mode 100644
index 0000000000..dd5eb80fb9
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/share_repository.dart
@@ -0,0 +1,35 @@
+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_backend/protobuf/flowy-error/errors.pb.dart';
+import 'package:appflowy_result/appflowy_result.dart';
+
+/// Abstract repository for sharing pages with users.
+///
+/// For example, we're using rust events now, but we can still use the http api
+/// for the future.
+abstract class ShareRepository {
+ /// Gets the list of users and their roles for a shared page.
+ Future<FlowyResult<List<SharedUser>, FlowyError>> getSharedUsersInPage({
+ required String pageId,
+ });
+
+ /// Gets the list of users that are available to be shared with.
+ Future<FlowyResult<List<SharedUser>, FlowyError>> getAvailableSharedUsers({
+ required String pageId,
+ });
+
+ /// Removes a user from a shared page.
+ Future<FlowyResult<void, FlowyError>> removeSharedUserFromPage({
+ required String pageId,
+ required List<String> emails,
+ });
+
+ /// Shares a page with a user, assigning a role.
+ ///
+ /// If the user is already in the shared page, the access level will be updated.
+ Future<FlowyResult<void, FlowyError>> sharePageWithUser({
+ required String pageId,
+ required ShareAccessLevel accessLevel,
+ required List<String> emails,
+ });
+}
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/logic/share_with_user_bloc.dart b/frontend/appflowy_flutter/lib/features/share_tab/logic/share_with_user_bloc.dart
new file mode 100644
index 0000000000..6c451da245
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/logic/share_with_user_bloc.dart
@@ -0,0 +1,335 @@
+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/repositories/share_repository.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/clipboard_service.dart';
+import 'package:appflowy/plugins/shared/share/constants.dart';
+import 'package:appflowy/startup/startup.dart';
+import 'package:appflowy/user/application/user_service.dart';
+import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
+import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';
+import 'package:appflowy_result/appflowy_result.dart';
+import 'package:bloc/bloc.dart';
+import 'package:freezed_annotation/freezed_annotation.dart';
+
+part 'share_with_user_bloc.freezed.dart';
+
+class ShareWithUserBloc extends Bloc<ShareWithUserEvent, ShareWithUserState> {
+ ShareWithUserBloc({
+ required this.repository,
+ required this.pageId,
+ required this.workspaceId,
+ }) : super(ShareWithUserState.initial()) {
+ on<Initial>(_onInitial);
+ on<GetSharedUsers>(_onGetSharedUsers);
+ on<ShareWithUser>(_onShare);
+ on<RemoveUser>(_onRemove);
+ on<UpdateAccessLevel>(_onUpdateAccessLevel);
+ on<UpdateGeneralAccess>(_onUpdateGeneralAccess);
+ on<CopyLink>(_onCopyLink);
+ on<SearchAvailableUsers>(_onSearchAvailableUsers);
+ }
+
+ final ShareRepository repository;
+ final String workspaceId;
+ final String pageId;
+
+ Future<void> _onInitial(
+ Initial event,
+ Emitter<ShareWithUserState> emit,
+ ) async {
+ final result = await UserBackendService.getCurrentUserProfile();
+ final currentUser = result.fold(
+ (user) => user,
+ (error) => null,
+ );
+
+ final shareLink = ShareConstants.buildShareUrl(
+ workspaceId: workspaceId,
+ viewId: pageId,
+ );
+
+ final shareResult = await repository.getSharedUsersInPage(
+ pageId: pageId,
+ );
+
+ final users = shareResult.fold(
+ (users) => users,
+ (error) => <SharedUser>[],
+ );
+
+ emit(
+ state.copyWith(
+ currentUser: currentUser,
+ shareLink: shareLink,
+ users: users,
+ ),
+ );
+ }
+
+ Future<void> _onGetSharedUsers(
+ GetSharedUsers event,
+ Emitter<ShareWithUserState> emit,
+ ) async {
+ emit(
+ state.copyWith(
+ errorMessage: '',
+ initialResult: null,
+ ),
+ );
+
+ final result = await repository.getSharedUsersInPage(
+ pageId: pageId,
+ );
+
+ result.fold(
+ (users) => emit(
+ state.copyWith(
+ users: users,
+ initialResult: FlowySuccess(null),
+ ),
+ ),
+ (error) => emit(
+ state.copyWith(
+ errorMessage: error.msg,
+ initialResult: FlowyFailure(error),
+ ),
+ ),
+ );
+ }
+
+ Future<void> _onShare(
+ ShareWithUser event,
+ Emitter<ShareWithUserState> emit,
+ ) async {
+ emit(
+ state.copyWith(
+ errorMessage: '',
+ shareResult: null,
+ ),
+ );
+
+ final result = await repository.sharePageWithUser(
+ pageId: pageId,
+ accessLevel: event.accessLevel,
+ emails: event.emails,
+ );
+
+ result.fold(
+ (_) {
+ emit(
+ state.copyWith(
+ shareResult: FlowySuccess(null),
+ ),
+ );
+
+ add(
+ const ShareWithUserEvent.getSharedUsers(),
+ );
+ },
+ (error) {
+ emit(
+ state.copyWith(
+ errorMessage: error.msg,
+ shareResult: FlowyFailure(error),
+ ),
+ );
+ },
+ );
+ }
+
+ Future<void> _onRemove(
+ RemoveUser event,
+ Emitter<ShareWithUserState> emit,
+ ) async {
+ emit(
+ state.copyWith(
+ removeResult: null,
+ ),
+ );
+
+ final result = await repository.removeSharedUserFromPage(
+ pageId: pageId,
+ emails: event.emails,
+ );
+
+ result.fold(
+ (_) {
+ emit(
+ state.copyWith(
+ removeResult: FlowySuccess(null),
+ ),
+ );
+
+ add(
+ const ShareWithUserEvent.getSharedUsers(),
+ );
+ },
+ (error) {
+ emit(
+ state.copyWith(
+ isLoading: false,
+ removeResult: FlowyFailure(error),
+ ),
+ );
+ },
+ );
+ }
+
+ Future<void> _onUpdateAccessLevel(
+ UpdateAccessLevel event,
+ Emitter<ShareWithUserState> emit,
+ ) async {
+ emit(
+ state.copyWith(
+ updateAccessLevelResult: null,
+ ),
+ );
+
+ final result = await repository.sharePageWithUser(
+ pageId: pageId,
+ accessLevel: event.accessLevel,
+ emails: [event.email],
+ );
+
+ result.fold(
+ (_) {
+ emit(
+ state.copyWith(
+ updateAccessLevelResult: FlowySuccess(null),
+ ),
+ );
+
+ add(
+ const ShareWithUserEvent.getSharedUsers(),
+ );
+ },
+ (error) => emit(
+ state.copyWith(
+ errorMessage: error.msg,
+ isLoading: false,
+ ),
+ ),
+ );
+ }
+
+ void _onUpdateGeneralAccess(
+ UpdateGeneralAccess event,
+ Emitter<ShareWithUserState> emit,
+ ) {
+ emit(
+ state.copyWith(
+ generalAccessRole: event.accessLevel,
+ ),
+ );
+ }
+
+ void _onCopyLink(CopyLink event, Emitter<ShareWithUserState> emit) {
+ getIt<ClipboardService>().setData(
+ ClipboardServiceData(
+ plainText: event.link,
+ ),
+ );
+
+ emit(
+ state.copyWith(
+ linkCopied: true,
+ ),
+ );
+ }
+
+ Future<void> _onSearchAvailableUsers(
+ SearchAvailableUsers event,
+ Emitter<ShareWithUserState> emit,
+ ) async {
+ emit(
+ state.copyWith(
+ errorMessage: '',
+ ),
+ );
+
+ final result = await repository.getAvailableSharedUsers(pageId: pageId);
+
+ result.fold(
+ (users) {
+ // filter by email and name
+ final availableUsers = users.where((user) {
+ final query = event.query.toLowerCase();
+ return user.name.toLowerCase().contains(query) ||
+ user.email.toLowerCase().contains(query);
+ }).toList();
+ emit(
+ state.copyWith(
+ availableUsers: availableUsers,
+ ),
+ );
+ },
+ (error) => emit(
+ state.copyWith(
+ errorMessage: error.msg,
+ availableUsers: [],
+ ),
+ ),
+ );
+ }
+}
+
+@freezed
+class ShareWithUserEvent with _$ShareWithUserEvent {
+ /// Initializes the bloc.
+ const factory ShareWithUserEvent.init() = Initial;
+
+ /// Loads the shared users for the page.
+ const factory ShareWithUserEvent.getSharedUsers() = GetSharedUsers;
+
+ /// Invites the users to the page.
+ const factory ShareWithUserEvent.share({
+ required List<String> emails,
+ required ShareAccessLevel accessLevel,
+ }) = ShareWithUser;
+
+ /// Removes the users from the page.
+ const factory ShareWithUserEvent.remove({
+ required List<String> emails,
+ }) = RemoveUser;
+
+ /// Updates the access level of the user.
+ const factory ShareWithUserEvent.updateAccessLevel({
+ required String email,
+ required ShareAccessLevel accessLevel,
+ }) = UpdateAccessLevel;
+
+ /// Updates the general access role for all users.
+ const factory ShareWithUserEvent.updateGeneralAccess({
+ required ShareAccessLevel accessLevel,
+ }) = UpdateGeneralAccess;
+
+ /// Copies the link to the clipboard.
+ const factory ShareWithUserEvent.copyLink({
+ required String link,
+ }) = CopyLink;
+
+ /// Searches available users by name or email.
+ const factory ShareWithUserEvent.searchAvailableUsers({
+ required String query,
+ }) = SearchAvailableUsers;
+}
+
+@freezed
+class ShareWithUserState with _$ShareWithUserState {
+ const factory ShareWithUserState({
+ @Default(null) UserProfilePB? currentUser,
+ @Default([]) List<SharedUser> users,
+ @Default([]) List<SharedUser> availableUsers,
+ @Default(false) bool isLoading,
+ @Default('') String errorMessage,
+ @Default('') String shareLink,
+ ShareAccessLevel? generalAccessRole,
+ @Default(false) bool linkCopied,
+ @Default(null) FlowyResult<void, FlowyError>? initialResult,
+ @Default(null) FlowyResult<void, FlowyError>? shareResult,
+ @Default(null) FlowyResult<void, FlowyError>? removeResult,
+ @Default(null) FlowyResult<void, FlowyError>? updateAccessLevelResult,
+ }) = _ShareWithUserState;
+
+ factory ShareWithUserState.initial() => const ShareWithUserState();
+}
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.dart
new file mode 100644
index 0000000000..ee49c7be75
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/share_tab.dart
@@ -0,0 +1,99 @@
+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/share_with_user_widget.dart';
+import 'package:appflowy_ui/appflowy_ui.dart';
+import 'package:flowy_infra_ui/flowy_infra_ui.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+
+class ShareTab extends StatelessWidget {
+ const ShareTab({
+ super.key,
+ required this.workspaceId,
+ required this.pageId,
+ });
+
+ final String workspaceId;
+ final String pageId;
+
+ @override
+ Widget build(BuildContext context) {
+ final theme = AppFlowyTheme.of(context);
+
+ return BlocBuilder<ShareWithUserBloc, ShareWithUserState>(
+ builder: (context, state) {
+ if (state.isLoading) {
+ return const SizedBox.shrink();
+ }
+
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ // share page with user by email
+ VSpace(theme.spacing.l),
+ ShareWithUserWidget(
+ onInvite: (emails) => _onSharePageWithUser(
+ context,
+ emails: emails,
+ accessLevel: ShareAccessLevel.readOnly,
+ ),
+ ),
+
+ // 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),
+ ),
+
+ // general access
+ VSpace(theme.spacing.m),
+ GeneralAccessSection(),
+
+ // copy link
+ VSpace(theme.spacing.l),
+ const AFDivider(),
+ VSpace(theme.spacing.xl),
+ CopyLinkWidget(shareLink: state.shareLink),
+ VSpace(theme.spacing.m),
+ ],
+ );
+ },
+ );
+ }
+
+ void _onSharePageWithUser(
+ BuildContext context, {
+ required List<String> emails,
+ required ShareAccessLevel accessLevel,
+ }) {
+ context.read<ShareWithUserBloc>().add(
+ ShareWithUserEvent.share(emails: emails, accessLevel: accessLevel),
+ );
+ }
+
+ PeopleWithAccessSectionCallbacks _buildPeopleWithAccessSectionCallbacks(
+ BuildContext context,
+ ) {
+ return PeopleWithAccessSectionCallbacks(
+ onSelectAccessLevel: (user, accessLevel) {
+ // do nothing. the event doesn't support in the backend yet
+ },
+ onTurnIntoMember: (user) {
+ // do nothing. the event doesn't support in the backend yet
+ },
+ onRemoveAccess: (user) {
+ context.read<ShareWithUserBloc>().add(
+ ShareWithUserEvent.remove(emails: [user.email]),
+ );
+ },
+ );
+ }
+}
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.dart
new file mode 100644
index 0000000000..17bec3a02c
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/access_level_list_widget.dart
@@ -0,0 +1,139 @@
+import 'package:appflowy/features/share_tab/data/models/models.dart';
+import 'package:appflowy/generated/flowy_svgs.g.dart';
+import 'package:appflowy_ui/appflowy_ui.dart';
+import 'package:flutter/material.dart';
+
+class AccessLevelListCallbacks {
+ const AccessLevelListCallbacks({
+ required this.onSelectAccessLevel,
+ required this.onTurnIntoMember,
+ required this.onRemoveAccess,
+ });
+
+ factory AccessLevelListCallbacks.none() {
+ return AccessLevelListCallbacks(
+ onSelectAccessLevel: (_) {},
+ onTurnIntoMember: () {},
+ onRemoveAccess: () {},
+ );
+ }
+
+ /// Callback when an access level is selected
+ final void Function(ShareAccessLevel accessLevel) onSelectAccessLevel;
+
+ /// Callback when the "Turn into Member" option is selected
+ final VoidCallback onTurnIntoMember;
+
+ /// Callback when the "Remove access" option is selected
+ final VoidCallback onRemoveAccess;
+
+ /// Copy
+ AccessLevelListCallbacks copyWith({
+ VoidCallback? onRemoveAccess,
+ VoidCallback? onTurnIntoMember,
+ void Function(ShareAccessLevel accessLevel)? onSelectAccessLevel,
+ }) {
+ return AccessLevelListCallbacks(
+ onRemoveAccess: onRemoveAccess ?? this.onRemoveAccess,
+ onTurnIntoMember: onTurnIntoMember ?? this.onTurnIntoMember,
+ onSelectAccessLevel: onSelectAccessLevel ?? this.onSelectAccessLevel,
+ );
+ }
+}
+
+/// A widget that displays a list of access levels for sharing.
+///
+/// This widget is used in a popover to allow users to select different access levels
+/// for shared content, as well as options to turn users into members or remove access.
+class AccessLevelListWidget extends StatelessWidget {
+ const AccessLevelListWidget({
+ super.key,
+ this.enableAccessLevelSelection = false,
+ required this.selectedAccessLevel,
+ required this.callbacks,
+ });
+
+ /// Enable access level selection
+ final bool enableAccessLevelSelection;
+
+ /// The currently selected access level
+ final ShareAccessLevel selectedAccessLevel;
+
+ /// Callbacks
+ final AccessLevelListCallbacks callbacks;
+
+ @override
+ Widget build(BuildContext context) {
+ final theme = AppFlowyTheme.of(context);
+ return AFMenu(
+ width: enableAccessLevelSelection ? 240 : 160,
+ children: [
+ // Display all available access level options
+ if (enableAccessLevelSelection) ...[
+ _buildAccessLevelItem(
+ context,
+ accessLevel: ShareAccessLevel.fullAccess,
+ onTap: () =>
+ callbacks.onSelectAccessLevel(ShareAccessLevel.fullAccess),
+ ),
+ _buildAccessLevelItem(
+ context,
+ accessLevel: ShareAccessLevel.readAndWrite,
+ onTap: () =>
+ callbacks.onSelectAccessLevel(ShareAccessLevel.readAndWrite),
+ ),
+ _buildAccessLevelItem(
+ context,
+ accessLevel: ShareAccessLevel.readAndComment,
+ onTap: () =>
+ callbacks.onSelectAccessLevel(ShareAccessLevel.readAndComment),
+ ),
+ _buildAccessLevelItem(
+ context,
+ accessLevel: ShareAccessLevel.readOnly,
+ onTap: () =>
+ callbacks.onSelectAccessLevel(ShareAccessLevel.readOnly),
+ ),
+ AFDivider(spacing: theme.spacing.m),
+ ],
+
+ // Additional user management options
+ AFTextMenuItem(
+ title: 'Turn into Member',
+ onTap: callbacks.onTurnIntoMember,
+ ),
+ AFTextMenuItem(
+ title: 'Remove access',
+ titleColor: theme.textColorScheme.error,
+ onTap: callbacks.onRemoveAccess,
+ ),
+ ],
+ );
+ }
+
+ /// Builds an individual access level menu item
+ ///
+ /// @param context The build context
+ /// @param accessLevel The access level to display
+ /// @param onTap Callback when this item is tapped
+ /// @return A menu item widget for the specified access level
+ Widget _buildAccessLevelItem(
+ BuildContext context, {
+ required ShareAccessLevel accessLevel,
+ required VoidCallback onTap,
+ }) {
+ return AFTextMenuItem(
+ title: accessLevel.i18n,
+ showSelectedBackground: false,
+ selected: selectedAccessLevel == accessLevel,
+ // Show a checkmark icon for the currently selected access level
+ trailing: selectedAccessLevel == accessLevel
+ ? FlowySvg(
+ FlowySvgs.m_blue_check_s,
+ blendMode: null,
+ )
+ : null,
+ onTap: onTap,
+ );
+ }
+}
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.dart
new file mode 100644
index 0000000000..2abda4e3c2
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/copy_link_widget.dart
@@ -0,0 +1,53 @@
+import 'package:appflowy/features/share_tab/logic/share_with_user_bloc.dart';
+import 'package:appflowy/generated/flowy_svgs.g.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';
+import 'package:flutter_bloc/flutter_bloc.dart';
+
+class CopyLinkWidget extends StatelessWidget {
+ const CopyLinkWidget({
+ super.key,
+ required this.shareLink,
+ });
+
+ final String shareLink;
+
+ @override
+ Widget build(BuildContext context) {
+ final theme = AppFlowyTheme.of(context);
+ return Row(
+ children: [
+ Expanded(
+ child: AFTextField(
+ initialText: shareLink,
+ size: AFTextFieldSize.m,
+ readOnly: true,
+ ),
+ ),
+ HSpace(theme.spacing.s),
+ AFOutlinedIconTextButton.normal(
+ text: 'Copy link',
+ size: AFButtonSize.l,
+ padding: EdgeInsets.symmetric(
+ horizontal: theme.spacing.l,
+ vertical: theme.spacing.s,
+ ),
+ iconBuilder: (context, isHovering, disabled) => FlowySvg(
+ FlowySvgs.toolbar_link_m,
+ ),
+ onTap: () {
+ context.read<ShareWithUserBloc>().add(
+ ShareWithUserEvent.copyLink(link: shareLink),
+ );
+
+ showToastNotification(
+ message: 'Copied link to clipboard',
+ );
+ },
+ ),
+ ],
+ );
+ }
+}
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/edit_access_level_widget.dart b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/edit_access_level_widget.dart
new file mode 100644
index 0000000000..4bbef2d5fd
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/edit_access_level_widget.dart
@@ -0,0 +1,95 @@
+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/flowy_svgs.g.dart';
+import 'package:appflowy_ui/appflowy_ui.dart';
+import 'package:flowy_infra_ui/widget/spacing.dart';
+import 'package:flutter/material.dart';
+
+class EditAccessLevelWidget extends StatefulWidget {
+ const EditAccessLevelWidget({
+ super.key,
+ required this.callbacks,
+ required this.selectedAccessLevel,
+ this.disabled = false,
+ });
+
+ /// Callbacks
+ final AccessLevelListCallbacks callbacks;
+
+ /// The currently selected access level
+ final ShareAccessLevel selectedAccessLevel;
+
+ /// Whether the widget is disabled
+ final bool disabled;
+
+ @override
+ State<EditAccessLevelWidget> createState() => _EditAccessLevelWidgetState();
+}
+
+class _EditAccessLevelWidgetState extends State<EditAccessLevelWidget> {
+ final popoverController = AFPopoverController();
+
+ @override
+ void dispose() {
+ popoverController.dispose();
+
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final theme = AppFlowyTheme.of(context);
+
+ return AFPopover(
+ padding: EdgeInsets.zero,
+ decoration: BoxDecoration(), // the access level widget has a border
+ controller: popoverController,
+ popover: (_) {
+ return AccessLevelListWidget(
+ selectedAccessLevel: widget.selectedAccessLevel,
+ callbacks: widget.callbacks.copyWith(
+ onSelectAccessLevel: (accessLevel) {
+ widget.callbacks.onSelectAccessLevel(accessLevel);
+
+ popoverController.hide();
+ },
+ onRemoveAccess: () {
+ widget.callbacks.onRemoveAccess();
+
+ popoverController.hide();
+ },
+ ),
+ );
+ },
+ child: AFGhostButton.normal(
+ disabled: widget.disabled,
+ onTap: () {
+ popoverController.show();
+ },
+ padding: EdgeInsets.symmetric(
+ vertical: theme.spacing.s,
+ horizontal: theme.spacing.l,
+ ),
+ builder: (context, isHovering, disabled) {
+ return Row(
+ children: [
+ Text(
+ widget.selectedAccessLevel.i18n,
+ style: theme.textStyle.body.standard(
+ color: disabled
+ ? theme.textColorScheme.secondary
+ : theme.textColorScheme.primary,
+ ),
+ ),
+ HSpace(theme.spacing.xs),
+ FlowySvg(
+ FlowySvgs.arrow_down_s,
+ color: theme.textColorScheme.secondary,
+ ),
+ ],
+ );
+ },
+ ),
+ );
+ }
+}
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/general_access_section.dart b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/general_access_section.dart
new file mode 100644
index 0000000000..718ef8e9cc
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/general_access_section.dart
@@ -0,0 +1,21 @@
+import 'package:appflowy/features/share_tab/presentation/widgets/shared_group_widget.dart';
+import 'package:appflowy_ui/appflowy_ui.dart';
+import 'package:flutter/material.dart';
+
+class GeneralAccessSection extends StatelessWidget {
+ const GeneralAccessSection({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ final theme = AppFlowyTheme.of(context);
+ return AFMenuSection(
+ title: 'General access',
+ padding: EdgeInsets.symmetric(
+ vertical: theme.spacing.s,
+ ),
+ children: [
+ SharedGroupWidget(),
+ ],
+ );
+ }
+}
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_acess_section.dart
new file mode 100644
index 0000000000..ced7a8a501
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/people_with_acess_section.dart
@@ -0,0 +1,79 @@
+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/shared_user_widget.dart';
+import 'package:appflowy_ui/appflowy_ui.dart';
+import 'package:collection/collection.dart';
+import 'package:flutter/material.dart';
+
+class PeopleWithAccessSectionCallbacks {
+ const PeopleWithAccessSectionCallbacks({
+ required this.onRemoveAccess,
+ required this.onTurnIntoMember,
+ required this.onSelectAccessLevel,
+ });
+
+ factory PeopleWithAccessSectionCallbacks.none() {
+ return PeopleWithAccessSectionCallbacks(
+ onSelectAccessLevel: (_, __) {},
+ onTurnIntoMember: (_) {},
+ onRemoveAccess: (_) {},
+ );
+ }
+
+ /// Callback when an access level is selected
+ final void Function(SharedUser user, ShareAccessLevel accessLevel)
+ onSelectAccessLevel;
+
+ /// Callback when the "Turn into Member" option is selected
+ final void Function(SharedUser user) onTurnIntoMember;
+
+ /// Callback when the "Remove access" option is selected
+ final void Function(SharedUser user) onRemoveAccess;
+}
+
+class PeopleWithAccessSection extends StatelessWidget {
+ const PeopleWithAccessSection({
+ super.key,
+ required this.currentUserEmail,
+ required this.users,
+ this.callbacks,
+ });
+
+ final String currentUserEmail;
+ final List<SharedUser> users;
+ final PeopleWithAccessSectionCallbacks? callbacks;
+
+ @override
+ Widget build(BuildContext context) {
+ final theme = AppFlowyTheme.of(context);
+ final currentUser = users.firstWhereOrNull(
+ (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,
+ ),
+ children: users.map((user) {
+ return SharedUserWidget(
+ user: user,
+ currentUser: currentUser,
+ callbacks: AccessLevelListCallbacks(
+ onRemoveAccess: () => callbacks?.onRemoveAccess.call(user),
+ onTurnIntoMember: () => callbacks?.onTurnIntoMember.call(user),
+ onSelectAccessLevel: (accessLevel) =>
+ callbacks?.onSelectAccessLevel.call(user, accessLevel),
+ ),
+ );
+ }).toList(),
+ );
+ }
+}
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.dart
new file mode 100644
index 0000000000..d0e5ffd275
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/share_with_user_widget.dart
@@ -0,0 +1,67 @@
+import 'package:appflowy_ui/appflowy_ui.dart';
+import 'package:flowy_infra_ui/widget/spacing.dart';
+import 'package:flutter/material.dart';
+import 'package:string_validator/string_validator.dart';
+
+class ShareWithUserWidget extends StatefulWidget {
+ const ShareWithUserWidget({
+ super.key,
+ required this.onInvite,
+ });
+
+ final void Function(List<String> emails) onInvite;
+
+ @override
+ State<ShareWithUserWidget> createState() => _ShareWithUserWidgetState();
+}
+
+class _ShareWithUserWidgetState extends State<ShareWithUserWidget> {
+ final TextEditingController controller = TextEditingController();
+ bool isButtonEnabled = false;
+
+ @override
+ void initState() {
+ super.initState();
+
+ controller.addListener(_onTextChanged);
+ }
+
+ @override
+ void dispose() {
+ controller.dispose();
+
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final theme = AppFlowyTheme.of(context);
+
+ return Row(
+ children: [
+ Expanded(
+ child: AFTextField(
+ controller: controller,
+ size: AFTextFieldSize.m,
+ hintText: 'Invite by email',
+ ),
+ ),
+ HSpace(theme.spacing.s),
+ AFFilledTextButton.primary(
+ text: 'Invite',
+ disabled: !isButtonEnabled,
+ onTap: () {
+ widget.onInvite(controller.text.trim().split(','));
+ },
+ ),
+ ],
+ );
+ }
+
+ void _onTextChanged() {
+ setState(() {
+ final texts = controller.text.trim().split(',');
+ isButtonEnabled = texts.isNotEmpty && texts.every(isEmail);
+ });
+ }
+}
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.dart
new file mode 100644
index 0000000000..785dd0151e
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/shared_group_widget.dart
@@ -0,0 +1,76 @@
+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_ui/appflowy_ui.dart';
+import 'package:flowy_infra_ui/widget/spacing.dart';
+import 'package:flutter/material.dart';
+
+class SharedGroupWidget extends StatelessWidget {
+ const SharedGroupWidget({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ final theme = AppFlowyTheme.of(context);
+
+ return AFMenuItem(
+ padding: EdgeInsets.symmetric(
+ vertical: theme.spacing.s,
+ ),
+ leading: _buildLeading(context),
+ title: _buildTitle(context),
+ subtitle: _buildSubtitle(context),
+ trailing: _buildTrailing(context),
+ );
+ }
+
+ Widget _buildLeading(BuildContext context) {
+ return AFAvatar(
+ child: Padding(
+ padding: const EdgeInsets.all(3.0),
+ child: FlowySvg(
+ FlowySvgs.app_logo_s, // replace it with group avatar
+ blendMode: null,
+ ),
+ ),
+ );
+ }
+
+ Widget _buildTitle(BuildContext context) {
+ 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,
+ ),
+ ),
+ HSpace(theme.spacing.xs),
+ FlowySvg(
+ FlowySvgs.arrow_down_s,
+ color: theme.textColorScheme.secondary,
+ ),
+ ],
+ );
+ }
+
+ 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
+ textAlign: TextAlign.left,
+ style: theme.textStyle.caption.standard(
+ color: theme.textColorScheme.secondary,
+ ),
+ );
+ }
+
+ Widget _buildTrailing(BuildContext context) {
+ return EditAccessLevelWidget(
+ disabled: true,
+ selectedAccessLevel: ShareAccessLevel.fullAccess,
+ callbacks: AccessLevelListCallbacks.none(),
+ );
+ }
+}
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.dart
new file mode 100644
index 0000000000..556e6dba0f
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/shared_user_widget.dart
@@ -0,0 +1,108 @@
+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_ui/appflowy_ui.dart';
+import 'package:flowy_infra_ui/flowy_infra_ui.dart';
+import 'package:flutter/material.dart';
+
+/// Widget to display a single shared user row as per the UI design, using AFMenuItem.
+class SharedUserWidget extends StatelessWidget {
+ const SharedUserWidget({
+ super.key,
+ required this.user,
+ required this.currentUser,
+ this.callbacks,
+ });
+
+ final SharedUser user;
+ final SharedUser currentUser;
+ final AccessLevelListCallbacks? callbacks;
+
+ @override
+ Widget build(BuildContext context) {
+ final theme = AppFlowyTheme.of(context);
+
+ return AFMenuItem(
+ padding: EdgeInsets.symmetric(
+ vertical: theme.spacing.s,
+ ),
+ leading: AFAvatar(
+ name: user.name,
+ url: user.avatarUrl,
+ colorHash: user.email,
+ ),
+ title: _buildTitle(context),
+ subtitle: _buildSubtitle(context),
+ trailing: _buildTrailing(context),
+ );
+ }
+
+ Widget _buildTitle(
+ BuildContext context,
+ ) {
+ final theme = AppFlowyTheme.of(context);
+ final isCurrentUser = user.email == currentUser.email;
+
+ return Row(
+ children: [
+ Text(
+ user.name,
+ style: theme.textStyle.body.standard(
+ color: theme.textColorScheme.primary,
+ ),
+ ),
+ // if the user is the current user, show '(You)'
+ if (isCurrentUser) ...[
+ HSpace(theme.spacing.xs),
+ Text(
+ '(You)',
+ style: theme.textStyle.body.standard(
+ color: theme.textColorScheme.secondary,
+ ),
+ ),
+ ],
+ // if the user is a guest, show 'Guest'
+ if (user.role == ShareRole.guest) ...[
+ HSpace(theme.spacing.xs),
+ Text(
+ 'Guest',
+ style: theme.textStyle.body.standard(
+ color: theme.textColorScheme.warning,
+ ),
+ ),
+ ],
+ ],
+ );
+ }
+
+ Widget _buildSubtitle(
+ BuildContext context,
+ ) {
+ final theme = AppFlowyTheme.of(context);
+ return Text(
+ user.email,
+ style: theme.textStyle.caption.standard(
+ color: theme.textColorScheme.secondary,
+ ),
+ );
+ }
+
+ Widget _buildTrailing(
+ BuildContext context,
+ ) {
+ final isCurrentUser = user.email == currentUser.email;
+ final theme = AppFlowyTheme.of(context);
+ // The current guest user can't edit the access level of the other user
+ return isCurrentUser || currentUser.role == ShareRole.guest
+ ? AFGhostTextButton.disabled(
+ text: user.accessLevel.i18n,
+ textStyle: theme.textStyle.body.standard(
+ color: theme.textColorScheme.secondary,
+ ),
+ )
+ : EditAccessLevelWidget(
+ selectedAccessLevel: user.accessLevel,
+ callbacks: callbacks ?? AccessLevelListCallbacks.none(),
+ );
+ }
+}
diff --git a/frontend/appflowy_flutter/lib/plugins/shared/share/_shared.dart b/frontend/appflowy_flutter/lib/plugins/shared/share/_shared.dart
index 803c9867c9..7cadebe1d4 100644
--- a/frontend/appflowy_flutter/lib/plugins/shared/share/_shared.dart
+++ b/frontend/appflowy_flutter/lib/plugins/shared/share/_shared.dart
@@ -1,14 +1,17 @@
+import 'package:appflowy/features/share_tab/data/models/models.dart';
+import 'package:appflowy/features/share_tab/logic/share_with_user_bloc.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/database/application/tab_bar_bloc.dart';
import 'package:appflowy/plugins/shared/share/share_bloc.dart';
import 'package:appflowy/plugins/shared/share/share_menu.dart';
import 'package:appflowy/workspace/application/user/user_workspace_bloc.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';
+import 'package:provider/provider.dart';
-class ShareMenuButton extends StatelessWidget {
+class ShareMenuButton extends StatefulWidget {
const ShareMenuButton({
super.key,
required this.tabs,
@@ -16,48 +19,98 @@ class ShareMenuButton extends StatelessWidget {
final List<ShareMenuTab> tabs;
+ @override
+ State<ShareMenuButton> createState() => _ShareMenuButtonState();
+}
+
+class _ShareMenuButtonState extends State<ShareMenuButton> {
+ final popoverController = AFPopoverController();
+ final popoverGroupId = SharePopoverGroupId();
+
+ @override
+ void initState() {
+ super.initState();
+
+ popoverController.addListener(() {
+ if (context.mounted && popoverController.isOpen) {
+ context.read<ShareBloc>().add(const ShareEvent.updatePublishStatus());
+ }
+ });
+ }
+
+ @override
+ void dispose() {
+ popoverController.dispose();
+ super.dispose();
+ }
+
@override
Widget build(BuildContext context) {
final shareBloc = context.read<ShareBloc>();
final databaseBloc = context.read<DatabaseTabBarBloc?>();
final userWorkspaceBloc = context.read<UserWorkspaceBloc>();
+ final shareWithUserBloc = context.read<ShareWithUserBloc>();
+ // final animationDuration = const Duration(milliseconds: 120);
+
return BlocBuilder<ShareBloc, ShareState>(
builder: (context, state) {
- return SizedBox(
- height: 32.0,
- child: IntrinsicWidth(
- child: AppFlowyPopover(
- direction: PopoverDirection.bottomWithRightAligned,
+ return AFPopover(
+ controller: popoverController,
+ groupId: popoverGroupId,
+ anchor: AFAnchorAuto(
+ offset: const Offset(-176, 12),
+ ),
+ // Enable animation
+ // effects: [
+ // FadeEffect(duration: animationDuration),
+ // ScaleEffect(
+ // duration: animationDuration,
+ // begin: Offset(0.95, 0.95),
+ // end: Offset(1, 1),
+ // alignment: Alignment.topRight,
+ // ),
+ // MoveEffect(
+ // duration: animationDuration,
+ // begin: Offset(20, -20),
+ // end: Offset(0, 0),
+ // curve: Curves.easeOutQuad,
+ // ),
+ // ],
+ popover: (_) {
+ return ConstrainedBox(
constraints: const BoxConstraints(
- maxWidth: 500,
+ maxWidth: 414,
),
- offset: const Offset(0, 8),
- onOpen: () {
- context
- .read<ShareBloc>()
- .add(const ShareEvent.updatePublishStatus());
- },
- popupBuilder: (_) {
- return MultiBlocProvider(
- providers: [
- if (databaseBloc != null)
- BlocProvider.value(
- value: databaseBloc,
- ),
- BlocProvider.value(value: shareBloc),
- BlocProvider.value(value: userWorkspaceBloc),
- ],
+ child: MultiBlocProvider(
+ providers: [
+ if (databaseBloc != null)
+ BlocProvider.value(
+ value: databaseBloc,
+ ),
+ BlocProvider.value(value: shareBloc),
+ BlocProvider.value(value: userWorkspaceBloc),
+ BlocProvider.value(value: shareWithUserBloc),
+ ],
+ child: Provider.value(
+ value: popoverGroupId,
child: ShareMenu(
- tabs: tabs,
+ tabs: widget.tabs,
viewName: state.viewName,
),
- );
- },
- child: PrimaryRoundedButton(
- text: LocaleKeys.shareAction_buttonText.tr(),
- figmaLineHeight: 16,
+ ),
),
- ),
+ );
+ },
+ child: AFFilledTextButton.primary(
+ text: LocaleKeys.shareAction_buttonText.tr(),
+ onTap: () {
+ popoverController.show();
+
+ /// Fetch the shared users when the popover is shown
+ context
+ .read<ShareWithUserBloc>()
+ .add(const ShareWithUserEvent.getSharedUsers());
+ },
),
);
},
diff --git a/frontend/appflowy_flutter/lib/plugins/shared/share/share_button.dart b/frontend/appflowy_flutter/lib/plugins/shared/share/share_button.dart
index 9020441b4e..c1fda78c34 100644
--- a/frontend/appflowy_flutter/lib/plugins/shared/share/share_button.dart
+++ b/frontend/appflowy_flutter/lib/plugins/shared/share/share_button.dart
@@ -1,9 +1,12 @@
+import 'package:appflowy/features/share_tab/data/repositories/rust_share_repository.dart';
+import 'package:appflowy/features/share_tab/logic/share_with_user_bloc.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/database/application/tab_bar_bloc.dart';
import 'package:appflowy/plugins/shared/share/_shared.dart';
import 'package:appflowy/plugins/shared/share/share_bloc.dart';
import 'package:appflowy/plugins/shared/share/share_menu.dart';
import 'package:appflowy/startup/startup.dart';
+import 'package:appflowy/workspace/application/user/user_workspace_bloc.dart';
import 'package:appflowy/workspace/application/view/view_ext.dart';
import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
@@ -22,6 +25,9 @@ class ShareButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
+ final workspaceId =
+ context.read<UserWorkspaceBloc>().state.currentWorkspace?.workspaceId ??
+ '';
return MultiBlocProvider(
providers: [
BlocProvider(
@@ -36,6 +42,14 @@ class ShareButton extends StatelessWidget {
enableCompactMode: false,
)..add(const DatabaseTabBarEvent.initial()),
),
+ BlocProvider(
+ create: (context) => ShareWithUserBloc(
+ // repository: MockShareRepository(),
+ repository: RustShareRepository(),
+ pageId: view.id,
+ workspaceId: workspaceId,
+ )..add(const ShareWithUserEvent.init()),
+ ),
],
child: BlocListener<ShareBloc, ShareState>(
listener: (context, state) {
diff --git a/frontend/appflowy_flutter/lib/plugins/shared/share/share_menu.dart b/frontend/appflowy_flutter/lib/plugins/shared/share/share_menu.dart
index 4decb1c092..cc98b6cb4c 100644
--- a/frontend/appflowy_flutter/lib/plugins/shared/share/share_menu.dart
+++ b/frontend/appflowy_flutter/lib/plugins/shared/share/share_menu.dart
@@ -1,9 +1,11 @@
+// import 'package:appflowy/features/share_tab/presentation/share_tab.dart';
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/mobile/presentation/home/tab/_round_underline_tab_indicator.dart';
import 'package:appflowy/plugins/shared/share/export_tab.dart';
import 'package:appflowy/plugins/shared/share/share_bloc.dart';
import 'package:appflowy/plugins/shared/share/share_tab.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';
@@ -57,25 +59,22 @@ class _ShareMenuState extends State<ShareMenu>
return const SizedBox.shrink();
}
+ final theme = AppFlowyTheme.of(context);
+
return Column(
mainAxisSize: MainAxisSize.min,
children: [
- const VSpace(10),
+ VSpace(theme.spacing.xs),
Container(
alignment: Alignment.centerLeft,
- height: 30,
+ height: 28,
child: _buildTabBar(context),
),
- Divider(
- color: Theme.of(context).dividerColor,
- height: 1,
- thickness: 1,
- ),
+ const AFDivider(),
Padding(
- padding: const EdgeInsets.symmetric(horizontal: 14.0),
+ padding: EdgeInsets.symmetric(horizontal: theme.spacing.m),
child: _buildTab(context),
),
- const VSpace(20),
],
);
}
@@ -87,10 +86,11 @@ class _ShareMenuState extends State<ShareMenu>
}
Widget _buildTabBar(BuildContext context) {
+ final theme = AppFlowyTheme.of(context);
final children = [
for (final tab in widget.tabs)
Padding(
- padding: const EdgeInsets.only(bottom: 10),
+ padding: EdgeInsets.only(bottom: theme.spacing.s),
child: _Segment(
tab: tab,
isSelected: selectedTab == tab,
@@ -105,7 +105,7 @@ class _ShareMenuState extends State<ShareMenu>
color: Theme.of(context).colorScheme.primary,
width: 3,
),
- insets: const EdgeInsets.only(bottom: -2),
+ insets: const EdgeInsets.only(bottom: -1),
),
isScrollable: true,
controller: tabController,
@@ -128,6 +128,11 @@ class _ShareMenuState extends State<ShareMenu>
return const ExportTab();
case ShareMenuTab.share:
return const ShareTab();
+ // TODO: enable it when share folder is ready.
+ // return ShareTab(
+ // workspaceId: context.read<ShareBloc>().state.workspaceId,
+ // pageId: context.read<ShareBloc>().state.viewId,
+ // );
}
}
}
@@ -150,20 +155,21 @@ class _SegmentState extends State<_Segment> {
@override
Widget build(BuildContext context) {
- Color? textColor = Theme.of(context).hintColor;
- if (isHovered) {
- textColor = const Color(0xFF00BCF0);
- } else if (widget.isSelected) {
- textColor = null;
- }
+ final theme = AppFlowyTheme.of(context);
+
+ final textColor = widget.isSelected || isHovered
+ ? theme.textColorScheme.primary
+ : theme.textColorScheme.secondary;
Widget child = MouseRegion(
onEnter: (_) => setState(() => isHovered = true),
onExit: (_) => setState(() => isHovered = false),
- child: FlowyText(
+ child: Text(
widget.tab.i18n,
textAlign: TextAlign.center,
- color: textColor,
+ style: theme.textStyle.body.enhanced(
+ color: textColor,
+ ),
),
);
diff --git a/frontend/appflowy_flutter/lib/workspace/application/sidebar/space/space_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/sidebar/space/space_bloc.dart
index 9de0c582cd..a1991ce148 100644
--- a/frontend/appflowy_flutter/lib/workspace/application/sidebar/space/space_bloc.dart
+++ b/frontend/appflowy_flutter/lib/workspace/application/sidebar/space/space_bloc.dart
@@ -15,7 +15,8 @@ import 'package:appflowy/workspace/application/workspace/workspace_sections_list
import 'package:appflowy/workspace/presentation/home/menu/sidebar/space/space_icon_popup.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.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_result/appflowy_result.dart';
import 'package:collection/collection.dart';
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/example/lib/src/avatar/avatar_page.dart b/frontend/appflowy_flutter/packages/appflowy_ui/example/lib/src/avatar/avatar_page.dart
index 15b8e1d5bf..6a662354f2 100644
--- a/frontend/appflowy_flutter/packages/appflowy_ui/example/lib/src/avatar/avatar_page.dart
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/example/lib/src/avatar/avatar_page.dart
@@ -15,11 +15,11 @@ class AvatarPage extends StatelessWidget {
Wrap(
spacing: 16,
children: [
- AFAvatar(name: 'Nina', size: AFAvatarSize.xs),
- AFAvatar(name: 'Nina', size: AFAvatarSize.s),
- AFAvatar(name: 'Nina', size: AFAvatarSize.m),
- AFAvatar(name: 'Nina', size: AFAvatarSize.l),
- AFAvatar(name: 'Nina', size: AFAvatarSize.xl),
+ AFAvatar(name: 'Lucas', size: AFAvatarSize.xs),
+ AFAvatar(name: 'Vivian', size: AFAvatarSize.s),
+ AFAvatar(name: 'John', size: AFAvatarSize.m),
+ AFAvatar(name: 'Cindy', size: AFAvatarSize.l),
+ AFAvatar(name: 'Alex', size: AFAvatarSize.xl),
],
),
const SizedBox(height: 32),
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/example/lib/src/menu/menu_page.dart b/frontend/appflowy_flutter/packages/appflowy_ui/example/lib/src/menu/menu_page.dart
index d9d986c3fa..172f96a5ab 100644
--- a/frontend/appflowy_flutter/packages/appflowy_ui/example/lib/src/menu/menu_page.dart
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/example/lib/src/menu/menu_page.dart
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:flutter_svg/svg.dart';
-/// A showcase page for the AFMenu, AFMenuSection, and AFMenuItem components.
+/// A showcase page for the AFMenu, AFMenuSection, and AFTextMenuItem components.
class MenuPage extends StatefulWidget {
const MenuPage({super.key});
@@ -57,11 +57,12 @@ class _MenuPageState extends State<MenuPage> {
spacing: 16,
children: [
AFMenu(
+ width: 240,
children: [
AFMenuSection(
title: 'Section 1',
children: [
- AFMenuItem(
+ AFTextMenuItem(
leading: leading,
title: 'Menu Item 1',
selected: true,
@@ -90,17 +91,17 @@ class _MenuPageState extends State<MenuPage> {
popover: (context) {
return AFMenu(
children: [
- AFMenuItem(
+ AFTextMenuItem(
leading: leading,
title: 'Menu Item 2-1',
onTap: () {},
),
- AFMenuItem(
+ AFTextMenuItem(
leading: leading,
title: 'Menu Item 2-2',
onTap: () {},
),
- AFMenuItem(
+ AFTextMenuItem(
leading: leading,
title: 'Menu Item 2-3',
onTap: () {},
@@ -108,7 +109,7 @@ class _MenuPageState extends State<MenuPage> {
],
);
},
- child: AFMenuItem(
+ child: AFTextMenuItem(
leading: leading,
title: 'Menu Item 2',
onTap: () {
@@ -116,7 +117,7 @@ class _MenuPageState extends State<MenuPage> {
},
),
),
- AFMenuItem(
+ AFTextMenuItem(
leading: leading,
title: 'Menu Item 3',
onTap: () {},
@@ -126,7 +127,7 @@ class _MenuPageState extends State<MenuPage> {
AFMenuSection(
title: 'Section 2',
children: [
- AFMenuItem(
+ AFTextMenuItem(
leading: logo,
title: 'Menu Item 4',
subtitle: 'Menu Item',
@@ -137,13 +138,13 @@ class _MenuPageState extends State<MenuPage> {
),
onTap: () {},
),
- AFMenuItem(
+ AFTextMenuItem(
leading: logo,
title: 'Menu Item 5',
subtitle: 'Menu Item',
onTap: () {},
),
- AFMenuItem(
+ AFTextMenuItem(
leading: logo,
title: 'Menu Item 6',
subtitle: 'Menu Item',
@@ -154,13 +155,13 @@ class _MenuPageState extends State<MenuPage> {
AFMenuSection(
title: 'Section 3',
children: [
- AFMenuItem(
+ AFTextMenuItem(
leading: leading,
title: 'Menu Item 7',
trailing: arrowRight,
onTap: () {},
),
- AFMenuItem(
+ AFTextMenuItem(
leading: leading,
title: 'Menu Item 8',
trailing: arrowRight,
@@ -173,18 +174,19 @@ class _MenuPageState extends State<MenuPage> {
const SizedBox(height: 32),
// Example: Menu with search bar
AFMenu(
+ width: 240,
children: [
- AFMenuItem(
+ AFTextMenuItem(
leading: leading,
title: 'Menu Item 1',
onTap: () {},
),
- AFMenuItem(
+ AFTextMenuItem(
leading: leading,
title: 'Menu Item 2',
onTap: () {},
),
- AFMenuItem(
+ AFTextMenuItem(
leading: leading,
title: 'Menu Item 3',
onTap: () {},
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Flutter/Flutter-Debug.xcconfig b/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Flutter/Flutter-Debug.xcconfig
index c2efd0b608..4b81f9b2d2 100644
--- a/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Flutter/Flutter-Debug.xcconfig
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Flutter/Flutter-Debug.xcconfig
@@ -1 +1,2 @@
+#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Flutter/Flutter-Release.xcconfig b/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Flutter/Flutter-Release.xcconfig
index c2efd0b608..5caa9d1579 100644
--- a/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Flutter/Flutter-Release.xcconfig
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Flutter/Flutter-Release.xcconfig
@@ -1 +1,2 @@
+#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Podfile b/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Podfile
new file mode 100644
index 0000000000..c795730db8
--- /dev/null
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Podfile
@@ -0,0 +1,43 @@
+platform :osx, '10.14'
+
+# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
+ENV['COCOAPODS_DISABLE_STATS'] = 'true'
+
+project 'Runner', {
+ 'Debug' => :debug,
+ 'Profile' => :release,
+ 'Release' => :release,
+}
+
+def flutter_root
+ generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
+ unless File.exist?(generated_xcode_build_settings_path)
+ raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
+ end
+
+ File.foreach(generated_xcode_build_settings_path) do |line|
+ matches = line.match(/FLUTTER_ROOT\=(.*)/)
+ return matches[1].strip if matches
+ end
+ raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
+end
+
+require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
+
+flutter_macos_podfile_setup
+
+target 'Runner' do
+ use_frameworks!
+ use_modular_headers!
+
+ flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
+ target 'RunnerTests' do
+ inherit! :search_paths
+ end
+end
+
+post_install do |installer|
+ installer.pods_project.targets.each do |target|
+ flutter_additional_macos_build_settings(target)
+ end
+end
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Podfile.lock b/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Podfile.lock
new file mode 100644
index 0000000000..2726b59238
--- /dev/null
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Podfile.lock
@@ -0,0 +1,30 @@
+PODS:
+ - FlutterMacOS (1.0.0)
+ - path_provider_foundation (0.0.1):
+ - Flutter
+ - FlutterMacOS
+ - sqflite_darwin (0.0.4):
+ - Flutter
+ - FlutterMacOS
+
+DEPENDENCIES:
+ - FlutterMacOS (from `Flutter/ephemeral`)
+ - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
+ - sqflite_darwin (from `Flutter/ephemeral/.symlinks/plugins/sqflite_darwin/darwin`)
+
+EXTERNAL SOURCES:
+ FlutterMacOS:
+ :path: Flutter/ephemeral
+ path_provider_foundation:
+ :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin
+ sqflite_darwin:
+ :path: Flutter/ephemeral/.symlinks/plugins/sqflite_darwin/darwin
+
+SPEC CHECKSUMS:
+ FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
+ path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564
+ sqflite_darwin: 20b2a3a3b70e43edae938624ce550a3cbf66a3d0
+
+PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367
+
+COCOAPODS: 1.16.2
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Runner.xcodeproj/project.pbxproj b/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Runner.xcodeproj/project.pbxproj
index f2aabe0564..0405cddf4c 100644
--- a/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Runner.xcodeproj/project.pbxproj
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Runner.xcodeproj/project.pbxproj
@@ -27,6 +27,8 @@
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
+ A8240F6CBA460C4ECE77B497 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 67F505219B8EAD64EC2D7058 /* Pods_Runner.framework */; };
+ ED985151D7C5493A133E2F4A /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99B39EDC5EC15A319D26431B /* Pods_RunnerTests.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -60,6 +62,8 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
+ 126A5ABCAF9A616F39D0C99A /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
+ 294E5A6C2D9F40258167A63C /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = "<group>"; };
331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; };
333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = "<group>"; };
@@ -76,8 +80,14 @@
33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = "<group>"; };
33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = "<group>"; };
33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; };
+ 67F505219B8EAD64EC2D7058 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+ 7323BEF11E938E0621A2FE27 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
+ 99B39EDC5EC15A319D26431B /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+ C27947A571D4D6E82250D9D4 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = "<group>"; };
+ DECDE2B61D56E070AC9CFE43 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
+ E8C30E6DE13EF821101E690E /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -85,6 +95,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ ED985151D7C5493A133E2F4A /* Pods_RunnerTests.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -92,6 +103,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ A8240F6CBA460C4ECE77B497 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -125,6 +137,7 @@
331C80D6294CF71000263BE5 /* RunnerTests */,
33CC10EE2044A3C60003C045 /* Products */,
D73912EC22F37F3D000D13A0 /* Frameworks */,
+ D0B4F9D1672BB1F3A8ADB1D5 /* Pods */,
);
sourceTree = "<group>";
};
@@ -172,9 +185,25 @@
path = Runner;
sourceTree = "<group>";
};
+ D0B4F9D1672BB1F3A8ADB1D5 /* Pods */ = {
+ isa = PBXGroup;
+ children = (
+ 126A5ABCAF9A616F39D0C99A /* Pods-Runner.debug.xcconfig */,
+ 7323BEF11E938E0621A2FE27 /* Pods-Runner.release.xcconfig */,
+ DECDE2B61D56E070AC9CFE43 /* Pods-Runner.profile.xcconfig */,
+ E8C30E6DE13EF821101E690E /* Pods-RunnerTests.debug.xcconfig */,
+ 294E5A6C2D9F40258167A63C /* Pods-RunnerTests.release.xcconfig */,
+ C27947A571D4D6E82250D9D4 /* Pods-RunnerTests.profile.xcconfig */,
+ );
+ name = Pods;
+ path = Pods;
+ sourceTree = "<group>";
+ };
D73912EC22F37F3D000D13A0 /* Frameworks */ = {
isa = PBXGroup;
children = (
+ 67F505219B8EAD64EC2D7058 /* Pods_Runner.framework */,
+ 99B39EDC5EC15A319D26431B /* Pods_RunnerTests.framework */,
);
name = Frameworks;
sourceTree = "<group>";
@@ -186,6 +215,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */;
buildPhases = (
+ 259F838CE5DFD9B02C9072E2 /* [CP] Check Pods Manifest.lock */,
331C80D1294CF70F00263BE5 /* Sources */,
331C80D2294CF70F00263BE5 /* Frameworks */,
331C80D3294CF70F00263BE5 /* Resources */,
@@ -204,11 +234,13 @@
isa = PBXNativeTarget;
buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
+ B8FE1B340A42EC42E5F2652D /* [CP] Check Pods Manifest.lock */,
33CC10E92044A3C60003C045 /* Sources */,
33CC10EA2044A3C60003C045 /* Frameworks */,
33CC10EB2044A3C60003C045 /* Resources */,
33CC110E2044A8840003C045 /* Bundle Framework */,
3399D490228B24CF009A79C7 /* ShellScript */,
+ 3CE63926704EF25F1635BDFC /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
@@ -291,6 +323,28 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
+ 259F838CE5DFD9B02C9072E2 /* [CP] Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ );
+ inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
+ );
+ name = "[CP] Check Pods Manifest.lock";
+ outputFileListPaths = (
+ );
+ outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ showEnvVarsInLog = 0;
+ };
3399D490228B24CF009A79C7 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
@@ -329,6 +383,45 @@
shellPath = /bin/sh;
shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire";
};
+ 3CE63926704EF25F1635BDFC /* [CP] Embed Pods Frameworks */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
+ );
+ name = "[CP] Embed Pods Frameworks";
+ outputFileListPaths = (
+ "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
+ B8FE1B340A42EC42E5F2652D /* [CP] Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ );
+ inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
+ );
+ name = "[CP] Check Pods Manifest.lock";
+ outputFileListPaths = (
+ );
+ outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ showEnvVarsInLog = 0;
+ };
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -380,6 +473,7 @@
/* Begin XCBuildConfiguration section */
331C80DB294CF71000263BE5 /* Debug */ = {
isa = XCBuildConfiguration;
+ baseConfigurationReference = E8C30E6DE13EF821101E690E /* Pods-RunnerTests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CURRENT_PROJECT_VERSION = 1;
@@ -394,6 +488,7 @@
};
331C80DC294CF71000263BE5 /* Release */ = {
isa = XCBuildConfiguration;
+ baseConfigurationReference = 294E5A6C2D9F40258167A63C /* Pods-RunnerTests.release.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CURRENT_PROJECT_VERSION = 1;
@@ -408,6 +503,7 @@
};
331C80DD294CF71000263BE5 /* Profile */ = {
isa = XCBuildConfiguration;
+ baseConfigurationReference = C27947A571D4D6E82250D9D4 /* Pods-RunnerTests.profile.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CURRENT_PROJECT_VERSION = 1;
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Runner.xcworkspace/contents.xcworkspacedata b/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Runner.xcworkspace/contents.xcworkspacedata
index 1d526a16ed..21a3cc14c7 100644
--- a/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Runner.xcworkspace/contents.xcworkspacedata
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/example/macos/Runner.xcworkspace/contents.xcworkspacedata
@@ -4,4 +4,7 @@
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
+ <FileRef
+ location = "group:Pods/Pods.xcodeproj">
+ </FileRef>
</Workspace>
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/avatar/avatar.dart b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/avatar/avatar.dart
index 3f7c533624..7916b01147 100644
--- a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/avatar/avatar.dart
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/avatar/avatar.dart
@@ -1,6 +1,7 @@
-import 'package:flutter/material.dart';
-import 'package:appflowy_ui/src/theme/definition/theme_data.dart';
import 'package:appflowy_ui/src/theme/appflowy_theme.dart';
+import 'package:appflowy_ui/src/theme/definition/theme_data.dart';
+import 'package:cached_network_image/cached_network_image.dart';
+import 'package:flutter/material.dart';
/// Avatar sizes in pixels
enum AFAvatarSize {
@@ -54,6 +55,7 @@ class AFAvatar extends StatelessWidget {
this.textColor,
this.backgroundColor,
this.child,
+ this.colorHash,
});
/// The name of the avatar. Used for initials if [child] and [url] are not provided.
@@ -69,23 +71,33 @@ class AFAvatar extends StatelessWidget {
final AFAvatarSize size;
/// The text color for initials. Only applies when showing initials.
+ /// If not provided, a matching thick color from badge color scheme will be used.
final Color? textColor;
/// The background color for initials. Only applies when showing initials.
+ /// If not provided, a light color from badge color scheme will be used.
final Color? backgroundColor;
+ /// The hash value used to pick the color. If it's not provided, the name hash will be used.
+ final String? colorHash;
+
@override
Widget build(BuildContext context) {
final theme = AppFlowyTheme.of(context);
final double avatarSize = size.size;
- final Color bgColor =
- backgroundColor ?? theme.backgroundColorScheme.primary;
- final Color txtColor = textColor ?? theme.textColorScheme.primary;
- final TextStyle textStyle = size.buildTextStyle(theme, txtColor);
+
+ // Pick color index based on name hash (1-20)
+ final int colorIndex = _pickColorIndexFromName(colorHash ?? name);
+ final Color backgroundColor =
+ this.backgroundColor ?? _getBadgeBackgroundColor(theme, colorIndex);
+ final Color textColor =
+ this.textColor ?? _getBadgeTextColor(theme, colorIndex);
+
+ final TextStyle textStyle = size.buildTextStyle(theme, textColor);
final Widget avatarContent = _buildAvatarContent(
avatarSize: avatarSize,
- bgColor: bgColor,
+ bgColor: backgroundColor,
textStyle: textStyle,
);
@@ -111,13 +123,13 @@ class AFAvatar extends StatelessWidget {
);
} else if (url != null && url!.isNotEmpty) {
return ClipOval(
- child: Image.network(
- url!,
+ child: CachedNetworkImage(
+ imageUrl: url!,
width: avatarSize,
height: avatarSize,
fit: BoxFit.cover,
// fallback to initials if the image is not found
- errorBuilder: (context, error, stackTrace) => _buildInitialsCircle(
+ errorWidget: (context, error, stackTrace) => _buildInitialsCircle(
avatarSize,
bgColor,
textStyle,
@@ -134,7 +146,7 @@ class AFAvatar extends StatelessWidget {
}
Widget _buildInitialsCircle(double size, Color bgColor, TextStyle textStyle) {
- final initials = _getInitials(name);
+ final initial = _getInitials(name);
return Container(
decoration: BoxDecoration(
color: bgColor,
@@ -142,7 +154,7 @@ class AFAvatar extends StatelessWidget {
),
alignment: Alignment.center,
child: Text(
- initials,
+ initial,
style: textStyle,
textAlign: TextAlign.center,
),
@@ -151,8 +163,72 @@ class AFAvatar extends StatelessWidget {
String _getInitials(String? name) {
if (name == null || name.trim().isEmpty) return '';
- final parts = name.trim().split(RegExp(r'\s+'));
- if (parts.length == 1) return parts[0][0].toUpperCase();
- return (parts[0][0] + parts[1][0]).toUpperCase();
+
+ // Always return just the first letter of the name
+ return name.trim()[0].toUpperCase();
+ }
+
+ /// Deterministically pick a color index (1-20) based on the user name
+ int _pickColorIndexFromName(String? name) {
+ if (name == null || name.isEmpty) return 1;
+ int hash = 0;
+ for (int i = 0; i < name.length; i++) {
+ hash = name.codeUnitAt(i) + ((hash << 5) - hash);
+ }
+ return (hash.abs() % 20) + 1;
+ }
+
+ /// Gets the background color from badge color scheme using a list
+ Color _getBadgeBackgroundColor(AppFlowyThemeData theme, int colorIndex) {
+ final List<Color> backgroundColors = [
+ theme.badgeColorScheme.color1Light2,
+ theme.badgeColorScheme.color2Light2,
+ theme.badgeColorScheme.color3Light2,
+ theme.badgeColorScheme.color4Light2,
+ theme.badgeColorScheme.color5Light2,
+ theme.badgeColorScheme.color6Light2,
+ theme.badgeColorScheme.color7Light2,
+ theme.badgeColorScheme.color8Light2,
+ theme.badgeColorScheme.color9Light2,
+ theme.badgeColorScheme.color10Light2,
+ theme.badgeColorScheme.color11Light2,
+ theme.badgeColorScheme.color12Light2,
+ theme.badgeColorScheme.color13Light2,
+ theme.badgeColorScheme.color14Light2,
+ theme.badgeColorScheme.color15Light2,
+ theme.badgeColorScheme.color16Light2,
+ theme.badgeColorScheme.color17Light2,
+ theme.badgeColorScheme.color18Light2,
+ theme.badgeColorScheme.color19Light2,
+ theme.badgeColorScheme.color20Light2,
+ ];
+ return backgroundColors[(colorIndex - 1).clamp(0, 19)];
+ }
+
+ /// Gets the text color from badge color scheme using a list
+ Color _getBadgeTextColor(AppFlowyThemeData theme, int colorIndex) {
+ final List<Color> textColors = [
+ theme.badgeColorScheme.color1Thick3,
+ theme.badgeColorScheme.color2Thick3,
+ theme.badgeColorScheme.color3Thick3,
+ theme.badgeColorScheme.color4Thick3,
+ theme.badgeColorScheme.color5Thick3,
+ theme.badgeColorScheme.color6Thick3,
+ theme.badgeColorScheme.color7Thick3,
+ theme.badgeColorScheme.color8Thick3,
+ theme.badgeColorScheme.color9Thick3,
+ theme.badgeColorScheme.color10Thick3,
+ theme.badgeColorScheme.color11Thick3,
+ theme.badgeColorScheme.color12Thick3,
+ theme.badgeColorScheme.color13Thick3,
+ theme.badgeColorScheme.color14Thick3,
+ theme.badgeColorScheme.color15Thick3,
+ theme.badgeColorScheme.color16Thick3,
+ theme.badgeColorScheme.color17Thick3,
+ theme.badgeColorScheme.color18Thick3,
+ theme.badgeColorScheme.color19Thick3,
+ theme.badgeColorScheme.color20Thick3,
+ ];
+ return textColors[(colorIndex - 1).clamp(0, 19)];
}
}
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/button/base_button/base_button.dart b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/button/base_button/base_button.dart
index 4e5361a7b3..81c1cc1ecf 100644
--- a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/button/base_button/base_button.dart
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/button/base_button/base_button.dart
@@ -82,9 +82,11 @@ class _AFBaseButtonState extends State<AFBaseButton> {
setState(() => this.isFocused = isFocused);
},
child: MouseRegion(
- cursor: widget.disabled
+ cursor: widget.onTap == null
? SystemMouseCursors.basic
- : SystemMouseCursors.click,
+ : widget.disabled
+ ? SystemMouseCursors.basic
+ : SystemMouseCursors.click,
onEnter: (_) => setState(() => isHovering = true),
onExit: (_) => setState(() => isHovering = false),
child: GestureDetector(
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/button/filled_button/filled_text_button.dart b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/button/filled_button/filled_text_button.dart
index 3febd1ccec..f5a9075e4b 100644
--- a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/button/filled_button/filled_text_button.dart
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/button/filled_button/filled_text_button.dart
@@ -39,8 +39,12 @@ class AFFilledTextButton extends AFBaseTextButton {
disabled: disabled,
alignment: alignment,
textStyle: textStyle,
- textColor: (context, isHovering, disabled) =>
- AppFlowyTheme.of(context).textColorScheme.onFill,
+ textColor: (context, isHovering, disabled) {
+ if (disabled) {
+ return AppFlowyTheme.of(context).textColorScheme.tertiary;
+ }
+ return AppFlowyTheme.of(context).textColorScheme.onFill;
+ },
backgroundColor: (context, isHovering, disabled) {
if (disabled) {
return AppFlowyTheme.of(context).fillColorScheme.contentHover;
@@ -75,8 +79,12 @@ class AFFilledTextButton extends AFBaseTextButton {
disabled: disabled,
alignment: alignment,
textStyle: textStyle,
- textColor: (context, isHovering, disabled) =>
- AppFlowyTheme.of(context).textColorScheme.onFill,
+ textColor: (context, isHovering, disabled) {
+ if (disabled) {
+ return AppFlowyTheme.of(context).textColorScheme.tertiary;
+ }
+ return AppFlowyTheme.of(context).textColorScheme.onFill;
+ },
backgroundColor: (context, isHovering, disabled) {
if (disabled) {
return AppFlowyTheme.of(context).fillColorScheme.contentHover;
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/menu/menu.dart b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/menu/menu.dart
index 620027942f..7dcad90e17 100644
--- a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/menu/menu.dart
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/menu/menu.dart
@@ -1,22 +1,23 @@
-export 'menu_item.dart';
-export 'section.dart';
-
import 'package:appflowy_ui/appflowy_ui.dart';
import 'package:flutter/material.dart';
+export 'menu_item.dart';
+export 'section.dart';
+export 'text_menu_item.dart';
+
/// The main menu container widget, supporting sections, menu items.
class AFMenu extends StatelessWidget {
const AFMenu({
super.key,
required this.children,
- this.width = 240,
+ this.width,
});
/// The list of widgets to display in the menu (sections or menu items).
final List<Widget> children;
/// The width of the menu.
- final double width;
+ final double? width;
@override
Widget build(BuildContext context) {
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/menu/menu_item.dart b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/menu/menu_item.dart
index 8b6d37d1a2..962af73eb6 100644
--- a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/menu/menu_item.dart
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/menu/menu_item.dart
@@ -9,41 +9,52 @@ class AFMenuItem extends StatelessWidget {
const AFMenuItem({
super.key,
required this.title,
- required this.onTap,
+ this.onTap,
this.leading,
this.subtitle,
this.selected = false,
this.trailing,
+ this.padding,
+ this.showSelectedBackground = true,
});
/// Widget to display before the title (e.g., an icon or avatar).
final Widget? leading;
/// The main text of the menu item.
- final String title;
+ final Widget title;
/// Optional secondary text displayed below the title.
- final String? subtitle;
+ final Widget? subtitle;
/// Whether the menu item is selected.
final bool selected;
+ /// Whether to show the selected background color.
+ final bool showSelectedBackground;
+
/// Called when the menu item is tapped.
- final VoidCallback onTap;
+ final VoidCallback? onTap;
/// Widget to display after the title (e.g., a trailing icon).
final Widget? trailing;
+ /// Padding of the menu item.
+ final EdgeInsets? padding;
+
@override
Widget build(BuildContext context) {
final theme = AppFlowyTheme.of(context);
+ final effectivePadding = padding ??
+ EdgeInsets.symmetric(
+ horizontal: theme.spacing.m,
+ vertical: theme.spacing.s,
+ );
+
return AFBaseButton(
onTap: onTap,
- padding: EdgeInsets.symmetric(
- horizontal: theme.spacing.m,
- vertical: theme.spacing.s,
- ),
+ padding: effectivePadding,
borderRadius: theme.borderRadius.m,
borderColor: (context, isHovering, disabled, isFocused) {
return Colors.transparent;
@@ -53,10 +64,10 @@ class AFMenuItem extends StatelessWidget {
if (disabled) {
return theme.fillColorScheme.content;
}
- if (selected) {
+ if (selected && showSelectedBackground) {
return theme.fillColorScheme.themeSelect;
}
- if (isHovering) {
+ if (isHovering && onTap != null) {
return theme.fillColorScheme.contentHover;
}
return theme.fillColorScheme.content;
@@ -75,20 +86,9 @@ class AFMenuItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Title text
- Text(
- title,
- style: theme.textStyle.body.standard(
- color: theme.textColorScheme.primary,
- ),
- ),
+ title,
// Subtitle text, if provided
- if (subtitle != null)
- Text(
- subtitle!,
- style: theme.textStyle.caption.standard(
- color: theme.textColorScheme.secondary,
- ),
- ),
+ if (subtitle != null) subtitle!,
],
),
),
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/menu/section.dart b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/menu/section.dart
index c6add29e49..a66fac86c2 100644
--- a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/menu/section.dart
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/menu/section.dart
@@ -7,6 +7,8 @@ class AFMenuSection extends StatelessWidget {
super.key,
this.title,
required this.children,
+ this.padding,
+ this.constraints,
});
/// The title of the section (e.g., 'Section 1').
@@ -15,18 +17,28 @@ class AFMenuSection extends StatelessWidget {
/// The widgets to display in this section (typically AFMenuItem widgets).
final List<Widget> children;
+ /// Section padding.
+ final EdgeInsets? padding;
+
+ /// The height of the section.
+ final BoxConstraints? constraints;
+
@override
Widget build(BuildContext context) {
final theme = AppFlowyTheme.of(context);
+
+ final effectivePadding = padding ??
+ EdgeInsets.symmetric(
+ horizontal: theme.spacing.m,
+ vertical: theme.spacing.s,
+ );
+
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (title != null) ...[
Padding(
- padding: EdgeInsets.symmetric(
- horizontal: theme.spacing.m,
- vertical: theme.spacing.s,
- ),
+ padding: effectivePadding,
child: Text(
title!,
style: theme.textStyle.caption.enhanced(
@@ -35,7 +47,14 @@ class AFMenuSection extends StatelessWidget {
),
),
],
- ...children,
+ Container(
+ constraints: constraints,
+ child: SingleChildScrollView(
+ child: Column(
+ children: children,
+ ),
+ ),
+ ),
],
);
}
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/menu/text_menu_item.dart b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/menu/text_menu_item.dart
new file mode 100644
index 0000000000..52c2fac5e3
--- /dev/null
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/menu/text_menu_item.dart
@@ -0,0 +1,74 @@
+import 'package:appflowy_ui/appflowy_ui.dart';
+import 'package:flutter/material.dart';
+
+/// Text menu item widget
+class AFTextMenuItem extends StatelessWidget {
+ /// Creates a text menu item.
+ ///
+ /// [title] and [onTap] are required. Optionally provide [leading], [subtitle], [selected], and [trailing].
+ const AFTextMenuItem({
+ super.key,
+ required this.title,
+ required this.onTap,
+ this.leading,
+ this.subtitle,
+ this.selected = false,
+ this.trailing,
+ this.titleColor,
+ this.subtitleColor,
+ this.showSelectedBackground = true,
+ });
+
+ /// Widget to display before the title (e.g., an icon or avatar).
+ final Widget? leading;
+
+ /// The main text of the menu item.
+ final String title;
+
+ /// The color of the title.
+ final Color? titleColor;
+
+ /// Optional secondary text displayed below the title.
+ final String? subtitle;
+
+ /// The color of the subtitle.
+ final Color? subtitleColor;
+
+ /// Whether the menu item is selected.
+ final bool selected;
+
+ /// Whether to show the selected background color.
+ final bool showSelectedBackground;
+
+ /// Called when the menu item is tapped.
+ final VoidCallback onTap;
+
+ /// Widget to display after the title (e.g., a trailing icon).
+ final Widget? trailing;
+
+ @override
+ Widget build(BuildContext context) {
+ final theme = AppFlowyTheme.of(context);
+ return AFMenuItem(
+ title: Text(
+ title,
+ style: theme.textStyle.body.standard(
+ color: titleColor ?? theme.textColorScheme.primary,
+ ),
+ ),
+ subtitle: subtitle != null
+ ? Text(
+ subtitle!,
+ style: theme.textStyle.caption.standard(
+ color: subtitleColor ?? theme.textColorScheme.secondary,
+ ),
+ )
+ : null,
+ leading: leading,
+ trailing: trailing,
+ selected: selected,
+ showSelectedBackground: showSelectedBackground,
+ onTap: onTap,
+ );
+ }
+}
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/popover/popover.dart b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/popover/popover.dart
index e47d53f86e..3174d3b4ca 100644
--- a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/popover/popover.dart
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/popover/popover.dart
@@ -1,4 +1,3 @@
-export 'anchor.dart';
import 'dart:ui';
import 'package:appflowy_ui/appflowy_ui.dart';
@@ -8,6 +7,8 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_animate/flutter_animate.dart';
+export 'anchor.dart';
+
/// Notes: The implementation of this page is copied from [flutter_shadcn_ui](https://github.com/nank1ro/flutter-shadcn-ui).
///
/// Renaming is for the consistency of the AppFlowy UI.
@@ -157,6 +158,15 @@ class AFPopover extends StatefulWidget {
}
class _AFPopoverState extends State<AFPopover> {
+ static final List<_AFPopoverState> _openPopovers = [];
+ static int? _lastPopoverClosedTimestamp;
+ static void _markPopoverClosedThisFrame() {
+ _lastPopoverClosedTimestamp = DateTime.now().microsecondsSinceEpoch;
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ _lastPopoverClosedTimestamp = null;
+ });
+ }
+
AFPopoverController? _controller;
AFPopoverController get controller => widget.controller ?? _controller!;
bool animating = false;
@@ -165,12 +175,27 @@ class _AFPopoverState extends State<AFPopover> {
Object get groupId => widget.groupId ?? _popoverKey;
+ bool get _isTopMostPopover =>
+ _openPopovers.isNotEmpty && _openPopovers.last == this;
+
@override
void initState() {
super.initState();
if (widget.controller == null) {
_controller = AFPopoverController();
}
+ controller.addListener(_onControllerChanged);
+ if (controller.isOpen) {
+ _registerPopover();
+ }
+ }
+
+ void _onControllerChanged() {
+ if (controller.isOpen) {
+ _registerPopover();
+ } else {
+ _unregisterPopover();
+ }
}
@override
@@ -187,6 +212,8 @@ class _AFPopoverState extends State<AFPopover> {
@override
void dispose() {
+ controller.removeListener(_onControllerChanged);
+ _unregisterPopover();
_controller?.dispose();
super.dispose();
}
@@ -196,20 +223,26 @@ class _AFPopoverState extends State<AFPopover> {
final theme = AppFlowyTheme.of(context);
final effectiveEffects = widget.effects ?? [];
- final effectivePadding = widget.padding ?? EdgeInsets.zero;
+ final effectivePadding = widget.padding ??
+ EdgeInsets.symmetric(
+ horizontal: theme.spacing.m,
+ vertical: theme.spacing.l,
+ );
final effectiveAnchor = widget.anchor ?? const ShadAnchorAuto();
+ final effectiveDecoration = widget.decoration ??
+ BoxDecoration(
+ color: theme.surfaceColorScheme.layer01,
+ borderRadius: BorderRadius.circular(theme.borderRadius.m),
+ boxShadow: theme.shadow.medium,
+ );
final effectiveFilter = widget.filter;
Widget popover = ShadMouseArea(
groupId: widget.areaGroupId,
child: DecoratedBox(
- decoration: widget.decoration ??
- BoxDecoration(
- color: theme.surfaceColorScheme.primary,
- borderRadius: BorderRadius.circular(theme.borderRadius.m),
- ),
+ decoration: effectiveDecoration,
child: Padding(
padding: effectivePadding,
child: DefaultTextStyle(
@@ -242,7 +275,15 @@ class _AFPopoverState extends State<AFPopover> {
popover = TapRegion(
groupId: groupId,
behavior: HitTestBehavior.opaque,
- onTapOutside: (_) => controller.hide(),
+ onTapOutside: (_) {
+ final now = DateTime.now().microsecondsSinceEpoch;
+ if (_isTopMostPopover &&
+ (_lastPopoverClosedTimestamp == null ||
+ now - _lastPopoverClosedTimestamp! > 1000)) {
+ controller.hide();
+ _markPopoverClosedThisFrame();
+ }
+ },
child: popover,
);
}
@@ -265,6 +306,7 @@ class _AFPopoverState extends State<AFPopover> {
);
},
);
+
if (widget.useSameGroupIdForChild) {
child = TapRegion(
groupId: groupId,
@@ -273,4 +315,14 @@ class _AFPopoverState extends State<AFPopover> {
}
return child;
}
+
+ void _registerPopover() {
+ if (!_openPopovers.contains(this)) {
+ _openPopovers.add(this);
+ }
+ }
+
+ void _unregisterPopover() {
+ _openPopovers.remove(this);
+ }
}
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/textfield/textfield.dart b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/textfield/textfield.dart
index c628be49c8..3f8462e932 100644
--- a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/textfield/textfield.dart
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/textfield/textfield.dart
@@ -31,6 +31,7 @@ class AFTextField extends StatefulWidget {
this.size = AFTextFieldSize.l,
this.groupId = EditableText,
this.focusNode,
+ this.readOnly = false,
});
/// The hint text to display when the text field is empty.
@@ -78,6 +79,9 @@ class AFTextField extends StatefulWidget {
/// The focus node for the text field.
final FocusNode? focusNode;
+ /// Readonly.
+ final bool readOnly;
+
@override
State<AFTextField> createState() => _AFTextFieldState();
}
@@ -125,11 +129,51 @@ class _AFTextFieldState extends AFTextFieldState {
final errorBorderColor = theme.borderColorScheme.errorThick;
final defaultBorderColor = theme.borderColorScheme.primary;
+ final border = OutlineInputBorder(
+ borderSide: BorderSide(
+ color: hasError ? errorBorderColor : defaultBorderColor,
+ ),
+ borderRadius: borderRadius,
+ );
+
+ final enabledBorder = OutlineInputBorder(
+ borderSide: BorderSide(
+ color: hasError ? errorBorderColor : defaultBorderColor,
+ ),
+ borderRadius: borderRadius,
+ );
+
+ final focusedBorder = OutlineInputBorder(
+ borderSide: BorderSide(
+ color: widget.readOnly
+ ? defaultBorderColor
+ : hasError
+ ? errorBorderColor
+ : theme.borderColorScheme.themeThick,
+ ),
+ borderRadius: borderRadius,
+ );
+
+ final errorBorder = OutlineInputBorder(
+ borderSide: BorderSide(
+ color: errorBorderColor,
+ ),
+ borderRadius: borderRadius,
+ );
+
+ final focusedErrorBorder = OutlineInputBorder(
+ borderSide: BorderSide(
+ color: errorBorderColor,
+ ),
+ borderRadius: borderRadius,
+ );
+
Widget child = TextField(
groupId: widget.groupId,
focusNode: widget.focusNode,
controller: effectiveController,
keyboardType: widget.keyboardType,
+ readOnly: widget.readOnly,
style: theme.textStyle.body.standard(
color: theme.textColorScheme.primary,
),
@@ -145,38 +189,11 @@ class _AFTextFieldState extends AFTextFieldState {
isDense: true,
constraints: BoxConstraints(),
contentPadding: contentPadding,
- border: OutlineInputBorder(
- borderSide: BorderSide(
- color: hasError ? errorBorderColor : defaultBorderColor,
- ),
- borderRadius: borderRadius,
- ),
- enabledBorder: OutlineInputBorder(
- borderSide: BorderSide(
- color: hasError ? errorBorderColor : defaultBorderColor,
- ),
- borderRadius: borderRadius,
- ),
- focusedBorder: OutlineInputBorder(
- borderSide: BorderSide(
- color: hasError
- ? errorBorderColor
- : theme.borderColorScheme.themeThick,
- ),
- borderRadius: borderRadius,
- ),
- errorBorder: OutlineInputBorder(
- borderSide: BorderSide(
- color: errorBorderColor,
- ),
- borderRadius: borderRadius,
- ),
- focusedErrorBorder: OutlineInputBorder(
- borderSide: BorderSide(
- color: errorBorderColor,
- ),
- borderRadius: borderRadius,
- ),
+ border: border,
+ enabledBorder: enabledBorder,
+ focusedBorder: focusedBorder,
+ errorBorder: errorBorder,
+ focusedErrorBorder: focusedErrorBorder,
hoverColor: theme.borderColorScheme.primaryHover,
suffixIcon: widget.suffixIconBuilder?.call(context, isObscured),
suffixIconConstraints: widget.suffixIconConstraints,
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/theme/definition/text_style/base/default_text_style.dart b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/theme/definition/text_style/base/default_text_style.dart
index e8825eede6..1cd086ce5a 100644
--- a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/theme/definition/text_style/base/default_text_style.dart
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/theme/definition/text_style/base/default_text_style.dart
@@ -517,7 +517,7 @@ class TextThemeCaption extends TextThemeType {
static TextStyle _defaultTextStyle({
required String family,
double fontSize = 12,
- double height = 16 / 12,
+ double height = 18 / 12,
FontWeight weight = FontWeight.normal,
TextDecoration decoration = TextDecoration.none,
Color? color,
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/pubspec.yaml b/frontend/appflowy_flutter/packages/appflowy_ui/pubspec.yaml
index 018db2af74..7140975736 100644
--- a/frontend/appflowy_flutter/packages/appflowy_ui/pubspec.yaml
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/pubspec.yaml
@@ -8,6 +8,7 @@ environment:
flutter: ">=1.17.0"
dependencies:
+ cached_network_image: ^3.4.1
flutter:
sdk: flutter
flutter_animate: ^4.5.2
diff --git a/frontend/appflowy_flutter/pubspec.yaml b/frontend/appflowy_flutter/pubspec.yaml
index d8be95b307..3475822354 100644
--- a/frontend/appflowy_flutter/pubspec.yaml
+++ b/frontend/appflowy_flutter/pubspec.yaml
@@ -4,7 +4,7 @@ description: Bring projects, wikis, and teams together with AI. AppFlowy is an
your data. The best open source alternative to Notion.
publish_to: "none"
-version: 0.9.2
+version: 0.9.3
environment:
flutter: ">=3.27.4"
diff --git a/frontend/appflowy_flutter/test/bloc_test/lib/features/share_tab/share_with_user_bloc_test.dart b/frontend/appflowy_flutter/test/bloc_test/lib/features/share_tab/share_with_user_bloc_test.dart
new file mode 100644
index 0000000000..c7e5367b91
--- /dev/null
+++ b/frontend/appflowy_flutter/test/bloc_test/lib/features/share_tab/share_with_user_bloc_test.dart
@@ -0,0 +1,108 @@
+import 'package:appflowy/features/share_tab/data/models/models.dart';
+import 'package:appflowy/features/share_tab/data/repositories/mock_share_repository.dart';
+import 'package:appflowy/features/share_tab/logic/share_with_user_bloc.dart';
+import 'package:bloc_test/bloc_test.dart';
+import 'package:flutter_test/flutter_test.dart';
+
+void main() {
+ const pageId = 'test_page_id';
+ const workspaceId = 'test_workspace_id';
+ late MockShareRepository repository;
+ late ShareWithUserBloc bloc;
+
+ setUp(() {
+ repository = MockShareRepository();
+ bloc = ShareWithUserBloc(
+ repository: repository,
+ pageId: pageId,
+ workspaceId: workspaceId,
+ );
+ });
+
+ const email = '[email protected]';
+
+ group('ShareWithUserBloc', () {
+ blocTest<ShareWithUserBloc, ShareWithUserState>(
+ 'shares page with user',
+ build: () => bloc,
+ act: (bloc) => bloc.add(
+ const ShareWithUserEvent.share(
+ emails: [email],
+ accessLevel: ShareAccessLevel.readOnly,
+ ),
+ ),
+ wait: const Duration(milliseconds: 100),
+ expect: () => [
+ // First state: shareResult is null
+ isA<ShareWithUserState>()
+ .having((s) => s.shareResult, 'shareResult', isNull),
+ // Second state: shareResult is Success
+ isA<ShareWithUserState>()
+ .having((s) => s.shareResult, 'shareResult', isNotNull),
+ // Third state: users updated, shareResult still Success
+ isA<ShareWithUserState>().having(
+ (s) => s.users.any((u) => u.email == email),
+ 'users contains new user',
+ isTrue,
+ ),
+ ],
+ );
+
+ blocTest<ShareWithUserBloc, ShareWithUserState>(
+ 'removes user from page',
+ build: () => bloc,
+ act: (bloc) => bloc.add(
+ const ShareWithUserEvent.remove(
+ emails: [email],
+ ),
+ ),
+ wait: const Duration(milliseconds: 100),
+ expect: () => [
+ // First state: removeResult is null
+ isA<ShareWithUserState>()
+ .having((s) => s.removeResult, 'removeResult', isNull),
+ // Second state: removeResult is Success
+ isA<ShareWithUserState>()
+ .having((s) => s.removeResult, 'removeResult', isNotNull),
+ // Third state: users updated, removeResult still Success
+ isA<ShareWithUserState>().having(
+ (s) => s.users.any((u) => u.email == email),
+ 'users contains removed user',
+ isFalse,
+ ),
+ ],
+ );
+
+ blocTest<ShareWithUserBloc, ShareWithUserState>(
+ 'updates access level for user',
+ build: () => bloc,
+ act: (bloc) => bloc.add(
+ const ShareWithUserEvent.updateAccessLevel(
+ email: email,
+ accessLevel: ShareAccessLevel.fullAccess,
+ ),
+ ),
+ wait: const Duration(milliseconds: 100),
+ expect: () => [
+ // First state: updateAccessLevelResult is null
+ isA<ShareWithUserState>().having(
+ (s) => s.updateAccessLevelResult,
+ 'updateAccessLevelResult',
+ isNull,
+ ),
+ // Second state: updateAccessLevelResult is Success
+ isA<ShareWithUserState>().having(
+ (s) => s.updateAccessLevelResult,
+ 'updateAccessLevelResult',
+ isNotNull,
+ ),
+ // Third state: users updated, vivian's access level is fullAccess
+ isA<ShareWithUserState>().having(
+ (s) => s.users.firstWhere((u) => u.email == email).accessLevel,
+ 'vivian accessLevel',
+ ShareAccessLevel.fullAccess,
+ ),
+ ],
+ );
+ });
+}
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.dart
new file mode 100644
index 0000000000..f3379206ae
--- /dev/null
+++ b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/access_level_list_widget_test.dart
@@ -0,0 +1,82 @@
+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_ui/appflowy_ui.dart';
+import 'package:flutter_test/flutter_test.dart';
+
+import '../../../widget_test_wrapper.dart';
+
+void main() {
+ group('access_level_list_widget.dart: ', () {
+ testWidgets('shows all access levels and highlights selected',
+ (WidgetTester tester) async {
+ // Track callback invocations
+ ShareAccessLevel? selectedLevel;
+ bool turnedIntoMember = false;
+ bool removedAccess = false;
+
+ await tester.pumpWidget(
+ WidgetTestWrapper(
+ child: AccessLevelListWidget(
+ enableAccessLevelSelection: true,
+ selectedAccessLevel: ShareAccessLevel.readAndWrite,
+ callbacks: AccessLevelListCallbacks(
+ onSelectAccessLevel: (level) => selectedLevel = level,
+ onTurnIntoMember: () => turnedIntoMember = true,
+ onRemoveAccess: () => removedAccess = true,
+ ),
+ ),
+ ),
+ );
+
+ // Check all access level options are present
+ expect(find.text(ShareAccessLevel.fullAccess.i18n), findsOneWidget);
+ expect(find.text(ShareAccessLevel.readAndWrite.i18n), findsOneWidget);
+ expect(find.text(ShareAccessLevel.readAndComment.i18n), findsOneWidget);
+ expect(find.text(ShareAccessLevel.readOnly.i18n), findsOneWidget);
+
+ // Check that the selected access level is visually marked
+ final selectedTile = tester
+ .widgetList<AFTextMenuItem>(find.byType(AFTextMenuItem))
+ .where((item) => item.selected);
+ expect(selectedTile.length, 1);
+ expect(selectedTile.first.title, ShareAccessLevel.readAndWrite.i18n);
+
+ // Tap on another access level
+ await tester.tap(find.text(ShareAccessLevel.readOnly.i18n));
+ await tester.pumpAndSettle();
+ expect(selectedLevel, ShareAccessLevel.readOnly);
+
+ // Tap on Turn into Member
+ await tester.tap(find.text('Turn into Member'));
+ await tester.pumpAndSettle();
+ expect(turnedIntoMember, isTrue);
+
+ // Tap on Remove access
+ await tester.tap(find.text('Remove access'));
+ await tester.pumpAndSettle();
+ expect(removedAccess, isTrue);
+ });
+
+ testWidgets('shows only management options when selection disabled',
+ (WidgetTester tester) async {
+ await tester.pumpWidget(
+ WidgetTestWrapper(
+ child: AccessLevelListWidget(
+ selectedAccessLevel: ShareAccessLevel.readOnly,
+ callbacks: AccessLevelListCallbacks.none(),
+ ),
+ ),
+ );
+
+ // Access level options should not be found
+ expect(find.text(ShareAccessLevel.fullAccess.i18n), findsNothing);
+ expect(find.text(ShareAccessLevel.readAndWrite.i18n), findsNothing);
+ expect(find.text(ShareAccessLevel.readAndComment.i18n), findsNothing);
+ 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);
+ });
+ });
+}
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.dart
new file mode 100644
index 0000000000..b930a3fa64
--- /dev/null
+++ b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/copy_link_widget_test.dart
@@ -0,0 +1,57 @@
+import 'package:appflowy/features/share_tab/data/repositories/mock_share_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/plugins/document/presentation/editor_plugins/copy_and_paste/clipboard_service.dart';
+import 'package:appflowy/startup/startup.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:mocktail/mocktail.dart';
+
+import '../../../widget_test_wrapper.dart';
+
+void main() {
+ setUpAll(() {
+ registerFallbackValue(const ClipboardServiceData());
+ });
+
+ setUp(() {
+ if (getIt.isRegistered<ClipboardService>()) {
+ getIt.unregister<ClipboardService>();
+ }
+ getIt.registerSingleton<ClipboardService>(_MockClipboardService());
+ });
+
+ group('copy_link_widget.dart: ', () {
+ testWidgets('shows the share link and copy button, triggers callback',
+ (WidgetTester tester) async {
+ final mockClipboard = getIt<ClipboardService>() as _MockClipboardService;
+ when(() => mockClipboard.setData(any())).thenAnswer((_) async {});
+ final bloc = ShareWithUserBloc(
+ repository: MockShareRepository(),
+ pageId: 'pageId',
+ workspaceId: 'workspaceId',
+ );
+ const testLink = 'https://test.link';
+ await tester.pumpWidget(
+ WidgetTestWrapper(
+ child: BlocProvider<ShareWithUserBloc>.value(
+ value: bloc,
+ child: CopyLinkWidget(shareLink: testLink),
+ ),
+ ),
+ );
+
+ expect(find.text(testLink), findsOneWidget);
+ expect(find.text('Copy link'), findsOneWidget);
+ await tester.tap(find.text('Copy link'));
+ await tester.pumpAndSettle();
+ // Timer (duration: 0:00:03.000000, periodic: false), created:
+ // #0 new FakeTimer._ (package:fake_async/fake_async.dart:308:62)
+ await tester.pump(const Duration(seconds: 4));
+
+ verify(() => mockClipboard.setData(any())).called(1);
+ });
+ });
+}
+
+class _MockClipboardService extends Mock implements ClipboardService {}
diff --git a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/edit_access_level_widget_test.dart b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/edit_access_level_widget_test.dart
new file mode 100644
index 0000000000..dcaec14f6d
--- /dev/null
+++ b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/edit_access_level_widget_test.dart
@@ -0,0 +1,31 @@
+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:flutter_test/flutter_test.dart';
+
+import '../../../widget_test_wrapper.dart';
+
+void main() {
+ group('edit_access_level_widget.dart: ', () {
+ testWidgets('shows selected access level and opens popover',
+ (WidgetTester tester) async {
+ await tester.pumpWidget(
+ WidgetTestWrapper(
+ child: EditAccessLevelWidget(
+ selectedAccessLevel: ShareAccessLevel.readOnly,
+ callbacks: AccessLevelListCallbacks(
+ onSelectAccessLevel: (level) {},
+ onTurnIntoMember: () {},
+ onRemoveAccess: () {},
+ ),
+ ),
+ ),
+ );
+ // Check selected access level is shown
+ expect(find.text(ShareAccessLevel.readOnly.i18n), findsOneWidget);
+ // Tap to open popover
+ await tester.tap(find.text(ShareAccessLevel.readOnly.i18n));
+ await tester.pumpAndSettle();
+ });
+ });
+}
diff --git a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/general_access_section_test.dart b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/general_access_section_test.dart
new file mode 100644
index 0000000000..2468e4c878
--- /dev/null
+++ b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/general_access_section_test.dart
@@ -0,0 +1,19 @@
+import 'package:appflowy/features/share_tab/presentation/widgets/general_access_section.dart';
+import 'package:flutter_test/flutter_test.dart';
+
+import '../../../widget_test_wrapper.dart';
+
+void main() {
+ group('general_access_section.dart: ', () {
+ testWidgets('shows section title and SharedGroupWidget',
+ (WidgetTester tester) async {
+ await tester.pumpWidget(
+ WidgetTestWrapper(
+ child: GeneralAccessSection(),
+ ),
+ );
+ expect(find.text('General access'), findsOneWidget);
+ expect(find.byType(GeneralAccessSection), findsOneWidget);
+ });
+ });
+}
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.dart
new file mode 100644
index 0000000000..f646e24985
--- /dev/null
+++ b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/people_with_access_section_test.dart
@@ -0,0 +1,35 @@
+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:flutter_test/flutter_test.dart';
+
+import '../../../widget_test_wrapper.dart';
+
+void main() {
+ group('people_with_access_section.dart: ', () {
+ testWidgets('shows section title and user widgets, triggers callbacks',
+ (WidgetTester tester) async {
+ final user = SharedUser(
+ name: 'Test User',
+ email: '[email protected]',
+ accessLevel: ShareAccessLevel.readOnly,
+ role: ShareRole.member,
+ );
+
+ await tester.pumpWidget(
+ WidgetTestWrapper(
+ child: PeopleWithAccessSection(
+ currentUserEmail: user.email,
+ users: [user],
+ callbacks: PeopleWithAccessSectionCallbacks(
+ onRemoveAccess: (_) {},
+ onTurnIntoMember: (_) {},
+ onSelectAccessLevel: (_, level) {},
+ ),
+ ),
+ ),
+ );
+ expect(find.text('People with access'), findsOneWidget);
+ expect(find.text('Test User'), findsOneWidget);
+ });
+ });
+}
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.dart
new file mode 100644
index 0000000000..4931e1051f
--- /dev/null
+++ b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/share_with_user_widget_test.dart
@@ -0,0 +1,29 @@
+import 'package:appflowy/features/share_tab/presentation/widgets/share_with_user_widget.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+
+import '../../../widget_test_wrapper.dart';
+
+void main() {
+ group('share_with_user_widget.dart: ', () {
+ testWidgets('shows input and button, triggers callback on valid email',
+ (WidgetTester tester) async {
+ List<String>? invited;
+ await tester.pumpWidget(
+ WidgetTestWrapper(
+ child: ShareWithUserWidget(
+ onInvite: (emails) => invited = emails,
+ ),
+ ),
+ );
+ expect(find.byType(TextField), findsOneWidget);
+ expect(find.text('Invite'), findsOneWidget);
+ await tester.enterText(find.byType(TextField), '[email protected]');
+ await tester.pumpAndSettle();
+ await tester.tap(find.text('Invite'));
+ 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.dart
new file mode 100644
index 0000000000..b71f8da708
--- /dev/null
+++ b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/shared_group_widget_test.dart
@@ -0,0 +1,24 @@
+import 'package:appflowy/features/share_tab/presentation/widgets/shared_group_widget.dart';
+import 'package:flutter_test/flutter_test.dart';
+
+import '../../../widget_test_wrapper.dart';
+
+void main() {
+ group('shared_group_widget.dart: ', () {
+ testWidgets('shows group name, description, and trailing widget',
+ (WidgetTester tester) async {
+ await tester.pumpWidget(
+ WidgetTestWrapper(
+ child: SharedGroupWidget(),
+ ),
+ );
+ expect(find.text('Anyone at AppFlowy'), findsOneWidget);
+ expect(
+ find.text('Anyone in this group with the link can edit'),
+ findsOneWidget,
+ );
+ // Trailing widget: EditAccessLevelWidget (disabled)
+ expect(find.byType(SharedGroupWidget), findsOneWidget);
+ });
+ });
+}
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.dart
new file mode 100644
index 0000000000..f5178236ee
--- /dev/null
+++ b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/shared_user_widget_test.dart
@@ -0,0 +1,49 @@
+import 'package:appflowy/features/share_tab/data/models/models.dart';
+import 'package:appflowy/features/share_tab/presentation/widgets/shared_user_widget.dart';
+import 'package:flutter_test/flutter_test.dart';
+
+import '../../../widget_test_wrapper.dart';
+
+void main() {
+ group('shared_user_widget.dart: ', () {
+ testWidgets('shows user name, email, and role',
+ (WidgetTester tester) async {
+ final user = SharedUser(
+ name: 'Test User',
+ email: '[email protected]',
+ accessLevel: ShareAccessLevel.readOnly,
+ role: ShareRole.member,
+ );
+ await tester.pumpWidget(
+ WidgetTestWrapper(
+ child: SharedUserWidget(
+ user: user,
+ currentUser: user,
+ ),
+ ),
+ );
+ expect(find.text('Test User'), findsOneWidget);
+ expect(find.text('[email protected]'), findsOneWidget);
+ expect(find.text('(You)'), findsOneWidget);
+ });
+
+ testWidgets('shows Guest label for guest user',
+ (WidgetTester tester) async {
+ final user = SharedUser(
+ name: 'Guest User',
+ email: '[email protected]',
+ accessLevel: ShareAccessLevel.readOnly,
+ role: ShareRole.guest,
+ );
+ await tester.pumpWidget(
+ WidgetTestWrapper(
+ child: SharedUserWidget(
+ user: user,
+ currentUser: user,
+ ),
+ ),
+ );
+ expect(find.text('Guest'), findsOneWidget);
+ });
+ });
+}
diff --git a/frontend/appflowy_flutter/test/widget_test/widget_test_wrapper.dart b/frontend/appflowy_flutter/test/widget_test/widget_test_wrapper.dart
new file mode 100644
index 0000000000..80cf3b8e60
--- /dev/null
+++ b/frontend/appflowy_flutter/test/widget_test/widget_test_wrapper.dart
@@ -0,0 +1,26 @@
+import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';
+import 'package:appflowy_ui/appflowy_ui.dart';
+import 'package:flutter/material.dart';
+
+class WidgetTestWrapper extends StatelessWidget {
+ const WidgetTestWrapper({super.key, required this.child});
+ final Widget child;
+
+ @override
+ Widget build(BuildContext context) {
+ final brightness = Theme.of(context).brightness;
+ final themeBuilder = AppFlowyDefaultTheme();
+ return ToastificationWrapper(
+ child: MaterialApp(
+ home: Material(
+ child: AppFlowyTheme(
+ data: brightness == Brightness.light
+ ? themeBuilder.light()
+ : themeBuilder.dark(),
+ child: child,
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lock
index 12ede1f9e9..646fbd3658 100644
--- a/frontend/rust-lib/Cargo.lock
+++ b/frontend/rust-lib/Cargo.lock
@@ -163,7 +163,7 @@ checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f"
[[package]]
name = "app-error"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=f840cd362cc6176079303adde973e0bd50cee749#f840cd362cc6176079303adde973e0bd50cee749"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=e75450c#e75450c050c60c29ad32bb579a5f0a9aef6e69ea"
dependencies = [
"anyhow",
"bincode",
@@ -183,7 +183,7 @@ dependencies = [
[[package]]
name = "appflowy-ai-client"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=f840cd362cc6176079303adde973e0bd50cee749#f840cd362cc6176079303adde973e0bd50cee749"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=e75450c#e75450c050c60c29ad32bb579a5f0a9aef6e69ea"
dependencies = [
"anyhow",
"bytes",
@@ -860,7 +860,7 @@ dependencies = [
[[package]]
name = "client-api"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=f840cd362cc6176079303adde973e0bd50cee749#f840cd362cc6176079303adde973e0bd50cee749"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=e75450c#e75450c050c60c29ad32bb579a5f0a9aef6e69ea"
dependencies = [
"again",
"anyhow",
@@ -915,7 +915,7 @@ dependencies = [
[[package]]
name = "client-api-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=f840cd362cc6176079303adde973e0bd50cee749#f840cd362cc6176079303adde973e0bd50cee749"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=e75450c#e75450c050c60c29ad32bb579a5f0a9aef6e69ea"
dependencies = [
"collab-entity",
"collab-rt-entity",
@@ -928,7 +928,7 @@ dependencies = [
[[package]]
name = "client-websocket"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=f840cd362cc6176079303adde973e0bd50cee749#f840cd362cc6176079303adde973e0bd50cee749"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=e75450c#e75450c050c60c29ad32bb579a5f0a9aef6e69ea"
dependencies = [
"futures-channel",
"futures-util",
@@ -1199,7 +1199,7 @@ dependencies = [
[[package]]
name = "collab-rt-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=f840cd362cc6176079303adde973e0bd50cee749#f840cd362cc6176079303adde973e0bd50cee749"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=e75450c#e75450c050c60c29ad32bb579a5f0a9aef6e69ea"
dependencies = [
"anyhow",
"bincode",
@@ -1221,7 +1221,7 @@ dependencies = [
[[package]]
name = "collab-rt-protocol"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=f840cd362cc6176079303adde973e0bd50cee749#f840cd362cc6176079303adde973e0bd50cee749"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=e75450c#e75450c050c60c29ad32bb579a5f0a9aef6e69ea"
dependencies = [
"anyhow",
"async-trait",
@@ -1648,7 +1648,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]]
name = "database-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=f840cd362cc6176079303adde973e0bd50cee749#f840cd362cc6176079303adde973e0bd50cee749"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=e75450c#e75450c050c60c29ad32bb579a5f0a9aef6e69ea"
dependencies = [
"bincode",
"bytes",
@@ -3186,7 +3186,7 @@ dependencies = [
[[package]]
name = "gotrue"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=f840cd362cc6176079303adde973e0bd50cee749#f840cd362cc6176079303adde973e0bd50cee749"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=e75450c#e75450c050c60c29ad32bb579a5f0a9aef6e69ea"
dependencies = [
"anyhow",
"getrandom 0.2.10",
@@ -3201,7 +3201,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=f840cd362cc6176079303adde973e0bd50cee749#f840cd362cc6176079303adde973e0bd50cee749"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=e75450c#e75450c050c60c29ad32bb579a5f0a9aef6e69ea"
dependencies = [
"app-error",
"jsonwebtoken",
@@ -3894,7 +3894,7 @@ dependencies = [
[[package]]
name = "infra"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=f840cd362cc6176079303adde973e0bd50cee749#f840cd362cc6176079303adde973e0bd50cee749"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=e75450c#e75450c050c60c29ad32bb579a5f0a9aef6e69ea"
dependencies = [
"anyhow",
"bytes",
@@ -6865,7 +6865,7 @@ dependencies = [
[[package]]
name = "shared-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=f840cd362cc6176079303adde973e0bd50cee749#f840cd362cc6176079303adde973e0bd50cee749"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=e75450c#e75450c050c60c29ad32bb579a5f0a9aef6e69ea"
dependencies = [
"anyhow",
"app-error",
@@ -8920,7 +8920,7 @@ dependencies = [
[[package]]
name = "workspace-template"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=f840cd362cc6176079303adde973e0bd50cee749#f840cd362cc6176079303adde973e0bd50cee749"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=e75450c#e75450c050c60c29ad32bb579a5f0a9aef6e69ea"
dependencies = [
"anyhow",
"async-trait",
diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.toml
index 2b5ef59146..0775e92b77 100644
--- a/frontend/rust-lib/Cargo.toml
+++ b/frontend/rust-lib/Cargo.toml
@@ -109,9 +109,9 @@ flowy-sqlite-vec = { path = "flowy-sqlite-vec" }
# Run the script.add_workspace_members:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
-client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "f840cd362cc6176079303adde973e0bd50cee749" }
-client-api-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "f840cd362cc6176079303adde973e0bd50cee749" }
-workspace-template = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "f840cd362cc6176079303adde973e0bd50cee749" }
+client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "e75450c" }
+client-api-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "e75450c" }
+workspace-template = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "e75450c" }
[profile.dev]
opt-level = 0
diff --git a/frontend/rust-lib/flowy-core/src/deps_resolve/cloud_service_impl.rs b/frontend/rust-lib/flowy-core/src/deps_resolve/cloud_service_impl.rs
index 8cb72cc415..006486287a 100644
--- a/frontend/rust-lib/flowy-core/src/deps_resolve/cloud_service_impl.rs
+++ b/frontend/rust-lib/flowy-core/src/deps_resolve/cloud_service_impl.rs
@@ -31,6 +31,9 @@ use flowy_folder_pub::cloud::{
use flowy_folder_pub::entities::PublishPayload;
use flowy_search_pub::cloud::SearchCloudService;
use flowy_server_pub::af_cloud_config::AFCloudConfiguration;
+use flowy_server_pub::guest_dto::{
+ RevokeSharedViewAccessRequest, ShareViewWithGuestRequest, SharedViewDetails,
+};
use flowy_storage_pub::cloud::{ObjectIdentity, ObjectValue, StorageCloudService};
use flowy_storage_pub::storage::{CompletedPartRequest, CreateUploadResponse, UploadPartResponse};
use flowy_user_pub::cloud::{UserCloudService, UserCloudServiceProvider};
@@ -404,6 +407,43 @@ impl FolderCloudService for ServerProvider {
.import_zip(file_path)
.await
}
+
+ async fn share_page_with_user(
+ &self,
+ workspace_id: &Uuid,
+ params: ShareViewWithGuestRequest,
+ ) -> Result<(), FlowyError> {
+ self
+ .get_server()?
+ .folder_service()
+ .share_page_with_user(workspace_id, params)
+ .await
+ }
+
+ async fn revoke_shared_page_access(
+ &self,
+ workspace_id: &Uuid,
+ view_id: &Uuid,
+ params: RevokeSharedViewAccessRequest,
+ ) -> Result<(), FlowyError> {
+ self
+ .get_server()?
+ .folder_service()
+ .revoke_shared_page_access(workspace_id, view_id, params)
+ .await
+ }
+
+ async fn get_shared_page_details(
+ &self,
+ workspace_id: &Uuid,
+ view_id: &Uuid,
+ ) -> Result<SharedViewDetails, FlowyError> {
+ self
+ .get_server()?
+ .folder_service()
+ .get_shared_page_details(workspace_id, view_id)
+ .await
+ }
}
#[async_trait]
diff --git a/frontend/rust-lib/flowy-folder-pub/src/cloud.rs b/frontend/rust-lib/flowy-folder-pub/src/cloud.rs
index 98416fd851..6423a73d74 100644
--- a/frontend/rust-lib/flowy-folder-pub/src/cloud.rs
+++ b/frontend/rust-lib/flowy-folder-pub/src/cloud.rs
@@ -1,6 +1,10 @@
use crate::entities::PublishPayload;
pub use anyhow::Error;
-use client_api::entity::{PublishInfo, workspace_dto::PublishInfoView};
+use client_api::entity::{
+ PublishInfo,
+ guest_dto::{RevokeSharedViewAccessRequest, ShareViewWithGuestRequest, SharedViewDetails},
+ workspace_dto::PublishInfoView,
+};
use collab::entity::EncodedCollab;
use collab_entity::CollabType;
pub use collab_folder::{Folder, FolderData, Workspace};
@@ -87,6 +91,28 @@ pub trait FolderCloudService: Send + Sync + 'static {
async fn get_publish_namespace(&self, workspace_id: &Uuid) -> Result<String, FlowyError>;
async fn import_zip(&self, file_path: &str) -> Result<(), FlowyError>;
+
+ /// Share a page with a user (member or guest)
+ async fn share_page_with_user(
+ &self,
+ workspace_id: &Uuid,
+ params: ShareViewWithGuestRequest,
+ ) -> Result<(), FlowyError>;
+
+ /// Revoke access to a page for a user (member or guest)
+ async fn revoke_shared_page_access(
+ &self,
+ workspace_id: &Uuid,
+ view_id: &Uuid,
+ params: RevokeSharedViewAccessRequest,
+ ) -> Result<(), FlowyError>;
+
+ /// Get the shared members/guests of a page
+ async fn get_shared_page_details(
+ &self,
+ workspace_id: &Uuid,
+ view_id: &Uuid,
+ ) -> Result<SharedViewDetails, FlowyError>;
}
#[derive(Debug)]
diff --git a/frontend/rust-lib/flowy-folder/src/entities/view.rs b/frontend/rust-lib/flowy-folder/src/entities/view.rs
index 77e1dcb160..973ffd24c0 100644
--- a/frontend/rust-lib/flowy-folder/src/entities/view.rs
+++ b/frontend/rust-lib/flowy-folder/src/entities/view.rs
@@ -1,3 +1,7 @@
+use client_api::entity::guest_dto::{
+ RevokeSharedViewAccessRequest, ShareViewWithGuestRequest, SharedUser, SharedViewDetails,
+};
+use client_api::entity::{AFAccessLevel, AFRole};
use collab_folder::{View, ViewIcon, ViewLayout};
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
use flowy_error::ErrorCode;
@@ -679,6 +683,160 @@ impl TryInto<DuplicateViewParams> for DuplicateViewPayloadPB {
}
}
+#[derive(Eq, PartialEq, Hash, Debug, ProtoBuf_Enum, Clone, Default)]
+pub enum AFAccessLevelPB {
+ #[default]
+ ReadOnly = 0,
+ ReadAndComment = 1,
+ ReadAndWrite = 2,
+ FullAccess = 3,
+}
+
+impl From<AFAccessLevelPB> for AFAccessLevel {
+ fn from(pb: AFAccessLevelPB) -> Self {
+ match pb {
+ AFAccessLevelPB::ReadOnly => AFAccessLevel::ReadOnly,
+ AFAccessLevelPB::ReadAndComment => AFAccessLevel::ReadAndComment,
+ AFAccessLevelPB::ReadAndWrite => AFAccessLevel::ReadAndWrite,
+ AFAccessLevelPB::FullAccess => AFAccessLevel::FullAccess,
+ }
+ }
+}
+
+impl From<AFAccessLevel> for AFAccessLevelPB {
+ fn from(level: AFAccessLevel) -> Self {
+ match level {
+ AFAccessLevel::ReadOnly => AFAccessLevelPB::ReadOnly,
+ AFAccessLevel::ReadAndComment => AFAccessLevelPB::ReadAndComment,
+ AFAccessLevel::ReadAndWrite => AFAccessLevelPB::ReadAndWrite,
+ AFAccessLevel::FullAccess => AFAccessLevelPB::FullAccess,
+ }
+ }
+}
+
+#[derive(Debug, ProtoBuf_Enum, Clone, Default, Eq, PartialEq)]
+pub enum AFRolePB {
+ Owner = 0,
+ Member = 1,
+ #[default]
+ Guest = 2,
+}
+
+impl From<AFRole> for AFRolePB {
+ fn from(value: AFRole) -> Self {
+ match value {
+ AFRole::Owner => AFRolePB::Owner,
+ AFRole::Member => AFRolePB::Member,
+ AFRole::Guest => AFRolePB::Guest,
+ }
+ }
+}
+
+impl From<AFRolePB> for AFRole {
+ fn from(value: AFRolePB) -> Self {
+ match value {
+ AFRolePB::Owner => AFRole::Owner,
+ AFRolePB::Member => AFRole::Member,
+ AFRolePB::Guest => AFRole::Guest,
+ }
+ }
+}
+
+#[derive(Default, ProtoBuf, Clone, Debug)]
+pub struct SharePageWithUserPayloadPB {
+ #[pb(index = 1)]
+ pub view_id: String,
+
+ #[pb(index = 2)]
+ pub emails: Vec<String>,
+
+ #[pb(index = 3)]
+ pub access_level: AFAccessLevelPB,
+}
+
+impl TryInto<ShareViewWithGuestRequest> for SharePageWithUserPayloadPB {
+ type Error = ErrorCode;
+ fn try_into(self) -> Result<ShareViewWithGuestRequest, Self::Error> {
+ let view_id = Uuid::parse_str(&self.view_id).map_err(|_| ErrorCode::InvalidParams)?;
+ Ok(ShareViewWithGuestRequest {
+ view_id,
+ emails: self.emails,
+ access_level: self.access_level.into(),
+ })
+ }
+}
+
+#[derive(Default, ProtoBuf, Clone, Debug)]
+pub struct RemoveUserFromSharedPagePayloadPB {
+ #[pb(index = 1)]
+ pub view_id: String,
+
+ #[pb(index = 2)]
+ pub emails: Vec<String>,
+}
+
+impl From<RemoveUserFromSharedPagePayloadPB> for RevokeSharedViewAccessRequest {
+ fn from(payload: RemoveUserFromSharedPagePayloadPB) -> Self {
+ RevokeSharedViewAccessRequest {
+ emails: payload.emails,
+ }
+ }
+}
+
+#[derive(Default, ProtoBuf, Clone, Debug)]
+pub struct SharedUserPB {
+ #[pb(index = 1)]
+ pub email: String,
+
+ #[pb(index = 2)]
+ pub name: String,
+
+ #[pb(index = 3)]
+ pub role: AFRolePB,
+
+ #[pb(index = 4)]
+ pub access_level: AFAccessLevelPB,
+
+ #[pb(index = 5, one_of)]
+ pub avatar_url: Option<String>,
+}
+
+impl From<SharedUser> for SharedUserPB {
+ fn from(user: SharedUser) -> Self {
+ SharedUserPB {
+ email: user.email,
+ name: user.name,
+ role: user.role.into(),
+ access_level: user.access_level.into(),
+ avatar_url: user.avatar_url,
+ }
+ }
+}
+
+#[derive(Default, ProtoBuf, Clone, Debug)]
+pub struct RepeatedSharedUserPB {
+ #[pb(index = 1)]
+ pub items: Vec<SharedUserPB>,
+}
+
+impl From<SharedViewDetails> for RepeatedSharedUserPB {
+ fn from(details: SharedViewDetails) -> Self {
+ RepeatedSharedUserPB {
+ items: details
+ .shared_with
+ .into_iter()
+ .map(|user| user.into())
+ .collect(),
+ }
+ }
+}
+
+#[derive(Default, ProtoBuf, Clone, Debug)]
+pub struct GetSharedUsersPayloadPB {
+ #[pb(index = 1)]
+ pub view_id: String,
+}
+
// impl<'de> Deserialize<'de> for ViewDataType {
// fn deserialize<D>(deserializer: D) -> Result<Self, <D as Deserializer<'de>>::Error>
// where
diff --git a/frontend/rust-lib/flowy-folder/src/event_handler.rs b/frontend/rust-lib/flowy-folder/src/event_handler.rs
index 72a863278a..780f1f6b58 100644
--- a/frontend/rust-lib/flowy-folder/src/event_handler.rs
+++ b/frontend/rust-lib/flowy-folder/src/event_handler.rs
@@ -1,3 +1,4 @@
+use client_api::entity::guest_dto::RevokeSharedViewAccessRequest;
use flowy_error::{FlowyError, FlowyResult};
use lib_dispatch::prelude::{AFPluginData, AFPluginState, DataResult, data_result_ok};
use std::str::FromStr;
@@ -541,3 +542,41 @@ pub(crate) async fn unlock_view_handler(
folder.unlock_view(&view_id).await?;
Ok(())
}
+
+#[tracing::instrument(level = "debug", skip(data, folder))]
+pub(crate) async fn get_shared_users_handler(
+ data: AFPluginData<GetSharedUsersPayloadPB>,
+ folder: AFPluginState<Weak<FolderManager>>,
+) -> DataResult<RepeatedSharedUserPB, FlowyError> {
+ let folder = upgrade_folder(folder)?;
+ let params = data.into_inner();
+ let view_id = Uuid::from_str(&params.view_id)?;
+ let shared_users = folder.get_shared_page_details(&view_id).await?;
+ data_result_ok(shared_users.into())
+}
+
+#[tracing::instrument(level = "debug", skip(data, folder))]
+pub(crate) async fn share_page_with_user_handler(
+ data: AFPluginData<SharePageWithUserPayloadPB>,
+ folder: AFPluginState<Weak<FolderManager>>,
+) -> Result<(), FlowyError> {
+ let folder = upgrade_folder(folder)?;
+ let params = data.into_inner().try_into()?;
+ folder.share_page_with_user(params).await?;
+ Ok(())
+}
+
+#[tracing::instrument(level = "debug", skip(data, folder))]
+pub(crate) async fn remove_user_from_shared_page_handler(
+ data: AFPluginData<RemoveUserFromSharedPagePayloadPB>,
+ folder: AFPluginState<Weak<FolderManager>>,
+) -> Result<(), FlowyError> {
+ let folder = upgrade_folder(folder)?;
+ let params = data.into_inner();
+ let page_id = Uuid::from_str(&params.view_id)?;
+ let params = RevokeSharedViewAccessRequest {
+ emails: params.emails,
+ };
+ folder.revoke_shared_page_access(&page_id, params).await?;
+ Ok(())
+}
diff --git a/frontend/rust-lib/flowy-folder/src/event_map.rs b/frontend/rust-lib/flowy-folder/src/event_map.rs
index c857353c4b..8adac46b43 100644
--- a/frontend/rust-lib/flowy-folder/src/event_map.rs
+++ b/frontend/rust-lib/flowy-folder/src/event_map.rs
@@ -54,6 +54,9 @@ pub fn init(folder: Weak<FolderManager>) -> AFPlugin {
.event(FolderEvent::RemoveDefaultPublishView, remove_default_publish_view_handler)
.event(FolderEvent::LockView, lock_view_handler)
.event(FolderEvent::UnlockView, unlock_view_handler)
+ .event(FolderEvent::SharePageWithUser, share_page_with_user_handler)
+ .event(FolderEvent::RemoveUserFromSharedPage, remove_user_from_shared_page_handler)
+ .event(FolderEvent::GetSharedUsers, get_shared_users_handler)
}
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
@@ -226,4 +229,13 @@ pub enum FolderEvent {
#[event(input = "ViewIdPB")]
UnlockView = 55,
+
+ #[event(input = "SharePageWithUserPayloadPB")]
+ SharePageWithUser = 56,
+
+ #[event(input = "RemoveUserFromSharedPagePayloadPB")]
+ RemoveUserFromSharedPage = 57,
+
+ #[event(input = "GetSharedUsersPayloadPB", output = "RepeatedSharedUserPB")]
+ GetSharedUsers = 58,
}
diff --git a/frontend/rust-lib/flowy-folder/src/manager.rs b/frontend/rust-lib/flowy-folder/src/manager.rs
index 4d6bf503af..3742841e29 100644
--- a/frontend/rust-lib/flowy-folder/src/manager.rs
+++ b/frontend/rust-lib/flowy-folder/src/manager.rs
@@ -18,6 +18,9 @@ use crate::view_operation::{
};
use arc_swap::ArcSwapOption;
use client_api::entity::PublishInfo;
+use client_api::entity::guest_dto::{
+ RevokeSharedViewAccessRequest, ShareViewWithGuestRequest, SharedViewDetails,
+};
use client_api::entity::workspace_dto::PublishInfoView;
use collab::core::collab::{DataSource, IndexContentReceiver};
use collab::lock::RwLock;
@@ -1350,6 +1353,46 @@ impl FolderManager {
Ok(())
}
+ /// Share the page with a user (member or guest).
+ pub async fn share_page_with_user(
+ &self,
+ params: ShareViewWithGuestRequest,
+ ) -> Result<(), FlowyError> {
+ let workspace_id = self.user.workspace_id()?;
+ self
+ .cloud_service()?
+ .share_page_with_user(&workspace_id, params)
+ .await?;
+ Ok(())
+ }
+
+ /// Revoke the shared page access of a user (member or guest).
+ pub async fn revoke_shared_page_access(
+ &self,
+ page_id: &Uuid,
+ params: RevokeSharedViewAccessRequest,
+ ) -> Result<(), FlowyError> {
+ let workspace_id = self.user.workspace_id()?;
+ self
+ .cloud_service()?
+ .revoke_shared_page_access(&workspace_id, page_id, params)
+ .await?;
+ Ok(())
+ }
+
+ /// Get the shared page details.
+ pub async fn get_shared_page_details(
+ &self,
+ page_id: &Uuid,
+ ) -> Result<SharedViewDetails, FlowyError> {
+ let workspace_id = self.user.workspace_id()?;
+ let result = self
+ .cloud_service()?
+ .get_shared_page_details(&workspace_id, page_id)
+ .await?;
+ Ok(result)
+ }
+
/// Publishes a view identified by the given `view_id`.
///
/// If `publish_name` is `None`, a default name will be generated using the view name and view id.
diff --git a/frontend/rust-lib/flowy-server/src/af_cloud/impls/folder.rs b/frontend/rust-lib/flowy-server/src/af_cloud/impls/folder.rs
index 76a50d06f9..68f0bbed6a 100644
--- a/frontend/rust-lib/flowy-server/src/af_cloud/impls/folder.rs
+++ b/frontend/rust-lib/flowy-server/src/af_cloud/impls/folder.rs
@@ -4,6 +4,9 @@ use client_api::entity::{
};
use client_api::entity::{PatchPublishedCollab, PublishInfo};
use collab_entity::CollabType;
+use flowy_server_pub::guest_dto::{
+ RevokeSharedViewAccessRequest, ShareViewWithGuestRequest, SharedViewDetails,
+};
use serde_json::to_vec;
use std::path::PathBuf;
use std::sync::Weak;
@@ -267,4 +270,44 @@ where
client.upload_import_file(&file_path, &url).await?;
Ok(())
}
+
+ async fn share_page_with_user(
+ &self,
+ workspace_id: &Uuid,
+ params: ShareViewWithGuestRequest,
+ ) -> Result<(), FlowyError> {
+ let try_get_client = self.inner.try_get_client();
+ try_get_client?
+ .share_view_with_guest(workspace_id, &params)
+ .await
+ .map_err(FlowyError::from)?;
+ Ok(())
+ }
+
+ async fn revoke_shared_page_access(
+ &self,
+ workspace_id: &Uuid,
+ view_id: &Uuid,
+ params: RevokeSharedViewAccessRequest,
+ ) -> Result<(), FlowyError> {
+ let try_get_client = self.inner.try_get_client();
+ try_get_client?
+ .revoke_shared_view_access(workspace_id, view_id, &params)
+ .await
+ .map_err(FlowyError::from)?;
+ Ok(())
+ }
+
+ async fn get_shared_page_details(
+ &self,
+ workspace_id: &Uuid,
+ view_id: &Uuid,
+ ) -> Result<SharedViewDetails, FlowyError> {
+ let try_get_client = self.inner.try_get_client();
+ let details = try_get_client?
+ .get_shared_view_details(workspace_id, view_id)
+ .await
+ .map_err(FlowyError::from)?;
+ Ok(details)
+ }
}
diff --git a/frontend/rust-lib/flowy-server/src/local_server/impls/folder.rs b/frontend/rust-lib/flowy-server/src/local_server/impls/folder.rs
index 6649bcc6b9..03a1217c95 100644
--- a/frontend/rust-lib/flowy-server/src/local_server/impls/folder.rs
+++ b/frontend/rust-lib/flowy-server/src/local_server/impls/folder.rs
@@ -15,6 +15,9 @@ use flowy_folder_pub::cloud::{
FolderCloudService, FolderCollabParams, FolderSnapshot, FullSyncCollabParams,
};
use flowy_folder_pub::entities::PublishPayload;
+use flowy_server_pub::guest_dto::{
+ RevokeSharedViewAccessRequest, ShareViewWithGuestRequest, SharedViewDetails,
+};
use lib_infra::async_trait::async_trait;
use std::sync::Arc;
use uuid::Uuid;
@@ -166,4 +169,29 @@ impl FolderCloudService for LocalServerFolderCloudServiceImpl {
async fn import_zip(&self, _file_path: &str) -> Result<(), FlowyError> {
Err(FlowyError::local_version_not_support())
}
+
+ async fn share_page_with_user(
+ &self,
+ workspace_id: &Uuid,
+ params: ShareViewWithGuestRequest,
+ ) -> Result<(), FlowyError> {
+ Err(FlowyError::local_version_not_support())
+ }
+
+ async fn revoke_shared_page_access(
+ &self,
+ workspace_id: &Uuid,
+ view_id: &Uuid,
+ params: RevokeSharedViewAccessRequest,
+ ) -> Result<(), FlowyError> {
+ Err(FlowyError::local_version_not_support())
+ }
+
+ async fn get_shared_page_details(
+ &self,
+ workspace_id: &Uuid,
+ view_id: &Uuid,
+ ) -> Result<SharedViewDetails, FlowyError> {
+ Err(FlowyError::local_version_not_support())
+ }
}