fixed bugs relating to ui and duplicating conversations.

This commit is contained in:
Joshua
2024-07-09 17:36:21 -06:00
parent 78e7f4b896
commit 097b99e0e6
15 changed files with 352 additions and 62 deletions
@@ -8,10 +8,13 @@ class ChatBubbleWidget extends StatelessWidget{
@override
Widget build(BuildContext context) {
double max_width = MediaQuery.of(context).size.width*0.65;
return Row(
mainAxisAlignment: c.role ? MainAxisAlignment.end : MainAxisAlignment.start,
children: [
Container(
width: max_width,
padding: const EdgeInsets.all(16.0),
margin: const EdgeInsets.all(8.0),
decoration: BoxDecoration(
@@ -14,11 +14,9 @@ import 'package:cached_network_image/cached_network_image.dart';
class ConversationThreadModel extends FlutterFlowModel<ConversationThreadWidget> {
final formKey = GlobalKey<FormState>();
late PromptBoxModel promptBoxModel;
late Conversation conversation;
Conversation conversation;
void updateConversation() {
conversation = Server.getLoadedConversation();
}
ConversationThreadModel(this.conversation);
@override
void initState(BuildContext context) {
@@ -15,15 +15,19 @@ import 'conversation_thread_model.dart';
export 'conversation_thread_model.dart';
class ConversationThreadWidget extends StatefulWidget {
const ConversationThreadWidget({super.key});
final Conversation conversation;
const ConversationThreadWidget({super.key, required this.conversation});
@override
State<ConversationThreadWidget> createState() =>
_ConversationThreadWidgetState();
_ConversationThreadWidgetState(conversation);
}
class _ConversationThreadWidgetState extends State<ConversationThreadWidget> {
late ConversationThreadModel _model;
Conversation conversation;
_ConversationThreadWidgetState(this.conversation);
@override
void setState(VoidCallback callback) {
@@ -34,7 +38,7 @@ class _ConversationThreadWidgetState extends State<ConversationThreadWidget> {
@override
void initState() {
super.initState();
_model = createModel(context, () => ConversationThreadModel());
_model = createModel(context, () => ConversationThreadModel(conversation));
}
@override
@@ -66,11 +70,7 @@ class _ConversationThreadWidgetState extends State<ConversationThreadWidget> {
reverse: false,
scrollDirection: Axis.vertical,
itemBuilder: (BuildContext context, int index) {
if(Server.getLoadedConversation().chats.last.role) {
return ChatBubbleWidget(c: Server.getLoadedConversation().chats[index]);
} else {
}
return ChatBubbleWidget(c: Server.getLoadedConversation().chats[index]);
},
);
},
@@ -221,6 +221,7 @@ class _PromptBoxWidgetState extends State<PromptBoxWidget> {
onFieldSubmitted: (text) {
// TODO: Clear text box
Server.respondWhenReady(text); // TODO: Connect with multimedia
_model.textController?.clear(); // Clear the text field
},
),
),