Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
feat: collapse space and switch space by shortcuts (#5554)
Lucas.Xua85d11fb6d79
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.dartindex 193c73f131..53c4a4038a 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@@ -84,7 +84,9 @@ class SpaceBloc extends Bloc<SpaceEvent, SpaceState> {);if (shouldShowUpgradeDialog) {- add(const SpaceEvent.migrate());+ if (!integrationMode().isTest) {+ add(const SpaceEvent.migrate());+ }}if (openFirstPage) {diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/shared_widget.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/shared_widget.dartindex 49dc1bc7e6..d4d7ab6772 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/shared_widget.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/shared_widget.dart@@ -214,20 +214,32 @@ class DeleteSpacePopup extends StatelessWidget {@overrideWidget build(BuildContext context) {+ final space = context.read<SpaceBloc>().state.currentSpace;+ final name = space != null ? space.name : '';return Padding(padding: const EdgeInsets.symmetric(- vertical: 12.0,+ vertical: 20.0,horizontal: 20.0,),child: Column(mainAxisSize: MainAxisSize.min,crossAxisAlignment: CrossAxisAlignment.start,children: [- FlowyText(- LocaleKeys.space_deleteConfirmation.tr(),- fontSize: 14.0,+ Row(+ children: [+ FlowyText(+ LocaleKeys.space_deleteConfirmation.tr() + name,+ fontSize: 14.0,+ ),+ const Spacer(),+ FlowyButton(+ useIntrinsicWidth: true,+ text: const FlowySvg(FlowySvgs.upgrade_close_s),+ onTap: () => Navigator.of(context).pop(),+ ),+ ],),- const VSpace(16.0),+ const VSpace(8.0),FlowyText.regular(LocaleKeys.space_deleteConfirmationDescription.tr(),fontSize: 12.0,@@ -245,7 +257,6 @@ class DeleteSpacePopup extends StatelessWidget {confirmButtonName: LocaleKeys.space_delete.tr(),confirmButtonColor: Theme.of(context).colorScheme.error,),- const VSpace(8.0),],),);diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/sidebar_space.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/sidebar_space.dartindex 890ae8e0de..e5fe8d2596 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/sidebar_space.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/sidebar_space.dart@@ -111,16 +111,17 @@ class _SpaceState extends State<_Space> {onCreateNewSpace: () => _showCreateSpaceDialog(context),onCollapseAllPages: () => isExpandedNotifier.value = true,),- MouseRegion(- onEnter: (_) => isHovered.value = true,- onExit: (_) => isHovered.value = false,- child: _Pages(- key: ValueKey(currentSpace.id),- isExpandedNotifier: isExpandedNotifier,- space: currentSpace,- isHovered: isHovered,+ if (state.isExpanded)+ MouseRegion(+ onEnter: (_) => isHovered.value = true,+ onExit: (_) => isHovered.value = false,+ child: _Pages(+ key: ValueKey(currentSpace.id),+ isExpandedNotifier: isExpandedNotifier,+ space: currentSpace,+ isHovered: isHovered,+ ),),- ),],);},diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/sidebar_space_header.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/sidebar_space_header.dartindex 5a672c61c4..6c277736cc 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/sidebar_space_header.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/sidebar_space_header.dart@@ -16,6 +16,7 @@ import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';import 'package:appflowy_popover/appflowy_popover.dart';import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';+import 'package:flowy_infra_ui/style_widget/hover.dart';import 'package:flowy_infra_ui/widget/flowy_tooltip.dart';import 'package:flutter/material.dart';import 'package:flutter_bloc/flutter_bloc.dart';@@ -53,15 +54,8 @@ class _SidebarSpaceHeaderState extends State<SidebarSpaceHeader> {@overrideWidget build(BuildContext context) {- return AppFlowyPopover(- constraints: const BoxConstraints(maxWidth: 252),- direction: PopoverDirection.bottomWithLeftAligned,- clickHandler: PopoverClickHandler.gestureDetector,- offset: const Offset(0, 4),- popupBuilder: (_) => BlocProvider.value(- value: context.read<SpaceBloc>(),- child: const SidebarSpaceMenu(),- ),+ return ValueListenableBuilder(+ valueListenable: isHovered,child: SizedBox(height: HomeSizes.workspaceSectionHeight,child: MouseRegion(@@ -70,13 +64,28 @@ class _SidebarSpaceHeaderState extends State<SidebarSpaceHeader> {child: Stack(alignment: Alignment.center,children: [- SizedBox(- height: HomeSizes.workspaceSectionHeight,- child: FlowyButton(- margin: const EdgeInsets.only(left: 6.0, right: 4.0),- iconPadding: 10.0,- text: _buildChild(),- rightIcon: const HSpace(60.0),+ Positioned(+ left: 3,+ top: 3,+ bottom: 3,+ child: SizedBox(+ height: HomeSizes.workspaceSectionHeight,+ child: AppFlowyPopover(+ constraints: const BoxConstraints(maxWidth: 252),+ direction: PopoverDirection.bottomWithLeftAligned,+ clickHandler: PopoverClickHandler.gestureDetector,+ offset: const Offset(0, 4),+ popupBuilder: (_) => BlocProvider.value(+ value: context.read<SpaceBloc>(),+ child: const SidebarSpaceMenu(),+ ),+ child: FlowyButton(+ useIntrinsicWidth: true,+ margin: const EdgeInsets.only(left: 3.0, right: 4.0),+ iconPadding: 10.0,+ text: _buildChild(),+ ),+ ),),),Positioned(@@ -87,6 +96,22 @@ class _SidebarSpaceHeaderState extends State<SidebarSpaceHeader> {),),),+ builder: (context, isHovered, child) {+ final style = HoverStyle(+ hoverColor: isHovered+ ? Theme.of(context).colorScheme.secondary+ : Colors.transparent,+ );+ return GestureDetector(+ onTap: () => context+ .read<SpaceBloc>()+ .add(SpaceEvent.expand(widget.space, !widget.isExpanded)),+ child: FlowyHoverContainer(+ style: style,+ child: child!,+ ),+ );+ },);}diff --git a/frontend/resources/translations/en.json b/frontend/resources/translations/en.jsonindex e1af37761e..50a3395568 100644--- a/frontend/resources/translations/en.json+++ b/frontend/resources/translations/en.json@@ -1892,7 +1892,7 @@},"space": {"delete": "Delete",- "deleteConfirmation": "Delete: {Space Name}",+ "deleteConfirmation": "Delete: ","deleteConfirmationDescription": "All pages within this Space will be deleted and moved to Trash.","rename": "Rename Space","changeIcon": "Change icon",