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: support mobile search AI Overview (#7932)
Morn3cffb3436480
diff --git a/frontend/appflowy_flutter/integration_test/mobile/search/search_test.dart b/frontend/appflowy_flutter/integration_test/mobile/search/search_test.dartindex 9510af6786..6a9e62ffdd 100644--- a/frontend/appflowy_flutter/integration_test/mobile/search/search_test.dart+++ b/frontend/appflowy_flutter/integration_test/mobile/search/search_test.dart@@ -1,6 +1,9 @@import 'package:appflowy/generated/flowy_svgs.g.dart';import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/mobile/presentation/home/home.dart';+import 'package:appflowy/mobile/presentation/notifications/mobile_notifications_screen.dart';import 'package:appflowy/mobile/presentation/search/mobile_search_ask_ai_entrance.dart';+import 'package:appflowy/mobile/presentation/search/mobile_search_page.dart';import 'package:appflowy/mobile/presentation/search/mobile_search_result.dart';import 'package:appflowy/mobile/presentation/search/mobile_search_textfield.dart';import 'package:easy_localization/easy_localization.dart';@@ -56,4 +59,35 @@ void main() {expect(cancelButton, findsNothing);});});++ testWidgets('tap to search page and back to home', (tester) async {+ await tester.launchInAnonymousMode();++ /// go to search page+ final searchButton = find.byFlowySvg(FlowySvgs.m_home_search_icon_m);+ expect(find.byType(MobileSearchScreen), findsNothing);+ await tester.tapButton(searchButton);+ expect(find.byType(MobileSearchScreen), findsOneWidget);++ /// back to home page+ final backButton = find.byFlowySvg(FlowySvgs.search_page_arrow_left_m);+ expect(backButton, findsOneWidget);+ expect(find.byType(MobileHomeScreen), findsNothing);+ await tester.tapButton(backButton);+ expect(find.byType(MobileHomeScreen), findsOneWidget);++ /// go to notification page+ final notificationButton = find.byFlowySvg(FlowySvgs.m_home_notification_m);+ expect(find.byType(MobileNotificationsScreenV2), findsNothing);+ await tester.tapButton(notificationButton);+ expect(find.byType(MobileNotificationsScreenV2), findsOneWidget);++ /// go to search page+ await tester.tapButton(searchButton);+ expect(find.byType(MobileNotificationsScreenV2), findsNothing);+ expect(find.byType(MobileSearchScreen), findsOneWidget);+ await tester.tapButton(backButton);+ expect(find.byType(MobileNotificationsScreenV2), findsOneWidget);+ expect(find.byType(MobileSearchScreen), findsNothing);+ });}diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/mobile_bottom_navigation_bar.dart b/frontend/appflowy_flutter/lib/mobile/presentation/mobile_bottom_navigation_bar.dartindex 0b59adf364..62d0ec26b5 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/mobile_bottom_navigation_bar.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/mobile_bottom_navigation_bar.dart@@ -19,6 +19,9 @@ import 'package:flutter/material.dart';import 'package:flutter_bloc/flutter_bloc.dart';import 'package:go_router/go_router.dart';+import 'home/mobile_home_page.dart';+import 'search/mobile_search_page.dart';+enum BottomNavigationBarActionType {home,notificationMultiSelect,@@ -38,6 +41,14 @@ enum BottomNavigationBarItemType {notification;String get label => name;+ String? get routeName {+ return switch (this) {+ home => MobileHomeScreen.routeName,+ search => MobileSearchScreen.routeName,+ notification => MobileNotificationsScreenV2.routeName,+ add => null,+ };+ }ValueKey get valueKey {return ValueKey(label);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 7d07d2bd36..cdb9eea3a7 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,20 +1,41 @@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';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 'mobile_search_summary_cell.dart';+class MobileSearchAskAiEntrance extends StatelessWidget {- const MobileSearchAskAiEntrance({super.key, this.query});- final String? query;+ const MobileSearchAskAiEntrance({super.key});++ @override+ Widget build(BuildContext context) {+ final bloc = context.read<CommandPaletteBloc?>(), state = bloc?.state;+ if (bloc == null || state == null) return _AskAIFor();++ final generatingAIOverview = state.generatingAIOverview;+ if (generatingAIOverview) return _AISearching();++ final hasMockSummary = _mockSummary?.isNotEmpty ?? false,+ hasSummaries = state.resultSummaries.isNotEmpty;+ if (hasMockSummary || hasSummaries) return _AIOverview();++ return _AskAIFor();+ }+}++class _AskAIFor extends StatelessWidget {+ const _AskAIFor();@overrideWidget build(BuildContext context) {- final theme = AppFlowyTheme.of(context);return GestureDetector(onTap: () {context@@ -30,21 +51,28 @@ class MobileSearchAskAiEntrance extends StatelessWidget {padding: EdgeInsets.fromLTRB(8, 12, 8, 12),child: Row(children: [- FlowySvg(- FlowySvgs.m_home_ai_chat_icon_m,- size: Size.square(24),- blendMode: null,+ SizedBox.square(+ dimension: 24,+ child: Center(+ child: FlowySvg(+ FlowySvgs.m_home_ai_chat_icon_m,+ size: Size.square(20),+ blendMode: null,+ ),+ ),),- HSpace(12),- buildText(theme),+ HSpace(8),+ buildText(context),],),),);}- Widget buildText(AppFlowyThemeData theme) {- final queryText = query ?? '';+ Widget buildText(BuildContext context) {+ final theme = AppFlowyTheme.of(context);+ final bloc = context.read<CommandPaletteBloc?>();+ final queryText = bloc?.state.query ?? '';if (queryText.isEmpty) {return Text(LocaleKeys.search_askAIAnything.tr(),@@ -74,3 +102,90 @@ class MobileSearchAskAiEntrance extends StatelessWidget {);}}++class _AISearching extends StatelessWidget {+ const _AISearching();++ @override+ Widget build(BuildContext context) {+ return Container(+ padding: EdgeInsets.symmetric(vertical: 8),+ margin: EdgeInsets.only(top: 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: context.searchSubtitleStyle,+ ),+ ],+ ),+ ),+ );+ }+}++class _AIOverview extends StatelessWidget {+ const _AIOverview();++ @override+ Widget build(BuildContext context) {+ final bloc = context.read<CommandPaletteBloc?>(), state = bloc?.state;+ final summaries = _mockSummary ?? state?.resultSummaries ?? [];+ if (summaries.isEmpty) {+ return const SizedBox.shrink();+ }+ return Container(+ margin: EdgeInsets.only(top: 8),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ VSpace(8),+ buildHeader(context),+ VSpace(12),+ LayoutBuilder(+ builder: (context, constrains) {+ final summary = summaries.first;+ return MobileSearchSummaryCell(+ key: ValueKey(summary.content.trim()),+ summary: summary,+ maxWidth: constrains.maxWidth,+ theme: AppFlowyTheme.of(context),+ textStyle: context.searchTitleStyle,+ );+ },+ ),+ ],+ ),+ );+ }++ 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,+ ),+ ],+ ),+ );+ }+}++List<SearchSummaryPB>? _mockSummary;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 9f6af36152..cd6fe02f23 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,4 +1,5 @@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/command_palette/search_result_ext.dart';import 'package:appflowy/workspace/application/view/view_ext.dart';@@ -19,8 +20,7 @@ class MobileSearchResultCell extends StatelessWidget {@overrideWidget build(BuildContext context) {- final theme = AppFlowyTheme.of(context),- textColor = theme.textColorScheme.primary;+ final theme = AppFlowyTheme.of(context);final commandPaletteState = context.read<CommandPaletteBloc>().state;final displayName = item.displayName.isEmpty? LocaleKeys.menuAppHeader_defaultNewPageName.tr()@@ -44,12 +44,10 @@ class MobileSearchResultCell extends StatelessWidget {overflow: TextOverflow.ellipsis,text: buildHighLightSpan(content: displayName,- normal: theme.textStyle.heading4.standard(color: textColor),- highlight: theme.textStyle.heading4- .standard(color: textColor)- .copyWith(- backgroundColor: theme.fillColorScheme.themeSelect,- ),+ normal: context.searchTitleStyle,+ highlight: context.searchTitleStyle.copyWith(+ backgroundColor: theme.fillColorScheme.themeSelect,+ ),),),buildPath(commandPaletteState, theme),@@ -67,7 +65,10 @@ class MobileSearchResultCell extends StatelessWidget {if (icon.ty == ResultIconTypePB.Emoji) {return icon.getIcon(size: 20) ?? SizedBox.shrink();} else {- return icon.getIcon(size: 20, iconColor: theme.iconColorScheme.primary) ??+ return icon.getIcon(+ size: 20,+ iconColor: theme.iconColorScheme.secondary,+ ) ??SizedBox.shrink();}}@@ -85,7 +86,7 @@ class MobileSearchResultCell extends StatelessWidget {return Text(displayPath.join(' / '),style: theme.textStyle.body- .standard(color: theme.textColorScheme.secondary),+ .standard(color: theme.textColorScheme.tertiary),);},),diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_page.dart b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_page.dartindex 5be836185e..a9e8b22544 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_page.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_page.dart@@ -97,39 +97,43 @@ class _MobileSearchPageState extends State<MobileSearchPage> {builder: (context, state) {return SafeArea(child: Scaffold(- body: Padding(- padding: const EdgeInsets.symmetric(horizontal: 16),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- MobileSearchTextfield(- focusNode: focusNode,- hintText: enableShowAISearch- ? LocaleKeys.search_searchOrAskAI.tr()- : LocaleKeys.search_label.tr(),- query: state.query ?? '',- onChanged: (value) =>- context.read<CommandPaletteBloc>().add(- CommandPaletteEvent.searchChanged(search: value),- ),- ),- if (enableShowAISearch)- MobileSearchAskAiEntrance(query: state.query),- Flexible(- child: NotificationListener(- child: MobileSearchResult(),- onNotification: (t) {- if (t is ScrollUpdateNotification) {- if (focusNode.hasFocus) {- focusNode.unfocus();- }+ body: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ MobileSearchTextfield(+ focusNode: focusNode,+ hintText: enableShowAISearch+ ? LocaleKeys.search_searchOrAskAI.tr()+ : LocaleKeys.search_label.tr(),+ query: state.query ?? '',+ onChanged: (value) => context.read<CommandPaletteBloc>().add(+ CommandPaletteEvent.searchChanged(search: value),+ ),+ ),+ Flexible(+ child: NotificationListener(+ onNotification: (t) {+ if (t is ScrollUpdateNotification) {+ if (focusNode.hasFocus) {+ focusNode.unfocus();}- return true;- },+ }+ return true;+ },+ child: SingleChildScrollView(+ child: Padding(+ padding: const EdgeInsets.symmetric(horizontal: 16),+ child: Column(+ children: [+ if (enableShowAISearch) MobileSearchAskAiEntrance(),+ MobileSearchResult(),+ ],+ ),+ ),),),- ],- ),+ ),+ ],),),);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.dartnew file mode 100644index 0000000000..41ca56fb48--- /dev/null+++ b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_reference_bottom_sheet.dart@@ -0,0 +1,152 @@+import 'package:appflowy/mobile/presentation/base/mobile_view_page.dart';+import 'package:appflowy/mobile/presentation/bottom_sheet/show_mobile_bottom_sheet.dart';+import 'package:appflowy/shared/icon_emoji_picker/tab.dart';+import 'package:appflowy/startup/tasks/app_widget.dart';+import 'package:appflowy/workspace/application/command_palette/search_result_ext.dart';+import 'package:appflowy/workspace/application/view/view_ext.dart';+import 'package:appflowy/workspace/application/view/view_service.dart';+import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';+import 'package:appflowy_backend/protobuf/flowy-search/result.pb.dart';+import 'package:flutter/material.dart';+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy_ui/appflowy_ui.dart';+import 'package:easy_localization/easy_localization.dart' hide TextDirection;+import 'package:flowy_infra_ui/flowy_infra_ui.dart';++class SearchSourceReferenceBottomSheet extends StatelessWidget {+ const SearchSourceReferenceBottomSheet(this.sources, {super.key});++ final List<SearchSourcePB> sources;+ @override+ Widget build(BuildContext context) {+ return PageReferenceList(+ sources: sources,+ onTap: (id) async {+ final theme = AppFlowyTheme.of(context);+ final view = (await ViewBackendService.getView(id)).toNullable();+ if (view == null) {+ showToastNotification(+ message: LocaleKeys.search_somethingWentWrong.tr(),+ type: ToastificationType.error,+ );+ return;+ }+ await showMobileBottomSheet(+ AppGlobals.rootNavKey.currentContext ?? context,+ showDragHandle: true,+ showDivider: false,+ enableDraggableScrollable: true,+ maxChildSize: 1.0,+ minChildSize: 1.0,+ initialChildSize: 1.0,+ backgroundColor: theme.surfaceColorScheme.primary,+ builder: (_) => SizedBox(+ height: MediaQuery.of(context).size.height,+ child: MobileViewPage(+ id: id,+ viewLayout: view.layout,+ title: view.nameOrDefault,+ tabs: PickerTabType.values,+ ),+ ),+ );+ },+ );+ }+}++class PageReferenceList extends StatelessWidget {+ const PageReferenceList({+ super.key,+ required this.sources,+ required this.onTap,+ });++ final List<SearchSourcePB> sources;+ final ValueChanged<String> onTap;++ @override+ Widget build(BuildContext context) {+ final theme = AppFlowyTheme.of(context);+ return Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Padding(+ padding: const EdgeInsets.only(left: 16, top: 8),+ child: Text(+ LocaleKeys.commandPalette_aiOverviewSource.tr(),+ style: theme.textStyle.body.enhanced(+ color: theme.textColorScheme.secondary,+ ),+ ),+ ),+ const VSpace(4),+ ListView.builder(+ shrinkWrap: true,+ padding: EdgeInsets.fromLTRB(16, 0, 16, 8),+ physics: const NeverScrollableScrollPhysics(),+ itemBuilder: (context, index) {+ final source = sources[index];+ final displayName = source.displayName.isEmpty+ ? LocaleKeys.menuAppHeader_defaultNewPageName.tr()+ : source.displayName;+ final sapceM = theme.spacing.m, spaceL = theme.spacing.l;+ return FlowyButton(+ onTap: () => onTap.call(source.id),+ margin: EdgeInsets.zero,+ text: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ if (index != 0) AFDivider(),+ Padding(+ padding: EdgeInsets.symmetric(+ vertical: sapceM,+ horizontal: spaceL,+ ),+ child: Row(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ SizedBox.square(+ dimension: 20,+ child: Center(child: buildIcon(source.icon, theme)),+ ),+ HSpace(12),+ Flexible(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,+ children: [+ Text(+ displayName,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: theme.textStyle.heading4.standard(+ color: theme.textColorScheme.primary,+ ),+ ),+ ],+ ),+ ),+ ],+ ),+ ),+ ],+ ),+ );+ },+ itemCount: sources.length,+ ),+ ],+ );+ }++ Widget buildIcon(ResultIconPB icon, AppFlowyThemeData theme) {+ if (icon.ty == ResultIconTypePB.Emoji) {+ return icon.getIcon(size: 16, lineHeight: 20 / 16) ?? SizedBox.shrink();+ } else {+ return icon.getIcon(size: 20, iconColor: theme.iconColorScheme.primary) ??+ SizedBox.shrink();+ }+ }+}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 9adb3f7ea7..37eaa8117d 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,11 +1,12 @@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/command_palette/search_result_list_bloc.dart';import 'package:appflowy/workspace/application/recent/recent_views_bloc.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:appflowy_backend/protobuf/flowy-folder/view.pb.dart';import 'package:appflowy_result/appflowy_result.dart';@@ -36,7 +37,6 @@ class MobileSearchRecentList extends StatelessWidget {@overrideWidget build(BuildContext context) {- final theme = AppFlowyTheme.of(context);final commandPaletteState = context.read<CommandPaletteBloc>().state;final trashIdSet = commandPaletteState.trash.map((e) => e.id).toSet();@@ -49,31 +49,30 @@ class MobileSearchRecentList extends StatelessWidget {.map((e) => e.item).where((e) => !trashIdSet.contains(e.id)).toList();- return SingleChildScrollView(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- const VSpace(16),- Text(- LocaleKeys.sideBar_recent.tr(),- style: theme.textStyle.body- .enhanced(color: theme.textColorScheme.secondary),- ),- const VSpace(4),- Column(- children: List.generate(recentViews.length, (index) {- final view = recentViews[index];- return GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: () => _goToView(context, view),- child: MobileSearchResultCell(- item: view.toSearchResultItem(),- ),- );- }),- ),- ],- ),+ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,+ children: [+ const VSpace(16),+ Text(+ LocaleKeys.sideBar_recent.tr(),+ style: context.searchSubtitleStyle,+ ),+ const VSpace(4),+ Column(+ mainAxisSize: MainAxisSize.min,+ children: List.generate(recentViews.length, (index) {+ final view = recentViews[index];+ return GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () => _goToView(context, view),+ child: MobileSearchResultCell(+ item: view.toSearchResultItem(),+ ),+ );+ }),+ ),+ ],);},),@@ -81,28 +80,9 @@ class MobileSearchRecentList extends StatelessWidget {}}-class MobileSearchResultList extends StatefulWidget {+class MobileSearchResultList extends StatelessWidget {const MobileSearchResultList({super.key});- @override- State<MobileSearchResultList> createState() => _MobileSearchResultListState();-}--class _MobileSearchResultListState extends State<MobileSearchResultList> {- late final SearchResultListBloc bloc;-- @override- void initState() {- super.initState();- bloc = SearchResultListBloc();- }-- @override- void dispose() {- bloc.close();- super.dispose();- }-@overrideWidget build(BuildContext context) {final state = context.read<CommandPaletteBloc>().state,@@ -113,50 +93,55 @@ class _MobileSearchResultListState extends State<MobileSearchResultList> {if (isSearching && !hasData) {return Center(child: CircularProgressIndicator.adaptive());} else if (!hasData) {- return buildNoResult(state.query ?? '');+ return buildNoResult(state.query ?? '', theme);}- return SingleChildScrollView(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- const VSpace(16),- Text(- LocaleKeys.commandPalette_bestMatches.tr(),- style: theme.textStyle.body- .enhanced(color: theme.textColorScheme.secondary),- ),- const VSpace(4),- Column(- children: List.generate(items.length, (index) {- final item = items[index];- return GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: () async {- final view = await ViewBackendService.getView(item.id)- .fold((s) => s, (s) => null);- if (view != null && context.mounted) {- await _goToView(context, view);- } else {- Log.error(- 'tapping search result, view not found: ${item.id}',- );- }- },- child: MobileSearchResultCell(- item: item,- query: state.query,- ),- );- }),- ),- ],- ),+ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,+ children: [+ const VSpace(16),+ Text(+ LocaleKeys.commandPalette_bestMatches.tr(),+ style: context.searchSubtitleStyle,+ ),+ const VSpace(4),+ ListView.separated(+ shrinkWrap: true,+ physics: const NeverScrollableScrollPhysics(),+ itemBuilder: (context, index) {+ final item = items[index];+ return GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () async {+ final view =+ await ViewBackendService.getView(item.id).toNullable();+ if (view != null && context.mounted) {+ await _goToView(context, view);+ } else {+ showToastNotification(+ message: LocaleKeys.search_somethingWentWrong.tr(),+ type: ToastificationType.error,+ );+ Log.error(+ 'tapping search result, view not found: ${item.id}',+ );+ }+ },+ child: MobileSearchResultCell(+ item: item,+ query: state.query,+ ),+ );+ },+ separatorBuilder: (context, index) => AFDivider(),+ itemCount: items.length,+ ),+ ],);}- Widget buildNoResult(String query) {- final theme = AppFlowyTheme.of(context),- textColor = theme.textColorScheme.secondary;+ Widget buildNoResult(String query, AppFlowyThemeData theme) {+ final textColor = theme.textColorScheme.secondary;return Align(alignment: Alignment.topCenter,child: SizedBox(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.dartnew file mode 100644index 0000000000..edf804fc95--- /dev/null+++ b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_special_styles.dart@@ -0,0 +1,24 @@+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.dartnew file mode 100644index 0000000000..78d75eb068--- /dev/null+++ b/frontend/appflowy_flutter/lib/mobile/presentation/search/mobile_search_summary_cell.dart@@ -0,0 +1,338 @@+import 'package:appflowy/generated/flowy_svgs.g.dart';+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet.dart';+import 'package:appflowy/mobile/presentation/home/tab/mobile_space_tab.dart';+import 'package:appflowy/mobile/presentation/search/mobile_search_cell.dart';+import 'package:appflowy/startup/tasks/app_widget.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';+import 'package:easy_localization/easy_localization.dart' hide TextDirection;+import 'package:flowy_infra_ui/widget/spacing.dart';+import 'package:flutter/material.dart';+import 'package:provider/provider.dart';++import 'mobile_search_reference_bottom_sheet.dart';++class MobileSearchSummaryCell extends StatefulWidget {+ const MobileSearchSummaryCell({+ super.key,+ required this.summary,+ required this.maxWidth,+ required this.theme,+ required this.textStyle,+ });++ final SearchSummaryPB summary;+ final double maxWidth;+ final AppFlowyThemeData theme;+ final TextStyle textStyle;++ @override+ State<MobileSearchSummaryCell> createState() =>+ _MobileSearchSummaryCellState();+}++class _MobileSearchSummaryCellState extends State<MobileSearchSummaryCell> {+ late TextPainter _painter;+ late _TextInfo _textInfo = _TextInfo.normal(summary.content);+ bool tappedShowMore = false;+ final maxLines = 4;++ SearchSummaryPB get summary => widget.summary;+ double get maxWidth => widget.maxWidth;+ AppFlowyThemeData get theme => widget.theme;++ TextStyle get textStyle => widget.textStyle;++ TextStyle get showMoreStyle =>+ theme.textStyle.heading4.standard(color: theme.textColorScheme.secondary);++ @override+ void initState() {+ super.initState();+ refreshTextPainter();+ }++ @override+ void didUpdateWidget(MobileSearchSummaryCell oldWidget) {+ super.didUpdateWidget(oldWidget);+ if (oldWidget.maxWidth != maxWidth) {+ refreshTextPainter();+ }+ }++ @override+ void dispose() {+ _painter.dispose();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ final showReference = summary.sources.isNotEmpty;+ final query = summary.highlights.isEmpty+ ? context.read<CommandPaletteBloc?>()?.state.query+ : summary.highlights;+ return _textInfo.build(+ context: context,+ normal: textStyle,+ more: showMoreStyle,+ summury: summary,+ query: query ?? '',+ showMore: () {+ setState(() {+ tappedShowMore = true;+ _textInfo = _TextInfo.normal(summary.content);+ });+ },+ normalWidgetSpan: showReference+ ? WidgetSpan(+ alignment: PlaceholderAlignment.middle,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () => showPageReferences(context),+ child: Padding(+ padding: const EdgeInsets.only(left: 4),+ child: Container(+ width: 21,+ height: 15,+ decoration: BoxDecoration(+ color: Theme.of(context).colorScheme.secondary,+ borderRadius: BorderRadius.circular(6),+ ),+ child: FlowySvg(+ FlowySvgs.toolbar_link_m,+ color: theme.iconColorScheme.primary,+ size: Size.square(10),+ ),+ ),+ ),+ ),+ )+ : null,+ overflowFadeCover: buildFadeCover(),+ );+ }++ Widget buildFadeCover() {+ final fillColor = Theme.of(context).scaffoldBackgroundColor;+ return Container(+ width: maxWidth,+ height: 40,+ decoration: BoxDecoration(+ gradient: LinearGradient(+ colors: [+ fillColor.withValues(alpha: 0),+ fillColor.withValues(alpha: 0.6 * 255),+ fillColor,+ ],+ begin: Alignment.topCenter,+ end: Alignment.bottomCenter,+ ),+ ),+ );+ }++ void refreshTextPainter() {+ final content = summary.content;+ if (!tappedShowMore) {+ _painter = TextPainter(+ text: TextSpan(text: content, style: textStyle),+ textDirection: TextDirection.ltr,+ maxLines: maxLines,+ );+ _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);+ final text = content.substring(0, range.offset);+ _textInfo = _TextInfo.overflow(text);+ } else {+ _textInfo = _TextInfo.normal(content);+ }+ }+ }++ void showPageReferences(BuildContext context) {+ final theme = AppFlowyTheme.of(context);+ showMobileBottomSheet(+ AppGlobals.rootNavKey.currentContext ?? context,+ showDragHandle: true,+ showDivider: false,+ enableDraggableScrollable: true,+ backgroundColor: theme.surfaceColorScheme.primary,+ builder: (_) => SearchSourceReferenceBottomSheet(summary.sources),+ );+ }+}++class _TextInfo {+ _TextInfo({required this.text, required this.isOverflow});++ _TextInfo.normal(this.text) : isOverflow = false;++ _TextInfo.overflow(this.text) : isOverflow = true;++ final String text;+ final bool isOverflow;++ Widget build({+ required BuildContext context,+ required TextStyle normal,+ required TextStyle more,+ required VoidCallback showMore,+ required String query,+ required SearchSummaryPB summury,+ WidgetSpan? normalWidgetSpan,+ Widget? overflowFadeCover,+ }) {+ final theme = AppFlowyTheme.of(context);+ if (isOverflow) {+ 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,+ ),+ ),+ ),+ ),+ 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,+ ),+ ),+ HSpace(8),+ Text(LocaleKeys.search_showMore.tr(), style: more),+ ],+ ),+ ),+ VSpace(16),+ ],+ ),+ );+ } else {+ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,+ children: [+ SelectionArea(+ child: Text.rich(+ TextSpan(+ children: [+ _buildHighLightSpan(+ content: text,+ normal: normal,+ query: query,+ highlight: normal.copyWith(+ backgroundColor: theme.fillColorScheme.themeSelect,+ ),+ ),+ if (normalWidgetSpan != null) normalWidgetSpan,+ ],+ ),+ ),+ ),+ VSpace(16),+ SizedBox(+ width: 156,+ height: 42,+ child: AFOutlinedButton.normal(+ borderRadius: 21,+ padding: EdgeInsets.zero,+ builder: (context, hovering, disabled) {+ return Center(+ child: SizedBox(+ height: 22,+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ FlowySvg(+ FlowySvgs.chat_ai_page_s,+ size: Size.square(20),+ color: theme.iconColorScheme.secondary,+ ),+ HSpace(8),+ Text(+ LocaleKeys.commandPalette_aiAskFollowUp.tr(),+ style: theme.textStyle.heading4.standard(+ color: theme.textColorScheme.primary,+ ),+ ),+ ],+ ),+ ),+ );+ },+ onTap: () {+ context.read<CommandPaletteBloc?>()?.add(+ CommandPaletteEvent.goingToAskAI(+ sources: summury.sources,+ ),+ );+ mobileCreateNewAIChatNotifier.value =+ mobileCreateNewAIChatNotifier.value + 1;+ },+ ),+ ),+ VSpace(16),+ ],+ );+ }+ }++ TextSpan _buildHighLightSpan({+ required String content,+ required TextStyle normal,+ required TextStyle highlight,+ String? query,+ }) {+ final queryText = (query ?? '').trim();+ if (queryText.isEmpty) {+ return TextSpan(text: content, style: normal);+ }+ final contents = content.splitIncludeSeparator(queryText);+ return TextSpan(+ children: List.generate(contents.length, (index) {+ final content = contents[index];+ final isHighlight = content.toLowerCase() == queryText.toLowerCase();+ return TextSpan(+ text: content,+ style: isHighlight ? highlight : normal,+ );+ }),+ );+ }+}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 84ac0948eb..53d3d3e796 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,9 +1,14 @@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/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';class MobileSearchTextfield extends StatefulWidget {const MobileSearchTextfield({@@ -28,6 +33,7 @@ class _MobileSearchTextfieldState extends State<MobileSearchTextfield> {final ValueNotifier<bool> hasFocusValueNotifier = ValueNotifier(true);FocusNode get focusNode => widget.focusNode;+ late String lastPage = bottomNavigationBarItemType.value ?? '';@overridevoid initState() {@@ -54,14 +60,50 @@ class _MobileSearchTextfieldState extends State<MobileSearchTextfield> {@overrideWidget build(BuildContext context) {final theme = AppFlowyTheme.of(context);- return SizedBox(+ return Container(height: 42,+ margin: EdgeInsets.symmetric(vertical: 8),+ padding: EdgeInsets.only(left: 4, right: 16),child: ValueListenableBuilder(valueListenable: controller,builder: (context, _, __) {final hasText = controller.text.isNotEmpty;return Row(children: [+ GestureDetector(+ onTap: () {+ if (lastPage.isEmpty) return;+ // close the popup menu+ closePopupMenu();+ try {+ BottomNavigationBarItemType label =+ BottomNavigationBarItemType.values.byName(lastPage);+ if (label == BottomNavigationBarItemType.search) {+ label = BottomNavigationBarItemType.home;+ }+ if (label == BottomNavigationBarItemType.notification) {+ getIt<ReminderBloc>().add(const ReminderEvent.refresh());+ }+ bottomNavigationBarItemType.value = label.label;+ final routeName = label.routeName;+ if (routeName != null) GoRouter.of(context).go(routeName);+ } on ArgumentError {+ Log.error(+ 'lastPage: [$lastPage] cannot be converted to BottomNavigationBarItemType',+ );+ }+ },+ child: SizedBox.square(+ dimension: 40,+ child: Center(+ child: FlowySvg(+ FlowySvgs.search_page_arrow_left_m,+ size: Size.square(20),+ color: theme.iconColorScheme.primary,+ ),+ ),+ ),+ ),Expanded(child: TextFormField(autovalidateMode: AutovalidateMode.onUserInteraction,@@ -131,9 +173,9 @@ class _MobileSearchTextfieldState extends State<MobileSearchTextfield> {border: border,enabledBorder: border,focusedBorder: enableBorder,- prefixIconConstraints: BoxConstraints.loose(Size(34, 40)),+ prefixIconConstraints: BoxConstraints.loose(Size(38, 40)),prefixIcon: Padding(- padding: const EdgeInsets.fromLTRB(8, 10, 4, 10),+ padding: const EdgeInsets.fromLTRB(8, 10, 8, 10),child: FlowySvg(FlowySvgs.m_home_search_icon_m,color: theme.iconColorScheme.secondary,@@ -172,6 +214,7 @@ class _MobileSearchTextfieldState extends State<MobileSearchTextfield> {} else {focusNode.unfocus();controller.clear();+ lastPage = label ?? '';}}}diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/mobile_chat_input.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/mobile_chat_input.dartindex c40442a6c6..aa4d989f61 100644--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/mobile_chat_input.dart+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/mobile_chat_input.dart@@ -207,12 +207,21 @@ class _MobileChatInputState extends State<MobileChatInput> {if (!UniversalPlatform.isMobile) return;final paletteBloc = context.read<CommandPaletteBloc?>(),paletteState = paletteBloc?.state;- final isAskingAI = paletteState?.askAI ?? false;+ if (paletteBloc == null || paletteState == null) return;+ final isAskingAI = paletteState.askAI;if (!isAskingAI) return;- final query = paletteState?.query ?? '';+ paletteBloc.add(CommandPaletteEvent.askedAI());+ final query = paletteState.query ?? '';if (query.isEmpty) return;- onSubmitText(query);- paletteBloc?.add(CommandPaletteEvent.askedAI());+ final sources = (paletteState.askAISources ?? []).map((e) => e.id).toList();+ final metadata =+ context.read<AIPromptInputBloc?>()?.consumeMetadata() ?? {};+ final promptState = context.read<AIPromptInputBloc?>()?.state;+ final predefinedFormat = promptState?.predefinedFormat;+ if (sources.isNotEmpty) {+ widget.onUpdateSelectedSources(sources);+ }+ widget.onSubmitted.call(query, predefinedFormat, metadata);}void handleTextControllerChanged() {diff --git a/frontend/appflowy_flutter/lib/workspace/application/command_palette/search_result_ext.dart b/frontend/appflowy_flutter/lib/workspace/application/command_palette/search_result_ext.dartindex f7d7d753d9..5e07d0905e 100644--- a/frontend/appflowy_flutter/lib/workspace/application/command_palette/search_result_ext.dart+++ b/frontend/appflowy_flutter/lib/workspace/application/command_palette/search_result_ext.dart@@ -3,6 +3,7 @@ import 'package:appflowy/plugins/document/presentation/editor_plugins/header/emoimport 'package:appflowy/shared/icon_emoji_picker/flowy_icon_emoji_picker.dart';import 'package:appflowy_backend/protobuf/flowy-search/result.pb.dart';import 'package:flutter/material.dart';+import 'package:universal_platform/universal_platform.dart';extension GetIcon on ResultIconPB {Widget? getIcon({@@ -18,7 +19,9 @@ extension GetIcon on ResultIconPB {strutStyle: StrutStyle(fontSize: size,height: lineHeight,- forceStrutHeight: true,++ /// currently [forceStrutHeight] set to true seems only work in iOS+ forceStrutHeight: UniversalPlatform.isIOS,leadingDistribution: TextLeadingDistribution.even,),)diff --git a/frontend/resources/flowy_icons/20x/search_page_arrow_left.svg b/frontend/resources/flowy_icons/20x/search_page_arrow_left.svgnew file mode 100644index 0000000000..e9b78ee742--- /dev/null+++ b/frontend/resources/flowy_icons/20x/search_page_arrow_left.svg@@ -0,0 +1,3 @@+<svg width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M13.5 16L7.5 10L13.5 4" stroke="#21232A" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>+</svg>diff --git a/frontend/resources/translations/en-US.json b/frontend/resources/translations/en-US.jsonindex 6bd2318e19..12b81c20f7 100644--- a/frontend/resources/translations/en-US.json+++ b/frontend/resources/translations/en-US.json@@ -2364,6 +2364,7 @@"noResultForSearchingHintWithoutTrash": "Try different questions or keywords\n Some pages may be in the ","bestMatch": "Best match","seeMore": "See more",+ "showMore": "Show more","somethingWentWrong": "Something went wrong","tryAgainOrLater": "Please try again later","placeholder": {