169 lines
6.1 KiB
Dart
169 lines
6.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../../core/theme/app_theme.dart';
|
|
import '../../../core/widgets/glass_container.dart';
|
|
import '../models/bot_models.dart';
|
|
|
|
class BotKpiHeader extends StatelessWidget {
|
|
final AccountSummaryModel summary;
|
|
final BotStatusModel status;
|
|
final double totalUnrealizedPnL;
|
|
final double totalRealizedPnL;
|
|
|
|
const BotKpiHeader({
|
|
super.key,
|
|
required this.summary,
|
|
required this.status,
|
|
required this.totalUnrealizedPnL,
|
|
required this.totalRealizedPnL,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final isPositiveUnrealized = totalUnrealizedPnL >= 0;
|
|
final isPositiveRealized = totalRealizedPnL >= 0;
|
|
|
|
return GlassContainer(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Container(
|
|
width: 10,
|
|
height: 10,
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
color: status.isRunning ? AppTheme.primaryEmerald : AppTheme.accentRed,
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: (status.isRunning ? AppTheme.primaryEmerald : AppTheme.accentRed).withValues(alpha: 0.5),
|
|
blurRadius: 8,
|
|
spreadRadius: 2,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(width: 8),
|
|
Text(
|
|
status.isRunning ? 'AUTONOMOUS BOT ONLINE' : 'BOT PAUSED',
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.bold,
|
|
letterSpacing: 1.2,
|
|
color: status.isRunning ? AppTheme.primaryEmerald : AppTheme.accentRed,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(12),
|
|
color: status.autoExecutionEnabled ? AppTheme.primaryEmerald.withValues(alpha: 0.15) : Colors.amber.withValues(alpha: 0.15),
|
|
border: Border.all(
|
|
color: status.autoExecutionEnabled ? AppTheme.primaryEmerald : Colors.amber,
|
|
width: 1,
|
|
),
|
|
),
|
|
child: Text(
|
|
status.autoExecutionEnabled ? 'AUTO-EXECUTE ON' : 'MANUAL APPROVAL',
|
|
style: TextStyle(
|
|
fontSize: 11,
|
|
fontWeight: FontWeight.w600,
|
|
color: status.autoExecutionEnabled ? AppTheme.primaryEmerald : Colors.amber,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 16),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: summary.hasAccountData
|
|
? _buildMetricCard(
|
|
title: 'Portfolio Equity',
|
|
value: '€${summary.equity!.toStringAsFixed(2)}',
|
|
subtitle: 'Buying Power: €${summary.buyingPower!.toStringAsFixed(0)}',
|
|
valueColor: Colors.white,
|
|
)
|
|
: _buildUnavailableMetricCard('Portfolio Equity'),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: _buildMetricCard(
|
|
title: 'Unrealized PnL',
|
|
value: '${isPositiveUnrealized ? '+' : ''}€${totalUnrealizedPnL.toStringAsFixed(2)}',
|
|
subtitle: 'Realized: ${isPositiveRealized ? '+' : ''}€${totalRealizedPnL.toStringAsFixed(2)}',
|
|
valueColor: isPositiveUnrealized ? AppTheme.primaryEmerald : AppTheme.accentRed,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildUnavailableMetricCard(String title) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(12),
|
|
color: Colors.white.withValues(alpha: 0.03),
|
|
border: Border.all(color: Colors.white.withValues(alpha: 0.06)),
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(title, style: TextStyle(color: AppTheme.textMuted, fontSize: 11)),
|
|
const SizedBox(height: 4),
|
|
Row(
|
|
children: [
|
|
Icon(Icons.error_outline, size: 14, color: AppTheme.textMuted),
|
|
const SizedBox(width: 4),
|
|
Expanded(
|
|
child: Text(
|
|
'Portfoliodaten nicht verfügbar',
|
|
style: TextStyle(color: AppTheme.textMuted, fontSize: 12, fontWeight: FontWeight.w600),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildMetricCard({
|
|
required String title,
|
|
required String value,
|
|
required String subtitle,
|
|
required Color valueColor,
|
|
}) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(12),
|
|
color: Colors.white.withValues(alpha: 0.03),
|
|
border: Border.all(color: Colors.white.withValues(alpha: 0.06)),
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(title, style: TextStyle(color: AppTheme.textMuted, fontSize: 11)),
|
|
const SizedBox(height: 4),
|
|
Text(value, style: TextStyle(color: valueColor, fontSize: 18, fontWeight: FontWeight.bold)),
|
|
const SizedBox(height: 4),
|
|
Text(subtitle, style: TextStyle(color: AppTheme.textMuted, fontSize: 10)),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|