Skip to content

Commit dc6f6d9

Browse files
author
Franco Bugnano
committed
Completed ChatBox events
1 parent 99b11eb commit dc6f6d9

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/src/chatbox.dart

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import './message.dart';
1818
typedef BlurHandler = void Function();
1919
typedef FocusHandler = void Function();
2020
typedef SendMessageHandler = void Function(SendMessageEvent event);
21-
typedef TranslationToggledHandler = void Function();
21+
typedef TranslationToggledHandler = void Function(TranslationToggledEvent event);
2222

2323
class SendMessageEvent {
2424
ConversationData conversation;
@@ -31,6 +31,15 @@ class SendMessageEvent {
3131
message = SentMessage.fromJson(json['message']);
3232
}
3333

34+
class TranslationToggledEvent {
35+
ConversationData conversation;
36+
bool isEnabled;
37+
38+
TranslationToggledEvent.fromJson(Map<String, dynamic> json)
39+
: conversation = ConversationData.fromJson(json['conversation']),
40+
isEnabled = json['isEnabled'];
41+
}
42+
3443
/// A messaging UI for just a single conversation.
3544
///
3645
/// Create a Chatbox through [Session.createChatbox] and then call [mount] to show it.
@@ -233,8 +242,8 @@ class ChatBoxState extends State<ChatBox> {
233242
if (kDebugMode) {
234243
print('📗 chatbox._jscTranslationToggled: ${message.message}');
235244
}
236-
// {"isEnabled":true,"conversation":{}}
237-
widget.onTranslationToggled?.call();
245+
246+
widget.onTranslationToggled?.call(TranslationToggledEvent.fromJson(json.decode(message.message)));
238247
}
239248

240249
/// For internal use only. Implementation detail that may change anytime.

0 commit comments

Comments
 (0)