WIP read aloud keeps playing across chats
This commit is contained in:
@@ -22,7 +22,7 @@ import 'paper/paper_quote.dart';
|
||||
import 'terminal/terminal_glyphs.dart';
|
||||
import 'chat_message_timestamp.dart';
|
||||
import 'chat_read_aloud_button.dart';
|
||||
import '../../speech/speech_controller.dart';
|
||||
import '../../speech/speech.dart';
|
||||
|
||||
/// Builds an assistant text part; the default keeps the server's text exactly.
|
||||
typedef ChatMessageTextBuilder = Widget Function(BuildContext, String);
|
||||
|
||||
@@ -13,6 +13,8 @@ const chatStopReadingLabel = 'Stop reading';
|
||||
/// Read aloud for one reply, styled like its Copy button. While this reply
|
||||
/// reads it becomes Pause (or Resume) and Stop, laid out along [direction]
|
||||
/// (a column in the narrow copy gutter). Absent where speech is unsupported.
|
||||
/// The reader is the app's, so a reply still reading after its chat was left
|
||||
/// shows Pause and Stop again when the chat is reopened.
|
||||
class ChatReadAloudButton extends StatelessWidget {
|
||||
const ChatReadAloudButton({
|
||||
super.key,
|
||||
@@ -40,7 +42,19 @@ class ChatReadAloudButton extends StatelessWidget {
|
||||
key: const Key('chat-message-read-aloud'),
|
||||
style: style,
|
||||
tooltip: chatReadAloudLabel,
|
||||
onPressed: () => unawaited(speech.read(messageId, parts)),
|
||||
onPressed: () {
|
||||
// The conversation's name labels the reading wherever it is
|
||||
// shown (the avatar's indicator, the global Stop).
|
||||
final origin = SpeechOrigin.maybeOf(context);
|
||||
unawaited(
|
||||
speech.read(
|
||||
messageId,
|
||||
parts,
|
||||
scope: origin?.scope,
|
||||
title: origin?.title ?? '',
|
||||
),
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.volume_up_outlined),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user