80 lines
2.7 KiB
Dart
80 lines
2.7 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import '../../../ui/adaptive/host.dart';
|
|
|
|
/// A named, explicit switch action above the inactive transcript. It occupies
|
|
/// space rather than obscuring the small chat's readable content.
|
|
class ChatPeekHeader extends StatelessWidget {
|
|
const ChatPeekHeader({
|
|
super.key,
|
|
required this.title,
|
|
required this.onActivate,
|
|
});
|
|
final String title;
|
|
final VoidCallback onActivate;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => LayoutBuilder(
|
|
builder: (context, constraints) {
|
|
final compact = constraints.maxHeight < 44;
|
|
final cupertino = usesCupertinoHost(context);
|
|
final textStyle = cupertino
|
|
? (compact
|
|
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle
|
|
: CupertinoTheme.of(context).textTheme.textStyle)
|
|
: (compact
|
|
? Theme.of(context).textTheme.labelMedium
|
|
: Theme.of(context).textTheme.labelLarge);
|
|
final foreground = cupertino
|
|
? CupertinoColors.label.resolveFrom(context)
|
|
: Theme.of(context).colorScheme.onSurface;
|
|
final background = cupertino
|
|
? CupertinoColors.secondarySystemBackground.resolveFrom(context)
|
|
: Theme.of(context).colorScheme.surfaceContainer;
|
|
final content = Row(
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
title,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: textStyle?.copyWith(color: foreground),
|
|
),
|
|
),
|
|
const SizedBox(width: 8),
|
|
Text('Switch', style: textStyle?.copyWith(color: foreground)),
|
|
const SizedBox(width: 4),
|
|
Icon(
|
|
cupertino ? CupertinoIcons.arrow_up : Icons.arrow_upward,
|
|
color: foreground,
|
|
size: 18,
|
|
),
|
|
],
|
|
);
|
|
return ColoredBox(
|
|
color: background,
|
|
child: Tooltip(
|
|
message: 'Switch to $title',
|
|
child: cupertino
|
|
? CupertinoButton(
|
|
minimumSize: const Size(0, 44),
|
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
onPressed: onActivate,
|
|
child: content,
|
|
)
|
|
: TextButton(
|
|
style: TextButton.styleFrom(
|
|
minimumSize: const Size(0, 44),
|
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
shape: const RoundedRectangleBorder(),
|
|
),
|
|
onPressed: onActivate,
|
|
child: content,
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|