enabled togglable chat history (during runtime) that uses different api endpoints.
This commit is contained in:
@@ -1,9 +1,22 @@
|
||||
import 'dart:convert';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class Chat {
|
||||
late String message;
|
||||
late bool isMe;
|
||||
final String content;
|
||||
final bool role;
|
||||
|
||||
// Most basic chat, text from server or from user.
|
||||
Chat(this.message, this.isMe);
|
||||
Chat(this.content, this.role);
|
||||
|
||||
String toJson() {
|
||||
Map<String, dynamic> c = {
|
||||
"content": content,
|
||||
"role": role,
|
||||
};
|
||||
|
||||
return json.encode(c);
|
||||
}
|
||||
|
||||
// TODO: Overload constructors to allow for multimedia.
|
||||
}
|
||||
@@ -9,7 +9,7 @@ class ChatBubbleWidget extends StatelessWidget{
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: c.isMe ? MainAxisAlignment.end : MainAxisAlignment.start,
|
||||
mainAxisAlignment: c.role ? MainAxisAlignment.end : MainAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
@@ -18,14 +18,14 @@ class ChatBubbleWidget extends StatelessWidget{
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: const Radius.circular(12.0),
|
||||
topRight: const Radius.circular(12.0),
|
||||
bottomLeft: c.isMe ? const Radius.circular(12.0) : const Radius
|
||||
bottomLeft: c.role ? const Radius.circular(12.0) : const Radius
|
||||
.circular(0.0),
|
||||
bottomRight: c.isMe ? const Radius.circular(12.0) : const Radius
|
||||
bottomRight: c.role ? const Radius.circular(12.0) : const Radius
|
||||
.circular(0.0),
|
||||
),
|
||||
color: c.isMe ? Colors.blue[200] : Colors.grey[200],
|
||||
color: c.role ? Colors.blue[200] : Colors.grey[200],
|
||||
),
|
||||
child: Text(c.message),
|
||||
child: Text(c.content),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user