Files
pipelines/app/lib/features/schedules/ui/pipeline/schedule_pipeline_row.dart
T

115 lines
3.7 KiB
Dart

import 'package:flutter/material.dart';
import '../../domain/saved_schedule.dart';
import '../list/schedule_list_format.dart';
import 'schedule_pipeline_styles.dart';
import 'schedule_pipeline_wording.dart';
/// One saved schedule in the pipeline Summary: name, state, pinned version and
/// timer words, the recorded due time, and its Edit/Pause-Enable/Delete actions.
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,
});
final SavedSchedule schedule;
final bool busy;
final String? error;
final VoidCallback onEdit;
final VoidCallback onToggle;
final VoidCallback onDelete;
@override
Widget build(BuildContext context) {
final id = schedule.id;
return Padding(
key: scheduleRowKey(id),
padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),
child: Semantics(
container: true,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
scheduleDisplayName(schedule),
style: schedulePipelineBodyStyle(context),
),
),
const SizedBox(width: 8),
Text(
scheduleStatusLabel(schedule),
style: schedulePipelineStatusStyle(context, schedule.enabled),
),
],
),
const SizedBox(height: 4),
Text(
'Pinned ${schedulePinnedVersionValue(schedule)} · '
'${scheduleRuleSummary(schedule)}',
style: schedulePipelineMutedStyle(context),
),
if (schedule.prompt.isNotEmpty) ...[
const SizedBox(height: 4),
Text(schedule.prompt, style: schedulePipelineBodyStyle(context)),
],
const SizedBox(height: 4),
Text(
'$scheduleNextPrefix${scheduleNextDueValue(schedule)}',
style: schedulePipelineMutedStyle(context),
),
const SizedBox(height: 4),
Wrap(
spacing: 8,
runSpacing: 4,
children: [
schedulePipelineTextButton(
context,
key: scheduleRowEditKey(id),
label: scheduleEditLabel,
onPressed: busy ? null : onEdit,
),
schedulePipelineTextButton(
context,
key: scheduleRowToggleKey(id),
label: schedule.enabled
? schedulePauseLabel
: scheduleEnableLabel,
onPressed: busy ? null : onToggle,
),
schedulePipelineTextButton(
context,
key: scheduleRowDeleteKey(id),
label: scheduleDeleteLabel,
onPressed: busy ? null : onDelete,
),
],
),
if (error case final text?)
Padding(
padding: const EdgeInsets.only(top: 4),
child: Semantics(
liveRegion: true,
child: Text(
text,
key: scheduleRowErrorKey(id),
style: schedulePipelineErrorStyle(context),
),
),
),
],
),
),
);
}
}