Merge: narrow list panes keep a readable title and row status
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import '../../../../ui/adaptive/segmented_bar_overflow.dart';
|
||||||
import '../../../../ui/theme/app_theme.dart';
|
import '../../../../ui/theme/app_theme.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -13,7 +14,7 @@ ChatControlsStyle chatControlsStyleOf(BuildContext context) =>
|
|||||||
? ChatControlsStyle.cupertino
|
? ChatControlsStyle.cupertino
|
||||||
: ChatControlsStyle.material;
|
: ChatControlsStyle.material;
|
||||||
|
|
||||||
class ChatBarAction extends StatelessWidget {
|
class ChatBarAction extends StatelessWidget implements SegmentedOverflowable {
|
||||||
const ChatBarAction({
|
const ChatBarAction({
|
||||||
super.key,
|
super.key,
|
||||||
required this.label,
|
required this.label,
|
||||||
@@ -27,6 +28,14 @@ class ChatBarAction extends StatelessWidget {
|
|||||||
final IconData materialIcon;
|
final IconData materialIcon;
|
||||||
final IconData cupertinoIcon;
|
final IconData cupertinoIcon;
|
||||||
|
|
||||||
|
/// A narrow bar moves it into its More menu, under the bar's host's icon.
|
||||||
|
@override
|
||||||
|
SegmentedOverflowEntry get overflowEntry => SegmentedOverflowEntry(
|
||||||
|
label: label,
|
||||||
|
icon: materialIcon,
|
||||||
|
onPressed: onPressed,
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ class ChatSessionRow extends StatelessWidget {
|
|||||||
selected: selected,
|
selected: selected,
|
||||||
emphasized: unread,
|
emphasized: unread,
|
||||||
divider: divider,
|
divider: divider,
|
||||||
keepMenuWhenCompact: true,
|
|
||||||
onTap: () => onOpen(session),
|
onTap: () => onOpen(session),
|
||||||
onLongPress: onLongPress,
|
onLongPress: onLongPress,
|
||||||
accent: chatColorShade(context, chatSessionColor(session)),
|
accent: chatColorShade(context, chatSessionColor(session)),
|
||||||
|
|||||||
@@ -327,24 +327,14 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
|||||||
Widget _settingsButton(BuildContext context) =>
|
Widget _settingsButton(BuildContext context) =>
|
||||||
pipelineSettingsButton(context, widget.onOpenSettings);
|
pipelineSettingsButton(context, widget.onOpenSettings);
|
||||||
|
|
||||||
Widget _refreshButton(BuildContext context) {
|
Widget _refreshButton(BuildContext context) => pipelineBarIconButton(
|
||||||
if (useCupertinoControls(context)) {
|
context,
|
||||||
return Semantics(
|
key: const Key('pipelines-refresh'),
|
||||||
button: true,
|
label: 'Refresh',
|
||||||
label: 'Refresh',
|
icon: Icons.refresh,
|
||||||
child: CupertinoButton(
|
cupertinoIcon: CupertinoIcons.refresh,
|
||||||
padding: EdgeInsets.zero,
|
onPressed: _controller.load,
|
||||||
onPressed: _controller.load,
|
);
|
||||||
child: const Icon(CupertinoIcons.refresh),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return IconButton(
|
|
||||||
tooltip: 'Refresh',
|
|
||||||
onPressed: _controller.load,
|
|
||||||
icon: const Icon(Icons.refresh),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _materialShell(BuildContext context, Widget body) {
|
Widget _materialShell(BuildContext context, Widget body) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../ui/adaptive/segmented_bar_overflow.dart';
|
||||||
import 'pipeline_controls.dart';
|
import 'pipeline_controls.dart';
|
||||||
|
|
||||||
/// One icon action in the Pipelines bar's actions pill: a Material
|
/// One icon action in the Pipelines bar's actions pill: a Material
|
||||||
/// [IconButton] with its tooltip, or a Cupertino button named for
|
/// [IconButton] with its tooltip, or a Cupertino button named for
|
||||||
/// accessibility.
|
/// accessibility. A narrow bar moves it into its More menu.
|
||||||
Widget pipelineBarIconButton(
|
Widget pipelineBarIconButton(
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
required Key key,
|
required Key key,
|
||||||
@@ -15,7 +16,8 @@ Widget pipelineBarIconButton(
|
|||||||
required VoidCallback? onPressed,
|
required VoidCallback? onPressed,
|
||||||
}) {
|
}) {
|
||||||
final Widget button;
|
final Widget button;
|
||||||
if (useCupertinoControls(context)) {
|
final cupertino = useCupertinoControls(context);
|
||||||
|
if (cupertino) {
|
||||||
button = CupertinoButton(
|
button = CupertinoButton(
|
||||||
key: key,
|
key: key,
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
@@ -30,10 +32,17 @@ Widget pipelineBarIconButton(
|
|||||||
icon: Icon(icon),
|
icon: Icon(icon),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Semantics(
|
return SegmentedOverflowAction(
|
||||||
button: true,
|
overflowEntry: SegmentedOverflowEntry(
|
||||||
label: label,
|
label: label,
|
||||||
child: ExcludeSemantics(child: button),
|
icon: cupertino ? cupertinoIcon : icon,
|
||||||
|
onPressed: onPressed,
|
||||||
|
),
|
||||||
|
child: Semantics(
|
||||||
|
button: true,
|
||||||
|
label: label,
|
||||||
|
child: ExcludeSemantics(child: button),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../../../shell/shell_list_shortcuts.dart';
|
import '../../../shell/shell_list_shortcuts.dart';
|
||||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||||
|
import '../../../ui/adaptive/segmented_bar_overflow.dart';
|
||||||
import '../../../ui/status/run_status_icon.dart';
|
import '../../../ui/status/run_status_icon.dart';
|
||||||
import '../pipeline_format.dart';
|
import '../pipeline_format.dart';
|
||||||
import '../pipeline_models.dart';
|
import '../pipeline_models.dart';
|
||||||
@@ -322,7 +323,13 @@ List<Widget> pipelineListActions(
|
|||||||
final label = filters.count == 0
|
final label = filters.count == 0
|
||||||
? 'Filter pipelines'
|
? 'Filter pipelines'
|
||||||
: '${filters.count} active ${filters.count == 1 ? 'filter' : 'filters'}';
|
: '${filters.count} active ${filters.count == 1 ? 'filter' : 'filters'}';
|
||||||
final filter = useCupertinoControls(context)
|
final cupertino = useCupertinoControls(context);
|
||||||
|
final filterIcon = cupertino
|
||||||
|
? (filters.count > 0
|
||||||
|
? CupertinoIcons.line_horizontal_3_decrease_circle_fill
|
||||||
|
: CupertinoIcons.line_horizontal_3_decrease_circle)
|
||||||
|
: (filters.count > 0 ? Icons.filter_alt : Icons.filter_alt_outlined);
|
||||||
|
final filter = cupertino
|
||||||
? Semantics(
|
? Semantics(
|
||||||
button: true,
|
button: true,
|
||||||
label: label,
|
label: label,
|
||||||
@@ -332,11 +339,7 @@ List<Widget> pipelineListActions(
|
|||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
|
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
|
||||||
onPressed: openFilters,
|
onPressed: openFilters,
|
||||||
child: Icon(
|
child: Icon(filterIcon),
|
||||||
filters.count > 0
|
|
||||||
? CupertinoIcons.line_horizontal_3_decrease_circle_fill
|
|
||||||
: CupertinoIcons.line_horizontal_3_decrease_circle,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: IconButton(
|
: IconButton(
|
||||||
@@ -344,17 +347,38 @@ List<Widget> pipelineListActions(
|
|||||||
tooltip: label,
|
tooltip: label,
|
||||||
isSelected: filters.count > 0,
|
isSelected: filters.count > 0,
|
||||||
onPressed: openFilters,
|
onPressed: openFilters,
|
||||||
icon: Icon(
|
icon: Icon(filterIcon),
|
||||||
filters.count > 0 ? Icons.filter_alt : Icons.filter_alt_outlined,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
// A narrow bar moves either into its More menu; sorting is then a
|
||||||
|
// submenu (Material) or a second action sheet (Cupertino).
|
||||||
return [
|
return [
|
||||||
filter,
|
SegmentedOverflowAction(
|
||||||
PipelineSortButton(
|
overflowEntry: SegmentedOverflowEntry(
|
||||||
key: const Key('pipeline-sort'),
|
label: label,
|
||||||
sort: controller.sort,
|
icon: filterIcon,
|
||||||
onSelected: controller.setSort,
|
onPressed: openFilters,
|
||||||
icon: true,
|
),
|
||||||
|
child: filter,
|
||||||
|
),
|
||||||
|
SegmentedOverflowAction(
|
||||||
|
overflowEntry: SegmentedOverflowEntry(
|
||||||
|
label: 'Sort pipelines: ${controller.sort.label}',
|
||||||
|
icon: cupertino ? CupertinoIcons.arrow_up_arrow_down : Icons.sort,
|
||||||
|
choices: [
|
||||||
|
for (final option in PipelineSort.values)
|
||||||
|
SegmentedMenuChoice(
|
||||||
|
label: option.label,
|
||||||
|
selected: option == controller.sort,
|
||||||
|
onSelected: () => controller.setSort(option),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: PipelineSortButton(
|
||||||
|
key: const Key('pipeline-sort'),
|
||||||
|
sort: controller.sort,
|
||||||
|
onSelected: controller.setSort,
|
||||||
|
icon: true,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,8 +113,8 @@ class RunListRow extends StatelessWidget {
|
|||||||
: RelativeTimeLabel(instant: createdAt, now: now),
|
: RelativeTimeLabel(instant: createdAt, now: now),
|
||||||
subtitle: Text(subtitle),
|
subtitle: Text(subtitle),
|
||||||
compactSubtitle: Text(compactSubtitle),
|
compactSubtitle: Text(compactSubtitle),
|
||||||
// A narrow list pane beside the open run leaves the row no room for a
|
// Kept in a narrow list pane too, so every run's actions stay one tap
|
||||||
// second control; the open run's detail beside it carries the same menu.
|
// away from the list.
|
||||||
menu:
|
menu:
|
||||||
!selecting &&
|
!selecting &&
|
||||||
gateway != null &&
|
gateway != null &&
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../ui/adaptive/host.dart';
|
import '../../../ui/adaptive/host.dart';
|
||||||
|
import '../../../ui/adaptive/segmented_bar_overflow.dart';
|
||||||
import '../../../ui/layout/app_sheet_header.dart';
|
import '../../../ui/layout/app_sheet_header.dart';
|
||||||
import '../../pipelines/pipeline_format.dart' show runStateLabel;
|
import '../../pipelines/pipeline_format.dart' show runStateLabel;
|
||||||
import 'runs_controller.dart';
|
import 'runs_controller.dart';
|
||||||
@@ -160,8 +161,9 @@ class RunsBarActions {
|
|||||||
VoidCallback onPressed, {
|
VoidCallback onPressed, {
|
||||||
bool active = false,
|
bool active = false,
|
||||||
}) {
|
}) {
|
||||||
|
final Widget button;
|
||||||
if (cupertino) {
|
if (cupertino) {
|
||||||
return Semantics(
|
button = Semantics(
|
||||||
button: true,
|
button: true,
|
||||||
label: label,
|
label: label,
|
||||||
excludeSemantics: true,
|
excludeSemantics: true,
|
||||||
@@ -175,13 +177,23 @@ class RunsBarActions {
|
|||||||
child: Icon(ios),
|
child: Icon(ios),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
button = IconButton(
|
||||||
|
key: key,
|
||||||
|
tooltip: label,
|
||||||
|
isSelected: active,
|
||||||
|
onPressed: onPressed,
|
||||||
|
icon: Icon(material),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return IconButton(
|
// A narrow bar moves it into its More menu.
|
||||||
key: key,
|
return SegmentedOverflowAction(
|
||||||
tooltip: label,
|
overflowEntry: SegmentedOverflowEntry(
|
||||||
isSelected: active,
|
label: label,
|
||||||
onPressed: onPressed,
|
icon: cupertino ? ios : material,
|
||||||
icon: Icon(material),
|
onPressed: onPressed,
|
||||||
|
),
|
||||||
|
child: button,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
import '../../../ui/adaptive/host.dart';
|
import '../../../ui/adaptive/host.dart';
|
||||||
|
import '../../../ui/adaptive/segmented_bar_overflow.dart';
|
||||||
import '../../../ui/layout/section_heading.dart';
|
import '../../../ui/layout/section_heading.dart';
|
||||||
import '../actions/delete_runs_action.dart';
|
import '../actions/delete_runs_action.dart';
|
||||||
import '../domain/run_deletion.dart';
|
import '../domain/run_deletion.dart';
|
||||||
@@ -24,29 +25,39 @@ ValueKey<String> runsDaySelectKey(String day) =>
|
|||||||
/// The Runs bar's `Select` action, entering multi-select.
|
/// The Runs bar's `Select` action, entering multi-select.
|
||||||
Widget runsSelectAction(BuildContext context, RunsController controller) {
|
Widget runsSelectAction(BuildContext context, RunsController controller) {
|
||||||
void enter() => controller.selection.enter();
|
void enter() => controller.selection.enter();
|
||||||
if (usesCupertinoHost(context)) {
|
final cupertino = usesCupertinoHost(context);
|
||||||
return Semantics(
|
// A narrow bar moves it into its More menu.
|
||||||
button: true,
|
return SegmentedOverflowAction(
|
||||||
|
overflowEntry: SegmentedOverflowEntry(
|
||||||
label: 'Select',
|
label: 'Select',
|
||||||
excludeSemantics: true,
|
icon: cupertino ? CupertinoIcons.checkmark_circle : Icons.checklist,
|
||||||
onTap: enter,
|
onPressed: enter,
|
||||||
child: CupertinoButton(
|
),
|
||||||
key: runsSelectKey,
|
child: cupertino
|
||||||
padding: EdgeInsets.zero,
|
? _selectButtonCupertino(enter)
|
||||||
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
|
: IconButton(
|
||||||
onPressed: enter,
|
key: runsSelectKey,
|
||||||
child: const Icon(CupertinoIcons.checkmark_circle),
|
tooltip: 'Select',
|
||||||
),
|
onPressed: enter,
|
||||||
);
|
icon: const Icon(Icons.checklist),
|
||||||
}
|
),
|
||||||
return IconButton(
|
|
||||||
key: runsSelectKey,
|
|
||||||
tooltip: 'Select',
|
|
||||||
onPressed: enter,
|
|
||||||
icon: const Icon(Icons.checklist),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _selectButtonCupertino(VoidCallback enter) => Semantics(
|
||||||
|
button: true,
|
||||||
|
label: 'Select',
|
||||||
|
excludeSemantics: true,
|
||||||
|
onTap: enter,
|
||||||
|
child: CupertinoButton(
|
||||||
|
key: runsSelectKey,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
|
||||||
|
onPressed: enter,
|
||||||
|
child: const Icon(CupertinoIcons.checkmark_circle),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
/// What the bar shows in select mode: `N selected` over the selection's size,
|
/// What the bar shows in select mode: `N selected` over the selection's size,
|
||||||
/// then Delete and Done.
|
/// then Delete and Done.
|
||||||
({String title, String? subtitle, List<Widget> actions}) runsSelectionBar(
|
({String title, String? subtitle, List<Widget> actions}) runsSelectionBar(
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ class SchedulePipelineRow extends StatelessWidget {
|
|||||||
'${scheduleRuleSummary(schedule)}',
|
'${scheduleRuleSummary(schedule)}',
|
||||||
),
|
),
|
||||||
// A narrow Summary still needs a way to pause or delete.
|
// A narrow Summary still needs a way to pause or delete.
|
||||||
keepMenuWhenCompact: true,
|
|
||||||
menu: AppOverflowMenu<_ScheduleAction>(
|
menu: AppOverflowMenu<_ScheduleAction>(
|
||||||
key: scheduleRowMenuKey(id),
|
key: scheduleRowMenuKey(id),
|
||||||
cupertino: cupertino,
|
cupertino: cupertino,
|
||||||
|
|||||||
@@ -0,0 +1,289 @@
|
|||||||
|
import 'dart:math' as math;
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
|
import 'package:flutter/scheduler.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
/// A bar's actions in one row, each at its natural width, with a trailing
|
||||||
|
/// [more] button that shows only when they do not all fit.
|
||||||
|
///
|
||||||
|
/// When the actions are wider than [overflowWidth] (the room the bar leaves
|
||||||
|
/// them beside a readable title), the [overflowable] ones leave the row from
|
||||||
|
/// its trailing end until the rest and [more] fit in it, so
|
||||||
|
/// every action left keeps its own (touch-target) width instead of being
|
||||||
|
/// squeezed. [onHidden] hears which actions left (by index) after a layout
|
||||||
|
/// that changes them, so the bar can list them in its More menu. Only when
|
||||||
|
/// the actions that stay are wider than the row may be at all (a long model
|
||||||
|
/// name, which cannot move) does the first of them shrink, as a [Flexible]
|
||||||
|
/// would, so the row never overflows.
|
||||||
|
class SegmentedActionRow extends MultiChildRenderObjectWidget {
|
||||||
|
SegmentedActionRow({
|
||||||
|
super.key,
|
||||||
|
required List<Widget> actions,
|
||||||
|
required Widget more,
|
||||||
|
required this.overflowable,
|
||||||
|
required this.overflowWidth,
|
||||||
|
required this.onHidden,
|
||||||
|
}) : assert(actions.length == overflowable.length),
|
||||||
|
super(children: [...actions, more]);
|
||||||
|
|
||||||
|
/// Whether each action may move into the More menu.
|
||||||
|
final List<bool> overflowable;
|
||||||
|
|
||||||
|
/// Past this width, [overflowable] actions move into the More menu.
|
||||||
|
final double overflowWidth;
|
||||||
|
final ValueChanged<List<int>> onHidden;
|
||||||
|
|
||||||
|
@override
|
||||||
|
RenderSegmentedActionRow createRenderObject(BuildContext context) =>
|
||||||
|
RenderSegmentedActionRow(
|
||||||
|
overflowable: overflowable,
|
||||||
|
overflowWidth: overflowWidth,
|
||||||
|
onHidden: onHidden,
|
||||||
|
textDirection: Directionality.of(context),
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void updateRenderObject(
|
||||||
|
BuildContext context,
|
||||||
|
RenderSegmentedActionRow renderObject,
|
||||||
|
) {
|
||||||
|
renderObject
|
||||||
|
..overflowable = overflowable
|
||||||
|
..overflowWidth = overflowWidth
|
||||||
|
..onHidden = onHidden
|
||||||
|
..textDirection = Directionality.of(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ActionParentData extends ContainerBoxParentData<RenderBox> {
|
||||||
|
bool shown = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The render object of [SegmentedActionRow].
|
||||||
|
class RenderSegmentedActionRow extends RenderBox
|
||||||
|
with
|
||||||
|
ContainerRenderObjectMixin<RenderBox, _ActionParentData>,
|
||||||
|
RenderBoxContainerDefaultsMixin<RenderBox, _ActionParentData> {
|
||||||
|
RenderSegmentedActionRow({
|
||||||
|
required this._overflowable,
|
||||||
|
required this._overflowWidth,
|
||||||
|
required this.onHidden,
|
||||||
|
required this._textDirection,
|
||||||
|
});
|
||||||
|
|
||||||
|
List<bool> _overflowable;
|
||||||
|
set overflowable(List<bool> value) {
|
||||||
|
if (listEquals(value, _overflowable)) return;
|
||||||
|
_overflowable = value;
|
||||||
|
markNeedsLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
double _overflowWidth;
|
||||||
|
set overflowWidth(double value) {
|
||||||
|
if (value == _overflowWidth) return;
|
||||||
|
_overflowWidth = value;
|
||||||
|
markNeedsLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueChanged<List<int>> onHidden;
|
||||||
|
|
||||||
|
TextDirection _textDirection;
|
||||||
|
set textDirection(TextDirection value) {
|
||||||
|
if (value == _textDirection) return;
|
||||||
|
_textDirection = value;
|
||||||
|
markNeedsLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// What the last layout reported to [onHidden]; nothing is hidden at
|
||||||
|
/// first, so a bar whose actions fit reports nothing.
|
||||||
|
List<int> _reported = const [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void setupParentData(RenderBox child) {
|
||||||
|
if (child.parentData is! _ActionParentData) {
|
||||||
|
child.parentData = _ActionParentData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<RenderBox> get _children {
|
||||||
|
final list = <RenderBox>[];
|
||||||
|
var child = firstChild;
|
||||||
|
while (child != null) {
|
||||||
|
list.add(child);
|
||||||
|
child = childAfter(child);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Which actions show, whether More shows, and the most the first shown
|
||||||
|
/// action may take (infinite when everything fits at its natural width).
|
||||||
|
({List<bool> shown, bool more, double firstMax}) _plan(
|
||||||
|
List<double> widths,
|
||||||
|
double moreWidth,
|
||||||
|
double maxWidth,
|
||||||
|
) {
|
||||||
|
final count = widths.length;
|
||||||
|
final shown = List.filled(count, true);
|
||||||
|
var total = widths.fold(0.0, (sum, width) => sum + width);
|
||||||
|
var more = false;
|
||||||
|
final soft = math.min(_overflowWidth, maxWidth);
|
||||||
|
if (total > soft && _overflowable.contains(true)) {
|
||||||
|
more = true;
|
||||||
|
for (var index = count - 1; index >= 0; index--) {
|
||||||
|
if (total + moreWidth <= soft) break;
|
||||||
|
if (!_overflowable[index]) continue;
|
||||||
|
shown[index] = false;
|
||||||
|
total -= widths[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final room = maxWidth - (more ? moreWidth : 0);
|
||||||
|
final first = shown.indexOf(true);
|
||||||
|
if (total <= room || first < 0) {
|
||||||
|
return (shown: shown, more: more, firstMax: double.infinity);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
shown: shown,
|
||||||
|
more: more,
|
||||||
|
firstMax: math.max(0, room - (total - widths[first])),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Size _layout(BoxConstraints constraints, {required bool dry}) {
|
||||||
|
final children = _children;
|
||||||
|
final actions = children.sublist(0, children.length - 1);
|
||||||
|
final moreChild = children.last;
|
||||||
|
final loose = BoxConstraints(maxHeight: constraints.maxHeight);
|
||||||
|
Size size(RenderBox child, BoxConstraints box) => dry
|
||||||
|
? child.getDryLayout(box)
|
||||||
|
: (child..layout(box, parentUsesSize: true)).size;
|
||||||
|
final sizes = [for (final child in actions) size(child, loose)];
|
||||||
|
final moreSize = size(moreChild, loose);
|
||||||
|
final plan = _plan(
|
||||||
|
[for (final s in sizes) s.width],
|
||||||
|
moreSize.width,
|
||||||
|
constraints.maxWidth,
|
||||||
|
);
|
||||||
|
final first = plan.shown.indexOf(true);
|
||||||
|
if (first >= 0 && plan.firstMax.isFinite) {
|
||||||
|
sizes[first] = size(
|
||||||
|
actions[first],
|
||||||
|
loose.copyWith(maxWidth: plan.firstMax),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final placed = [
|
||||||
|
for (final (index, s) in sizes.indexed)
|
||||||
|
if (plan.shown[index]) (actions[index], s),
|
||||||
|
if (plan.more) (moreChild, moreSize),
|
||||||
|
];
|
||||||
|
final height = placed.fold(
|
||||||
|
0.0,
|
||||||
|
(most, entry) => math.max(most, entry.$2.height),
|
||||||
|
);
|
||||||
|
final width = placed.fold(0.0, (sum, entry) => sum + entry.$2.width);
|
||||||
|
final result = constraints.constrain(Size(width, height));
|
||||||
|
if (dry) return result;
|
||||||
|
for (final child in children) {
|
||||||
|
(child.parentData! as _ActionParentData).shown = false;
|
||||||
|
}
|
||||||
|
var x = 0.0;
|
||||||
|
for (final (child, s) in placed) {
|
||||||
|
final data = child.parentData! as _ActionParentData;
|
||||||
|
data.shown = true;
|
||||||
|
final dx = _textDirection == TextDirection.ltr
|
||||||
|
? x
|
||||||
|
: result.width - x - s.width;
|
||||||
|
data.offset = Offset(dx, (result.height - s.height) / 2);
|
||||||
|
x += s.width;
|
||||||
|
}
|
||||||
|
final hidden = [
|
||||||
|
for (final (index, shown) in plan.shown.indexed)
|
||||||
|
if (!shown) index,
|
||||||
|
];
|
||||||
|
if (!listEquals(hidden, _reported)) {
|
||||||
|
_reported = hidden;
|
||||||
|
final report = onHidden;
|
||||||
|
// The bar rebuilds its More menu from this, which it may not do in
|
||||||
|
// the middle of a layout.
|
||||||
|
SchedulerBinding.instance.addPostFrameCallback((_) => report(hidden));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void performLayout() {
|
||||||
|
size = _layout(constraints, dry: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Size computeDryLayout(covariant BoxConstraints constraints) =>
|
||||||
|
_layout(constraints, dry: true);
|
||||||
|
|
||||||
|
Iterable<RenderBox> get _actionChildren =>
|
||||||
|
_children.sublist(0, childCount - 1);
|
||||||
|
|
||||||
|
@override
|
||||||
|
double computeMinIntrinsicWidth(double height) {
|
||||||
|
final children = _children;
|
||||||
|
// At its narrowest: the actions that cannot move, and More.
|
||||||
|
var width = children.last.getMinIntrinsicWidth(height);
|
||||||
|
for (final (index, child) in _actionChildren.indexed) {
|
||||||
|
if (!_overflowable[index]) width += child.getMinIntrinsicWidth(height);
|
||||||
|
}
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
double computeMaxIntrinsicWidth(double height) => _actionChildren.fold(
|
||||||
|
0.0,
|
||||||
|
(sum, child) => sum + child.getMaxIntrinsicWidth(height),
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
double computeMinIntrinsicHeight(double width) => _children.fold(
|
||||||
|
0.0,
|
||||||
|
(most, child) => math.max(most, child.getMinIntrinsicHeight(width)),
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
double computeMaxIntrinsicHeight(double width) => _children.fold(
|
||||||
|
0.0,
|
||||||
|
(most, child) => math.max(most, child.getMaxIntrinsicHeight(width)),
|
||||||
|
);
|
||||||
|
|
||||||
|
bool _shown(RenderBox child) =>
|
||||||
|
(child.parentData! as _ActionParentData).shown;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void paint(PaintingContext context, Offset offset) {
|
||||||
|
for (final child in _children) {
|
||||||
|
if (!_shown(child)) continue;
|
||||||
|
final data = child.parentData! as _ActionParentData;
|
||||||
|
context.paintChild(child, offset + data.offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool hitTestChildren(BoxHitTestResult result, {required Offset position}) {
|
||||||
|
for (final child in _children.reversed) {
|
||||||
|
if (!_shown(child)) continue;
|
||||||
|
final data = child.parentData! as _ActionParentData;
|
||||||
|
final hit = result.addWithPaintOffset(
|
||||||
|
offset: data.offset,
|
||||||
|
position: position,
|
||||||
|
hitTest: (result, transformed) =>
|
||||||
|
child.hitTest(result, position: transformed),
|
||||||
|
);
|
||||||
|
if (hit) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void visitChildrenForSemantics(RenderObjectVisitor visitor) {
|
||||||
|
for (final child in _children) {
|
||||||
|
if (_shown(child)) visitor(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,23 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'pop_entrance.dart';
|
import 'pop_entrance.dart';
|
||||||
|
import 'segmented_action_row.dart';
|
||||||
import 'segmented_bar_entrance.dart';
|
import 'segmented_bar_entrance.dart';
|
||||||
|
import 'segmented_bar_overflow.dart';
|
||||||
import 'segmented_bar_motion.dart';
|
import 'segmented_bar_motion.dart';
|
||||||
import 'segmented_bar_pieces.dart';
|
import 'segmented_bar_pieces.dart';
|
||||||
|
|
||||||
|
export 'segmented_bar_overflow.dart'
|
||||||
|
show
|
||||||
|
SegmentedMenuChoice,
|
||||||
|
SegmentedOverflowAction,
|
||||||
|
SegmentedOverflowEntry,
|
||||||
|
SegmentedOverflowable,
|
||||||
|
segmentedMoreKey;
|
||||||
export 'segmented_bar_pieces.dart' show SegmentedBackButton, SegmentedPill;
|
export 'segmented_bar_pieces.dart' show SegmentedBackButton, SegmentedPill;
|
||||||
|
|
||||||
/// The app's top bar: separate frosted-glass pieces floating over the page's
|
/// The app's top bar: separate frosted-glass pieces floating over the page's
|
||||||
@@ -17,9 +27,11 @@ export 'segmented_bar_pieces.dart' show SegmentedBackButton, SegmentedPill;
|
|||||||
/// Back, implied as the stock bars do when [automaticallyImplyLeading]), a
|
/// Back, implied as the stock bars do when [automaticallyImplyLeading]), a
|
||||||
/// pill with the [title] and an optional one-line [subtitle] that runs
|
/// pill with the [title] and an optional one-line [subtitle] that runs
|
||||||
/// [onTitlePressed] when given, and a pill holding the [actions] at the
|
/// [onTitlePressed] when given, and a pill holding the [actions] at the
|
||||||
/// trailing edge. The actions take their natural width first and the title
|
/// trailing edge. The title keeps its own width (up to [maxTitleShare] of the
|
||||||
/// shrinks; only when the title is down to [minTitleShare] of the bar does
|
/// bar, and never under [minTitleShare]); the actions take their natural
|
||||||
/// the first action ellipsise.
|
/// width beside it, and those that do not fit move into one More menu
|
||||||
|
/// (when they are [SegmentedOverflowable]) rather than shrink below their
|
||||||
|
/// touch targets. Only actions that cannot move ellipsise the first of them.
|
||||||
///
|
///
|
||||||
/// A page whose bar is mainly an input (Search) passes [titleWidget] instead:
|
/// A page whose bar is mainly an input (Search) passes [titleWidget] instead:
|
||||||
/// it takes the title pill's place as one pill that fills the space beside
|
/// it takes the title pill's place as one pill that fills the space beside
|
||||||
@@ -123,9 +135,14 @@ class SegmentedBar extends StatefulWidget
|
|||||||
|
|
||||||
static const double _topPadding = 8;
|
static const double _topPadding = 8;
|
||||||
|
|
||||||
/// The share of the bar the title keeps before the actions shrink.
|
/// The share of the bar the title always keeps beside the actions.
|
||||||
static const double minTitleShare = 0.25;
|
static const double minTitleShare = 0.25;
|
||||||
|
|
||||||
|
/// The most of the bar the title's own width claims before the actions:
|
||||||
|
/// a short title (a destination's name) shows whole, a long one leaves
|
||||||
|
/// the actions room.
|
||||||
|
static const double maxTitleShare = 0.5;
|
||||||
|
|
||||||
/// Bar text grows with the reader's setting up to this factor, like the
|
/// Bar text grows with the reader's setting up to this factor, like the
|
||||||
/// stock app bar caps its title, so the bar never takes over the page.
|
/// stock app bar caps its title, so the bar never takes over the page.
|
||||||
static const double maxTextScale = 2;
|
static const double maxTextScale = 2;
|
||||||
@@ -262,42 +279,70 @@ class _SegmentedBarState extends State<SegmentedBar> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Which actions (by identity) a narrow bar moved into its More menu.
|
||||||
|
Set<Object> _overflowed = const {};
|
||||||
|
|
||||||
|
void _hidden(List<Object> ids, List<int> indexes) {
|
||||||
|
if (!mounted) return;
|
||||||
|
final next = {
|
||||||
|
for (final index in indexes)
|
||||||
|
if (index < ids.length) ids[index],
|
||||||
|
};
|
||||||
|
if (setEquals(next, _overflowed)) return;
|
||||||
|
setState(() => _overflowed = next);
|
||||||
|
}
|
||||||
|
|
||||||
/// The actions, each keyed by its identity ([segmentedActionIds]) so one
|
/// The actions, each keyed by its identity ([segmentedActionIds]) so one
|
||||||
/// arriving or leaving leaves the others be, each popping in on its own.
|
/// arriving or leaving leaves the others be, each popping in on its own,
|
||||||
/// Only the first shrinks (ellipsises); the rest keep their natural width
|
/// at its natural width. Those that do not fit leave for the trailing More
|
||||||
/// as inflexible (flex 0) children, up to an even share of [maxWidth] (the
|
/// button ([SegmentedActionRow]), so none is squeezed below its touch
|
||||||
/// pill's widest): a long control (a permission mode's name beside the
|
/// target; one moved there is out of the focus order too.
|
||||||
/// model) leaves room for the first, and icons in a narrow pane squeeze
|
Widget _actionRow(
|
||||||
/// together rather than overflow the pill.
|
|
||||||
List<Widget> _actionIslands(
|
|
||||||
List<Widget> actions,
|
List<Widget> actions,
|
||||||
List<Object> ids,
|
List<Object> ids,
|
||||||
List<SegmentedActionEntrance> entrances, {
|
List<SegmentedActionEntrance> entrances, {
|
||||||
required bool cupertino,
|
required bool cupertino,
|
||||||
required double maxWidth,
|
required double overflowWidth,
|
||||||
}) => [
|
}) {
|
||||||
for (final (index, action) in actions.indexed)
|
final entries = [
|
||||||
Flexible(
|
for (final (index, action) in actions.indexed)
|
||||||
key: ValueKey(ids[index]),
|
if (action is SegmentedOverflowable && _overflowed.contains(ids[index]))
|
||||||
flex: index == 0 ? 1 : 0,
|
(action as SegmentedOverflowable).overflowEntry,
|
||||||
child: ConstrainedBox(
|
];
|
||||||
constraints: BoxConstraints(
|
return SegmentedActionRow(
|
||||||
maxWidth: index == 0 ? double.infinity : maxWidth / actions.length,
|
overflowable: [
|
||||||
),
|
for (final action in actions) action is SegmentedOverflowable,
|
||||||
child: PopEntrance(
|
],
|
||||||
play: entrances[index].play,
|
overflowWidth: overflowWidth,
|
||||||
delay: entrances[index].delay,
|
onHidden: (indexes) => _hidden(ids, indexes),
|
||||||
glass: false,
|
more: ExcludeFocus(
|
||||||
child: SegmentedPress(
|
excluding: entries.isEmpty,
|
||||||
cupertino: cupertino,
|
child: SegmentedPress(
|
||||||
tint: widget.foregroundColor,
|
cupertino: cupertino,
|
||||||
enabled: actions.length > 1,
|
tint: widget.foregroundColor,
|
||||||
child: action,
|
child: SegmentedMoreButton(cupertino: cupertino, entries: entries),
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
];
|
actions: [
|
||||||
|
for (final (index, action) in actions.indexed)
|
||||||
|
ExcludeFocus(
|
||||||
|
key: ValueKey(ids[index]),
|
||||||
|
excluding: _overflowed.contains(ids[index]),
|
||||||
|
child: PopEntrance(
|
||||||
|
play: entrances[index].play,
|
||||||
|
delay: entrances[index].delay,
|
||||||
|
glass: false,
|
||||||
|
child: SegmentedPress(
|
||||||
|
cupertino: cupertino,
|
||||||
|
tint: widget.foregroundColor,
|
||||||
|
enabled: actions.length > 1,
|
||||||
|
child: action,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -349,15 +394,39 @@ class _SegmentedBarState extends State<SegmentedBar> {
|
|||||||
final Widget bar = LayoutBuilder(
|
final Widget bar = LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
// The actions keep to the trailing edge at their natural width, so
|
// The actions keep to the trailing edge at their natural width, so
|
||||||
// a model name shows whole while the title has room; only past the
|
// a model name shows whole while the title has room. The title keeps
|
||||||
// title's minimum share does the first action ellipsise.
|
// at least [SegmentedBar.minTitleShare] of the bar, and its own
|
||||||
|
// width (a destination's name) up to [SegmentedBar.maxTitleShare];
|
||||||
|
// actions that do not fit beside it move into the More menu.
|
||||||
|
final width = constraints.maxWidth;
|
||||||
|
final titleMinimum = titleWidget != null || !showTitle
|
||||||
|
? width * SegmentedBar.minTitleShare
|
||||||
|
: math.max(
|
||||||
|
width * SegmentedBar.minTitleShare,
|
||||||
|
math.min(
|
||||||
|
segmentedTitleWidth(
|
||||||
|
context,
|
||||||
|
cupertino: cupertino,
|
||||||
|
title: title,
|
||||||
|
subtitle: subtitle,
|
||||||
|
subtitleIcon: subtitleIcon,
|
||||||
|
foreground: foregroundColor,
|
||||||
|
),
|
||||||
|
width * SegmentedBar.maxTitleShare,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final besideTitle =
|
||||||
|
width -
|
||||||
|
(leading == null ? 0 : segmentedPieceHeight(cupertino) + 8) -
|
||||||
|
8;
|
||||||
|
// Actions that cannot move (a model picker) may take the room down
|
||||||
|
// to the title's minimum share; the rest leave for the More menu
|
||||||
|
// before the title goes under its own width.
|
||||||
final actionsMaxWidth = math.max(
|
final actionsMaxWidth = math.max(
|
||||||
0.0,
|
0.0,
|
||||||
constraints.maxWidth -
|
besideTitle - width * SegmentedBar.minTitleShare,
|
||||||
(leading == null ? 0 : segmentedPieceHeight(cupertino) + 8) -
|
|
||||||
8 -
|
|
||||||
constraints.maxWidth * SegmentedBar.minTitleShare,
|
|
||||||
);
|
);
|
||||||
|
final overflowWidth = math.max(0.0, besideTitle - titleMinimum);
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
if (leading != null) ...[
|
if (leading != null) ...[
|
||||||
@@ -411,15 +480,12 @@ class _SegmentedBarState extends State<SegmentedBar> {
|
|||||||
child: SegmentedPill(
|
child: SegmentedPill(
|
||||||
cupertino: cupertino,
|
cupertino: cupertino,
|
||||||
fill: pillColor,
|
fill: pillColor,
|
||||||
child: Row(
|
child: _actionRow(
|
||||||
mainAxisSize: MainAxisSize.min,
|
actions,
|
||||||
children: _actionIslands(
|
actionIds,
|
||||||
actions,
|
entrances.actions,
|
||||||
actionIds,
|
cupertino: cupertino,
|
||||||
entrances.actions,
|
overflowWidth: overflowWidth,
|
||||||
cupertino: cupertino,
|
|
||||||
maxWidth: actionsMaxWidth,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,24 +1,34 @@
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import '../motion/motion.dart';
|
import '../motion/motion.dart';
|
||||||
|
import 'segmented_bar_overflow.dart';
|
||||||
|
|
||||||
/// The identity of each of a bar's [actions]: its own key, or its type and
|
/// The identity of each of a bar's [actions]: its own key, or its type and
|
||||||
/// place among actions of that type, within [group] (whoever supplied the
|
/// place among actions of that type, within [group] (whoever supplied the
|
||||||
/// actions). An action keeps its identity, and so its entrance, while the
|
/// actions). An action keeps its identity, and so its entrance, while the
|
||||||
/// bar rebuilds; a new [group] makes every action new.
|
/// bar rebuilds; a new [group] makes every action new. A
|
||||||
|
/// [SegmentedOverflowAction] is known by the action it wraps.
|
||||||
List<Object> segmentedActionIds(List<Widget> actions, Object? group) {
|
List<Object> segmentedActionIds(List<Widget> actions, Object? group) {
|
||||||
final seen = <Type, int>{};
|
final seen = <Type, int>{};
|
||||||
return [
|
return [
|
||||||
for (final action in actions)
|
for (final action in actions)
|
||||||
(
|
if ((action is SegmentedOverflowAction && action.key == null
|
||||||
'segmented.action',
|
? action.child
|
||||||
group,
|
: action)
|
||||||
action.key ??
|
case final identity)
|
||||||
(
|
(
|
||||||
action.runtimeType,
|
'segmented.action',
|
||||||
seen.update(action.runtimeType, (n) => n + 1, ifAbsent: () => 0),
|
group,
|
||||||
),
|
identity.key ??
|
||||||
),
|
(
|
||||||
|
identity.runtimeType,
|
||||||
|
seen.update(
|
||||||
|
identity.runtimeType,
|
||||||
|
(n) => n + 1,
|
||||||
|
ifAbsent: () => 0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,175 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
/// The key of a [SegmentedBar]'s More button, shown when its actions do not
|
||||||
|
/// all fit.
|
||||||
|
const segmentedMoreKey = ValueKey<String>('segmented.more');
|
||||||
|
|
||||||
|
/// One choice under a [SegmentedOverflowEntry] (a sort order): a submenu on
|
||||||
|
/// Material, a second action sheet on Cupertino.
|
||||||
|
class SegmentedMenuChoice {
|
||||||
|
const SegmentedMenuChoice({
|
||||||
|
required this.label,
|
||||||
|
required this.onSelected,
|
||||||
|
this.selected = false,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String label;
|
||||||
|
final VoidCallback onSelected;
|
||||||
|
final bool selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// How a bar action reads in the bar's More menu once a narrow bar moves it
|
||||||
|
/// there: its label and icon, and what choosing it does.
|
||||||
|
class SegmentedOverflowEntry {
|
||||||
|
const SegmentedOverflowEntry({
|
||||||
|
required this.label,
|
||||||
|
required this.icon,
|
||||||
|
this.onPressed,
|
||||||
|
this.choices = const [],
|
||||||
|
});
|
||||||
|
|
||||||
|
final String label;
|
||||||
|
final IconData icon;
|
||||||
|
|
||||||
|
/// What choosing the entry does; null (with no [choices]) disables it.
|
||||||
|
final VoidCallback? onPressed;
|
||||||
|
|
||||||
|
/// Choices offered under the entry instead of [onPressed].
|
||||||
|
final List<SegmentedMenuChoice> choices;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A bar action the bar may move into its More menu. An action that is not
|
||||||
|
/// [SegmentedOverflowable] always stays in the bar.
|
||||||
|
abstract interface class SegmentedOverflowable {
|
||||||
|
SegmentedOverflowEntry get overflowEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Marks any bar action as [SegmentedOverflowable]: it draws [child] in the
|
||||||
|
/// bar and [overflowEntry] in the More menu.
|
||||||
|
class SegmentedOverflowAction extends StatelessWidget
|
||||||
|
implements SegmentedOverflowable {
|
||||||
|
const SegmentedOverflowAction({
|
||||||
|
super.key,
|
||||||
|
required this.overflowEntry,
|
||||||
|
required this.child,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
final SegmentedOverflowEntry overflowEntry;
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => child;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The bar's More button: the host's overflow icon at the platform's touch
|
||||||
|
/// target, opening a Material menu or a Cupertino action sheet of [entries].
|
||||||
|
class SegmentedMoreButton extends StatelessWidget {
|
||||||
|
const SegmentedMoreButton({
|
||||||
|
super.key,
|
||||||
|
required this.cupertino,
|
||||||
|
required this.entries,
|
||||||
|
});
|
||||||
|
|
||||||
|
final bool cupertino;
|
||||||
|
final List<SegmentedOverflowEntry> entries;
|
||||||
|
|
||||||
|
static const String label = 'More actions';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
if (cupertino) {
|
||||||
|
return Semantics(
|
||||||
|
button: true,
|
||||||
|
label: label,
|
||||||
|
excludeSemantics: true,
|
||||||
|
child: CupertinoButton(
|
||||||
|
key: segmentedMoreKey,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
|
||||||
|
onPressed: () => _showSheet(context),
|
||||||
|
child: const Icon(CupertinoIcons.ellipsis),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return MenuAnchor(
|
||||||
|
menuChildren: [
|
||||||
|
for (final entry in entries)
|
||||||
|
if (entry.choices.isEmpty)
|
||||||
|
MenuItemButton(
|
||||||
|
leadingIcon: Icon(entry.icon),
|
||||||
|
onPressed: entry.onPressed,
|
||||||
|
child: Text(entry.label),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
SubmenuButton(
|
||||||
|
leadingIcon: Icon(entry.icon),
|
||||||
|
menuChildren: [
|
||||||
|
for (final choice in entry.choices)
|
||||||
|
MenuItemButton(
|
||||||
|
leadingIcon: Icon(
|
||||||
|
Icons.check,
|
||||||
|
color: choice.selected ? null : Colors.transparent,
|
||||||
|
),
|
||||||
|
onPressed: choice.onSelected,
|
||||||
|
child: Semantics(
|
||||||
|
selected: choice.selected,
|
||||||
|
child: Text(choice.label),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
child: Text(entry.label),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
builder: (context, menu, _) => IconButton(
|
||||||
|
key: segmentedMoreKey,
|
||||||
|
tooltip: label,
|
||||||
|
onPressed: () => menu.isOpen ? menu.close() : menu.open(),
|
||||||
|
icon: const Icon(Icons.more_vert),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _showSheet(BuildContext context) async {
|
||||||
|
final picked = await _sheet<SegmentedOverflowEntry>(context, [
|
||||||
|
for (final entry in entries)
|
||||||
|
if (entry.onPressed != null || entry.choices.isNotEmpty)
|
||||||
|
(entry.label, false, entry),
|
||||||
|
]);
|
||||||
|
if (picked == null || !context.mounted) return;
|
||||||
|
if (picked.choices.isEmpty) {
|
||||||
|
picked.onPressed?.call();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final choice = await _sheet<SegmentedMenuChoice>(context, [
|
||||||
|
for (final choice in picked.choices)
|
||||||
|
(choice.label, choice.selected, choice),
|
||||||
|
], title: picked.label);
|
||||||
|
choice?.onSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<T?> _sheet<T>(
|
||||||
|
BuildContext context,
|
||||||
|
List<(String, bool, T)> items, {
|
||||||
|
String? title,
|
||||||
|
}) => showCupertinoModalPopup<T>(
|
||||||
|
context: context,
|
||||||
|
builder: (sheet) => CupertinoActionSheet(
|
||||||
|
title: title == null ? null : Text(title),
|
||||||
|
actions: [
|
||||||
|
for (final (label, selected, value) in items)
|
||||||
|
CupertinoActionSheetAction(
|
||||||
|
// The current choice is the sheet's default (bold) action.
|
||||||
|
isDefaultAction: selected,
|
||||||
|
onPressed: () => Navigator.of(sheet).pop(value),
|
||||||
|
child: Semantics(selected: selected, child: Text(label)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
cancelButton: CupertinoActionSheetAction(
|
||||||
|
onPressed: () => Navigator.of(sheet).pop(),
|
||||||
|
child: const Text('Cancel'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -83,6 +83,81 @@ Widget? impliedSegmentedLeading(BuildContext context, bool cupertino) {
|
|||||||
return dialog ? const CloseButton() : const BackButton();
|
return dialog ? const CloseButton() : const BackButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The title pill's title and subtitle styles, from the host's type scale.
|
||||||
|
(TextStyle, TextStyle) segmentedTitleStyles(
|
||||||
|
BuildContext context, {
|
||||||
|
required bool cupertino,
|
||||||
|
Color? foreground,
|
||||||
|
}) {
|
||||||
|
if (cupertino) {
|
||||||
|
final text = CupertinoTheme.of(context).textTheme;
|
||||||
|
return (
|
||||||
|
text.textStyle.copyWith(fontWeight: FontWeight.w600, color: foreground),
|
||||||
|
text.textStyle.copyWith(
|
||||||
|
fontSize: 13,
|
||||||
|
color:
|
||||||
|
foreground ?? CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
return (
|
||||||
|
(theme.textTheme.titleSmall ?? const TextStyle()).copyWith(
|
||||||
|
color: foreground ?? theme.colorScheme.onSurface,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
(theme.textTheme.labelSmall ?? const TextStyle()).copyWith(
|
||||||
|
color: foreground ?? theme.colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The title pill's horizontal padding on each side.
|
||||||
|
const double segmentedTitlePadding = 16;
|
||||||
|
|
||||||
|
/// The width the title pill needs to show [title] and [subtitle] whole (at
|
||||||
|
/// the text scale at [context]).
|
||||||
|
double segmentedTitleWidth(
|
||||||
|
BuildContext context, {
|
||||||
|
required bool cupertino,
|
||||||
|
required String title,
|
||||||
|
String? subtitle,
|
||||||
|
IconData? subtitleIcon,
|
||||||
|
Color? foreground,
|
||||||
|
}) {
|
||||||
|
final (titleStyle, subtitleStyle) = segmentedTitleStyles(
|
||||||
|
context,
|
||||||
|
cupertino: cupertino,
|
||||||
|
foreground: foreground,
|
||||||
|
);
|
||||||
|
final scaler = MediaQuery.textScalerOf(context);
|
||||||
|
final direction = Directionality.of(context);
|
||||||
|
double measure(String text, TextStyle style) {
|
||||||
|
if (text.isEmpty) return 0;
|
||||||
|
final painter = TextPainter(
|
||||||
|
text: TextSpan(text: text, style: style),
|
||||||
|
textDirection: direction,
|
||||||
|
textScaler: scaler,
|
||||||
|
maxLines: 1,
|
||||||
|
)..layout();
|
||||||
|
final width = painter.width;
|
||||||
|
painter.dispose();
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
final sub = subtitle ?? '';
|
||||||
|
final subWidth = sub.isEmpty
|
||||||
|
? 0.0
|
||||||
|
: measure(sub, subtitleStyle) +
|
||||||
|
(subtitleIcon == null
|
||||||
|
? 0
|
||||||
|
: scaler.scale(subtitleStyle.fontSize ?? 12) +
|
||||||
|
measure(' ', subtitleStyle));
|
||||||
|
final text = measure(title, titleStyle);
|
||||||
|
return (text > subWidth ? text : subWidth).ceilToDouble() +
|
||||||
|
segmentedTitlePadding * 2;
|
||||||
|
}
|
||||||
|
|
||||||
/// The title, with an optional one-line subtitle, in one pill; pressing it
|
/// The title, with an optional one-line subtitle, in one pill; pressing it
|
||||||
/// runs [onPressed] when given.
|
/// runs [onPressed] when given.
|
||||||
class SegmentedTitlePill extends StatelessWidget {
|
class SegmentedTitlePill extends StatelessWidget {
|
||||||
@@ -117,31 +192,17 @@ class SegmentedTitlePill extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final TextStyle titleStyle;
|
final (titleStyle, subtitleStyle) = segmentedTitleStyles(
|
||||||
final TextStyle subtitleStyle;
|
context,
|
||||||
if (cupertino) {
|
cupertino: cupertino,
|
||||||
final text = CupertinoTheme.of(context).textTheme;
|
foreground: foreground,
|
||||||
titleStyle = text.textStyle.copyWith(
|
);
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: foreground,
|
|
||||||
);
|
|
||||||
subtitleStyle = text.textStyle.copyWith(
|
|
||||||
fontSize: 13,
|
|
||||||
color:
|
|
||||||
foreground ?? CupertinoColors.secondaryLabel.resolveFrom(context),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
final theme = Theme.of(context);
|
|
||||||
titleStyle = (theme.textTheme.titleSmall ?? const TextStyle()).copyWith(
|
|
||||||
color: foreground ?? theme.colorScheme.onSurface,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
);
|
|
||||||
subtitleStyle = (theme.textTheme.labelSmall ?? const TextStyle())
|
|
||||||
.copyWith(color: foreground ?? theme.colorScheme.onSurfaceVariant);
|
|
||||||
}
|
|
||||||
final subtitle = this.subtitle ?? '';
|
final subtitle = this.subtitle ?? '';
|
||||||
final content = Padding(
|
final content = Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: segmentedTitlePadding,
|
||||||
|
vertical: 4,
|
||||||
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
|||||||
@@ -5,13 +5,20 @@ import '../adaptive/host.dart';
|
|||||||
import 'app_list_avatar.dart';
|
import 'app_list_avatar.dart';
|
||||||
|
|
||||||
/// Below this row width (a list pane squeezed beside its detail) a row is
|
/// Below this row width (a list pane squeezed beside its detail) a row is
|
||||||
/// compact: no avatar, no time and (by default) no menu, so the title keeps
|
/// compact: it keeps its avatar (a run's status) and its menu, so no row
|
||||||
/// the width and a tap on the row never lands on a second control.
|
/// loses its state or its actions, and moves the time under the subtitle,
|
||||||
|
/// leaving the title the line's width.
|
||||||
const double kAppListRowCompactWidth = 280;
|
const double kAppListRowCompactWidth = 280;
|
||||||
|
|
||||||
|
/// Below this row width (narrower than any list pane, as in a row squeezed
|
||||||
|
/// by its host) the avatar and the menu would leave the text no room, so the
|
||||||
|
/// row drops them rather than overflow.
|
||||||
|
const double kAppListRowMinimalWidth = 160;
|
||||||
|
|
||||||
/// The rows' horizontal inset and the gap after the avatar.
|
/// The rows' horizontal inset and the gap after the avatar.
|
||||||
const double kAppListRowInset = 16;
|
const double kAppListRowInset = 16;
|
||||||
const double _avatarGap = 12;
|
const double _avatarGap = 12;
|
||||||
|
const double _compactAvatarGap = 8;
|
||||||
|
|
||||||
/// Keys on a row's highlight surface and inset divider, for tests.
|
/// Keys on a row's highlight surface and inset divider, for tests.
|
||||||
const appListRowSurfaceKey = ValueKey<String>('app-list-row-surface');
|
const appListRowSurfaceKey = ValueKey<String>('app-list-row-surface');
|
||||||
@@ -29,8 +36,9 @@ bool _darkSurface(BuildContext context, bool cupertino) => cupertino
|
|||||||
/// the [time] at its trailing edge, then one muted [subtitle] line (with an
|
/// the [time] at its trailing edge, then one muted [subtitle] line (with an
|
||||||
/// optional [subtitleLeading] dot/prefix and [subtitleTrailing] mark), then
|
/// optional [subtitleLeading] dot/prefix and [subtitleTrailing] mark), then
|
||||||
/// the optional [menu] (an `AppOverflowMenu`). A row in a multi-select list
|
/// the optional [menu] (an `AppOverflowMenu`). A row in a multi-select list
|
||||||
/// puts its checkbox in [selectionControl], which leads the row even when it
|
/// puts its checkbox in [selectionControl], which leads the row. A compact
|
||||||
/// is compact. An inset hairline [divider]
|
/// row (narrower than [compactWidth]) keeps all of these and shows the time
|
||||||
|
/// on a line of its own under the subtitle. An inset hairline [divider]
|
||||||
/// under the text column separates rows. Nothing has a fixed height: the row
|
/// under the text column separates rows. Nothing has a fixed height: the row
|
||||||
/// grows with text scaling and every line ellipsises.
|
/// grows with text scaling and every line ellipsises.
|
||||||
///
|
///
|
||||||
@@ -57,7 +65,6 @@ class AppListRow extends StatelessWidget {
|
|||||||
this.selected = false,
|
this.selected = false,
|
||||||
this.emphasized = false,
|
this.emphasized = false,
|
||||||
this.divider = true,
|
this.divider = true,
|
||||||
this.keepMenuWhenCompact = false,
|
|
||||||
this.compactWidth = kAppListRowCompactWidth,
|
this.compactWidth = kAppListRowCompactWidth,
|
||||||
this.cupertino,
|
this.cupertino,
|
||||||
this.accent,
|
this.accent,
|
||||||
@@ -84,7 +91,7 @@ class AppListRow extends StatelessWidget {
|
|||||||
/// A touch long-press on the row (for example, entering a select mode).
|
/// A touch long-press on the row (for example, entering a select mode).
|
||||||
final VoidCallback? onLongPress;
|
final VoidCallback? onLongPress;
|
||||||
|
|
||||||
/// A checkbox leading the row in a multi-select list; kept when compact.
|
/// A checkbox leading the row in a multi-select list.
|
||||||
final Widget? selectionControl;
|
final Widget? selectionControl;
|
||||||
|
|
||||||
/// Placed on the tap target ([InkWell] / [GestureDetector]).
|
/// Placed on the tap target ([InkWell] / [GestureDetector]).
|
||||||
@@ -92,10 +99,6 @@ class AppListRow extends StatelessWidget {
|
|||||||
final bool selected;
|
final bool selected;
|
||||||
final bool emphasized;
|
final bool emphasized;
|
||||||
final bool divider;
|
final bool divider;
|
||||||
|
|
||||||
/// Keeps the menu in a compact row when the list has no other way to reach
|
|
||||||
/// the row's actions.
|
|
||||||
final bool keepMenuWhenCompact;
|
|
||||||
final double compactWidth;
|
final double compactWidth;
|
||||||
|
|
||||||
/// Overrides the host detection (some features pick a style per platform).
|
/// Overrides the host detection (some features pick a style per platform).
|
||||||
@@ -123,9 +126,11 @@ class AppListRow extends StatelessWidget {
|
|||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
final compact = constraints.maxWidth < compactWidth;
|
final compact = constraints.maxWidth < compactWidth;
|
||||||
final showLeading = leading != null && !compact;
|
final minimal = constraints.maxWidth < kAppListRowMinimalWidth;
|
||||||
final showMenu = menu != null && (!compact || keepMenuWhenCompact);
|
final showLeading = leading != null && !minimal;
|
||||||
|
final showMenu = menu != null && !minimal;
|
||||||
final start = compact ? 12.0 : kAppListRowInset;
|
final start = compact ? 12.0 : kAppListRowInset;
|
||||||
|
final avatarGap = compact ? _compactAvatarGap : _avatarGap;
|
||||||
final content = Padding(
|
final content = Padding(
|
||||||
padding: EdgeInsetsDirectional.only(
|
padding: EdgeInsetsDirectional.only(
|
||||||
start: start,
|
start: start,
|
||||||
@@ -142,7 +147,7 @@ class AppListRow extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
if (showLeading)
|
if (showLeading)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsetsDirectional.only(end: _avatarGap),
|
padding: EdgeInsetsDirectional.only(end: avatarGap),
|
||||||
child: leading,
|
child: leading,
|
||||||
),
|
),
|
||||||
Expanded(child: _text(styles, compact)),
|
Expanded(child: _text(styles, compact)),
|
||||||
@@ -198,7 +203,7 @@ class AppListRow extends StatelessWidget {
|
|||||||
// not known here, so a selectable row's divider starts at the inset.
|
// not known here, so a selectable row's divider starts at the inset.
|
||||||
final textStart = selectionControl != null
|
final textStart = selectionControl != null
|
||||||
? start
|
? start
|
||||||
: start + (showLeading ? kAppListAvatarSize + _avatarGap : 0);
|
: start + (showLeading ? kAppListAvatarSize + avatarGap : 0);
|
||||||
final line = Padding(
|
final line = Padding(
|
||||||
padding: EdgeInsetsDirectional.only(start: textStart),
|
padding: EdgeInsetsDirectional.only(start: textStart),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
@@ -227,8 +232,27 @@ class AppListRow extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The time, one ellipsised line in the time style, or null without one.
|
||||||
|
Widget? _time(_RowStyles styles) {
|
||||||
|
if (timeWidget == null && (time == null || time!.isEmpty)) return null;
|
||||||
|
return timeWidget == null
|
||||||
|
? Text(
|
||||||
|
time!,
|
||||||
|
style: styles.time,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
)
|
||||||
|
: DefaultTextStyle(
|
||||||
|
style: styles.time,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
child: timeWidget!,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _text(_RowStyles styles, bool compact) {
|
Widget _text(_RowStyles styles, bool compact) {
|
||||||
final line = compact ? (compactSubtitle ?? subtitle) : subtitle;
|
final line = compact ? (compactSubtitle ?? subtitle) : subtitle;
|
||||||
|
final time = _time(styles);
|
||||||
final titleLine = LayoutBuilder(
|
final titleLine = LayoutBuilder(
|
||||||
// The time keeps at most 40% of the line, so very large text in a
|
// The time keeps at most 40% of the line, so very large text in a
|
||||||
// narrow row ellipsises instead of overflowing.
|
// narrow row ellipsises instead of overflowing.
|
||||||
@@ -242,32 +266,27 @@ class AppListRow extends StatelessWidget {
|
|||||||
child: title,
|
child: title,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!compact &&
|
if (!compact && time != null)
|
||||||
(timeWidget != null || (time != null && time!.isNotEmpty)))
|
|
||||||
ConstrainedBox(
|
ConstrainedBox(
|
||||||
constraints: BoxConstraints(maxWidth: constraints.maxWidth * 0.4),
|
constraints: BoxConstraints(maxWidth: constraints.maxWidth * 0.4),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsetsDirectional.only(start: 8),
|
padding: const EdgeInsetsDirectional.only(start: 8),
|
||||||
child: timeWidget == null
|
child: time,
|
||||||
? Text(
|
|
||||||
time!,
|
|
||||||
style: styles.time,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
)
|
|
||||||
: DefaultTextStyle(
|
|
||||||
style: styles.time,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
child: timeWidget!,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
// A compact row has no room beside its title: the time takes a line of
|
||||||
|
// its own under the subtitle.
|
||||||
|
final timeLine = compact ? time : null;
|
||||||
if (line == null && subtitleLeading == null && subtitleTrailing == null) {
|
if (line == null && subtitleLeading == null && subtitleTrailing == null) {
|
||||||
return titleLine;
|
if (timeLine == null) return titleLine;
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [titleLine, const SizedBox(height: 2), timeLine],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@@ -297,6 +316,7 @@ class AppListRow extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
?timeLine,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,9 +26,11 @@ component, on both hosts.
|
|||||||
Cupertino uses `separator` at 1 physical pixel; Material uses
|
Cupertino uses `separator` at 1 physical pixel; Material uses
|
||||||
`outlineVariant` at 1. Lists turn it off for the last row of a group.
|
`outlineVariant` at 1. Lists turn it off for the last row of a group.
|
||||||
- Compact mode: when the row is narrower than `kAppListRowCompactWidth`
|
- Compact mode: when the row is narrower than `kAppListRowCompactWidth`
|
||||||
(280), it drops the avatar, the time and the menu, and shows
|
(280), it keeps the avatar (a run's status) and the menu, moves the time
|
||||||
`compactSubtitle` if one is given. `keepMenuWhenCompact` keeps the menu
|
to its own line under the subtitle and shows `compactSubtitle` if one is
|
||||||
(chat, pipeline schedules).
|
given. Only below `kAppListRowMinimalWidth` (160, narrower than any list
|
||||||
|
pane) does it drop the avatar and menu so the text never overflows.
|
||||||
|
(`keepMenuWhenCompact` is gone: every row keeps its menu.)
|
||||||
- No fixed heights. Padding is 16 horizontal and 10 vertical. At 2x text in
|
- No fixed heights. Padding is 16 horizontal and 10 vertical. At 2x text in
|
||||||
a 320px row everything ellipsises without overflowing.
|
a 320px row everything ellipsises without overflowing.
|
||||||
- Test keys: `appListRowSurfaceKey` and `appListRowDividerKey`.
|
- Test keys: `appListRowSurfaceKey` and `appListRowDividerKey`.
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'package:pipelines_app/features/settings/settings_screen.dart';
|
|||||||
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
import '../bar_action.dart';
|
||||||
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
||||||
import '../features/pipelines/fixtures.dart';
|
import '../features/pipelines/fixtures.dart';
|
||||||
import 'pipelines_app_test.dart' show webServer;
|
import 'pipelines_app_test.dart' show webServer;
|
||||||
@@ -77,7 +78,11 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
|
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
|
||||||
|
|
||||||
await tester.tap(find.byKey(const Key('pipelines-open-settings')));
|
await tapBarAction(
|
||||||
|
tester,
|
||||||
|
find.byKey(const Key('pipelines-open-settings')),
|
||||||
|
'Settings',
|
||||||
|
);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(provider.value.uri.path, '/settings');
|
expect(provider.value.uri.path, '/settings');
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'package:pipelines_app/application/pipelines_app.dart';
|
|||||||
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
import '../bar_action.dart';
|
||||||
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
||||||
import '../features/pipelines/fixtures.dart';
|
import '../features/pipelines/fixtures.dart';
|
||||||
import 'pipelines_app_test.dart' show webServer, requestOf;
|
import 'pipelines_app_test.dart' show webServer, requestOf;
|
||||||
@@ -51,7 +52,11 @@ void main() {
|
|||||||
);
|
);
|
||||||
await replyPipelines(tester, channel, PipelineFixture());
|
await replyPipelines(tester, channel, PipelineFixture());
|
||||||
|
|
||||||
await tester.tap(find.byKey(const Key('pipelines-open-settings')));
|
await tapBarAction(
|
||||||
|
tester,
|
||||||
|
find.byKey(const Key('pipelines-open-settings')),
|
||||||
|
'Settings',
|
||||||
|
);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(provider.value.uri.path, '/settings');
|
expect(provider.value.uri.path, '/settings');
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||||
|
|
||||||
|
/// Taps a top-bar action: in the bar while it fits, or through the bar's
|
||||||
|
/// More menu (by its [label]) when a narrow bar moved it there.
|
||||||
|
Future<void> tapBarAction(
|
||||||
|
WidgetTester tester,
|
||||||
|
Finder action,
|
||||||
|
String label,
|
||||||
|
) async {
|
||||||
|
if (action.hitTestable().evaluate().isNotEmpty) {
|
||||||
|
await tester.tap(action);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.text(label).last);
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ import 'package:pipelines_app/core/api_gateway.dart';
|
|||||||
import 'package:pipelines_app/features/runs/domain/run_models.dart';
|
import 'package:pipelines_app/features/runs/domain/run_models.dart';
|
||||||
import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
|
import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
|
||||||
import 'package:pipelines_app/features/runs/ui/runs_list.dart';
|
import 'package:pipelines_app/features/runs/ui/runs_list.dart';
|
||||||
|
import 'package:pipelines_app/ui/status/run_status_icon.dart';
|
||||||
|
import 'package:pipelines_app/ui/text/relative_time_label.dart';
|
||||||
|
|
||||||
final _finished = {
|
final _finished = {
|
||||||
'id': 42,
|
'id': 42,
|
||||||
@@ -108,29 +110,39 @@ void main() {
|
|||||||
expect(find.byKey(runMoreMenuKey), findsNothing);
|
expect(find.byKey(runMoreMenuKey), findsNothing);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('compact rows keep a title and one metadata line', (
|
for (final status in ['succeeded', 'failed']) {
|
||||||
tester,
|
testWidgets('a compact $status row keeps its status, menu and time', (
|
||||||
) async {
|
tester,
|
||||||
tester.view.physicalSize = const Size(240, 400);
|
) async {
|
||||||
tester.view.devicePixelRatio = 1;
|
tester.view.physicalSize = const Size(240, 400);
|
||||||
addTearDown(tester.view.reset);
|
tester.view.devicePixelRatio = 1;
|
||||||
await tester.pumpWidget(
|
addTearDown(tester.view.reset);
|
||||||
MaterialApp(
|
await tester.pumpWidget(
|
||||||
home: Scaffold(
|
MaterialApp(
|
||||||
body: RunListRow(
|
home: Scaffold(
|
||||||
run: _finished,
|
body: RunListRow(
|
||||||
now: DateTime.utc(2026, 10, 22),
|
run: {..._finished, 'status': status},
|
||||||
gateway: _FakeGateway(),
|
now: DateTime.utc(2026, 10, 22),
|
||||||
onRunChanged: (_) {},
|
gateway: _FakeGateway(),
|
||||||
|
onRunChanged: (_) {},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
|
||||||
|
|
||||||
expect(find.text('Ship the release notes'), findsOneWidget);
|
expect(find.text('Ship the release notes'), findsOneWidget);
|
||||||
expect(find.text('release'), findsOneWidget);
|
expect(find.text('release'), findsOneWidget);
|
||||||
expect(find.text('2m 5s'), findsNothing);
|
expect(find.text('2m 5s'), findsNothing);
|
||||||
expect(find.byKey(const ValueKey('run-list-more-menu-42')), findsNothing);
|
// The status tells a failed run from a succeeded one at any width.
|
||||||
expect(tester.takeException(), isNull);
|
final icon = find.byType(RunStatusIcon);
|
||||||
});
|
expect(icon, findsOneWidget);
|
||||||
|
expect(tester.widget<RunStatusIcon>(icon).state, status);
|
||||||
|
final menu = find.byKey(const ValueKey('run-list-more-menu-42'));
|
||||||
|
expect(menu, findsOneWidget);
|
||||||
|
expect(tester.getRect(menu).right, lessThanOrEqualTo(240));
|
||||||
|
expect(tester.getSize(menu).width, greaterThanOrEqualTo(44));
|
||||||
|
expect(find.byType(RelativeTimeLabel), findsOneWidget);
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,247 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||||
|
|
||||||
|
void _size(WidgetTester tester, double width) {
|
||||||
|
tester.view.physicalSize = Size(width, 700);
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
|
addTearDown(tester.view.reset);
|
||||||
|
}
|
||||||
|
|
||||||
|
const _names = ['Needs you', 'Usage', 'Filter', 'Sort', 'Select'];
|
||||||
|
|
||||||
|
Key _key(String name) => ValueKey('action.$name');
|
||||||
|
|
||||||
|
/// An icon action like the list bars' own, at the host's touch target.
|
||||||
|
Widget _icon(bool cupertino, String name, VoidCallback onPressed) => cupertino
|
||||||
|
? Semantics(
|
||||||
|
button: true,
|
||||||
|
label: name,
|
||||||
|
excludeSemantics: true,
|
||||||
|
child: CupertinoButton(
|
||||||
|
key: _key(name),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
|
||||||
|
onPressed: onPressed,
|
||||||
|
child: const Icon(CupertinoIcons.circle),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: IconButton(
|
||||||
|
key: _key(name),
|
||||||
|
tooltip: name,
|
||||||
|
onPressed: onPressed,
|
||||||
|
icon: const Icon(Icons.circle_outlined),
|
||||||
|
);
|
||||||
|
|
||||||
|
/// The Runs bar's shape: a bell that always stays, then four that may move.
|
||||||
|
List<Widget> _actions(bool cupertino, List<String> pressed) => [
|
||||||
|
for (final name in _names)
|
||||||
|
if (name == 'Needs you')
|
||||||
|
_icon(cupertino, name, () => pressed.add(name))
|
||||||
|
else
|
||||||
|
SegmentedOverflowAction(
|
||||||
|
overflowEntry: SegmentedOverflowEntry(
|
||||||
|
label: name,
|
||||||
|
icon: Icons.circle_outlined,
|
||||||
|
onPressed: () => pressed.add(name),
|
||||||
|
),
|
||||||
|
child: _icon(cupertino, name, () => pressed.add(name)),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
Widget _app(bool cupertino, SegmentedBar bar, {Brightness? brightness}) =>
|
||||||
|
cupertino
|
||||||
|
? CupertinoApp(
|
||||||
|
theme: CupertinoThemeData(brightness: brightness),
|
||||||
|
home: CupertinoPageScaffold(
|
||||||
|
navigationBar: bar,
|
||||||
|
child: const SizedBox.expand(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: MaterialApp(
|
||||||
|
theme: ThemeData(brightness: brightness ?? Brightness.light),
|
||||||
|
home: Scaffold(
|
||||||
|
extendBodyBehindAppBar: true,
|
||||||
|
appBar: bar,
|
||||||
|
body: const SizedBox.expand(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Pumps the bar and the frame its More menu settles in.
|
||||||
|
Future<void> _pump(WidgetTester tester, Widget app) async {
|
||||||
|
await tester.pumpWidget(app);
|
||||||
|
await tester.pump();
|
||||||
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _whole(WidgetTester tester, String text) {
|
||||||
|
final paragraph = tester.renderObject<RenderParagraph>(find.text(text));
|
||||||
|
final natural = (TextPainter(
|
||||||
|
text: TextSpan(text: text, style: paragraph.text.style),
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
textScaler: paragraph.textScaler,
|
||||||
|
)..layout()).width;
|
||||||
|
return !paragraph.didExceedMaxLines && paragraph.size.width >= natural - 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
for (final cupertino in [false, true]) {
|
||||||
|
final host = cupertino ? 'Cupertino' : 'Material';
|
||||||
|
for (final width in [240.0, 270.0, 320.0]) {
|
||||||
|
for (final brightness in Brightness.values) {
|
||||||
|
testWidgets('$host ${brightness.name} ${width.toInt()}px: the title '
|
||||||
|
'shows whole, actions keep their targets, the rest are in More', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
_size(tester, width);
|
||||||
|
final pressed = <String>[];
|
||||||
|
await _pump(
|
||||||
|
tester,
|
||||||
|
_app(
|
||||||
|
cupertino,
|
||||||
|
brightness: brightness,
|
||||||
|
SegmentedBar(
|
||||||
|
cupertino: cupertino,
|
||||||
|
title: 'Runs',
|
||||||
|
actions: _actions(cupertino, pressed),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
expect(_whole(tester, 'Runs'), isTrue);
|
||||||
|
final title = tester.getRect(find.text('Runs'));
|
||||||
|
final shown = [
|
||||||
|
for (final name in _names)
|
||||||
|
if (find.byKey(_key(name)).hitTestable().evaluate().isNotEmpty)
|
||||||
|
name,
|
||||||
|
];
|
||||||
|
// The bell cannot move; at these widths the others do not all fit.
|
||||||
|
expect(shown, contains('Needs you'));
|
||||||
|
expect(shown.length, lessThan(_names.length));
|
||||||
|
final more = find.byKey(segmentedMoreKey).hitTestable();
|
||||||
|
expect(more, findsOneWidget);
|
||||||
|
final rects = [
|
||||||
|
for (final name in shown) tester.getRect(find.byKey(_key(name))),
|
||||||
|
tester.getRect(more),
|
||||||
|
];
|
||||||
|
final target = cupertino ? 44.0 : 48.0;
|
||||||
|
for (final (index, rect) in rects.indexed) {
|
||||||
|
expect(rect.width, greaterThanOrEqualTo(target));
|
||||||
|
expect(rect.height, greaterThanOrEqualTo(target));
|
||||||
|
// Clear of the title and inside the bar's edge padding.
|
||||||
|
expect(rect.left, greaterThan(title.right));
|
||||||
|
expect(rect.right, lessThanOrEqualTo(width - 12));
|
||||||
|
if (index > 0) {
|
||||||
|
expect(rect.left, greaterThanOrEqualTo(rects[index - 1].right));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Each moved action is in the More menu and runs from there.
|
||||||
|
await tester.tap(more);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
final moved = [
|
||||||
|
for (final name in _names)
|
||||||
|
if (!shown.contains(name)) name,
|
||||||
|
];
|
||||||
|
for (final name in moved) {
|
||||||
|
expect(find.text(name), findsOneWidget, reason: name);
|
||||||
|
}
|
||||||
|
await tester.tap(find.text(moved.last));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(pressed, [moved.last]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
testWidgets('$host: a wide bar shows every action and no More', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
_size(tester, 800);
|
||||||
|
await _pump(
|
||||||
|
tester,
|
||||||
|
_app(
|
||||||
|
cupertino,
|
||||||
|
SegmentedBar(
|
||||||
|
cupertino: cupertino,
|
||||||
|
title: 'Runs',
|
||||||
|
actions: _actions(cupertino, []),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
for (final name in _names) {
|
||||||
|
expect(find.byKey(_key(name)).hitTestable(), findsOneWidget);
|
||||||
|
}
|
||||||
|
expect(find.byKey(segmentedMoreKey).hitTestable(), findsNothing);
|
||||||
|
// A hidden More is out of the semantics tree too.
|
||||||
|
expect(find.bySemanticsLabel('More actions'), findsNothing);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('$host: a longer title keeps a readable share at 240px', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
_size(tester, 240);
|
||||||
|
await _pump(
|
||||||
|
tester,
|
||||||
|
_app(
|
||||||
|
cupertino,
|
||||||
|
SegmentedBar(
|
||||||
|
cupertino: cupertino,
|
||||||
|
title: 'Pipelines',
|
||||||
|
actions: _actions(cupertino, []),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
// The test font's glyphs are squares, wider than a real font's, so
|
||||||
|
// the name may ellipsise here, but never to nothing.
|
||||||
|
final paragraph = tester.renderObject<RenderParagraph>(
|
||||||
|
find.text('Pipelines'),
|
||||||
|
);
|
||||||
|
expect(paragraph.size.width, greaterThan(3 * 14));
|
||||||
|
expect(find.byKey(segmentedMoreKey).hitTestable(), findsOneWidget);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('$host: a choice entry offers its choices from More', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
_size(tester, 240);
|
||||||
|
String? picked;
|
||||||
|
await _pump(
|
||||||
|
tester,
|
||||||
|
_app(
|
||||||
|
cupertino,
|
||||||
|
SegmentedBar(
|
||||||
|
cupertino: cupertino,
|
||||||
|
title: 'Runs',
|
||||||
|
actions: [
|
||||||
|
for (final name in ['A', 'B', 'C'])
|
||||||
|
SegmentedOverflowAction(
|
||||||
|
overflowEntry: SegmentedOverflowEntry(
|
||||||
|
label: 'Sort $name',
|
||||||
|
icon: Icons.sort,
|
||||||
|
choices: [
|
||||||
|
for (final order in ['Newest', 'Oldest'])
|
||||||
|
SegmentedMenuChoice(
|
||||||
|
label: order,
|
||||||
|
selected: order == 'Newest',
|
||||||
|
onSelected: () => picked = '$name $order',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: _icon(cupertino, name, () {}),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await tester.tap(find.byKey(segmentedMoreKey));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.text('Sort C'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.text('Oldest'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(picked, 'C Oldest');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -182,37 +182,40 @@ void main() {
|
|||||||
expect(_paint(tester, '9d ago').color, isNot(accent));
|
expect(_paint(tester, '9d ago').color, isNot(accent));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('$host: a narrow pane drops the avatar, time and menu', (
|
for (final width in [240.0, 270.0]) {
|
||||||
tester,
|
for (final brightness in Brightness.values) {
|
||||||
) async {
|
testWidgets('$host ${brightness.name}: a ${width.toInt()}px pane keeps '
|
||||||
_size(tester, 240);
|
'the status avatar and the menu, and the time under the subtitle', (
|
||||||
await tester.pumpWidget(_host(cupertino, _row()));
|
tester,
|
||||||
expect(find.byKey(const Key('avatar')), findsNothing);
|
) async {
|
||||||
expect(find.text('9d ago'), findsNothing);
|
_size(tester, width);
|
||||||
expect(find.byKey(const Key('menu')), findsNothing);
|
await tester.pumpWidget(
|
||||||
expect(find.text('Running'), findsOneWidget);
|
_host(cupertino, brightness: brightness, _row(title: _longTitle)),
|
||||||
expect(find.text('pipeline · 2 stages'), findsNothing);
|
);
|
||||||
expect(tester.takeException(), isNull);
|
final row = tester.getRect(find.byKey(const Key('row')));
|
||||||
});
|
final avatar = tester.getRect(find.byKey(const Key('avatar')));
|
||||||
|
final menu = tester.getRect(find.byKey(const Key('menu')));
|
||||||
testWidgets('$host: keepMenuWhenCompact keeps the menu', (tester) async {
|
// Both inside the row, at the leading and trailing edges.
|
||||||
_size(tester, 240);
|
expect(avatar.left, greaterThanOrEqualTo(row.left));
|
||||||
await tester.pumpWidget(
|
expect(menu.right, lessThanOrEqualTo(row.right));
|
||||||
_host(
|
expect(menu.width, greaterThanOrEqualTo(44));
|
||||||
cupertino,
|
expect(menu.height, greaterThanOrEqualTo(44));
|
||||||
AppListRow(
|
expect(find.text('Running'), findsOneWidget);
|
||||||
keepMenuWhenCompact: true,
|
expect(find.text('pipeline · 2 stages'), findsNothing);
|
||||||
title: const Text('Chat'),
|
// The time sits on its own line, under the subtitle.
|
||||||
menu: AppOverflowMenu<int>(
|
final time = tester.getRect(find.text('9d ago'));
|
||||||
key: const Key('menu'),
|
final subtitle = tester.getRect(find.text('Running'));
|
||||||
actions: const [AppMenuAction(value: 1, label: 'Star')],
|
expect(time.top, greaterThanOrEqualTo(subtitle.bottom));
|
||||||
onSelected: (_, _) {},
|
expect(time.left, greaterThan(avatar.right));
|
||||||
),
|
expect(time.right, lessThan(menu.left));
|
||||||
),
|
// The title ellipsises between them.
|
||||||
),
|
final title = tester.getRect(find.text(_longTitle));
|
||||||
);
|
expect(title.left, greaterThan(avatar.right));
|
||||||
expect(find.byKey(const Key('menu')), findsOneWidget);
|
expect(title.right, lessThanOrEqualTo(menu.left));
|
||||||
});
|
expect(tester.takeException(), isNull);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (final brightness in Brightness.values) {
|
for (final brightness in Brightness.values) {
|
||||||
testWidgets('$host ${brightness.name}: 320px at 2x text ellipsises '
|
testWidgets('$host ${brightness.name}: 320px at 2x text ellipsises '
|
||||||
|
|||||||
Reference in New Issue
Block a user