dd250788f6
The backend retired /api/briefing/* and the RSS feature entirely. This
Flutter change mirrors what landed web-side: rename the briefing surface
to journal, repoint at /api/journal/*, and drop the news/RSS UI since
its endpoints no longer exist.
New (mirrors briefing structure with adapted shapes):
- lib/data/api/journal_api.dart — getToday, getDay, getDays, triggerPrep
- lib/data/models/journal_day.dart — {day_date, conversation, messages}
- lib/providers/journal_provider.dart — async notifier, sendReply, polling,
silent refresh, regeneratePrep. Mirrors the briefing notifier 1:1
- lib/widgets/journal_prep_card.dart — adapted briefing_digest_card
- lib/screens/journal/journal_screen.dart — adapted briefing_screen,
weather card preserved (rendered from msg_metadata.sections.weather
on the daily-prep assistant message). News cards / RSS reactions /
article-discuss removed
- lib/screens/journal/journal_history_screen.dart — past days picker
pulls /api/journal/days, drills into /api/journal/day/<iso>
Wiring:
- Routes.briefing → Routes.journal (constants.dart)
- Routes.news removed
- briefingApiProvider → journalApiProvider (api_client_provider.dart)
- newsApiProvider removed
- app.dart: shell tab "Briefing" → "Journal"; News destination removed
from nav rail, bottom nav, and the More sheet
- splash_screen.dart and login_screen.dart: redirect Routes.journal
instead of Routes.briefing
- chat_api.dart: drop openArticleInChat (calls deleted /api/chat/from-article)
- settings_provider.dart: drop rssEnabled getter and rssEnabledProvider
Deleted:
- lib/screens/briefing/ (whole directory)
- lib/screens/news/ (whole directory)
- lib/data/api/briefing_api.dart, news_api.dart
- lib/data/models/briefing_conversation.dart, briefing_feed.dart, news_item.dart
- lib/providers/briefing_provider.dart, news_provider.dart
- lib/widgets/briefing_digest_card.dart, news_card.dart
- test cases for NewsItem and BriefingFeed in test/widget_test.dart
flutter analyze: 0 issues.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
132 lines
4.0 KiB
Dart
132 lines
4.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_markdown_plus/flutter_markdown_plus.dart';
|
|
|
|
import '../data/models/message.dart';
|
|
|
|
class JournalPrepCard extends StatefulWidget {
|
|
/// The first assistant message from today's journal — the daily prep
|
|
/// (LLM-generated briefing-style opener), or null if not yet generated.
|
|
final Message? message;
|
|
|
|
/// Called when the user taps "Generate now".
|
|
final VoidCallback? onGenerateNow;
|
|
|
|
const JournalPrepCard({
|
|
super.key,
|
|
required this.message,
|
|
this.onGenerateNow,
|
|
});
|
|
|
|
@override
|
|
State<JournalPrepCard> createState() => _JournalPrepCardState();
|
|
}
|
|
|
|
class _JournalPrepCardState extends State<JournalPrepCard> {
|
|
bool _expanded = false;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final scheme = Theme.of(context).colorScheme;
|
|
final textTheme = Theme.of(context).textTheme;
|
|
|
|
return Card(
|
|
margin: const EdgeInsets.fromLTRB(12, 8, 12, 4),
|
|
elevation: 0,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(14),
|
|
side: BorderSide(
|
|
color: scheme.outlineVariant.withValues(alpha: 0.5),
|
|
width: 1,
|
|
),
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Icon(Icons.menu_book_outlined, size: 18, color: scheme.primary),
|
|
const SizedBox(width: 8),
|
|
Text(
|
|
_todayLabel(),
|
|
style: textTheme.labelMedium?.copyWith(
|
|
color: scheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 10),
|
|
if (widget.message == null) ...[
|
|
Text(
|
|
'No prep yet today.',
|
|
style: textTheme.bodyMedium?.copyWith(
|
|
color: scheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
if (widget.onGenerateNow != null)
|
|
FilledButton.tonal(
|
|
onPressed: widget.onGenerateNow,
|
|
child: const Text('Generate now'),
|
|
),
|
|
] else ...[
|
|
AnimatedSize(
|
|
duration: const Duration(milliseconds: 250),
|
|
curve: Curves.easeInOut,
|
|
alignment: Alignment.topCenter,
|
|
child: _expanded
|
|
? MarkdownBody(data: widget.message!.content)
|
|
: _TruncatedMarkdown(
|
|
data: widget.message!.content,
|
|
maxLines: 5,
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
GestureDetector(
|
|
onTap: () => setState(() => _expanded = !_expanded),
|
|
child: Text(
|
|
_expanded ? 'Show less ↑' : 'Show more ↓',
|
|
style: TextStyle(
|
|
color: scheme.primary,
|
|
fontSize: 13,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
String _todayLabel() {
|
|
final now = DateTime.now();
|
|
const days = [
|
|
'Monday', 'Tuesday', 'Wednesday', 'Thursday',
|
|
'Friday', 'Saturday', 'Sunday'
|
|
];
|
|
const months = [
|
|
'January', 'February', 'March', 'April', 'May', 'June',
|
|
'July', 'August', 'September', 'October', 'November', 'December'
|
|
];
|
|
return '${days[now.weekday - 1]}, ${months[now.month - 1]} ${now.day}';
|
|
}
|
|
}
|
|
|
|
/// Renders Markdown truncated to [maxLines] visible lines.
|
|
class _TruncatedMarkdown extends StatelessWidget {
|
|
final String data;
|
|
final int maxLines;
|
|
const _TruncatedMarkdown({required this.data, required this.maxLines});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ConstrainedBox(
|
|
constraints: BoxConstraints(maxHeight: maxLines * 20.0),
|
|
child: ClipRect(child: MarkdownBody(data: data)),
|
|
);
|
|
}
|
|
}
|