3c56db37fd
AppListRow (Material + Cupertino) with avatar, bold title and trailing time, one muted line, one overflow menu style, inset dividers, selected and emphasised states and a compact mode. Pipelines get a legible initial avatar, schedule rows shrink to two lines with Edit/Pause/Delete in an overflow menu, and the shell chat list scrolls behind the bar.
108 lines
3.4 KiB
Dart
108 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.
|
|
keepMenuWhenCompact: true,
|
|
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),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|