Files
pipelines/app/lib/features/settings/settings_design_section.dart
T
alan 7d2c3412a1 Paper design: warm paper, serif reading text and a typeset transcript
Adds the Paper design and generalises design tokens (transcript, composer,
selected-row styles, reading type, panel fill, chat colour saturation).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 18:00:07 +00:00

114 lines
3.6 KiB
Dart

import 'dart:async';
import 'package:flutter/material.dart';
import '../../ui/theme/app_design.dart';
import '../../ui/theme/app_design_controller.dart';
import 'settings_group.dart';
import 'settings_theme.dart';
const designSectionTitle = 'Design';
const designSectionFooter =
'Saved on this device only and applied at once. Light and dark follow '
'the system under every design. Terminal uses its monospace font '
'instead of the Font choice below; Paper keeps that font for the '
'interface and sets reading text in its own serif.';
const designSaveFailedText =
'Not saved on this device; it applies until reload.';
ValueKey<String> settingsDesignKey(AppDesign design) =>
ValueKey<String>('settings-design-${design.id}');
/// The device's app-wide design: one radio row per [AppDesign], each with a
/// one-line summary. A choice applies at once, without a restart.
class SettingsDesignSection extends StatelessWidget {
const SettingsDesignSection({super.key, required this.controller});
final AppDesignController controller;
@override
Widget build(BuildContext context) => ListenableBuilder(
listenable: controller,
builder: (context, _) => RadioGroup<AppDesign>(
groupValue: controller.design,
onChanged: (design) {
if (design != null) unawaited(controller.select(design));
},
child: SettingsGroup(
title: designSectionTitle,
footer: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Text(designSectionFooter),
if (controller.saveFailed)
Text(
designSaveFailedText,
style: TextStyle(color: settingsErrorColor(context)),
),
],
),
children: [
for (final design in AppDesign.values)
RadioListTile<AppDesign>(
key: settingsDesignKey(design),
value: design,
title: Text(design.label),
subtitle: Text(design.description),
secondary: DesignSwatchPreview(
swatch: design.swatch(Theme.of(context).brightness),
),
),
],
),
),
);
}
/// A design's small preview in the picker: its page with a line of its ink
/// and a dot of its accent, framed by a hairline.
class DesignSwatchPreview extends StatelessWidget {
const DesignSwatchPreview({super.key, required this.swatch});
final DesignSwatch swatch;
@override
Widget build(BuildContext context) => ExcludeSemantics(
child: Container(
width: 48,
height: 32,
decoration: BoxDecoration(
color: swatch.page,
borderRadius: const BorderRadius.all(Radius.circular(6)),
border: Border.all(color: Theme.of(context).colorScheme.outlineVariant),
),
padding: const EdgeInsets.all(8),
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(height: 2, color: swatch.ink),
FractionallySizedBox(
widthFactor: 0.6,
child: Container(height: 2, color: swatch.ink),
),
],
),
),
const SizedBox(width: 4),
Container(
width: 6,
height: 6,
decoration: BoxDecoration(
color: swatch.accent,
shape: BoxShape.circle,
),
),
],
),
),
);
}