From a480889c281f45d5f026f87278572bba8d68f109 Mon Sep 17 00:00:00 2001 From: Richard Shiue <71320345+richardshiue@users.noreply.github.com> Date: Fri, 13 Jun 2025 09:51:59 +0800 Subject: [PATCH] chore(mobile): add selected sources count indicator (#8056) --- .../select_sources_bottom_sheet.dart | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/frontend/appflowy_flutter/lib/ai/widgets/prompt_input/select_sources_bottom_sheet.dart b/frontend/appflowy_flutter/lib/ai/widgets/prompt_input/select_sources_bottom_sheet.dart index 33a7ae8372..c941189fff 100644 --- a/frontend/appflowy_flutter/lib/ai/widgets/prompt_input/select_sources_bottom_sheet.dart +++ b/frontend/appflowy_flutter/lib/ai/widgets/prompt_input/select_sources_bottom_sheet.dart @@ -7,6 +7,7 @@ import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/mobile/presentation/base/flowy_search_text_field.dart'; import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet.dart'; import 'package:appflowy/plugins/base/drag_handler.dart'; +import 'package:appflowy/plugins/document/application/document_bloc.dart'; import 'package:appflowy/workspace/application/sidebar/space/space_bloc.dart'; import 'package:appflowy/workspace/application/view/view_ext.dart'; import 'package:appflowy/workspace/presentation/home/menu/view/view_item.dart'; @@ -99,6 +100,26 @@ class _PromptInputMobileSelectSourcesButtonState color: Theme.of(context).iconTheme.color, size: const Size.square(20.0), ), + const HSpace(2.0), + ValueListenableBuilder( + valueListenable: widget.selectedSourcesNotifier, + builder: (context, selectedSourceIds, _) { + final documentId = + context.read()?.documentId; + final label = documentId != null && + selectedSourceIds.length == 1 && + selectedSourceIds[0] == documentId + ? LocaleKeys.chat_currentPage.tr() + : selectedSourceIds.length.toString(); + return FlowyText( + label, + fontSize: 14, + figmaLineHeight: 20, + color: Theme.of(context).hintColor, + ); + }, + ), + const HSpace(2.0), FlowySvg( FlowySvgs.ai_source_drop_down_s, color: Theme.of(context).hintColor, @@ -200,6 +221,48 @@ class _MobileSelectSourcesSheetBody extends StatelessWidget { ), ), ), + BlocBuilder( + builder: (context, state) { + return SliverList( + delegate: SliverChildBuilderDelegate( + childCount: state.selectedSources.length, + (context, index) { + final source = state.selectedSources.elementAt(index); + return ViewSelectorTreeItem( + key: ValueKey( + 'selected_select_sources_tree_item_${source.view.id}', + ), + viewSelectorItem: source, + level: 0, + isDescendentOfSpace: source.view.isSpace, + isSelectedSection: true, + onSelected: (item) { + context + .read() + .toggleSelectedStatus(item, true); + }, + height: 40.0, + ); + }, + ), + ); + }, + ), + BlocBuilder( + builder: (context, state) { + if (state.selectedSources.isNotEmpty && + state.visibleSources.isNotEmpty) { + return SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: AFDivider(), + ), + ); + } + + return const SliverToBoxAdapter(); + }, + ), BlocBuilder( builder: (context, state) { return SliverList(