Merge: Next chat button cycles through the list
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
|
||||
/// The open chat's Next chat button: the platform's icon button, labelled
|
||||
/// "Next chat", that opens the chat after this one in the list.
|
||||
///
|
||||
/// It stays in the bar rather than leaving for the More menu on a narrow
|
||||
/// bar (it is not [SegmentedOverflowable]): it is the one-tap way to cycle
|
||||
/// chats on a phone, so the title gives up the room instead.
|
||||
class ChatNextChatButton extends StatelessWidget {
|
||||
const ChatNextChatButton({super.key, required this.onPressed});
|
||||
|
||||
static const label = 'Next chat';
|
||||
|
||||
final VoidCallback onPressed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
||||
return Semantics(
|
||||
label: label,
|
||||
button: true,
|
||||
child: CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onPressed,
|
||||
child: const Icon(CupertinoIcons.arrow_right_to_line),
|
||||
),
|
||||
);
|
||||
}
|
||||
return IconButton(
|
||||
tooltip: label,
|
||||
onPressed: onPressed,
|
||||
icon: const Icon(Icons.keyboard_tab),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import '../domain/chat_attachment_picker.dart';
|
||||
import '../domain/chat_colors.dart';
|
||||
import '../domain/chat_transcript.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import 'chat_next_chat_button.dart';
|
||||
import '../ui/sessions/chat_color_picker.dart';
|
||||
import '../ui/sessions/session_actions.dart';
|
||||
import '../ui/transcript/chat_markdown_view.dart';
|
||||
@@ -87,10 +88,15 @@ class ChatThreadView extends StatefulWidget {
|
||||
this.onSessionClosed,
|
||||
this.fileBridge = const ArtifactFileBridge(),
|
||||
this.onColorSelected,
|
||||
this.onNextChat,
|
||||
});
|
||||
|
||||
final ApiGateway gateway;
|
||||
|
||||
/// Opens the chat after this one in the list (wrapping to the first), from
|
||||
/// the bar's Next chat button; null when there is no other chat to open.
|
||||
final VoidCallback? onNextChat;
|
||||
|
||||
/// Sets the chat's shared colour (a palette name, null for none) from the
|
||||
/// information sheet; null leaves the sheet without the Colour choice.
|
||||
final ValueChanged<String?>? onColorSelected;
|
||||
@@ -1199,6 +1205,8 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
answeredBy: answeredBy,
|
||||
),
|
||||
if (hasMode) _modeControl(),
|
||||
if (widget.onNextChat case final next?)
|
||||
ChatNextChatButton(key: const Key('chat-next'), onPressed: next),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user