202 lines
8.1 KiB
Dart
202 lines
8.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../../../core/theme/app_theme.dart';
|
|
import '../models/trade_model.dart';
|
|
import 'trade_detail_content.dart';
|
|
|
|
class TradeDetailModal extends StatelessWidget {
|
|
final TradeModel trade;
|
|
final VoidCallback? onAccept;
|
|
final VoidCallback? onClose;
|
|
|
|
const TradeDetailModal({
|
|
super.key,
|
|
required this.trade,
|
|
this.onAccept,
|
|
this.onClose,
|
|
});
|
|
|
|
static Future<void> show(
|
|
BuildContext context, {
|
|
required TradeModel trade,
|
|
VoidCallback? onAccept,
|
|
VoidCallback? onClose,
|
|
}) {
|
|
return showModalBottomSheet(
|
|
context: context,
|
|
isScrollControlled: true,
|
|
backgroundColor: Colors.transparent,
|
|
builder: (ctx) => TradeDetailModal(
|
|
trade: trade,
|
|
onAccept: onAccept,
|
|
onClose: onClose,
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final isBuy = trade.signalType == 'BUY';
|
|
final signalColor = isBuy ? AppTheme.primaryEmerald : AppTheme.accentRed;
|
|
|
|
return Container(
|
|
constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.height * 0.85),
|
|
decoration: BoxDecoration(
|
|
color: AppTheme.cardSurface,
|
|
borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),
|
|
border: Border.all(color: Colors.white.withValues(alpha: 0.1)),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withValues(alpha: 0.6),
|
|
blurRadius: 25,
|
|
spreadRadius: 5,
|
|
)
|
|
],
|
|
),
|
|
child: SafeArea(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Container(
|
|
margin: const EdgeInsets.symmetric(vertical: 12),
|
|
width: 40,
|
|
height: 4,
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withValues(alpha: 0.2),
|
|
borderRadius: BorderRadius.circular(2),
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
|
decoration: BoxDecoration(
|
|
color: signalColor.withValues(alpha: 0.18),
|
|
borderRadius: BorderRadius.circular(10),
|
|
border: Border.all(color: signalColor.withValues(alpha: 0.5)),
|
|
),
|
|
child: Text(
|
|
trade.signalType,
|
|
style: TextStyle(color: signalColor, fontWeight: FontWeight.bold, fontSize: 14),
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
trade.symbol.isNotEmpty && trade.symbol != 'UNKNOWN'
|
|
? trade.symbol
|
|
: (trade.companyName.isNotEmpty && trade.companyName != 'UNKNOWN' ? trade.companyName : (trade.isin.isNotEmpty ? trade.isin : 'Aktie')),
|
|
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 20, color: Colors.white),
|
|
),
|
|
if (trade.companyName.isNotEmpty && trade.companyName != trade.symbol && trade.companyName != 'UNKNOWN')
|
|
Text(
|
|
trade.companyName,
|
|
style: TextStyle(color: AppTheme.textMuted, fontSize: 13),
|
|
),
|
|
if (trade.isin.isNotEmpty || trade.sector.isNotEmpty)
|
|
Text(
|
|
'${trade.isin.isNotEmpty ? trade.isin : ""}${trade.isin.isNotEmpty && trade.sector.isNotEmpty ? " • " : ""}${trade.sector.isNotEmpty ? trade.sector : ""}',
|
|
style: TextStyle(color: AppTheme.textMuted.withValues(alpha: 0.7), fontSize: 11),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
|
decoration: BoxDecoration(
|
|
color: Colors.amber.withValues(alpha: 0.15),
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: Border.all(color: Colors.amber.withValues(alpha: 0.4)),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
const Icon(Icons.star, size: 14, color: Colors.amber),
|
|
const SizedBox(width: 4),
|
|
Text(
|
|
'${trade.winRate.toStringAsFixed(0)}% Win-Rate',
|
|
style: const TextStyle(color: Colors.amber, fontWeight: FontWeight.bold, fontSize: 11),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
const Divider(color: Colors.white10, height: 1),
|
|
Expanded(
|
|
child: SingleChildScrollView(
|
|
padding: const EdgeInsets.all(20),
|
|
child: TradeDetailContent(trade: trade),
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: OutlinedButton(
|
|
onPressed: () => Navigator.pop(context),
|
|
style: OutlinedButton.styleFrom(
|
|
side: BorderSide(color: Colors.white.withValues(alpha: 0.2)),
|
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
|
),
|
|
child: const Text('Schließen', style: TextStyle(color: Colors.white70)),
|
|
),
|
|
),
|
|
if (trade.isProposed && onAccept != null) ...[
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
flex: 2,
|
|
child: ElevatedButton.icon(
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
onAccept!();
|
|
},
|
|
icon: const Icon(Icons.check_circle_outline, size: 18),
|
|
label: const Text('Trade Übernehmen'),
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: AppTheme.primaryEmerald,
|
|
foregroundColor: Colors.white,
|
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
if (trade.isActive && onClose != null) ...[
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
flex: 2,
|
|
child: ElevatedButton.icon(
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
onClose!();
|
|
},
|
|
icon: const Icon(Icons.close, size: 18),
|
|
label: const Text('Position Schließen'),
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: AppTheme.accentRed,
|
|
foregroundColor: Colors.white,
|
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|