Skip to content

Commit 1030dad

Browse files
committed
chore: adjust database custom prompt ui
1 parent 7f7657e commit 1030dad

File tree

9 files changed

+379
-231
lines changed

9 files changed

+379
-231
lines changed

frontend/appflowy_flutter/lib/ai/service/ai_prompt_selector_cubit.dart

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class AiPromptSelectorCubit extends Cubit<AiPromptSelectorState> {
8080
final customPrompts =
8181
await _aiService.getDatabasePrompts(databaseViewId);
8282

83-
if (customPrompts == null || customPrompts.isEmpty) {
83+
if (customPrompts == null) {
8484
final prompts = availablePrompts.where((prompt) => prompt.isFeatured);
8585
final visiblePrompts = _getFilteredPrompts(prompts);
8686
final selectedPromptId = _getVisibleSelectedPrompt(
@@ -277,37 +277,18 @@ class AiPromptSelectorCubit extends Cubit<AiPromptSelectorState> {
277277
emit(
278278
state.maybeMap(
279279
ready: (readyState) {
280-
if (customPrompts.isEmpty) {
281-
final prompts =
282-
availablePrompts.where((prompt) => prompt.isFeatured);
283-
final visiblePrompts = _getFilteredPrompts(prompts);
284-
final selectedPromptId = _getVisibleSelectedPrompt(
285-
visiblePrompts,
286-
readyState.selectedPromptId,
287-
);
288-
return readyState.copyWith(
289-
visiblePrompts: visiblePrompts.toList(),
290-
selectedPromptId: selectedPromptId,
291-
customPromptDatabaseViewId: viewId,
292-
isLoadingCustomPrompts: false,
293-
isFeaturedSectionSelected: true,
294-
isCustomPromptSectionSelected: false,
295-
selectedCategory: null,
296-
);
297-
} else {
298-
final prompts = _getPromptsByCategory(readyState);
299-
final visiblePrompts = _getFilteredPrompts(prompts);
300-
final selectedPromptId = _getVisibleSelectedPrompt(
301-
visiblePrompts,
302-
readyState.selectedPromptId,
303-
);
304-
return readyState.copyWith(
305-
visiblePrompts: visiblePrompts.toList(),
306-
selectedPromptId: selectedPromptId,
307-
customPromptDatabaseViewId: viewId,
308-
isLoadingCustomPrompts: false,
309-
);
310-
}
280+
final prompts = _getPromptsByCategory(readyState);
281+
final visiblePrompts = _getFilteredPrompts(prompts);
282+
final selectedPromptId = _getVisibleSelectedPrompt(
283+
visiblePrompts,
284+
readyState.selectedPromptId,
285+
);
286+
return readyState.copyWith(
287+
visiblePrompts: visiblePrompts.toList(),
288+
selectedPromptId: selectedPromptId,
289+
customPromptDatabaseViewId: viewId,
290+
isLoadingCustomPrompts: false,
291+
);
311292
},
312293
orElse: () => state,
313294
),

frontend/appflowy_flutter/lib/ai/widgets/ai_prompt_modal/ai_prompt_category_list.dart

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,8 @@ class AiPromptCustomPromptSection extends StatelessWidget {
148148
return state.maybeMap(
149149
ready: (readyState) {
150150
final isSelected = readyState.isCustomPromptSectionSelected;
151-
final isDisabled = context
152-
.read<AiPromptSelectorCubit>()
153-
.availablePrompts
154-
.every((prompt) => !prompt.isCustom);
151+
155152
return AFBaseButton(
156-
disabled: isDisabled,
157153
onTap: () {
158154
if (!isSelected) {
159155
context.read<AiPromptSelectorCubit>().selectCustomSection();
@@ -163,9 +159,7 @@ class AiPromptCustomPromptSection extends StatelessWidget {
163159
return Text(
164160
LocaleKeys.ai_customPrompt_custom.tr(),
165161
style: AppFlowyTheme.of(context).textStyle.body.standard(
166-
color: disabled
167-
? theme.textColorScheme.tertiary
168-
: theme.textColorScheme.primary,
162+
color: theme.textColorScheme.primary,
169163
),
170164
overflow: TextOverflow.ellipsis,
171165
);
@@ -178,9 +172,6 @@ class AiPromptCustomPromptSection extends StatelessWidget {
178172
borderColor: (context, isHovering, disabled, isFocused) =>
179173
Colors.transparent,
180174
backgroundColor: (context, isHovering, disabled) {
181-
if (disabled) {
182-
return Colors.transparent;
183-
}
184175
if (isSelected) {
185176
return theme.fillColorScheme.themeSelect;
186177
}

0 commit comments

Comments
 (0)