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
fix: some search LR issues (#7971)
Morn5e397c06d29e
diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/base/mobile_view_page.dart b/frontend/appflowy_flutter/lib/mobile/presentation/base/mobile_view_page.dartindex 318b06394a..863dbcd94c 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/base/mobile_view_page.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/base/mobile_view_page.dart@@ -40,6 +40,7 @@ class MobileViewPage extends StatefulWidget {this.fixedTitle,this.showMoreButton = true,this.blockId,+ this.bodyPaddingTop = 0.0,this.tabs = const [PickerTabType.emoji, PickerTabType.icon],});@@ -50,6 +51,7 @@ class MobileViewPage extends StatefulWidget {final Map<String, dynamic>? arguments;final bool showMoreButton;final String? blockId;+ final double bodyPaddingTop;final List<PickerTabType> tabs;// only used in row page@@ -176,7 +178,10 @@ class _MobileViewPageState extends State<MobileViewPage> {return Scaffold(extendBodyBehindAppBar: isDocument,appBar: appBar,- body: body,+ body: Padding(+ padding: EdgeInsets.only(top: widget.bodyPaddingTop),+ child: body,+ ),);}@@ -433,7 +438,8 @@ class _MobileViewPageState extends State<MobileViewPage> {if (notification is ScrollUpdateNotification &&defaultScrollNotificationPredicate(notification)) {final ScrollMetrics metrics = notification.metrics;- double height = MediaQuery.of(context).padding.top;+ double height =+ MediaQuery.of(context).padding.top + widget.bodyPaddingTop;if (defaultTargetPlatform == TargetPlatform.android) {height += AppBarTheme.of(context).toolbarHeight ?? kToolbarHeight;}diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/home/space/mobile_space_menu.dart b/frontend/appflowy_flutter/lib/mobile/presentation/home/space/mobile_space_menu.dartindex 485e07a28c..2198e0ac99 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/home/space/mobile_space_menu.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/home/space/mobile_space_menu.dart@@ -109,7 +109,7 @@ class MobileSpaceMenuItem extends StatelessWidget {currentSpace: context.read<SpaceBloc>().state.currentSpace,),onTap: () {- context.read<SpaceBloc>().add(SpaceEvent.open(space));+ context.read<SpaceBloc>().add(SpaceEvent.open(space: space));Navigator.of(context).pop();},);diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_ask_ai_entrance.dart b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_ask_ai_entrance.dartindex 660ea647aa..2f1e1f47d4 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_ask_ai_entrance.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_ask_ai_entrance.dart@@ -1,7 +1,6 @@import 'package:appflowy/generated/flowy_svgs.g.dart';import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/mobile/presentation/home/tab/mobile_space_tab.dart';-import 'package:appflowy/mobile/presentation/search/mobile_search_special_styles.dart';import 'package:appflowy/workspace/application/command_palette/command_palette_bloc.dart';import 'package:appflowy_backend/protobuf/flowy-search/result.pb.dart';import 'package:appflowy_ui/appflowy_ui.dart';@@ -50,10 +49,7 @@ class _AskAIFor extends StatelessWidget {behavior: HitTestBehavior.opaque,child: Container(margin: EdgeInsets.only(top: spaceM),- padding: EdgeInsets.symmetric(- horizontal: spaceM,- vertical: spaceL,- ),+ padding: EdgeInsets.all(spaceL),child: Row(children: [SizedBox.square(@@ -117,21 +113,27 @@ class _AISearching extends StatelessWidget {spaceM = theme.spacing.m,spaceL = theme.spacing.l;return Container(- padding: EdgeInsets.fromLTRB(0, spaceM, 0, spaceL),margin: EdgeInsets.only(top: spaceM),+ padding: EdgeInsets.all(spaceL),child: SizedBox(height: 24,child: Row(children: [- FlowySvg(- FlowySvgs.ai_searching_icon_m,- size: Size.square(20),- blendMode: null,+ SizedBox.square(+ dimension: 24,+ child: Center(+ child: FlowySvg(+ FlowySvgs.m_home_ai_chat_icon_m,+ size: Size.square(20),+ blendMode: null,+ ),+ ),),HSpace(8),Text(LocaleKeys.search_searching.tr(),- style: context.searchSubtitleStyle,+ style: theme.textStyle.heading4+ .standard(color: theme.textColorScheme.secondary),),],),@@ -169,7 +171,9 @@ class _AIOverview extends StatelessWidget {summary: summary,maxWidth: constrains.maxWidth,theme: AppFlowyTheme.of(context),- textStyle: context.searchTitleStyle,+ textStyle: theme.textStyle.heading4+ .standard(color: theme.textColorScheme.primary)+ .copyWith(height: 22 / 16),);},),@@ -179,22 +183,21 @@ class _AIOverview extends StatelessWidget {}Widget buildHeader(BuildContext context) {- return SizedBox(- height: 24,- child: Row(- children: [- FlowySvg(- FlowySvgs.ai_searching_icon_m,- size: Size.square(20),- blendMode: null,- ),- HSpace(8),- Text(- LocaleKeys.commandPalette_aiOverview.tr(),- style: context.searchSubtitleStyle,- ),- ],- ),+ final theme = AppFlowyTheme.of(context);+ return Row(+ children: [+ FlowySvg(+ FlowySvgs.ai_searching_icon_m,+ size: Size.square(20),+ blendMode: null,+ ),+ HSpace(8),+ Text(+ LocaleKeys.commandPalette_aiOverview.tr(),+ style: theme.textStyle.heading4+ .enhanced(color: theme.textColorScheme.primary),+ ),+ ],);}}diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_cell.dart b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_cell.dartindex 488fa2359d..e6c4a2a524 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_cell.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_cell.dart@@ -1,5 +1,4 @@import 'package:appflowy/generated/locale_keys.g.dart';-import 'package:appflowy/mobile/presentation/search/mobile_search_special_styles.dart';import 'package:appflowy/workspace/application/command_palette/command_palette_bloc.dart';import 'package:appflowy/workspace/application/view/view_ext.dart';import 'package:appflowy/workspace/presentation/command_palette/widgets/search_icon.dart';@@ -31,7 +30,9 @@ class MobileSearchResultCell extends StatelessWidget {final displayName = item.displayName.isEmpty? LocaleKeys.menuAppHeader_defaultNewPageName.tr(): item.displayName;-+ final titleStyle = theme.textStyle.heading4+ .standard(color: theme.textColorScheme.primary)+ .copyWith(height: 24 / 16);return Padding(padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 12),child: Row(@@ -54,8 +55,8 @@ class MobileSearchResultCell extends StatelessWidget {overflow: TextOverflow.ellipsis,text: buildHighLightSpan(content: displayName,- normal: context.searchTitleStyle,- highlight: context.searchTitleStyle.copyWith(+ normal: titleStyle,+ highlight: titleStyle.copyWith(backgroundColor: theme.fillColorScheme.themeSelect,),),@@ -72,16 +73,20 @@ class MobileSearchResultCell extends StatelessWidget {Widget buildPath(CommandPaletteState state, AppFlowyThemeData theme) {return BlocProvider(+ key: ValueKey(item.id),create: (context) => ViewAncestorBloc(item.id),child: BlocBuilder<ViewAncestorBloc, ViewAncestorState>(builder: (context, state) {final ancestors = state.ancestor.ancestors;+ if(ancestors.isEmpty) return const SizedBox.shrink();List<String> displayPath = ancestors.map((e) => e.name).toList();if (ancestors.length > 2) {displayPath = [ancestors.first.name, '...', ancestors.last.name];}return Text(displayPath.join(' / '),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,style: theme.textStyle.body.standard(color: theme.textColorScheme.tertiary),);@@ -99,9 +104,9 @@ class MobileSearchResultCell extends StatelessWidget {overflow: TextOverflow.ellipsis,text: buildHighLightSpan(content: item.content,- normal: theme.textStyle.heading4+ normal: theme.textStyle.body.standard(color: theme.textColorScheme.secondary),- highlight: theme.textStyle.heading4+ highlight: theme.textStyle.body.standard(color: theme.textColorScheme.primary).copyWith(backgroundColor: theme.fillColorScheme.themeSelect,diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_reference_bottom_sheet.dart b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_reference_bottom_sheet.dartindex 41ca56fb48..ba906d66a4 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_reference_bottom_sheet.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_reference_bottom_sheet.dart@@ -47,6 +47,8 @@ class SearchSourceReferenceBottomSheet extends StatelessWidget {viewLayout: view.layout,title: view.nameOrDefault,tabs: PickerTabType.values,+ bodyPaddingTop:+ AppBarTheme.of(context).toolbarHeight ?? kToolbarHeight,),),);@@ -81,7 +83,7 @@ class PageReferenceList extends StatelessWidget {),),),- const VSpace(4),+ const VSpace(6),ListView.builder(shrinkWrap: true,padding: EdgeInsets.fromLTRB(16, 0, 16, 8),@@ -101,8 +103,8 @@ class PageReferenceList extends StatelessWidget {if (index != 0) AFDivider(),Padding(padding: EdgeInsets.symmetric(- vertical: sapceM,- horizontal: spaceL,+ vertical: spaceL,+ horizontal: sapceM,),child: Row(crossAxisAlignment: CrossAxisAlignment.start,diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_result.dart b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_result.dartindex 6baccbcbed..08f1a667dd 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_result.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_result.dart@@ -1,7 +1,6 @@import 'package:appflowy/generated/flowy_svgs.g.dart';import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/mobile/application/mobile_router.dart';-import 'package:appflowy/mobile/presentation/search/mobile_search_special_styles.dart';import 'package:appflowy/shared/icon_emoji_picker/tab.dart';import 'package:appflowy/workspace/application/command_palette/command_palette_bloc.dart';import 'package:appflowy/workspace/application/recent/recent_views_bloc.dart';@@ -36,7 +35,7 @@ class MobileSearchRecentList extends StatelessWidget {@overrideWidget build(BuildContext context) {final commandPaletteState = context.read<CommandPaletteBloc>().state;-+ final theme = AppFlowyTheme.of(context);final trashIdSet = commandPaletteState.trash.map((e) => e.id).toSet();return BlocProvider(create: (context) =>@@ -54,7 +53,12 @@ class MobileSearchRecentList extends StatelessWidget {const VSpace(16),Text(LocaleKeys.sideBar_recent.tr(),- style: context.searchSubtitleStyle,+ style: theme.textStyle.heading4+ .enhanced(color: theme.textColorScheme.secondary)+ .copyWith(+ letterSpacing: 0.2,+ height: 24 / 16,+ ),),const VSpace(4),Column(@@ -85,13 +89,23 @@ class MobileSearchResultList extends StatelessWidget {Widget build(BuildContext context) {final state = context.read<CommandPaletteBloc>().state,theme = AppFlowyTheme.of(context);- final isSearching = state.searching,- items = state.combinedResponseItems.values.toList(),- hasData = items.isNotEmpty;+ final isSearching = state.searching || state.generatingAIOverview,+ cachedViews = state.cachedViews;+ List<SearchResultItem> displayItems =+ state.combinedResponseItems.values.toList();+ if (cachedViews.isNotEmpty) {+ displayItems =+ displayItems.where((item) => cachedViews[item.id] != null).toList();+ }+ final hasData = displayItems.isNotEmpty;+if (isSearching && !hasData) {- return Center(child: CircularProgressIndicator.adaptive());+ return SizedBox(+ height: 400,+ child: Center(child: CircularProgressIndicator.adaptive()),+ );} else if (!hasData) {- return buildNoResult(state.query ?? '', theme);+ return _NoResult();}return Column(crossAxisAlignment: CrossAxisAlignment.start,@@ -100,14 +114,19 @@ class MobileSearchResultList extends StatelessWidget {const VSpace(16),Text(LocaleKeys.commandPalette_bestMatches.tr(),- style: context.searchSubtitleStyle,+ style: theme.textStyle.heading4+ .enhanced(color: theme.textColorScheme.secondary)+ .copyWith(+ letterSpacing: 0.2,+ height: 24 / 16,+ ),),const VSpace(4),ListView.separated(shrinkWrap: true,physics: const NeverScrollableScrollPhysics(),itemBuilder: (context, index) {- final item = items[index];+ final item = displayItems[index];final view = state.cachedViews[item.id];return GestureDetector(behavior: HitTestBehavior.opaque,@@ -116,7 +135,7 @@ class MobileSearchResultList extends StatelessWidget {await _goToView(context, view);} else {showToastNotification(- message: LocaleKeys.search_somethingWentWrong.tr(),+ message: LocaleKeys.search_pageNotExist.tr(),type: ToastificationType.error,);Log.error(@@ -132,13 +151,19 @@ class MobileSearchResultList extends StatelessWidget {);},separatorBuilder: (context, index) => AFDivider(),- itemCount: items.length,+ itemCount: displayItems.length,),],);}+}++class _NoResult extends StatelessWidget {+ const _NoResult();- Widget buildNoResult(String query, AppFlowyThemeData theme) {+ @override+ Widget build(BuildContext context) {+ final theme = AppFlowyTheme.of(context);final textColor = theme.textColorScheme.secondary;return Align(alignment: Alignment.topCenter,diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_special_styles.dart b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_special_styles.dartdeleted file mode 100644index edf804fc95..0000000000--- a/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_special_styles.dart+++ /dev/null@@ -1,24 +0,0 @@-import 'package:appflowy_ui/appflowy_ui.dart';-import 'package:flutter/material.dart';--extension MobileSearchSpecialStylesExtension on BuildContext {- TextStyle get searchSubtitleStyle {- return TextStyle(- fontSize: 16,- letterSpacing: 0.2,- height: 24 / 16,- fontWeight: FontWeight.w500,- color: AppFlowyTheme.of(this).textColorScheme.secondary,- );- }-- TextStyle get searchTitleStyle {- return TextStyle(- fontSize: 16,- letterSpacing: 0.2,- height: 24 / 16,- fontWeight: FontWeight.w400,- color: AppFlowyTheme.of(this).textColorScheme.primary,- );- }-}diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_summary_cell.dart b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_summary_cell.dartindex 78d75eb068..dd9c86a36b 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_summary_cell.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_summary_cell.dart@@ -93,7 +93,7 @@ class _MobileSearchSummaryCellState extends State<MobileSearchSummaryCell> {behavior: HitTestBehavior.opaque,onTap: () => showPageReferences(context),child: Padding(- padding: const EdgeInsets.only(left: 4),+ padding: const EdgeInsets.fromLTRB(4, 4, 15, 4),child: Container(width: 21,height: 15,@@ -197,50 +197,52 @@ class _TextInfo {return GestureDetector(behavior: HitTestBehavior.opaque,onTap: showMore,- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Stack(- children: [- SelectionArea(- child: Text.rich(- _buildHighLightSpan(- content: text,- normal: normal,- query: query,- highlight: normal.copyWith(- backgroundColor: theme.fillColorScheme.themeSelect,+ child: IgnorePointer(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Stack(+ children: [+ SelectionArea(+ child: Text.rich(+ _buildHighLightSpan(+ content: text,+ normal: normal,+ query: query,+ highlight: normal.copyWith(+ backgroundColor: theme.fillColorScheme.themeSelect,+ ),),),),- ),- if (overflowFadeCover != null)- Positioned(- bottom: 0,- left: 0,- child: overflowFadeCover,- ),- ],- ),- SizedBox(- height: 34,- child: Row(- children: [- Padding(- padding: const EdgeInsets.symmetric(vertical: 7),- child: FlowySvg(- FlowySvgs.arrow_down_s,- size: Size.square(20),- color: theme.iconColorScheme.secondary,+ if (overflowFadeCover != null)+ Positioned(+ bottom: 0,+ left: 0,+ child: overflowFadeCover,),- ),- HSpace(8),- Text(LocaleKeys.search_showMore.tr(), style: more),],),- ),- VSpace(16),- ],+ SizedBox(+ height: 34,+ child: Row(+ children: [+ Padding(+ padding: const EdgeInsets.symmetric(vertical: 7),+ child: FlowySvg(+ FlowySvgs.arrow_down_s,+ size: Size.square(20),+ color: theme.iconColorScheme.secondary,+ ),+ ),+ HSpace(8),+ Text(LocaleKeys.search_showMore.tr(), style: more),+ ],+ ),+ ),+ VSpace(16),+ ],+ ),),);} else {diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_textfield.dart b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_textfield.dartindex f89fbb3974..916abc96d3 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_textfield.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_textfield.dart@@ -1,15 +1,16 @@import 'package:appflowy/generated/flowy_svgs.g.dart';-import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/mobile/presentation/mobile_bottom_navigation_bar.dart';import 'package:appflowy/shared/popup_menu/appflowy_popup_menu.dart';import 'package:appflowy/startup/startup.dart';+import 'package:appflowy/startup/tasks/af_navigator_observer.dart';import 'package:appflowy/user/application/reminder/reminder_bloc.dart';import 'package:appflowy_backend/log.dart';import 'package:appflowy_ui/appflowy_ui.dart';-import 'package:easy_localization/easy_localization.dart';import 'package:flutter/material.dart';import 'package:go_router/go_router.dart';+import 'mobile_search_page.dart';+class MobileSearchTextfield extends StatefulWidget {const MobileSearchTextfield({super.key,@@ -28,32 +29,36 @@ class MobileSearchTextfield extends StatefulWidget {State<MobileSearchTextfield> createState() => _MobileSearchTextfieldState();}-class _MobileSearchTextfieldState extends State<MobileSearchTextfield> {+class _MobileSearchTextfieldState extends State<MobileSearchTextfield>+ with RouteAware {late final TextEditingController controller;- final ValueNotifier<bool> hasFocusValueNotifier = ValueNotifier(true);FocusNode get focusNode => widget.focusNode;late String lastPage = bottomNavigationBarItemType.value ?? '';+ String lastText = '';@overridevoid initState() {super.initState();controller = TextEditingController(text: widget.query);- focusNode.addListener(onFocusChanged);controller.addListener(() {if (!mounted) return;- widget.onChanged?.call(controller.text);+ if (lastText != controller.text) {+ widget.onChanged?.call(controller.text);+ lastText = controller.text;+ }});bottomNavigationBarItemType.addListener(onBackOrLeave);- focusNode.requestFocus();+ makeSureHasFocus();+ getIt<AFNavigatorObserver>().addListener(onRoute);}@overridevoid dispose() {controller.dispose();- focusNode.removeListener(onFocusChanged);- hasFocusValueNotifier.dispose();bottomNavigationBarItemType.removeListener(onBackOrLeave);+ getIt<AFNavigatorObserver>().removeListener(onRoute);+super.dispose();}@@ -67,7 +72,6 @@ class _MobileSearchTextfieldState extends State<MobileSearchTextfield> {child: ValueListenableBuilder(valueListenable: controller,builder: (context, _, __) {- final hasText = controller.text.isNotEmpty;return Row(children: [GestureDetector(@@ -107,7 +111,6 @@ class _MobileSearchTextfieldState extends State<MobileSearchTextfield> {Expanded(child: TextFormField(autovalidateMode: AutovalidateMode.onUserInteraction,- autofocus: true,focusNode: focusNode,textAlign: TextAlign.left,controller: controller,@@ -120,28 +123,6 @@ class _MobileSearchTextfieldState extends State<MobileSearchTextfield> {decoration: buildInputDecoration(context),),),- ValueListenableBuilder(- valueListenable: hasFocusValueNotifier,- builder: (context, hasFocus, __) {- if (!hasFocus || !hasText) return SizedBox.shrink();- return GestureDetector(- onTap: () => focusNode.unfocus(),- behavior: HitTestBehavior.opaque,- child: Container(- height: 42,- padding: EdgeInsets.only(left: 8),- child: Align(- alignment: Alignment.centerLeft,- child: Text(- LocaleKeys.button_cancel.tr(),- style: theme.textStyle.body- .standard(color: theme.textColorScheme.action),- ),- ),- ),- );- },- ),],);},@@ -202,9 +183,12 @@ class _MobileSearchTextfieldState extends State<MobileSearchTextfield> {);}- void onFocusChanged() {- if (!mounted) return;- hasFocusValueNotifier.value = focusNode.hasFocus;+ Future<void> makeSureHasFocus() async {+ if (!mounted || focusNode.hasFocus) return;+ focusNode.requestFocus();+ WidgetsBinding.instance.addPostFrameCallback((_) {+ makeSureHasFocus();+ });}void onBackOrLeave() {@@ -217,4 +201,12 @@ class _MobileSearchTextfieldState extends State<MobileSearchTextfield> {lastPage = label ?? '';}}++ void onRoute(RouteInfo routeInfo) {+ final oldName = routeInfo.oldRoute?.settings.name;+ if (oldName != MobileSearchScreen.routeName) return;+ if (routeInfo is PushRouterInfo) {+ focusNode.unfocus();+ }+ }}diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_view_ancestors.dart b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_view_ancestors.dartindex 2fa8c8eff0..86b8906c59 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_view_ancestors.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_view_ancestors.dart@@ -1,5 +1,4 @@import 'package:appflowy/startup/startup.dart';-import 'package:appflowy/workspace/presentation/command_palette/widgets/search_special_styles.dart';import 'package:appflowy_ui/appflowy_ui.dart';import 'package:flowy_infra_ui/widget/spacing.dart';import 'package:flutter/material.dart';@@ -32,7 +31,9 @@ class ViewAncestorBloc extends Bloc<ViewAncestorEvent, ViewAncestorState> {}},);- emit(state.copyWith(ancestor: ancester, isLoading: false));+ if(ancester != null) {+ emit(state.copyWith(ancestor: ancester, isLoading: false));+ }},);},@@ -108,24 +109,27 @@ extension ViewAncestorTextExtension on ViewAncestorState {if (ancestors.length > 2) {displayPath = [ancestors.first.name, '...', ancestors.last.name];}- return SizedBox(- height: 18,- child: Row(- children: [- HSpace(8),- Text(- '-',- style: context.searchPanelPath.copyWith(height: 1),- ),- HSpace(8),- Text(- displayPath.join(' / '),- style: context.searchPanelPath.copyWith(height: 1),- maxLines: 1,- overflow: TextOverflow.ellipsis,+ final theme = AppFlowyTheme.of(context);+ final style = theme.textStyle.caption+ .standard(color: theme.textColorScheme.tertiary)+ .copyWith(letterSpacing: 0.1);+ return Row(+ children: [+ HSpace(8),+ Text(+ '-',+ style: style.copyWith(+ color: theme.borderColorScheme.primaryHover,),- ],- ),+ ),+ HSpace(8),+ Text(+ displayPath.join(' / '),+ style: style,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ ),+ ],);}}diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/search/view_ancestor_cache.dart b/frontend/appflowy_flutter/lib/mobile/presentation/search/view_ancestor_cache.dartindex 708f015901..51a9de19af 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/search/view_ancestor_cache.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/search/view_ancestor_cache.dart@@ -11,7 +11,7 @@ class ViewAncestorCache {final Map<String, ViewAncestor> _ancestors = {};- Future<ViewAncestor> getAncestor(+ Future<ViewAncestor?> getAncestor(String viewId, {ValueChanged<ViewAncestor>? onRefresh,}) async {@@ -23,23 +23,26 @@ class ViewAncestorCache {return _getAncestor(viewId);}- Future<ViewAncestor> _getAncestor(+ Future<ViewAncestor?> _getAncestor(String viewId, {ValueChanged<ViewAncestor>? onRefresh,}) async {- final List<ViewPB> ancestors =+ final List<ViewPB>? ancestors =await ViewBackendService.getViewAncestors(viewId).fold((s) => s.items.where((e) => e.parentViewId.isNotEmpty && e.id != viewId).toList(),- (f) => [],+ (f) => null,);- final newAncestors = ViewAncestor(- ancestors: ancestors.map((e) => ViewParent.fromViewPB(e)).toList(),- );- _ancestors[viewId] = newAncestors;- onRefresh?.call(newAncestors);- return newAncestors;+ if (ancestors != null) {+ final newAncestors = ViewAncestor(+ ancestors: ancestors.map((e) => ViewParent.fromViewPB(e)).toList(),+ );+ _ancestors[viewId] = newAncestors;+ onRefresh?.call(newAncestors);+ return newAncestors;+ }+ return null;}}diff --git a/frontend/appflowy_flutter/lib/startup/startup.dart b/frontend/appflowy_flutter/lib/startup/startup.dartindex 88d0640af0..1f5ce5e5ee 100644--- a/frontend/appflowy_flutter/lib/startup/startup.dart+++ b/frontend/appflowy_flutter/lib/startup/startup.dart@@ -18,6 +18,7 @@ import 'deps_resolver.dart';import 'entry_point.dart';import 'launch_configuration.dart';import 'plugin/plugin.dart';+import 'tasks/af_navigator_observer.dart';import 'tasks/file_storage_task.dart';import 'tasks/prelude.dart';@@ -191,6 +192,7 @@ Future<void> initGetIt(getIt.registerSingleton<PluginSandbox>(PluginSandbox());getIt.registerSingleton<ViewExpanderRegistry>(ViewExpanderRegistry());getIt.registerSingleton<LinkHoverTriggers>(LinkHoverTriggers());+ getIt.registerSingleton<AFNavigatorObserver>(AFNavigatorObserver());getIt.registerSingleton<FloatingToolbarController>(FloatingToolbarController(),);diff --git a/frontend/appflowy_flutter/lib/startup/tasks/af_navigator_observer.dart b/frontend/appflowy_flutter/lib/startup/tasks/af_navigator_observer.dartnew file mode 100644index 0000000000..2d793cc7aa--- /dev/null+++ b/frontend/appflowy_flutter/lib/startup/tasks/af_navigator_observer.dart@@ -0,0 +1,53 @@+import 'package:flutter/material.dart';++class AFNavigatorObserver extends NavigatorObserver {+ final Set<ValueChanged<RouteInfo>> _listeners = {};++ void addListener(ValueChanged<RouteInfo> listener) {+ _listeners.add(listener);+ }++ void removeListener(ValueChanged<RouteInfo> listener) {+ _listeners.remove(listener);+ }++ @override+ void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {+ for (final listener in Set.of(_listeners)) {+ listener(PushRouterInfo(newRoute: route, oldRoute: previousRoute));+ }+ }++ @override+ void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {+ for (final listener in Set.of(_listeners)) {+ listener(PopRouterInfo(newRoute: route, oldRoute: previousRoute));+ }+ }++ @override+ void didReplace({Route<dynamic>? newRoute, Route<dynamic>? oldRoute}) {+ for (final listener in Set.of(_listeners)) {+ listener(ReplaceRouterInfo(newRoute: newRoute, oldRoute: oldRoute));+ }+ }+}++abstract class RouteInfo {+ RouteInfo({this.oldRoute, this.newRoute});++ final Route? oldRoute;+ final Route? newRoute;+}++class PushRouterInfo extends RouteInfo {+ PushRouterInfo({super.newRoute, super.oldRoute});+}++class PopRouterInfo extends RouteInfo {+ PopRouterInfo({super.newRoute, super.oldRoute});+}++class ReplaceRouterInfo extends RouteInfo {+ ReplaceRouterInfo({super.newRoute, super.oldRoute});+}diff --git a/frontend/appflowy_flutter/lib/startup/tasks/generate_router.dart b/frontend/appflowy_flutter/lib/startup/tasks/generate_router.dartindex e2d30bd967..48f305a6d2 100644--- a/frontend/appflowy_flutter/lib/startup/tasks/generate_router.dart+++ b/frontend/appflowy_flutter/lib/startup/tasks/generate_router.dart@@ -41,10 +41,12 @@ import 'package:sheet/route.dart';import 'package:universal_platform/universal_platform.dart';import '../../shared/icon_emoji_picker/tab.dart';+import 'af_navigator_observer.dart';GoRouter generateRouter(Widget child) {return GoRouter(navigatorKey: AppGlobals.rootNavKey,+ observers: [getIt.get<AFNavigatorObserver>()],initialLocation: '/',routes: [// Root route is SplashScreen.@@ -140,42 +142,72 @@ StatefulShellRoute _mobileHomeScreenWithNavigationBarRoute() {// branches in a stateful way.return MobileBottomNavigationBar(navigationShell: navigationShell);},+ pageBuilder: (context, state, navigationShell) {+ String name = MobileHomeScreen.routeName;+ switch (navigationShell.currentIndex) {+ case 0:+ name = MobileHomeScreen.routeName;+ break;+ case 1:+ name = MobileSearchScreen.routeName;+ break;+ case 2:+ name = MobileFavoriteScreen.routeName;+ break;+ case 3:+ name = MobileNotificationsScreenV2.routeName;+ break;+ }+ return MaterialExtendedPage(+ child: MobileBottomNavigationBar(navigationShell: navigationShell),+ name: name,+ );+ },branches: <StatefulShellBranch>[StatefulShellBranch(routes: <RouteBase>[GoRoute(path: MobileHomeScreen.routeName,- builder: (BuildContext context, GoRouterState state) {- return const MobileHomeScreen();- },+ pageBuilder: (context, state) => MaterialExtendedPage(+ child: const MobileHomeScreen(),+ name: MobileHomeScreen.routeName,+ ),),],),StatefulShellBranch(routes: <RouteBase>[GoRoute(+ name: MobileSearchScreen.routeName,path: MobileSearchScreen.routeName,- builder: (BuildContext context, GoRouterState state) {- return const MobileSearchScreen();- },+ pageBuilder: (context, state) => MaterialExtendedPage(+ child: const MobileSearchScreen(),+ name: MobileSearchScreen.routeName,+ ),),],),StatefulShellBranch(routes: <RouteBase>[GoRoute(+ name: MobileFavoriteScreen.routeName,path: MobileFavoriteScreen.routeName,- builder: (BuildContext context, GoRouterState state) {- return const MobileFavoriteScreen();- },+ pageBuilder: (context, state) => MaterialExtendedPage(+ child: const MobileFavoriteScreen(),+ name: MobileFavoriteScreen.routeName,+ ),),],),StatefulShellBranch(routes: <RouteBase>[GoRoute(+ name: MobileNotificationsScreenV2.routeName,path: MobileNotificationsScreenV2.routeName,- builder: (_, __) => const MobileNotificationsScreenV2(),+ pageBuilder: (context, state) => MaterialExtendedPage(+ child: const MobileNotificationsScreenV2(),+ name: MobileNotificationsScreenV2.routeName,+ ),),],),@@ -188,7 +220,10 @@ GoRoute _mobileHomeSettingPageRoute() {parentNavigatorKey: AppGlobals.rootNavKey,path: MobileHomeSettingPage.routeName,pageBuilder: (context, state) {- return const MaterialExtendedPage(child: MobileHomeSettingPage());+ return const MaterialExtendedPage(+ child: MobileHomeSettingPage(),+ name: MobileHomeSettingPage.routeName,+ );},);}@@ -200,6 +235,7 @@ GoRoute _mobileNotificationMultiSelectPageRoute() {pageBuilder: (context, state) {return const MaterialExtendedPage(child: MobileNotificationsMultiSelectScreen(),+ name: MobileNotificationsMultiSelectScreen.routeName,);},);@@ -212,6 +248,7 @@ GoRoute _mobileInviteMembersPageRoute() {pageBuilder: (context, state) {return const MaterialExtendedPage(child: InviteMembersScreen(),+ name: InviteMembersScreen.routeName,);},);@@ -222,7 +259,10 @@ GoRoute _mobileAddMembersPageRoute() {parentNavigatorKey: AppGlobals.rootNavKey,path: AddMembersScreen.routeName,pageBuilder: (context, state) {- return const MaterialExtendedPage(child: AddMembersScreen());+ return const MaterialExtendedPage(+ child: AddMembersScreen(),+ name: AddMembersScreen.routeName,+ );},);}@@ -232,7 +272,10 @@ GoRoute _mobileCloudSettingAppFlowyCloudPageRoute() {parentNavigatorKey: AppGlobals.rootNavKey,path: AppFlowyCloudPage.routeName,pageBuilder: (context, state) {- return const MaterialExtendedPage(child: AppFlowyCloudPage());+ return const MaterialExtendedPage(+ child: AppFlowyCloudPage(),+ name: AppFlowyCloudPage.routeName,+ );},);}@@ -242,7 +285,10 @@ GoRoute _mobileLaunchSettingsPageRoute() {parentNavigatorKey: AppGlobals.rootNavKey,path: MobileLaunchSettingsPage.routeName,pageBuilder: (context, state) {- return const MaterialExtendedPage(child: MobileLaunchSettingsPage());+ return const MaterialExtendedPage(+ child: MobileLaunchSettingsPage(),+ name: MobileLaunchSettingsPage.routeName,+ );},);}@@ -252,7 +298,10 @@ GoRoute _mobileFeatureFlagPageRoute() {parentNavigatorKey: AppGlobals.rootNavKey,path: FeatureFlagScreen.routeName,pageBuilder: (context, state) {- return const MaterialExtendedPage(child: FeatureFlagScreen());+ return const MaterialExtendedPage(+ child: FeatureFlagScreen(),+ name: FeatureFlagScreen.routeName,+ );},);}@@ -262,7 +311,10 @@ GoRoute _mobileHomeTrashPageRoute() {parentNavigatorKey: AppGlobals.rootNavKey,path: MobileHomeTrashPage.routeName,pageBuilder: (context, state) {- return const MaterialExtendedPage(child: MobileHomeTrashPage());+ return const MaterialExtendedPage(+ child: MobileHomeTrashPage(),+ name: MobileHomeTrashPage.routeName,+ );},);}@@ -282,6 +334,7 @@ GoRoute _mobileBlockSettingsPageRoute() {child: MobileBlockSettingsScreen(actions: actions ?? MobileBlockActionType.standard,),+ name: MobileBlockSettingsScreen.routeName,);},);@@ -323,6 +376,7 @@ GoRoute _mobileEmojiPickerPageRoute() {tabs: tabs,documentId: documentId,),+ name: MobileEmojiPickerScreen.routeName,);},);@@ -336,9 +390,8 @@ GoRoute _mobileColorPickerPageRoute() {final title =state.uri.queryParameters[MobileColorPickerScreen.pageTitle] ?? '';return MaterialExtendedPage(- child: MobileColorPickerScreen(- title: title,- ),+ child: MobileColorPickerScreen(title: title),+ name: MobileColorPickerScreen.routeName,);},);@@ -351,6 +404,7 @@ GoRoute _mobileImagePickerPageRoute() {pageBuilder: (context, state) {return const MaterialExtendedPage(child: MobileImagePickerScreen(),+ name: MobileImagePickerScreen.routeName,);},);@@ -363,6 +417,7 @@ GoRoute _mobileCodeLanguagePickerPageRoute() {pageBuilder: (context, state) {return const MaterialExtendedPage(child: MobileCodeLanguagePickerScreen(),+ name: MobileCodeLanguagePickerScreen.routeName,);},);@@ -375,6 +430,7 @@ GoRoute _mobileLanguagePickerPageRoute() {pageBuilder: (context, state) {return const MaterialExtendedPage(child: LanguagePickerScreen(),+ name: LanguagePickerScreen.routeName,);},);@@ -387,6 +443,7 @@ GoRoute _mobileFontPickerPageRoute() {pageBuilder: (context, state) {return const MaterialExtendedPage(child: FontPickerScreen(),+ name: FontPickerScreen.routeName,);},);@@ -409,6 +466,7 @@ GoRoute _mobileNewPropertyPageRoute() {viewId: viewId,fieldType: FieldType.valueOf(value),),+ name: MobileNewPropertyScreen.routeName,);},);@@ -426,6 +484,7 @@ GoRoute _mobileEditPropertyPageRoute() {viewId: args[MobileEditPropertyScreen.argViewId],field: args[MobileEditPropertyScreen.argField],),+ name: MobileEditPropertyScreen.routeName,);},);@@ -446,6 +505,7 @@ GoRoute _mobileCalendarEventsPageRoute() {rowCache: args[MobileCalendarEventsScreen.calendarRowCacheKey],viewId: args[MobileCalendarEventsScreen.calendarViewIdKey],),+ name: MobileCalendarEventsScreen.routeName,);},);@@ -547,6 +607,7 @@ GoRoute _mobileEditorScreenRoute() {blockId: blockId,tabs: tabs,),+ name: MobileDocumentScreen.routeName,);},);diff --git a/frontend/appflowy_flutter/lib/workspace/application/action_navigation/action_navigation_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/action_navigation/action_navigation_bloc.dartindex 5bc64b6785..b74ea3bf6c 100644--- a/frontend/appflowy_flutter/lib/workspace/application/action_navigation/action_navigation_bloc.dart+++ b/frontend/appflowy_flutter/lib/workspace/application/action_navigation/action_navigation_bloc.dart@@ -1,6 +1,10 @@+import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/workspace/application/action_navigation/navigation_action.dart';import 'package:appflowy/workspace/application/view/view_service.dart';+import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';+import 'package:appflowy_backend/log.dart';import 'package:bloc/bloc.dart';+import 'package:easy_localization/easy_localization.dart';import 'package:freezed_annotation/freezed_annotation.dart';part 'action_navigation_bloc.freezed.dart';@@ -10,7 +14,7 @@ class ActionNavigationBlocActionNavigationBloc() : super(const ActionNavigationState.initial()) {on<ActionNavigationEvent>((event, emit) async {await event.when(- performAction: (action, nextActions) async {+ performAction: (action, showErrorToast, nextActions) async {NavigationAction currentAction = action;if (currentAction.arguments?[ActionArgumentKeys.view] == null &&action.type == ActionType.openView) {@@ -20,8 +24,16 @@ class ActionNavigationBlocif (currentAction.arguments == null) {currentAction = currentAction.copyWith(arguments: {});}-currentAction.arguments?.addAll({ActionArgumentKeys.view: view});++ } else {+ Log.error('Open view failed: ${action.objectId}');+ if (showErrorToast) {+ showToastNotification(+ message: LocaleKeys.search_pageNotExist.tr(),+ type: ToastificationType.error,+ );+ }}}@@ -50,6 +62,7 @@ class ActionNavigationBlocclass ActionNavigationEvent with _$ActionNavigationEvent {const factory ActionNavigationEvent.performAction({required NavigationAction action,+ @Default(false) bool showErrorToast,@Default([]) List<NavigationAction> nextActions,}) = _PerformAction;}diff --git a/frontend/appflowy_flutter/lib/workspace/application/command_palette/command_palette_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/command_palette/command_palette_bloc.dartindex d1c8cf6106..6347492c89 100644--- a/frontend/appflowy_flutter/lib/workspace/application/command_palette/command_palette_bloc.dart+++ b/frontend/appflowy_flutter/lib/workspace/application/command_palette/command_palette_bloc.dart@@ -127,7 +127,7 @@ class CommandPaletteBloc_PerformSearch event,Emitter<CommandPaletteState> emit,) async {- if (event.search.isEmpty && event.search != state.query) {+ if (event.search.isEmpty) {emit(state.copyWith(query: null,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 a1991ce148..ae07a48134 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@@ -92,7 +92,7 @@ class SpaceBloc extends Bloc<SpaceEvent, SpaceState> {if (openFirstPage) {if (currentSpace != null) {if (!isClosed) {- add(SpaceEvent.open(currentSpace));+ add(SpaceEvent.open(space: currentSpace));}}}@@ -121,7 +121,7 @@ class SpaceBloc extends Bloc<SpaceEvent, SpaceState> {currentSpace: space,),);- add(SpaceEvent.open(space));+ add(SpaceEvent.open(space: space));Log.info('open space: ${space.name}(${space.id})');if (createNewPageByDefault) {@@ -238,7 +238,7 @@ class SpaceBloc extends Bloc<SpaceEvent, SpaceState> {);}},- open: (space) async {+ open: (space, afterOpen) async {await _openSpace(space);final isExpanded = await _getSpaceExpandStatus(space);final views = await ViewBackendService.getChildViews(@@ -279,6 +279,7 @@ class SpaceBloc extends Bloc<SpaceEvent, SpaceState> {);}}+ afterOpen?.call();},expand: (space, isExpanded) async {await _setSpaceExpandStatus(space, isExpanded);@@ -357,7 +358,7 @@ class SpaceBloc extends Bloc<SpaceEvent, SpaceState> {final currentIndex = spaces.indexOf(currentSpace);final nextIndex = (currentIndex + 1) % spaces.length;final nextSpace = spaces[nextIndex];- add(SpaceEvent.open(nextSpace));+ add(SpaceEvent.open(space: nextSpace));},duplicate: (space) async {space ??= state.currentSpace;@@ -374,7 +375,7 @@ class SpaceBloc extends Bloc<SpaceEvent, SpaceState> {// open the duplicated spaceif (newSpace != null) {add(const SpaceEvent.didReceiveSpaceUpdate());- add(SpaceEvent.open(newSpace));+ add(SpaceEvent.open(space: newSpace));}emit(state.copyWith(isDuplicatingSpace: false));@@ -763,7 +764,10 @@ class SpaceEvent with _$SpaceEvent {String? iconColor,SpacePermission? permission,}) = _Update;- const factory SpaceEvent.open(ViewPB space) = _Open;+ const factory SpaceEvent.open({+ required ViewPB space,+ VoidCallback? afterOpen,+ }) = _Open;const factory SpaceEvent.expand(ViewPB space, bool isExpanded) = _Expand;const factory SpaceEvent.createPage({required String name,diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/command_palette.dart b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/command_palette.dartindex 3d77d4d0df..efe2cb4261 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/command_palette.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/command_palette.dart@@ -204,7 +204,8 @@ class CommandPaletteModal extends StatelessWidget {builder: (context, state) {final theme = AppFlowyTheme.of(context);final noQuery = state.query?.isEmpty ?? true, hasQuery = !noQuery;- final hasResult = state.combinedResponseItems.isNotEmpty;+ final hasResult = state.combinedResponseItems.isNotEmpty,+ searching = state.searching;final spaceXl = theme.spacing.xl;return FlowyDialog(backgroundColor: theme.surfaceColorScheme.layer01,@@ -223,7 +224,7 @@ class CommandPaletteModal extends StatelessWidget {padding: EdgeInsets.fromLTRB(spaceXl, spaceXl, spaceXl, 0),child: Column(children: [- SearchField(query: state.query, isLoading: state.searching),+ SearchField(query: state.query, isLoading: searching),if (noQuery)Flexible(child: RecentViewsList(@@ -241,12 +242,20 @@ class CommandPaletteModal extends StatelessWidget {)// When there are no results and the query is not empty and not loading,// show the no results message, centered in the available space.- else if (hasQuery && !state.searching) ...[+ else if (hasQuery && !searching) ...[if (showAskingAI) SearchAskAiEntrance(),Expanded(child: const NoSearchResultsHint(),),],+ if (hasQuery && searching && !hasResult)+ // Show a loading indicator when searching+ Expanded(+ child: Center(+ child:+ Center(child: CircularProgressIndicator.adaptive()),+ ),+ ),],),),diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/navigation_bloc_extension.dart b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/navigation_bloc_extension.dartnew file mode 100644index 0000000000..67b16430d9--- /dev/null+++ b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/navigation_bloc_extension.dart@@ -0,0 +1,14 @@+import 'package:appflowy/startup/startup.dart';+import 'package:appflowy/workspace/application/action_navigation/action_navigation_bloc.dart';+import 'package:appflowy/workspace/application/action_navigation/navigation_action.dart';++extension NavigationBlocExtension on String {+ void navigateTo() {+ getIt<ActionNavigationBloc>().add(+ ActionNavigationEvent.performAction(+ action: NavigationAction(objectId: this),+ showErrorToast: true,+ ),+ );+ }+}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/page_preview.dart b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/page_preview.dartindex 73f82d4078..07b208e6c9 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/page_preview.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/page_preview.dart@@ -18,7 +18,7 @@ import 'package:appflowy/workspace/application/view/view_ext.dart';import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';import 'package:appflowy_editor/appflowy_editor.dart';import 'package:appflowy_ui/appflowy_ui.dart';-import 'package:easy_localization/easy_localization.dart';+import 'package:easy_localization/easy_localization.dart' hide TextDirection;import 'package:flowy_infra/theme_extension.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flutter/material.dart';@@ -54,7 +54,10 @@ class PagePreview extends StatelessWidget {color: backgroundColor,borderRadius: BorderRadius.circular(12),),- margin: EdgeInsets.symmetric(vertical: 16),+ margin: EdgeInsets.only(+ top: theme.spacing.m,+ bottom: theme.spacing.xl,+ ),child: Stack(children: [SingleChildScrollView(@@ -197,43 +200,60 @@ class PagePreview extends StatelessWidget {.enhanced(color: theme.textColorScheme.primary),titleHoverStyle =titleStyle.copyWith(decoration: TextDecoration.underline);- return SizedBox(- height: 28,- child: Row(- children: [- Flexible(- child: AFBaseButton(- padding: EdgeInsets.zero,- builder: (context, isHovering, disabled) =>- SelectionContainer.disabled(- child: Text(- view.nameOrDefault,- style: isHovering ? titleHoverStyle : titleStyle,- maxLines: 1,- overflow: TextOverflow.ellipsis,- ),- ),- borderColor: (_, __, ___, ____) => Colors.transparent,- borderRadius: 0,- onTap: onViewOpened,- ),- ),- HSpace(4),- FlowyTooltip(- message: LocaleKeys.settings_files_open.tr(),- child: AFGhostButton.normal(- size: AFButtonSize.s,- padding: EdgeInsets.all(theme.spacing.xs),- onTap: onViewOpened,- builder: (context, isHovering, disabled) => FlowySvg(- FlowySvgs.search_open_tab_m,- color: theme.iconColorScheme.secondary,- size: const Size.square(20),+ return LayoutBuilder(+ builder: (context, constrains) {+ final maxWidth = constrains.maxWidth;+ String displayText = view.nameOrDefault;+ final painter = TextPainter(+ text: TextSpan(text: displayText, style: titleStyle),+ maxLines: 3,+ textDirection: TextDirection.ltr,+ ellipsis: '... ',+ );+ painter.layout(maxWidth: maxWidth);+ if (painter.didExceedMaxLines) {+ final lines = painter.computeLineMetrics();+ final lastLine = lines.last;+ final offset = Offset(+ lastLine.left + lastLine.width,+ lines.map((e) => e.height).reduce((a, b) => a + b),+ );+ final range = painter.getPositionForOffset(offset);+ displayText = '${displayText.substring(0, range.offset)}...';+ }+ return AFBaseButton(+ borderColor: (_, __, ___, ____) => Colors.transparent,+ borderRadius: 0,+ onTap: onViewOpened,+ padding: EdgeInsets.zero,+ builder: (context, isHovering, disabled) {+ return RichText(+ text: TextSpan(+ children: [+ TextSpan(+ text: displayText,+ style: isHovering ? titleHoverStyle : titleStyle,+ ),+ WidgetSpan(+ alignment: PlaceholderAlignment.middle,+ child: Padding(+ padding: const EdgeInsets.only(left: 4),+ child: FlowyTooltip(+ message: LocaleKeys.settings_files_open.tr(),+ child: FlowySvg(+ FlowySvgs.search_open_tab_m,+ color: theme.iconColorScheme.secondary,+ size: const Size.square(20),+ ),+ ),+ ),+ ),+ ],),- ),- ),- ],- ),+ );+ },+ );+ },);}@@ -295,30 +315,43 @@ class SomethingWentWrong extends StatelessWidget {@overrideWidget build(BuildContext context) {final theme = AppFlowyTheme.of(context);- return Center(- child: Column(- mainAxisSize: MainAxisSize.min,+ return SizedBox(+ width: 300,+ child: Row(children: [- FlowySvg(- FlowySvgs.something_wrong_warning_m,- color: theme.iconColorScheme.secondary,- size: Size.square(24),- ),- const VSpace(8),- Text(- LocaleKeys.search_somethingWentWrong.tr(),- style: theme.textStyle.body- .enhanced(color: theme.textColorScheme.secondary),- maxLines: 1,- overflow: TextOverflow.ellipsis,- ),- const VSpace(4),- Text(- LocaleKeys.search_tryAgainOrLater.tr(),- style: theme.textStyle.caption- .standard(color: theme.textColorScheme.secondary),- maxLines: 1,- overflow: TextOverflow.ellipsis,+ AFDivider(axis: Axis.vertical),+ Expanded(+ child: Padding(+ padding: const EdgeInsets.only(bottom: 100),+ child: Center(+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ FlowySvg(+ FlowySvgs.something_wrong_warning_m,+ color: theme.iconColorScheme.secondary,+ size: Size.square(24),+ ),+ const VSpace(8),+ Text(+ LocaleKeys.search_somethingWentWrong.tr(),+ style: theme.textStyle.body+ .enhanced(color: theme.textColorScheme.secondary),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ ),+ const VSpace(4),+ Text(+ LocaleKeys.search_tryAgainOrLater.tr(),+ style: theme.textStyle.caption+ .standard(color: theme.textColorScheme.secondary),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ ),+ ],+ ),+ ),+ ),),],),diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/recent_views_list.dart b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/recent_views_list.dartindex 4f6b5fc38d..ea389b6214 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/recent_views_list.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/recent_views_list.dart@@ -1,12 +1,9 @@import 'package:appflowy/generated/locale_keys.g.dart';-import 'package:appflowy/startup/startup.dart';-import 'package:appflowy/workspace/application/action_navigation/action_navigation_bloc.dart';-import 'package:appflowy/workspace/application/action_navigation/navigation_action.dart';import 'package:appflowy/workspace/application/recent/recent_views_bloc.dart';import 'package:appflowy/workspace/application/user/user_workspace_bloc.dart';+import 'package:appflowy/workspace/presentation/command_palette/navigation_bloc_extension.dart';import 'package:appflowy/workspace/presentation/command_palette/widgets/search_icon.dart';import 'package:appflowy/workspace/presentation/command_palette/widgets/search_recent_view_cell.dart';-import 'package:appflowy/workspace/presentation/command_palette/widgets/search_special_styles.dart';import 'package:appflowy_backend/protobuf/flowy-user/workspace.pbenum.dart';import 'package:appflowy_ui/appflowy_ui.dart';import 'package:easy_localization/easy_localization.dart';@@ -63,6 +60,7 @@ class RecentViewsList extends StatelessWidget {padding: EdgeInsets.only(right: hidePreview ? 0 : 6),child: FlowyScrollbar(controller: controller,+ thumbVisibility: false,child: SingleChildScrollView(controller: controller,physics: const ClampingScrollPhysics(),@@ -99,7 +97,12 @@ class RecentViewsList extends StatelessWidget {),child: Text(LocaleKeys.sideBar_recent.tr(),- style: context.searchPanelTitle1,+ style: theme.textStyle.heading4+ .enhanced(color: theme.textColorScheme.secondary)+ .copyWith(+ letterSpacing: 0.2,+ height: 24 / 16,+ ),),);}@@ -138,7 +141,7 @@ class RecentViewsList extends StatelessWidget {Widget buildPreview(RecentViewsState state) {final hoveredView = state.hoveredView;if (hoveredView == null) {- return const SizedBox.shrink();+ return SizedBox.shrink();}return Align(alignment: Alignment.topLeft,@@ -146,13 +149,7 @@ class RecentViewsList extends StatelessWidget {key: ValueKey(hoveredView.id),view: hoveredView,onViewOpened: () {- getIt<ActionNavigationBloc>().add(- ActionNavigationEvent.performAction(- action: NavigationAction(- objectId: hoveredView.id,- ),- ),- );+ hoveredView.id.navigateTo();onSelected();},),diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_ask_ai_entrance.dart b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_ask_ai_entrance.dartindex c693b9f1c7..7925fba20f 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_ask_ai_entrance.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_ask_ai_entrance.dart@@ -1,7 +1,6 @@import 'package:appflowy/generated/flowy_svgs.g.dart';import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/workspace/application/command_palette/command_palette_bloc.dart';-import 'package:appflowy/workspace/presentation/command_palette/widgets/search_special_styles.dart';import 'package:appflowy_backend/protobuf/flowy-search/result.pb.dart';import 'package:appflowy_ui/appflowy_ui.dart';import 'package:easy_localization/easy_localization.dart';@@ -36,44 +35,41 @@ class _AskAIFor extends StatelessWidget {@overrideWidget build(BuildContext context) {final theme = AppFlowyTheme.of(context);- final spaceM = theme.spacing.m, spaceXL = theme.spacing.xl;- return Padding(- padding: EdgeInsets.only(top: spaceM),- child: AFBaseButton(- borderRadius: spaceM,- padding: EdgeInsets.symmetric(vertical: spaceXL, horizontal: spaceM),- backgroundColor: (context, isHovering, disable) {- if (isHovering) {- return theme.fillColorScheme.contentHover;- }- return Colors.transparent;- },- borderColor: (context, isHovering, disable, isFocused) =>- Colors.transparent,- builder: (ctx, isHovering, disable) {- return Row(- children: [- SizedBox.square(- dimension: 24,- child: Center(- child: FlowySvg(- FlowySvgs.m_home_ai_chat_icon_m,- size: Size.square(20),- blendMode: null,- ),+ final spaceM = theme.spacing.m, spaceL = theme.spacing.l;+ return AFBaseButton(+ borderRadius: spaceM,+ padding: EdgeInsets.all(spaceL),+ backgroundColor: (context, isHovering, disable) {+ if (isHovering) {+ return theme.fillColorScheme.contentHover;+ }+ return Colors.transparent;+ },+ borderColor: (context, isHovering, disable, isFocused) =>+ Colors.transparent,+ builder: (ctx, isHovering, disable) {+ return Row(+ children: [+ SizedBox.square(+ dimension: 20,+ child: Center(+ child: FlowySvg(+ FlowySvgs.m_home_ai_chat_icon_m,+ size: Size.square(20),+ blendMode: null,),),- HSpace(8),- buildText(context),- ],- );- },- onTap: () {- context- .read<CommandPaletteBloc?>()- ?.add(CommandPaletteEvent.goingToAskAI());- },- ),+ ),+ HSpace(8),+ buildText(context),+ ],+ );+ },+ onTap: () {+ context+ .read<CommandPaletteBloc?>()+ ?.add(CommandPaletteEvent.goingToAskAI());+ },);}@@ -84,8 +80,9 @@ class _AskAIFor extends StatelessWidget {if (queryText.isEmpty) {return Text(LocaleKeys.search_askAIAnything.tr(),- style:- theme.textStyle.body.standard(color: theme.textColorScheme.primary),+ style: theme.textStyle.body+ .enhanced(color: theme.textColorScheme.primary)+ .copyWith(height: 22 / 14),);}return Flexible(@@ -102,7 +99,8 @@ class _AskAIFor extends StatelessWidget {TextSpan(text: ' "$queryText"',style: theme.textStyle.body- .enhanced(color: theme.textColorScheme.primary),+ .enhanced(color: theme.textColorScheme.primary)+ .copyWith(height: 22 / 14),),],),@@ -118,24 +116,27 @@ class _AISearching extends StatelessWidget {Widget build(BuildContext context) {final theme = AppFlowyTheme.of(context);return Padding(- padding: EdgeInsets.symmetric(vertical: 20, horizontal: 8),- child: SizedBox(- height: 24,- child: Row(- children: [- FlowySvg(- FlowySvgs.ai_searching_icon_m,- size: Size.square(20),- blendMode: null,- ),- HSpace(8),- Text(- LocaleKeys.search_searching.tr(),- style: theme.textStyle.heading4- .enhanced(color: theme.textColorScheme.secondary),+ padding: EdgeInsets.all(theme.spacing.l),+ child: Row(+ children: [+ SizedBox.square(+ dimension: 20,+ child: Center(+ child: FlowySvg(+ FlowySvgs.m_home_ai_chat_icon_m,+ size: Size.square(20),+ blendMode: null,+ ),),- ],- ),+ ),+ HSpace(8),+ Text(+ LocaleKeys.search_searching.tr(),+ style: theme.textStyle.body+ .standard(color: theme.textColorScheme.secondary)+ .copyWith(height: 22 / 14),+ ),+ ],),);}@@ -154,14 +155,14 @@ class _AIOverview extends StatelessWidget {}return Padding(padding: EdgeInsets.symmetric(- vertical: theme.spacing.xxl,+ vertical: theme.spacing.l,horizontal: theme.spacing.m,),child: Column(crossAxisAlignment: CrossAxisAlignment.start,children: [buildHeader(context),- VSpace(12),+ VSpace(theme.spacing.l),LayoutBuilder(builder: (context, constrains) {final summary = summaries.first;@@ -170,7 +171,9 @@ class _AIOverview extends StatelessWidget {summary: summary,maxWidth: constrains.maxWidth,theme: AppFlowyTheme.of(context),- textStyle: context.searchPanelTitle3,+ textStyle: theme.textStyle.body+ .standard(color: theme.textColorScheme.primary)+ .copyWith(height: 22 / 14),);},),@@ -213,22 +216,23 @@ class _AIOverview extends StatelessWidget {}Widget buildHeader(BuildContext context) {- return SizedBox(- height: 24,- child: Row(- children: [- FlowySvg(- FlowySvgs.ai_searching_icon_m,- size: Size.square(20),- blendMode: null,- ),- HSpace(8),- Text(- LocaleKeys.commandPalette_aiOverview.tr(),- style: context.searchPanelAIOverview,- ),- ],- ),+ final theme = AppFlowyTheme.of(context);++ return Row(+ children: [+ FlowySvg(+ FlowySvgs.ai_searching_icon_m,+ size: Size.square(20),+ blendMode: null,+ ),+ HSpace(theme.spacing.l),+ Text(+ LocaleKeys.commandPalette_aiOverview.tr(),+ style: theme.textStyle.heading4+ .enhanced(color: theme.textColorScheme.secondary)+ .copyWith(height: 22 / 16, letterSpacing: 0.2),+ ),+ ],);}}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_field.dart b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_field.dartindex 2598dfc40f..0c9a7aea9e 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_field.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_field.dart@@ -57,8 +57,9 @@ class _SearchFieldState extends State<SearchField> {}Widget _buildSuffixIcon(BuildContext context) {+ final theme = AppFlowyTheme.of(context);return Padding(- padding: const EdgeInsets.only(left: 8, right: 12),+ padding: EdgeInsets.only(left: theme.spacing.m, right: theme.spacing.l),child: FlowyTooltip(message: LocaleKeys.commandPalette_clearSearchTooltip.tr(),child: MouseRegion(@@ -87,14 +88,16 @@ class _SearchFieldState extends State<SearchField> {final theme = AppFlowyTheme.of(context);final radius = BorderRadius.circular(theme.spacing.l);- return SizedBox(+ return Container(height: 44,+ margin: EdgeInsets.only(bottom: theme.spacing.m),child: ValueListenableBuilder<TextEditingValue>(valueListenable: controller,builder: (context, value, _) {final hasText = value.text.trim().isNotEmpty;return FlowyTextField(focusNode: focusNode,+ cursorHeight: 22,controller: controller,textStyle: theme.textStyle.heading4.standard(color: theme.textColorScheme.primary),diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_recent_view_cell.dart b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_recent_view_cell.dartindex 24956f5dc5..df920850f7 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_recent_view_cell.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_recent_view_cell.dart@@ -1,10 +1,7 @@import 'package:appflowy/mobile/presentation/search/mobile_view_ancestors.dart';-import 'package:appflowy/startup/startup.dart';-import 'package:appflowy/workspace/application/action_navigation/action_navigation_bloc.dart';-import 'package:appflowy/workspace/application/action_navigation/navigation_action.dart';import 'package:appflowy/workspace/application/recent/recent_views_bloc.dart';import 'package:appflowy/workspace/application/view/view_ext.dart';-import 'package:appflowy/workspace/presentation/command_palette/widgets/search_special_styles.dart';+import 'package:appflowy/workspace/presentation/command_palette/navigation_bloc_extension.dart';import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';import 'package:appflowy_ui/appflowy_ui.dart';import 'package:flowy_infra/theme_extension.dart';@@ -46,7 +43,7 @@ class _SearchRecentViewCellState extends State<SearchRecentViewCell> {@overrideWidget build(BuildContext context) {final theme = AppFlowyTheme.of(context);- final sapceM = theme.spacing.m, spaceL = theme.spacing.l;+ final spaceL = theme.spacing.l;final bloc = context.read<RecentViewsBloc>(), state = bloc.state;final hoveredView = state.hoveredView, hasHovered = hoveredView != null;final hovering = hoveredView == view;@@ -81,29 +78,27 @@ class _SearchRecentViewCellState extends State<SearchRecentViewCell> {),isSelected: () => hovering,child: Padding(- padding: EdgeInsets.symmetric(vertical: spaceL, horizontal: sapceM),- child: SizedBox(- height: 20,- child: Row(- children: [- widget.icon,- HSpace(8),- Container(- constraints: BoxConstraints(- maxWidth: (!widget.isNarrowWindow && hasHovered)- ? 480.0- : 680.0,- ),- child: Text(- view.nameOrDefault,- maxLines: 1,- style: context.searchPanelTitle2.copyWith(height: 1),- overflow: TextOverflow.ellipsis,- ),+ padding: EdgeInsets.all(spaceL),+ child: Row(+ children: [+ widget.icon,+ HSpace(8),+ Container(+ constraints: BoxConstraints(+ maxWidth:+ (!widget.isNarrowWindow && hasHovered) ? 480.0 : 680.0,),- Flexible(child: buildPath(theme)),- ],- ),+ child: Text(+ view.nameOrDefault,+ maxLines: 1,+ style: theme.textStyle.body+ .enhanced(color: theme.textColorScheme.primary)+ .copyWith(height: 22 / 14),+ overflow: TextOverflow.ellipsis,+ ),+ ),+ Flexible(child: buildPath(theme)),+ ],),),),@@ -113,6 +108,7 @@ class _SearchRecentViewCellState extends State<SearchRecentViewCell> {Widget buildPath(AppFlowyThemeData theme) {return BlocProvider(+ key: ValueKey(view.id),create: (context) => ViewAncestorBloc(view.id),child: BlocBuilder<ViewAncestorBloc, ViewAncestorState>(builder: (context, state) {@@ -126,10 +122,6 @@ class _SearchRecentViewCellState extends State<SearchRecentViewCell> {/// Helper to handle the selection action.void _handleSelection(String id) {widget.onSelected();- getIt<ActionNavigationBloc>().add(- ActionNavigationEvent.performAction(- action: NavigationAction(objectId: id),- ),- );+ id.navigateTo();}}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_result_cell.dart b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_result_cell.dartindex 85ea6b10ee..912421c8ef 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_result_cell.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_result_cell.dart@@ -5,7 +5,6 @@ import 'package:appflowy/util/string_extension.dart';import 'package:appflowy/workspace/application/command_palette/command_palette_bloc.dart';import 'package:appflowy/workspace/application/command_palette/search_result_list_bloc.dart';import 'package:appflowy/workspace/presentation/command_palette/widgets/search_icon.dart';-import 'package:appflowy/workspace/presentation/command_palette/widgets/search_special_styles.dart';import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';import 'package:appflowy_ui/appflowy_ui.dart';import 'package:easy_localization/easy_localization.dart';@@ -67,6 +66,9 @@ class _SearchResultCellState extends State<SearchResultCell> {final hasHovered = searchResultBloc.state.hoveredResult != null;final theme = AppFlowyTheme.of(context);+ final titleStyle = theme.textStyle.body+ .enhanced(color: theme.textColorScheme.primary)+ .copyWith(height: 22 / 14);return GestureDetector(behavior: HitTestBehavior.opaque,onTap: _handleSelection,@@ -107,48 +109,39 @@ class _SearchResultCellState extends State<SearchResultCell> {foregroundColorOnHover: AFThemeExtension.of(context).textColor,),child: Padding(- padding: EdgeInsets.symmetric(- horizontal: theme.spacing.m,- vertical: theme.spacing.xl,- ),+ padding: EdgeInsets.all(theme.spacing.l),child: Column(mainAxisSize: MainAxisSize.min,crossAxisAlignment: CrossAxisAlignment.start,children: [- SizedBox(- height: 20,- child: Row(- children: [- SizedBox.square(- dimension: 20,- child: Center(child: buildIcon(theme)),+ Row(+ children: [+ SizedBox.square(+ dimension: 20,+ child: Center(child: buildIcon(theme)),+ ),+ HSpace(8),+ Container(+ constraints: BoxConstraints(+ maxWidth: (!widget.isNarrowWindow && hasHovered)+ ? 480.0+ : 680.0,),- HSpace(8),- Container(- constraints: BoxConstraints(- maxWidth: (!widget.isNarrowWindow && hasHovered)- ? 480.0- : 680.0,- ),- child: RichText(- maxLines: 1,- textAlign: TextAlign.center,- overflow: TextOverflow.ellipsis,- text: buildHighLightSpan(- content: title,- normal:- context.searchPanelTitle2.copyWith(height: 1),- highlight: context.searchPanelTitle2.copyWith(- backgroundColor:- theme.fillColorScheme.themeSelect,- height: 1,- ),+ child: RichText(+ maxLines: 1,+ textAlign: TextAlign.center,+ overflow: TextOverflow.ellipsis,+ text: buildHighLightSpan(+ content: title,+ normal: titleStyle,+ highlight: titleStyle.copyWith(+ backgroundColor: theme.fillColorScheme.themeSelect,),),),- Flexible(child: buildPath(theme)),- ],- ),+ ),+ Flexible(child: buildPath(theme)),+ ],),...buildSummary(theme),],@@ -167,6 +160,7 @@ class _SearchResultCellState extends State<SearchResultCell> {Widget buildPath(AppFlowyThemeData theme) {return BlocProvider(+ key: ValueKey(item.id),create: (context) => ViewAncestorBloc(item.id),child: BlocBuilder<ViewAncestorBloc, ViewAncestorState>(builder: (context, state) {@@ -201,16 +195,23 @@ class _SearchResultCellState extends State<SearchResultCell> {List<Widget> buildSummary(AppFlowyThemeData theme) {if (item.content.isEmpty) return [];+ final style = theme.textStyle.caption+ .standard(color: theme.textColorScheme.secondary)+ .copyWith(letterSpacing: 0.1);return [VSpace(4),- RichText(- maxLines: 2,- overflow: TextOverflow.ellipsis,- text: buildHighLightSpan(- content: item.content,- normal: context.searchPanelSummary,- highlight: context.searchPanelSummary.copyWith(- backgroundColor: theme.fillColorScheme.themeSelect,+ Padding(+ padding: const EdgeInsets.only(left: 28),+ child: RichText(+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ text: buildHighLightSpan(+ content: item.content,+ normal: style,+ highlight: style.copyWith(+ backgroundColor: theme.fillColorScheme.themeSelect,+ color: theme.textColorScheme.primary,+ ),),),),diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_results_list.dart b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_results_list.dartindex 4e6c3fe391..deef7491dc 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_results_list.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_results_list.dart@@ -1,11 +1,8 @@-import 'package:appflowy/startup/startup.dart';-import 'package:appflowy/workspace/application/action_navigation/action_navigation_bloc.dart';-import 'package:appflowy/workspace/application/action_navigation/navigation_action.dart';import 'package:appflowy/workspace/application/command_palette/command_palette_bloc.dart';import 'package:appflowy/workspace/application/command_palette/search_result_list_bloc.dart';import 'package:appflowy/workspace/application/user/user_workspace_bloc.dart';+import 'package:appflowy/workspace/presentation/command_palette/navigation_bloc_extension.dart';import 'package:appflowy/workspace/presentation/command_palette/widgets/search_ask_ai_entrance.dart';-import 'package:appflowy/workspace/presentation/command_palette/widgets/search_special_styles.dart';import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';import 'package:appflowy_backend/protobuf/flowy-user/workspace.pbenum.dart';import 'package:appflowy_ui/appflowy_ui.dart';@@ -16,6 +13,7 @@ import 'package:appflowy_backend/protobuf/flowy-search/result.pb.dart';import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flutter_bloc/flutter_bloc.dart';+import 'page_preview.dart';import 'search_result_cell.dart';class SearchResultList extends StatefulWidget {@@ -55,13 +53,10 @@ class _SearchResultListState extends State<SearchResultList> {value: bloc,child: BlocListener<SearchResultListBloc, SearchResultListState>(listener: (context, state) {- if (state.openPageId != null) {+ final pageId = state.openPageId;+ if (pageId != null && pageId.isNotEmpty) {FlowyOverlay.pop(context);- getIt<ActionNavigationBloc>().add(- ActionNavigationEvent.performAction(- action: NavigationAction(objectId: state.openPageId!),- ),- );+ pageId.navigateTo();}},child: BlocBuilder<SearchResultListBloc, SearchResultListState>(@@ -96,7 +91,12 @@ class _SearchResultListState extends State<SearchResultList> {),child: Text(LocaleKeys.commandPalette_bestMatches.tr(),- style: context.searchPanelTitle1,+ style: theme.textStyle.heading4+ .enhanced(color: theme.textColorScheme.secondary)+ .copyWith(+ letterSpacing: 0.2,+ height: 24 / 16,+ ),),);}@@ -106,9 +106,13 @@ class _SearchResultListState extends State<SearchResultList> {final showAskingAI =workspaceState?.userProfile.workspaceType == WorkspaceTypePB.ServerW;if (widget.resultItems.isEmpty) return const SizedBox.shrink();- final resultItems = widget.resultItems- .where((item) => widget.cachedViews[item.id] != null)- .toList();+ List<SearchResultItem> resultItems = widget.resultItems;+ final hasCachedViews = widget.cachedViews.isNotEmpty;+ if (hasCachedViews) {+ resultItems = widget.resultItems+ .where((item) => widget.cachedViews[item.id] != null)+ .toList();+ }return ScrollControllerBuilder(builder: (context, controller) {final hoveredId = bloc.state.hoveredResult?.id;@@ -116,11 +120,14 @@ class _SearchResultListState extends State<SearchResultList> {padding: EdgeInsets.only(right: hidePreview ? 0 : 6),child: FlowyScrollbar(controller: controller,+ thumbVisibility: false,child: SingleChildScrollView(controller: controller,physics: ClampingScrollPhysics(),child: Padding(- padding: EdgeInsets.only(right: hidePreview ? 0 : 6),+ padding: EdgeInsets.only(+ right: hidePreview ? 0 : 6,+ ),child: Column(crossAxisAlignment: CrossAxisAlignment.start,children: [@@ -130,20 +137,8 @@ class _SearchResultListState extends State<SearchResultList> {mainAxisSize: MainAxisSize.min,children: [_buildSectionHeader(context),- VSpace(8),- ListView.separated(+ ListView.builder(physics: const NeverScrollableScrollPhysics(),- separatorBuilder: (_, index) {- final item = resultItems[index];- final isHovered = hoveredId == item.id;- if (isHovered) return VSpace(1);- if (index < resultItems.length - 1) {- final nextView = resultItems[index + 1];- final isNextHovered = hoveredId == nextView.id;- if (isNextHovered) return VSpace(1);- }- return const AFDivider();- },shrinkWrap: true,itemCount: resultItems.length,itemBuilder: (_, index) {@@ -187,7 +182,7 @@ class SearchCellPreview extends StatelessWidget {if (view != null) {return SearchResultPreview(view: view);}- return const SizedBox.shrink();+ return SomethingWentWrong();},);}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_special_styles.dart b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_special_styles.dartdeleted file mode 100644index 108434e609..0000000000--- a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_special_styles.dart+++ /dev/null@@ -1,56 +0,0 @@-import 'package:appflowy_ui/appflowy_ui.dart';-import 'package:flutter/material.dart';--extension DesktopSearchSpecialStyles on BuildContext {- TextStyle get searchPanelTitle1 {- return TextStyle(- fontSize: 16,- height: 24 / 16,- fontWeight: FontWeight.w500,- letterSpacing: 0.2,- color: AppFlowyTheme.of(this).textColorScheme.secondary,- );- }-- TextStyle get searchPanelTitle2 {- return TextStyle(- fontSize: 14,- height: 20 / 14,- fontWeight: FontWeight.w500,- color: AppFlowyTheme.of(this).textColorScheme.primary,- );- }-- TextStyle get searchPanelTitle3 {- return TextStyle(- fontSize: 14,- height: 22 / 14,- fontWeight: FontWeight.w400,- color: AppFlowyTheme.of(this).textColorScheme.primary,- );- }-- TextStyle get searchPanelAIOverview {- return TextStyle(- fontSize: 16,- height: 24 / 16,- fontWeight: FontWeight.w500,- letterSpacing: 0.2,- color: AppFlowyTheme.of(this).textColorScheme.secondary,- );- }-- TextStyle get searchPanelPath {- return TextStyle(- fontSize: 12,- height: 18 / 12,- fontWeight: FontWeight.w400,- letterSpacing: 0.1,- color: AppFlowyTheme.of(this).textColorScheme.tertiary,- );- }-- TextStyle get searchPanelSummary => searchPanelPath.copyWith(- color: AppFlowyTheme.of(this).textColorScheme.secondary,- );-}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_summary_cell.dart b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_summary_cell.dartindex b83a7ad853..0060bbca8b 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_summary_cell.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/widgets/search_summary_cell.dart@@ -1,11 +1,9 @@import 'package:appflowy/generated/flowy_svgs.g.dart';import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/mobile/presentation/search/mobile_search_cell.dart';-import 'package:appflowy/startup/startup.dart';-import 'package:appflowy/workspace/application/action_navigation/action_navigation_bloc.dart';-import 'package:appflowy/workspace/application/action_navigation/navigation_action.dart';import 'package:appflowy/workspace/application/command_palette/command_palette_bloc.dart';import 'package:appflowy/workspace/application/command_palette/search_result_ext.dart';+import 'package:appflowy/workspace/presentation/command_palette/navigation_bloc_extension.dart';import 'package:appflowy/workspace/presentation/command_palette/widgets/search_icon.dart';import 'package:appflowy_backend/protobuf/flowy-search/result.pb.dart';import 'package:appflowy_editor/appflowy_editor.dart';@@ -378,11 +376,7 @@ class ReferenceSources extends StatelessWidget {return AFBaseButton(borderRadius: spaceM,onTap: () {- getIt<ActionNavigationBloc>().add(- ActionNavigationEvent.performAction(- action: NavigationAction(objectId: source.id),- ),- );+ source.id.navigateTo();onClose?.call();},padding: EdgeInsets.symmetric(@@ -409,19 +403,13 @@ class ReferenceSources extends StatelessWidget {),HSpace(8),Flexible(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- mainAxisSize: MainAxisSize.min,- children: [- Text(- displayName,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: theme.textStyle.body.standard(- color: theme.textColorScheme.primary,- ),- ),- ],+ child: Text(+ displayName,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: theme.textStyle.body.standard(+ color: theme.textColorScheme.primary,+ ),),),],diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/sidebar.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/sidebar.dartindex 6904521914..65c6122ab0 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/sidebar.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/sidebar.dart@@ -3,6 +3,7 @@ import 'dart:io';import 'package:appflowy/generated/flowy_svgs.g.dart';import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/mobile/presentation/search/view_ancestor_cache.dart';import 'package:appflowy/plugins/blank/blank.dart';import 'package:appflowy/plugins/document/presentation/editor_notification.dart';import 'package:appflowy/shared/feature_flags.dart';@@ -22,6 +23,7 @@ import 'package:appflowy/workspace/application/sidebar/space/space_bloc.dart';import 'package:appflowy/workspace/application/tabs/tabs_bloc.dart';import 'package:appflowy/workspace/application/user/user_workspace_bloc.dart';import 'package:appflowy/workspace/application/view/view_ext.dart';+import 'package:appflowy/workspace/application/view/view_service.dart';import 'package:appflowy/workspace/presentation/command_palette/command_palette.dart';import 'package:appflowy/workspace/presentation/home/home_sizes.dart';import 'package:appflowy/workspace/presentation/home/menu/sidebar/footer/sidebar_footer.dart';@@ -33,6 +35,8 @@ import 'package:appflowy/workspace/presentation/home/menu/sidebar/shared/sidebarimport 'package:appflowy/workspace/presentation/home/menu/sidebar/space/sidebar_space.dart';import 'package:appflowy/workspace/presentation/home/menu/sidebar/space/space_migration.dart';import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/sidebar_workspace.dart';+import 'package:appflowy_backend/log.dart';+import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';import 'package:appflowy_backend/protobuf/flowy-folder/workspace.pb.dart';import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart'show UserProfilePB;@@ -232,19 +236,59 @@ class HomeSideBar extends StatelessWidget {);}- final blockId = action.arguments?[ActionArgumentKeys.blockId];- if (blockId != null) {- arguments[PluginArgumentKeys.blockId] = blockId;- }+ checkForSpace(+ context.read<SpaceBloc>(),+ view,+ () => openView(action, context, view, arguments),+ );+ openView(action, context, view, arguments);+ }+ }+ }- final rowId = action.arguments?[ActionArgumentKeys.rowId];- if (rowId != null) {- arguments[PluginArgumentKeys.rowId] = rowId;- }+ Future<void> checkForSpace(+ SpaceBloc spaceBloc,+ ViewPB view,+ VoidCallback afterOpen,+ ) async {+ /// open space+ final acestorCache = getIt<ViewAncestorCache>();+ final ancestor = await acestorCache.getAncestor(view.id);+ if (ancestor?.ancestors.isEmpty ?? true) return;+ final firstAncestor = ancestor!.ancestors.first;+ if (firstAncestor.id != spaceBloc.state.currentSpace?.id) {+ final space =+ (await ViewBackendService.getView(firstAncestor.id)).toNullable();+ if (space != null) {+ Log.info(+ 'Switching space from (${firstAncestor.name}-${firstAncestor.id}) to (${space.name}-${space.id})',+ );+ spaceBloc.add(SpaceEvent.open(space: space, afterOpen: afterOpen));+ }+ }+ }++ void openView(+ NavigationAction action,+ BuildContext context,+ ViewPB view,+ Map<String, dynamic> arguments,+ ) {+ final blockId = action.arguments?[ActionArgumentKeys.blockId];+ if (blockId != null) {+ arguments[PluginArgumentKeys.blockId] = blockId;+ }++ final rowId = action.arguments?[ActionArgumentKeys.rowId];+ if (rowId != null) {+ arguments[PluginArgumentKeys.rowId] = rowId;+ }+ WidgetsBinding.instance.addPostFrameCallback((_) {+ if (context.mounted) {context.read<TabsBloc>().openPlugin(view, arguments: arguments);}- }+ });}}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 dab2c977f9..2970aa9c93 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@@ -217,6 +217,6 @@ class _SpaceState extends State<_Space> {return;}- context.read<SpaceBloc>().add(SpaceEvent.open(space));+ context.read<SpaceBloc>().add(SpaceEvent.open(space: space));}}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/sidebar_space_menu.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/sidebar_space_menu.dartindex f4d910700d..ff365c5f8d 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/sidebar_space_menu.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/sidebar_space_menu.dart@@ -98,7 +98,7 @@ class SidebarSpaceMenuItem extends StatelessWidget {): null,onTap: () {- context.read<SpaceBloc>().add(SpaceEvent.open(space));+ context.read<SpaceBloc>().add(SpaceEvent.open(space: space));PopoverContainer.of(context).close();},);diff --git a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/scrollbar.dart b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/scrollbar.dartindex e55fd16ccd..9201052cc5 100644--- a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/scrollbar.dart+++ b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/scrollbar.dart@@ -4,11 +4,13 @@ class FlowyScrollbar extends StatefulWidget {const FlowyScrollbar({super.key,this.controller,+ this.thumbVisibility = true,required this.child,});final ScrollController? controller;final Widget child;+ final bool thumbVisibility;@overrideState<FlowyScrollbar> createState() => _FlowyScrollbarState();@@ -33,7 +35,7 @@ class _FlowyScrollbarState extends State<FlowyScrollbar> {valueListenable: isHovered,builder: (context, isHovered, child) {return Scrollbar(- thumbVisibility: isHovered,+ thumbVisibility: isHovered && widget.thumbVisibility,// the radius should be fixed to 12radius: const Radius.circular(12),controller: widget.controller,diff --git a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text_field.dart b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text_field.dartindex c4f72f2261..b4aac3cec4 100644--- a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text_field.dart+++ b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text_field.dart@@ -38,6 +38,7 @@ class FlowyTextField extends StatefulWidget {final bool isDense;final bool readOnly;final Color? enableBorderColor;+ final double? cursorHeight;final BorderRadius? borderRadius;final void Function()? onTap;final Function(PointerDownEvent)? onTapOutside;@@ -80,6 +81,7 @@ class FlowyTextField extends StatefulWidget {this.borderRadius,this.onTap,this.onTapOutside,+ this.cursorHeight,});@override@@ -153,6 +155,7 @@ class FlowyTextFieldState extends State<FlowyTextField> {@overrideWidget build(BuildContext context) {return TextField(+ cursorHeight: widget.cursorHeight,readOnly: widget.readOnly,controller: controller,focusNode: focusNode,diff --git a/frontend/resources/flowy_icons/20x/search_icon.svg b/frontend/resources/flowy_icons/20x/search_icon.svgindex 73d9aae054..644982fdc8 100644--- a/frontend/resources/flowy_icons/20x/search_icon.svg+++ b/frontend/resources/flowy_icons/20x/search_icon.svg@@ -1,3 +1,3 @@-<svg width="20" height="21" viewBox="0 0 20 21" fill="none" xmlns="http://www.w3.org/2000/svg">-<path d="M15.8553 16.8427C16.0516 17.0369 16.3681 17.0353 16.5624 16.839C16.7566 16.6428 16.755 16.3262 16.5588 16.1319L15.8553 16.8427ZM15.2946 9.9746H14.7946C14.7946 12.7242 12.5413 14.9619 9.75082 14.9619V15.4619V15.9619C13.0839 15.9619 15.7946 13.2861 15.7946 9.9746H15.2946ZM9.75082 15.4619V14.9619C6.96037 14.9619 4.70703 12.7242 4.70703 9.9746H4.20703H3.70703C3.70703 13.2861 6.41777 15.9619 9.75082 15.9619V15.4619ZM4.20703 9.9746H4.70703C4.70703 7.22501 6.96037 4.9873 9.75082 4.9873V4.4873V3.9873C6.41777 3.9873 3.70703 6.66309 3.70703 9.9746H4.20703ZM9.75082 4.4873V4.9873C12.5413 4.9873 14.7946 7.22501 14.7946 9.9746H15.2946H15.7946C15.7946 6.66309 13.0839 3.9873 9.75082 3.9873V4.4873ZM13.2303 13.5409L12.8785 13.8963L15.8553 16.8427L16.207 16.4873L16.5588 16.1319L13.582 13.1855L13.2303 13.5409Z" fill="#6F748C"/>+<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M18.0581 18.942C18.3022 19.186 18.698 19.186 18.942 18.9419C19.186 18.6978 19.186 18.302 18.9419 18.058L18.0581 18.942ZM16.8266 9.66138L16.2016 9.66138C16.2016 13.2712 13.2745 16.1978 9.6633 16.1978V16.8228V17.4478C13.9645 17.4478 17.4516 13.9618 17.4516 9.66138H16.8266ZM9.6633 16.8228V16.1978C6.05214 16.1978 3.125 13.2712 3.125 9.66138H2.5L1.875 9.66138C1.875 13.9618 5.3621 17.4478 9.6633 17.4478V16.8228ZM2.5 9.66138H3.125C3.125 6.0516 6.05214 3.125 9.6633 3.125V2.5V1.875C5.3621 1.875 1.875 5.36093 1.875 9.66138L2.5 9.66138ZM9.6633 2.5V3.125C13.2745 3.125 16.2016 6.0516 16.2016 9.66138L16.8266 9.66138H17.4516C17.4516 5.36093 13.9645 1.875 9.6633 1.875V2.5ZM14.4067 14.4078L13.9648 14.8498L18.0581 18.942L18.5 18.5L18.9419 18.058L14.8486 13.9658L14.4067 14.4078Z" fill="#6F748C"/></svg>diff --git a/frontend/resources/translations/en-US.json b/frontend/resources/translations/en-US.jsonindex 12b81c20f7..d63d3d240d 100644--- a/frontend/resources/translations/en-US.json+++ b/frontend/resources/translations/en-US.json@@ -2366,6 +2366,7 @@"seeMore": "See more","showMore": "Show more","somethingWentWrong": "Something went wrong",+ "pageNotExist": "This page doesn’t exist","tryAgainOrLater": "Please try again later","placeholder": {"actions": "Search actions..."@@ -2822,7 +2823,7 @@"betaTooltip": "We currently only support searching for pages and content in documents","fromTrashHint": "From trash","noResultsHint": "We didn't find what you're looking for, try searching for another term.",- "clearSearchTooltip": "Clear search field",+ "clearSearchTooltip": "Clear input","location": "Location","created": "Created","edited": "Edited"