import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import '../models/lenormand_pairs.dart'; import '../services/lenormand_pairs_repository.dart'; import 'lenormand_station_screen.dart'; class LenormandPairScreen extends StatelessWidget { final int left; final int right; final LenormandCardEntry? Function(int n)? lookup; final String title; const LenormandPairScreen({ super.key, required this.left, required this.right, this.lookup, this.title = 'Сочетание', }); @override Widget build(BuildContext context) { final lookup = this.lookup ?? (n) => LenormandPairsRepository().byNumber(n); final a = lookup(left); final b = lookup(right); LenormandPairLink? link; if (a != null) { for (final p in a.pairs) { if (p.n == right) { link = p; break; } } } if (a == null || b == null || link == null) { return Scaffold( backgroundColor: const Color(0xFF0C0E1A), appBar: AppBar(title: Text(title)), body: const Center( child: Text('Пара не найдена', style: TextStyle(color: Color(0xFF8C93B8))), ), ); } return Scaffold( backgroundColor: const Color(0xFF0C0E1A), appBar: AppBar( title: Text('${a.name} + ${b.name}'), ), body: ListView( padding: const EdgeInsets.fromLTRB(16, 8, 16, 32), children: [ Row( children: [ Expanded(child: _CardChip(n: a.n, name: a.name, symbol: a.symbol)), const Padding( padding: EdgeInsets.symmetric(horizontal: 8), child: Text('+', style: TextStyle(color: Color(0xFFFFD54F), fontSize: 22, fontWeight: FontWeight.w900)), ), Expanded(child: _CardChip(n: b.n, name: b.name, symbol: b.symbol)), ], ), const SizedBox(height: 8), Row( children: [ TextButton( onPressed: () { HapticFeedback.selectionClick(); Navigator.pushReplacement( context, MaterialPageRoute( builder: (_) => LenormandStationScreen( number: a.n, lookup: lookup, title: title, ), ), ); }, child: Text('← ${a.name}'), ), const Spacer(), TextButton( onPressed: () { HapticFeedback.selectionClick(); Navigator.pushReplacement( context, MaterialPageRoute( builder: (_) => LenormandStationScreen( number: b.n, lookup: lookup, title: title, ), ), ); }, child: Text('${b.name} →'), ), ], ), const SizedBox(height: 14), Container( width: double.infinity, padding: const EdgeInsets.fromLTRB(14, 12, 14, 14), decoration: BoxDecoration( color: const Color(0xFF151829), borderRadius: BorderRadius.circular(14), border: Border.all(color: const Color(0x4DFFD54F)), ), child: Text( link.displayText, style: const TextStyle( color: Color(0xFFE8EAF6), fontSize: 14, height: 1.5, ), ), ), ], ), ); } } class _CardChip extends StatelessWidget { final int n; final String name; final String symbol; const _CardChip({required this.n, required this.name, required this.symbol}); @override Widget build(BuildContext context) { return Container( padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10), decoration: BoxDecoration( color: const Color(0xFF151829), borderRadius: BorderRadius.circular(12), border: Border.all(color: const Color(0x4DFFD54F)), ), child: Column( children: [ Text(symbol, style: const TextStyle(fontSize: 22)), const SizedBox(height: 4), Text( '$n. $name', textAlign: TextAlign.center, style: const TextStyle( color: Color(0xFFFFF9C4), fontWeight: FontWeight.w800, fontSize: 13, ), ), ], ), ); } }