feat(app): section titles read as dividers; one Rendered/Raw switch per definition; schedule rows with labelled facts and a status pill

This commit is contained in:
2026-10-23 22:09:46 +01:00
parent c467872ee3
commit b44cecf35c
10 changed files with 355 additions and 77 deletions
+101
View File
@@ -0,0 +1,101 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../adaptive/host.dart';
/// The look every section title shares, so it reads as a divider and not as
/// another row: a tinted strip with an accent bar, a bold title and a hairline
/// underneath.
class SectionHeadingStyle {
const SectionHeadingStyle({
required this.background,
required this.accent,
required this.title,
required this.line,
});
final Color background;
final Color accent;
final TextStyle title;
final Color line;
static SectionHeadingStyle of(BuildContext context) {
if (usesCupertinoHost(context)) {
final base = CupertinoTheme.of(context).textTheme.textStyle;
return SectionHeadingStyle(
background: CupertinoColors.secondarySystemGroupedBackground
.resolveFrom(context),
accent: CupertinoTheme.of(context).primaryColor,
title: base.copyWith(
fontWeight: FontWeight.w700,
color: CupertinoColors.label.resolveFrom(context),
),
line: CupertinoColors.separator.resolveFrom(context),
);
}
final scheme = Theme.of(context).colorScheme;
return SectionHeadingStyle(
background: scheme.surfaceContainerHigh,
accent: scheme.primary,
title: (Theme.of(context).textTheme.titleSmall ?? const TextStyle())
.copyWith(fontWeight: FontWeight.w700, color: scheme.onSurface),
line: scheme.outlineVariant,
);
}
}
/// A section title strip: [title], then any [trailing] controls.
class SectionHeading extends StatelessWidget {
const SectionHeading({
super.key,
required this.title,
this.leading,
this.trailing = const [],
this.titleColor,
this.padding = const EdgeInsetsDirectional.only(start: 12, end: 8),
this.minHeight = 40,
});
final String title;
final Widget? leading;
final List<Widget> trailing;
final Color? titleColor;
final EdgeInsetsGeometry padding;
final double minHeight;
@override
Widget build(BuildContext context) {
final style = SectionHeadingStyle.of(context);
return DecoratedBox(
decoration: BoxDecoration(
color: style.background,
border: Border(
left: BorderSide(color: style.accent, width: 3),
bottom: BorderSide(color: style.line, width: 0.5),
),
),
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: minHeight),
child: Padding(
padding: padding,
child: Row(
children: [
if (leading != null) ...[leading!, const SizedBox(width: 8)],
Expanded(
child: Text(
title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: titleColor == null
? style.title
: style.title.copyWith(color: titleColor),
),
),
...trailing,
],
),
),
),
);
}
}
+15 -14
View File
@@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../adaptive/host.dart';
import 'section_heading.dart';
/// A collapsible section for a [CustomScrollView]: its title stays pinned at
/// the top while its content scrolls under it, so it can always be closed
@@ -76,24 +77,24 @@ class StickySectionTitle extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final background = cupertino
? CupertinoColors.systemGroupedBackground.resolveFrom(context)
: Theme.of(context).colorScheme.surface;
// The shared section-title look: it reads as a divider, not a row.
final heading = SectionHeadingStyle.of(context);
final muted = cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
final style = TextStyle(
fontWeight: FontWeight.w600,
color:
color ??
(cupertino
? CupertinoColors.label.resolveFrom(context)
: Theme.of(context).colorScheme.onSurface),
);
return ColoredBox(
color: background,
final style = color == null
? heading.title
: heading.title.copyWith(color: color);
return DecoratedBox(
decoration: BoxDecoration(
color: heading.background,
border: Border(
left: BorderSide(color: heading.accent, width: 3),
bottom: BorderSide(color: heading.line, width: 0.5),
),
),
child: Padding(
padding: const EdgeInsetsDirectional.only(start: 16, end: 8),
padding: const EdgeInsetsDirectional.only(start: 13, end: 8),
child: Row(
children: [
Expanded(
+30 -14
View File
@@ -14,7 +14,6 @@ class MarkdownSourceView extends StatefulWidget {
/// The exact text as the screen already showed it.
final Widget raw;
@override
State<MarkdownSourceView> createState() => _MarkdownSourceViewState();
}
@@ -25,14 +24,39 @@ class _MarkdownSourceViewState extends State<MarkdownSourceView> {
void _set(bool raw) => setState(() => _raw = raw);
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
MarkdownModeSwitch(raw: _raw, onChanged: _set),
const SizedBox(height: 8),
if (_raw) widget.raw else ChatMarkdownView(text: widget.text),
],
);
}
}
/// The Rendered | Raw switch for markdown text; one switch can govern a
/// whole page of fields.
class MarkdownModeSwitch extends StatelessWidget {
const MarkdownModeSwitch({
super.key,
required this.raw,
required this.onChanged,
});
final bool raw;
final ValueChanged<bool> onChanged;
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final control = cupertino
return cupertino
? CupertinoSlidingSegmentedControl<bool>(
key: const Key('markdown-source-mode'),
groupValue: _raw,
onValueChanged: (raw) => _set(raw ?? false),
groupValue: raw,
onValueChanged: (value) => onChanged(value ?? false),
children: const {false: Text('Rendered'), true: Text('Raw')},
)
: SegmentedButton<bool>(
@@ -42,16 +66,8 @@ class _MarkdownSourceViewState extends State<MarkdownSourceView> {
ButtonSegment(value: false, label: Text('Rendered')),
ButtonSegment(value: true, label: Text('Raw')),
],
selected: {_raw},
onSelectionChanged: (value) => _set(value.single),
selected: {raw},
onSelectionChanged: (value) => onChanged(value.single),
);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
control,
const SizedBox(height: 8),
if (_raw) widget.raw else ChatMarkdownView(text: widget.text),
],
);
}
}