feat(app): clean architecture with typed repositories, DTO models and calendar event logos
This commit is contained in:
@@ -8,6 +8,8 @@ class CorporateEventModel extends Equatable {
|
||||
final String eventType;
|
||||
final DateTime eventDate;
|
||||
final String description;
|
||||
final String? image;
|
||||
final String? ticker;
|
||||
|
||||
const CorporateEventModel({
|
||||
required this.id,
|
||||
@@ -17,6 +19,8 @@ class CorporateEventModel extends Equatable {
|
||||
required this.eventDate,
|
||||
required this.description,
|
||||
required this.isin,
|
||||
this.image,
|
||||
this.ticker,
|
||||
});
|
||||
|
||||
factory CorporateEventModel.fromJson(Map<String, dynamic> json) {
|
||||
@@ -37,9 +41,12 @@ class CorporateEventModel extends Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
final isinVal = json['isin']?.toString() ?? json['Isin']?.toString() ?? '';
|
||||
final imageVal = json['image']?.toString() ?? json['Image']?.toString() ?? (isinVal.isNotEmpty ? '/api/v1/logo/$isinVal' : null);
|
||||
|
||||
return CorporateEventModel(
|
||||
id: json['id']?.toString() ?? json['Id']?.toString() ?? '',
|
||||
isin: json['isin']?.toString() ?? json['Isin']?.toString() ?? '',
|
||||
isin: isinVal,
|
||||
symbol: json['symbol']?.toString() ?? json['Symbol']?.toString() ?? '',
|
||||
companyName: json['companyName']?.toString() ??
|
||||
json['CompanyName']?.toString() ??
|
||||
@@ -50,6 +57,8 @@ class CorporateEventModel extends Equatable {
|
||||
description: json['description']?.toString() ??
|
||||
json['Description']?.toString() ??
|
||||
'',
|
||||
image: imageVal,
|
||||
ticker: json['ticker']?.toString() ?? json['Ticker']?.toString(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -62,10 +71,12 @@ class CorporateEventModel extends Equatable {
|
||||
'eventType': eventType,
|
||||
'eventDate': eventDate.toIso8601String(),
|
||||
'description': description,
|
||||
if (image != null) 'image': image,
|
||||
if (ticker != null) 'ticker': ticker,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props =>
|
||||
[id, symbol, companyName, eventType, eventDate, description];
|
||||
[id, symbol, companyName, eventType, eventDate, description, isin, image, ticker];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../core/theme/app_theme.dart';
|
||||
import '../../../core/widgets/asset_logo_widget.dart';
|
||||
import '../../../core/widgets/glass_container.dart';
|
||||
import '../../../core/widgets/status_badge.dart';
|
||||
|
||||
@@ -11,11 +12,13 @@ class CalendarEventItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isin = event['isin']?.toString() ?? '';
|
||||
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() ?? '';
|
||||
final image = event['image']?.toString() ?? (isin.isNotEmpty ? '/api/v1/logo/$isin' : null);
|
||||
|
||||
Color badgeColor = AppTheme.primaryEmerald;
|
||||
if (type == 'ExDividend') badgeColor = AppTheme.accentCyan;
|
||||
@@ -25,16 +28,11 @@ class CalendarEventItem extends StatelessWidget {
|
||||
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,
|
||||
),
|
||||
AssetLogoWidget(
|
||||
symbolOrName: isin.isNotEmpty ? isin : company,
|
||||
imageUrl: image,
|
||||
size: 36,
|
||||
enableHero: false,
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
|
||||
@@ -68,7 +68,7 @@ class CalendarEventTile extends StatelessWidget {
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
AssetLogoWidget(symbolOrName: companyName, imageUrl: image, size: 28),
|
||||
AssetLogoWidget(symbolOrName: isin.isNotEmpty ? isin : companyName, imageUrl: image, size: 28, enableHero: false),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Column(
|
||||
|
||||
Reference in New Issue
Block a user