import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../ui/adaptive/segmented_bar.dart'; import '../ui/sessions/chat_adaptive.dart'; /// The open conversation's bar: the app's [SegmentedBar] above the /// transcript. /// /// From the leading edge: a round Back (only where the page can go back), a /// pill with the conversation's title and folder that opens the chat's /// information, and a pill holding [controls] (model and mode). class ChatThreadHeader extends StatelessWidget { const ChatThreadHeader({ super.key, required this.title, required this.folder, required this.onInfo, this.showBack = false, this.onBack, this.controls = const [], }); final String title; /// The working folder's name, shown beneath the title; empty for none. final String folder; final VoidCallback onInfo; /// Whether the bar shows Back at all. final bool showBack; /// What Back does; null keeps the platform's stock action (pop the route). final VoidCallback? onBack; final List controls; @override Widget build(BuildContext context) { final cupertino = chatControlsStyleOf(context) == ChatControlsStyle.cupertino; return SegmentedBar( cupertino: cupertino, automaticallyImplyLeading: false, // The platform's own Back, so it reads and behaves as every other // page's Back; its key stays for finders. leading: showBack ? SegmentedBackButton( key: const Key('chat-back'), cupertino: cupertino, onPressed: onBack, ) : null, title: title.isEmpty ? 'Chat' : title, subtitle: folder, subtitleIcon: cupertino ? CupertinoIcons.folder : Icons.folder_outlined, onTitlePressed: onInfo, titleSemanticLabel: 'Chat information', titleKey: const Key('chat-info'), actions: controls, bottomPadding: 16, ); } }