Remove Cupertino chat transcript branches
Keep the existing Material transcript path while preserving public Cupertino parameters for callers. Narrow transcript tests to the Material-only behavior and remove Cupertino-only fixtures.
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../sessions/chat_adaptive.dart';
|
||||
|
||||
/// A block opened with the host's own disclosure control (collapsed by default).
|
||||
///
|
||||
/// [childBuilder] runs only while the block is open, so a closed disclosure
|
||||
/// never encodes or lays out its body.
|
||||
class NativeDisclosure extends StatefulWidget {
|
||||
/// never encodes or lays out its body. The [ExpansionTile] keeps the open state.
|
||||
class NativeDisclosure extends StatelessWidget {
|
||||
const NativeDisclosure({
|
||||
super.key,
|
||||
required this.label,
|
||||
@@ -20,63 +17,16 @@ class NativeDisclosure extends StatefulWidget {
|
||||
final bool initiallyExpanded;
|
||||
|
||||
@override
|
||||
State<NativeDisclosure> createState() => _NativeDisclosureState();
|
||||
}
|
||||
|
||||
class _NativeDisclosureState extends State<NativeDisclosure> {
|
||||
late bool _expanded = widget.initiallyExpanded;
|
||||
|
||||
void _toggle() => setState(() => _expanded = !_expanded);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (chatControlsStyleOf(context) != ChatControlsStyle.cupertino) {
|
||||
return ExpansionTile(
|
||||
title: Text(widget.label),
|
||||
initiallyExpanded: widget.initiallyExpanded,
|
||||
maintainState: false,
|
||||
// A transcript block starts at the row edge, like its answer text; the
|
||||
// tile's own padding would indent it, and its body defaults to centred,
|
||||
// which floats a short body in the middle of the row.
|
||||
tilePadding: EdgeInsets.zero,
|
||||
expandedAlignment: AlignmentDirectional.centerStart,
|
||||
expandedCrossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [Builder(builder: widget.childBuilder)],
|
||||
);
|
||||
}
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// One node carries the label, the button action and the state; the
|
||||
// Cupertino button's own node would otherwise drop the state.
|
||||
Semantics(
|
||||
container: true,
|
||||
button: true,
|
||||
expanded: _expanded,
|
||||
label: widget.label,
|
||||
onTap: _toggle,
|
||||
child: ExcludeSemantics(
|
||||
child: CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: _toggle,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(widget.label, textAlign: TextAlign.start),
|
||||
),
|
||||
Icon(
|
||||
_expanded
|
||||
? CupertinoIcons.chevron_up
|
||||
: CupertinoIcons.chevron_down,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_expanded) widget.childBuilder(context),
|
||||
],
|
||||
);
|
||||
}
|
||||
Widget build(BuildContext context) => ExpansionTile(
|
||||
title: Text(label),
|
||||
initiallyExpanded: initiallyExpanded,
|
||||
maintainState: false,
|
||||
// A transcript block starts at the row edge, like its answer text; the
|
||||
// tile's own padding would indent it, and its body defaults to centred,
|
||||
// which floats a short body in the middle of the row.
|
||||
tilePadding: EdgeInsets.zero,
|
||||
expandedAlignment: AlignmentDirectional.centerStart,
|
||||
expandedCrossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [Builder(builder: childBuilder)],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user