feat(App): update Finlytic Flutter app UI and blocs
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../core/theme/app_theme.dart';
|
||||
import '../../../core/widgets/glass_container.dart';
|
||||
import '../../../core/widgets/status_badge.dart';
|
||||
|
||||
/// Corporate Calendar event item widget.
|
||||
class CalendarEventItem extends StatelessWidget {
|
||||
final Map<String, dynamic> event;
|
||||
|
||||
const CalendarEventItem({super.key, required this.event});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final symbol = event['symbol']?.toString() ?? 'ASSET';
|
||||
final company = event['companyName']?.toString() ?? symbol;
|
||||
final type = event['eventType']?.toString() ?? 'Earnings';
|
||||
final desc = event['description']?.toString() ?? '';
|
||||
final dateStr = event['eventDate']?.toString() ?? '';
|
||||
|
||||
Color badgeColor = AppTheme.primaryEmerald;
|
||||
if (type == 'ExDividend') badgeColor = AppTheme.accentCyan;
|
||||
if (type == 'Payout') badgeColor = Colors.amber;
|
||||
|
||||
return GlassContainer(
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: badgeColor.withValues(alpha: 0.15),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Icon(
|
||||
type == 'Earnings' ? Icons.bar_chart : (type == 'ExDividend' ? Icons.content_cut : Icons.payments),
|
||||
color: badgeColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text('$company ($symbol)', style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 14)),
|
||||
const Spacer(),
|
||||
StatusBadge(label: type, color: badgeColor),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(desc, style: TextStyle(color: AppTheme.textSecondary, fontSize: 12)),
|
||||
const SizedBox(height: 4),
|
||||
Text('Datum: $dateStr', style: TextStyle(color: AppTheme.textMuted, fontSize: 11)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../core/network/api_client.dart';
|
||||
import '../../../core/theme/app_theme.dart';
|
||||
import '../../../core/utils/asset_utils.dart';
|
||||
import '../../../core/widgets/asset_logo_widget.dart';
|
||||
import '../../../core/widgets/glass_container.dart';
|
||||
import '../../../core/widgets/status_badge.dart';
|
||||
import '../../asset_detail/views/asset_detail_screen.dart';
|
||||
|
||||
/// Glassmorphic Event Tile widget for Corporate Calendar (Kachelansicht).
|
||||
class CalendarEventTile extends StatelessWidget {
|
||||
final Map<String, dynamic> event;
|
||||
final ApiClient apiClient;
|
||||
|
||||
const CalendarEventTile({
|
||||
super.key,
|
||||
required this.event,
|
||||
required this.apiClient,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final rawSymbol = event['symbol']?.toString() ?? event['Symbol']?.toString() ?? 'ASSET';
|
||||
final rawCompany = event['companyName']?.toString() ?? event['CompanyName']?.toString() ?? rawSymbol;
|
||||
final displayName = AssetUtils.getAssetName(rawCompany.isNotEmpty ? rawCompany : rawSymbol);
|
||||
final type = event['eventType']?.toString() ?? event['EventType']?.toString() ?? 'Earnings';
|
||||
final desc = event['description']?.toString() ?? event['Description']?.toString() ?? '';
|
||||
final dateStr = event['eventDate']?.toString() ?? event['EventDate']?.toString() ?? '';
|
||||
|
||||
String formattedDate = dateStr;
|
||||
try {
|
||||
final dt = DateTime.parse(dateStr);
|
||||
formattedDate = '${dt.day.toString().padLeft(2, '0')}.${dt.month.toString().padLeft(2, '0')}.${dt.year}';
|
||||
} catch (_) {}
|
||||
|
||||
Color badgeColor = AppTheme.primaryEmerald;
|
||||
String typeLabel = 'Quartalszahlen';
|
||||
|
||||
if (type == 'ExDividend') {
|
||||
badgeColor = AppTheme.accentCyan;
|
||||
typeLabel = 'Ex-Dividende';
|
||||
} else if (type == 'Payout') {
|
||||
badgeColor = Colors.amber;
|
||||
typeLabel = 'Zahlungstag';
|
||||
}
|
||||
|
||||
return GlassContainer(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => AssetDetailScreen(
|
||||
symbol: displayName,
|
||||
apiClient: apiClient,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
AssetLogoWidget(symbolOrName: displayName, size: 28),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
displayName,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 13.5),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Text(
|
||||
rawSymbol,
|
||||
style: TextStyle(color: AppTheme.textMuted, fontSize: 10),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
StatusBadge(label: typeLabel, color: badgeColor),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
desc,
|
||||
style: TextStyle(color: AppTheme.textSecondary, fontSize: 12),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Row(
|
||||
children: [
|
||||
Text('Termin:', style: TextStyle(color: AppTheme.textMuted, fontSize: 10.5)),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
formattedDate,
|
||||
style: TextStyle(color: AppTheme.accentCyan, fontWeight: FontWeight.bold, fontSize: 11),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../core/theme/app_theme.dart';
|
||||
import '../../../core/widgets/glass_container.dart';
|
||||
|
||||
/// Compact Interactive Monthly Calendar Grid with event markers and event count dots.
|
||||
class MonthCalendarWidget extends StatelessWidget {
|
||||
final DateTime currentMonth;
|
||||
final DateTime? selectedDate;
|
||||
final List<dynamic> events;
|
||||
final Function(DateTime) onDateSelected;
|
||||
final Function(DateTime) onMonthChanged;
|
||||
|
||||
const MonthCalendarWidget({
|
||||
super.key,
|
||||
required this.currentMonth,
|
||||
required this.selectedDate,
|
||||
required this.events,
|
||||
required this.onDateSelected,
|
||||
required this.onMonthChanged,
|
||||
});
|
||||
|
||||
static const List<String> weekDays = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'];
|
||||
static const List<String> monthNames = [
|
||||
'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni',
|
||||
'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'
|
||||
];
|
||||
|
||||
DateTime _parseEventDate(dynamic raw) {
|
||||
if (raw == null) return DateTime(1970);
|
||||
final str = raw.toString();
|
||||
try {
|
||||
if (str.contains('.')) {
|
||||
final parts = str.split('.');
|
||||
if (parts.length >= 3) {
|
||||
return DateTime(int.parse(parts[2]), int.parse(parts[1]), int.parse(parts[0]));
|
||||
}
|
||||
}
|
||||
return DateTime.parse(str);
|
||||
} catch (_) {
|
||||
return DateTime(1970);
|
||||
}
|
||||
}
|
||||
|
||||
List<dynamic> _getEventsForDate(DateTime date) {
|
||||
return events.where((e) {
|
||||
final dt = _parseEventDate(e['eventDate'] ?? e['EventDate']);
|
||||
return dt.year == date.year && dt.month == date.month && dt.day == date.day;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final firstDayOfMonth = DateTime(currentMonth.year, currentMonth.month, 1);
|
||||
final daysInMonth = DateTime(currentMonth.year, currentMonth.month + 1, 0).day;
|
||||
|
||||
// ISO weekday: Monday = 1, Sunday = 7
|
||||
final firstWeekday = firstDayOfMonth.weekday;
|
||||
final leadingEmptyDays = firstWeekday - 1;
|
||||
final totalCells = ((leadingEmptyDays + daysInMonth) / 7).ceil() * 7;
|
||||
|
||||
return Center(
|
||||
child: Container(
|
||||
child: GlassContainer(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Month Header Navigation
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.chevron_left, color: AppTheme.accentCyan, size: 20),
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
onPressed: () => onMonthChanged(DateTime(currentMonth.year, currentMonth.month - 1, 1)),
|
||||
),
|
||||
Text(
|
||||
'${monthNames[currentMonth.month - 1]} ${currentMonth.year}',
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: AppTheme.textPrimary),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.chevron_right, color: AppTheme.accentCyan, size: 20),
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
onPressed: () => onMonthChanged(DateTime(currentMonth.year, currentMonth.month + 1, 1)),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
// Weekday Labels
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: weekDays.map((w) => Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
w,
|
||||
style: TextStyle(color: AppTheme.textMuted, fontSize: 11, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
)).toList(),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
// Days Grid
|
||||
GridView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: totalCells,
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 7,
|
||||
childAspectRatio: 2,
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
final dayNumber = index - leadingEmptyDays + 1;
|
||||
if (dayNumber < 1 || dayNumber > daysInMonth) {
|
||||
return const SizedBox();
|
||||
}
|
||||
|
||||
final cellDate = DateTime(currentMonth.year, currentMonth.month, dayNumber);
|
||||
final isSelected = selectedDate != null &&
|
||||
selectedDate!.year == cellDate.year &&
|
||||
selectedDate!.month == cellDate.month &&
|
||||
selectedDate!.day == cellDate.day;
|
||||
|
||||
final isToday = DateTime.now().year == cellDate.year &&
|
||||
DateTime.now().month == cellDate.month &&
|
||||
DateTime.now().day == cellDate.day;
|
||||
|
||||
final dayEvents = _getEventsForDate(cellDate);
|
||||
final eventCount = dayEvents.length;
|
||||
|
||||
return InkWell(
|
||||
onTap: () => onDateSelected(cellDate),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
child: Container(
|
||||
margin: const EdgeInsets.all(1.5),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? AppTheme.primaryEmerald.withValues(alpha: 0.3)
|
||||
: (isToday ? AppTheme.glassSurface : Colors.transparent),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
border: Border.all(
|
||||
color: isSelected
|
||||
? AppTheme.primaryEmerald
|
||||
: (eventCount > 0 ? AppTheme.accentCyan.withValues(alpha: 0.6) : Colors.transparent),
|
||||
width: isSelected ? 1.5 : 1.0,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'$dayNumber',
|
||||
style: TextStyle(
|
||||
fontSize: 11.5,
|
||||
fontWeight: isSelected || isToday || eventCount > 0 ? FontWeight.bold : FontWeight.normal,
|
||||
color: isSelected
|
||||
? AppTheme.primaryEmerald
|
||||
: (eventCount > 0 ? AppTheme.textPrimary : AppTheme.textSecondary),
|
||||
),
|
||||
),
|
||||
if (eventCount > 0) ...[
|
||||
const SizedBox(height: 1),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: List.generate(
|
||||
eventCount > 4 ? 4 : eventCount,
|
||||
(i) => Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 1),
|
||||
width: 4,
|
||||
height: 4,
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.accentCyan,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user