feat(news,calendar): improve corporate calendar filters and news sentiment dialogs

This commit is contained in:
2026-08-15 19:30:00 +02:00
parent 067f1bfdd5
commit 960a4bdbd6
11 changed files with 556 additions and 87 deletions
@@ -1,3 +1,4 @@
import 'package:finlytic_app/core/widgets/status_badge.dart';
import 'package:finlytic_app/features/favorites/cubit/favorites_cubit.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -10,15 +11,17 @@ import '../../asset_detail/views/asset_detail_screen.dart';
import '../models/news_article_model.dart';
import 'article_sentiment_dialog.dart';
/// News Card Item displaying news info, tagged assets, timestamp, and sentiment.
/// News Card Item displaying news info, tagged assets, timestamp, and sentiment badge (wie auf dem Dashboard).
class NewsCardItem extends StatelessWidget {
final dynamic item;
final ApiClient apiClient;
final ValueChanged<NewsArticleModel>? onArticleUpdated;
const NewsCardItem({
super.key,
required this.item,
required this.apiClient,
this.onArticleUpdated,
});
@override
@@ -44,7 +47,9 @@ class NewsCardItem extends StatelessWidget {
final String? sentimentLabel = sentimentObj?['label']?.toString() ?? article['sentiment']?.toString();
final double? score = ((sentimentObj?['compoundScore'] ?? sentimentObj?['compound_score'] ?? article['sentimentScore']) as num?)?.toDouble();
final Widget? badgeWidget = (sentimentLabel != null && sentimentLabel.trim().isNotEmpty)
? StatusBadge.sentiment(sentimentLabel, score: score)
: null;
final matchedAssetsRaw = article['MatchedAssets'] ?? article['matchedAssets'];
final matchedAssets = matchedAssetsRaw is List ? matchedAssetsRaw : [];
@@ -79,7 +84,11 @@ class NewsCardItem extends StatelessWidget {
}
showDialog(
context: context,
builder: (_) => ArticleSentimentDialog(articleData: articleModel),
builder: (_) => ArticleSentimentDialog(
articleData: articleModel,
apiClient: apiClient,
onArticleUpdated: onArticleUpdated,
),
);
},
child: Column(
@@ -89,43 +98,61 @@ class NewsCardItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(title, style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 15)),
child: Text(
title,
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 14.5),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
const SizedBox(width: 8),
//badgeWidget,
if (badgeWidget != null) ...[
const SizedBox(width: 8),
badgeWidget,
],
],
),
const SizedBox(height: 8),
Text(summary, maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle(color: AppTheme.textSecondary, fontSize: 13)),
if (summary.isNotEmpty) ...[
const SizedBox(height: 8),
Text(
summary,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: AppTheme.textSecondary, fontSize: 12.5),
),
],
const SizedBox(height: 10),
Text('$author$pubTime', style: TextStyle(color: AppTheme.textMuted, fontSize: 11)),
if (matchedAssets.isNotEmpty) ...[
const SizedBox(height: 8),
Wrap(
spacing: 4,
spacing: 6,
runSpacing: 4,
children: matchedAssets.map((assetItem) {
final isin = assetItem['isin']!;
final name = assetItem['name']!;
final String isin = (assetItem is Map ? (assetItem['isin'] ?? assetItem['Isin']) : assetItem)?.toString() ?? '';
final String name = (assetItem is Map ? (assetItem['name'] ?? assetItem['Name'] ?? assetItem['symbol'] ?? isin) : isin)?.toString() ?? isin;
final match = favourites.where((e) => e.isin == isin);
final symbol = match.isEmpty ? null : match.first;
return ActionChip(
label: Text(name, style: TextStyle(fontSize: 10, color: AppTheme.accentCyan)),
avatar: Icon(Icons.show_chart, size: 14, color: AppTheme.accentCyan),
label: Text(name, style: TextStyle(fontSize: 11, color: AppTheme.accentCyan, fontWeight: FontWeight.bold)),
backgroundColor: AppTheme.glassSurface,
padding: EdgeInsets.zero,
side: BorderSide(color: AppTheme.glassBorder),
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 0),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => AssetDetailScreen(
isin: assetItem,
name: name,
symbol: symbol != null ? symbol.symbol : null,
apiClient: apiClient,
if (isin.isNotEmpty) {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => AssetDetailScreen(
isin: isin,
name: name,
symbol: symbol != null ? symbol.symbol : null,
apiClient: apiClient,
),
),
),
);
);
}
},
);
}).toList(),