Files
pipelines/app/lib/features/schedules/ui/pipeline/schedule_pipeline_row.dart
T
alan a40a6e2e1c Narrow list panes: readable bar title, More overflow menu, rows keep status and actions
The floating bar keeps the title at its own width (up to half the bar) and
moves overflowable actions into one More menu instead of squeezing them
below their touch targets. List rows keep their leading status avatar and
More actions at any list-pane width; the time moves under the subtitle.
2026-11-03 18:04:10 +00:00

107 lines
3.4 KiB
Dart

import 'package:flutter/material.dart';
import '../../../../ui/adaptive/host.dart';
import '../../../../ui/layout/app_list_row.dart';
import '../../../../ui/layout/app_overflow_menu.dart';
import '../../domain/saved_schedule.dart';
import '../list/schedule_list_format.dart';
import '../list/schedule_list_row.dart';
import 'schedule_pipeline_styles.dart';
import 'schedule_pipeline_wording.dart';
enum _ScheduleAction { edit, toggle, delete }
/// One saved schedule in the pipeline Summary, in the app's shared row: the
/// clock avatar, the name with its next run (or `Paused`), one muted line with
/// the pinned version and timer words, and an overflow menu with Edit,
/// Pause/Enable and Delete. A tap on the row edits it; a refused action's
/// message sits under the row.
class SchedulePipelineRow extends StatelessWidget {
const SchedulePipelineRow({
super.key,
required this.schedule,
required this.busy,
required this.onEdit,
required this.onToggle,
required this.onDelete,
this.error,
this.divider = false,
});
final SavedSchedule schedule;
final bool busy;
final String? error;
final VoidCallback onEdit;
final VoidCallback onToggle;
final VoidCallback onDelete;
final bool divider;
@override
Widget build(BuildContext context) {
final id = schedule.id;
final cupertino = usesCupertinoHost(context);
final row = AppListRow(
cupertino: cupertino,
divider: divider && error == null,
onTap: busy ? null : onEdit,
leading: ScheduleAvatar(schedule: schedule, cupertino: cupertino),
title: Text(scheduleDisplayName(schedule)),
time: scheduleNextDueShort(schedule),
subtitle: Text(
'${schedulePinnedVersionValue(schedule)} · '
'${scheduleRuleSummary(schedule)}',
),
// A narrow Summary still needs a way to pause or delete.
menu: AppOverflowMenu<_ScheduleAction>(
key: scheduleRowMenuKey(id),
cupertino: cupertino,
enabled: !busy,
label: 'Schedule actions for ${scheduleDisplayName(schedule)}',
sheetTitle: scheduleDisplayName(schedule),
actions: [
AppMenuAction(
key: scheduleRowEditKey(id),
value: _ScheduleAction.edit,
label: scheduleEditLabel,
),
AppMenuAction(
key: scheduleRowToggleKey(id),
value: _ScheduleAction.toggle,
label: schedule.enabled ? schedulePauseLabel : scheduleEnableLabel,
),
AppMenuAction(
key: scheduleRowDeleteKey(id),
value: _ScheduleAction.delete,
label: scheduleDeleteLabel,
destructive: true,
),
],
onSelected: (_, action) => switch (action) {
_ScheduleAction.edit => onEdit(),
_ScheduleAction.toggle => onToggle(),
_ScheduleAction.delete => onDelete(),
},
),
);
return Column(
key: scheduleRowKey(id),
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
row,
if (error case final text?)
Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 8),
child: Semantics(
liveRegion: true,
child: Text(
text,
key: scheduleRowErrorKey(id),
style: schedulePipelineErrorStyle(context),
),
),
),
],
);
}
}