96de9f5bea
Keep the Material-only conversation implementation while preserving public Cupertino parameters for callers. Narrow affected tests to Material hosts so the dead platform paths are no longer exercised.
66 lines
1.9 KiB
Dart
66 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../ui/adaptive/segmented_bar.dart';
|
|
|
|
enum ChatSidebarMode { expanded, compact, hidden }
|
|
|
|
/// Native list-layout selector, also available in the chat actions menu.
|
|
class ChatSidebarButton extends StatelessWidget
|
|
implements SegmentedOverflowable {
|
|
const ChatSidebarButton({
|
|
super.key,
|
|
required this.mode,
|
|
required this.onChanged,
|
|
});
|
|
final ChatSidebarMode mode;
|
|
final ValueChanged<ChatSidebarMode> onChanged;
|
|
|
|
@override
|
|
SegmentedOverflowEntry get overflowEntry => SegmentedOverflowEntry(
|
|
label: 'Chat list layout',
|
|
icon: Icons.view_sidebar_outlined,
|
|
choices: [
|
|
for (final value in ChatSidebarMode.values)
|
|
SegmentedMenuChoice(
|
|
label: _label(value),
|
|
selected: value == mode,
|
|
onSelected: () => onChanged(value),
|
|
),
|
|
],
|
|
);
|
|
|
|
Future<void> _choose(BuildContext context) async {
|
|
final choice = await showDialog<ChatSidebarMode>(
|
|
context: context,
|
|
builder: (context) => SimpleDialog(
|
|
title: const Text('Chat list'),
|
|
children: [
|
|
for (final value in ChatSidebarMode.values)
|
|
SimpleDialogOption(
|
|
onPressed: () => Navigator.pop(context, value),
|
|
child: Row(
|
|
children: [
|
|
Expanded(child: Text(_label(value))),
|
|
if (value == mode) const Icon(Icons.check),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
if (choice != null && context.mounted) onChanged(choice);
|
|
}
|
|
|
|
static String _label(ChatSidebarMode value) => switch (value) {
|
|
ChatSidebarMode.expanded => 'Expanded chat list',
|
|
ChatSidebarMode.compact => 'Compact chat list',
|
|
ChatSidebarMode.hidden => 'Hide chat list',
|
|
};
|
|
@override
|
|
Widget build(BuildContext context) => IconButton(
|
|
tooltip: 'Chat list layout',
|
|
onPressed: () => _choose(context),
|
|
icon: const Icon(Icons.view_sidebar_outlined),
|
|
);
|
|
}
|