mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 02:39:19 +08:00
genai: Fixed ModelSelector InkWell Bleed & made it visible in History
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:apidash/screens/home_page/editor_pane/url_card.dart';
|
||||
import 'package:apidash_core/apidash_core.dart';
|
||||
import 'package:apidash_design_system/apidash_design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -58,6 +59,12 @@ class HistoryURLCard extends StatelessWidget {
|
||||
),
|
||||
isCompact ? kHSpacer10 : kHSpacer20,
|
||||
],
|
||||
if (apiType == APIType.ai) ...[
|
||||
AIProviderSelector(
|
||||
readOnlyModel: historyRequestModel?.aiRequestModel,
|
||||
),
|
||||
SizedBox(width: 20),
|
||||
],
|
||||
Expanded(
|
||||
child: ReadOnlyTextField(
|
||||
initialValue: url,
|
||||
|
||||
@@ -4,30 +4,34 @@ import 'package:flutter/material.dart';
|
||||
|
||||
class DefaultLLMSelectorButton extends StatelessWidget {
|
||||
final LLMSaveObject? defaultLLM;
|
||||
final bool readonly;
|
||||
final Function(LLMSaveObject) onDefaultLLMUpdated;
|
||||
const DefaultLLMSelectorButton({
|
||||
super.key,
|
||||
this.defaultLLM,
|
||||
this.readonly = false,
|
||||
required this.onDefaultLLMUpdated,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ElevatedButton(
|
||||
onPressed: () async {
|
||||
final saveObject = await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
scrollable: true,
|
||||
content: DefaultLLMSelectorDialog(defaultLLM: defaultLLM),
|
||||
contentPadding: EdgeInsets.all(10),
|
||||
);
|
||||
},
|
||||
);
|
||||
if (saveObject == null) return;
|
||||
onDefaultLLMUpdated(saveObject);
|
||||
},
|
||||
onPressed: readonly
|
||||
? null
|
||||
: () async {
|
||||
final saveObject = await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
scrollable: true,
|
||||
content: DefaultLLMSelectorDialog(defaultLLM: defaultLLM),
|
||||
contentPadding: EdgeInsets.all(10),
|
||||
);
|
||||
},
|
||||
);
|
||||
if (saveObject == null) return;
|
||||
onDefaultLLMUpdated(saveObject);
|
||||
},
|
||||
child: Text(defaultLLM?.selectedLLM.modelName ?? 'Select Model'),
|
||||
);
|
||||
}
|
||||
@@ -171,37 +175,41 @@ class _DefaultLLMSelectorDialogState extends State<DefaultLLMSelectorDialog> {
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: const Color.fromARGB(27, 0, 0, 0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
...selectedLLMProvider.models.map(
|
||||
(x) => ListTile(
|
||||
title: Text(x.modelName),
|
||||
subtitle: Text(x.identifier),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (llmSaveObject.selectedLLM.identifier ==
|
||||
x.identifier)
|
||||
CircleAvatar(
|
||||
radius: 5,
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => removeModel(x),
|
||||
icon: Icon(
|
||||
Icons.delete,
|
||||
size: 20,
|
||||
))
|
||||
],
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: SingleChildScrollView(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: Column(
|
||||
children: [
|
||||
...selectedLLMProvider.models.map(
|
||||
(x) => ListTile(
|
||||
title: Text(x.modelName),
|
||||
subtitle: Text(x.identifier),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (llmSaveObject.selectedLLM.identifier ==
|
||||
x.identifier)
|
||||
CircleAvatar(
|
||||
radius: 5,
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => removeModel(x),
|
||||
icon: Icon(
|
||||
Icons.delete,
|
||||
size: 20,
|
||||
))
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
llmSaveObject.selectedLLM = x;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
onTap: () {
|
||||
llmSaveObject.selectedLLM = x;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -171,15 +171,18 @@ class SendRequestButton extends ConsumerWidget {
|
||||
}
|
||||
|
||||
class AIProviderSelector extends ConsumerWidget {
|
||||
final AIRequestModel? readOnlyModel;
|
||||
|
||||
const AIProviderSelector({
|
||||
super.key,
|
||||
this.readOnlyModel,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final selectedId = ref.watch(selectedIdStateProvider);
|
||||
final req = ref.watch(collectionStateNotifierProvider)![selectedId]!;
|
||||
AIRequestModel? aiRequestModel = req.aiRequestModel;
|
||||
AIRequestModel? aiRequestModel = readOnlyModel ?? req.aiRequestModel;
|
||||
|
||||
if (aiRequestModel == null) {
|
||||
return Container();
|
||||
@@ -194,6 +197,7 @@ class AIProviderSelector extends ConsumerWidget {
|
||||
);
|
||||
|
||||
return DefaultLLMSelectorButton(
|
||||
readonly: (readOnlyModel != null),
|
||||
key: ValueKey(ref.watch(selectedIdStateProvider)),
|
||||
defaultLLM: defaultLLMSO,
|
||||
onDefaultLLMUpdated: (llmso) {
|
||||
|
||||
Reference in New Issue
Block a user