import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import '../models/interpreter_persona.dart'; import '../services/settings_repository.dart'; class InterpreterPersonaPicker extends StatelessWidget { final ValueChanged? onSelected; final bool compact; const InterpreterPersonaPicker({ super.key, this.onSelected, this.compact = false, }); @override Widget build(BuildContext context) { final settings = SettingsRepository(); return ListenableBuilder( listenable: settings, builder: (context, _) { final selectedId = settings.personaId; return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Row( children: [ Icon(Icons.record_voice_over_rounded, size: 16, color: Color(0xFFFFD54F)), SizedBox(width: 6), Text( 'Кто толкует знаки', style: TextStyle( fontSize: 12.5, fontWeight: FontWeight.w900, letterSpacing: 0.3, color: Color(0xFFFFD54F), ), ), ], ), const SizedBox(height: 8), Wrap( spacing: 8, runSpacing: 8, children: [ for (final persona in InterpreterPersona.all) _PersonaChip( persona: persona, selected: persona.id == selectedId, compact: compact, onTap: () { HapticFeedback.selectionClick(); settings.setPersonaId(persona.id); onSelected?.call(persona); }, ), ], ), ], ); }, ); } } class _PersonaChip extends StatelessWidget { final InterpreterPersona persona; final bool selected; final bool compact; final VoidCallback onTap; const _PersonaChip({ required this.persona, required this.selected, required this.compact, required this.onTap, }); @override Widget build(BuildContext context) { return Material( color: Colors.transparent, child: InkWell( onTap: onTap, borderRadius: BorderRadius.circular(14), child: AnimatedContainer( duration: const Duration(milliseconds: 160), padding: EdgeInsets.symmetric( horizontal: compact ? 10 : 12, vertical: compact ? 8 : 10, ), decoration: BoxDecoration( color: selected ? const Color(0xFF2A2D4A) : const Color(0xFF17192C), borderRadius: BorderRadius.circular(14), border: Border.all( color: selected ? const Color(0xFFFFD54F) : const Color(0xFFFFD54F).withValues(alpha: 0.22), width: selected ? 1.5 : 1, ), ), child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( persona.icon, size: 16, color: const Color(0xFFFFD54F), ), const SizedBox(width: 6), Text( persona.title, style: TextStyle( fontSize: 12.5, fontWeight: FontWeight.w800, color: selected ? const Color(0xFFFFF9C4) : const Color(0xFFE8EAF6), ), ), ], ), ), ), ); } }