import 'package:flutter/material.dart'; import '../../data/db/app_database.dart'; /// reference 1건을 펼치기 카드로 표시. /// /// 본 이슈 (#226) 에선 url 표시만 (탭 시 launcher 호출 X — #FF1 이후). class ReferenceExpandCard extends StatelessWidget { const ReferenceExpandCard({super.key, required this.reference}); final ReferenceRow reference; @override Widget build(BuildContext context) { final kindLabel = switch (reference.kind) { 'paper' => '논문', 'podcast_episode' => '팟캐스트', 'book' => '서적', 'url' => '웹', 'korean_explainer' => '한국어 해설', _ => reference.kind, }; return Card( child: ExpansionTile( title: Text( reference.title, maxLines: 2, overflow: TextOverflow.ellipsis, ), subtitle: Text(kindLabel, style: Theme.of(context).textTheme.bodySmall), children: [ Padding( padding: const EdgeInsets.fromLTRB(16, 0, 16, 12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ if (reference.year != null) _row(context, '연도', reference.year.toString()), if (reference.journal != null) _row(context, '저널', reference.journal!), if (reference.publisher != null) _row(context, '출판', reference.publisher!), if (reference.episodeNumber != null) _row(context, '에피소드', reference.episodeNumber.toString()), if (reference.doi != null) _row(context, 'DOI', reference.doi!), if (reference.url != null) _row(context, 'URL', reference.url!), if (reference.note != null) _row(context, '메모', reference.note!), ], ), ), ], ), ); } Widget _row(BuildContext context, String label, String value) { return Padding( padding: const EdgeInsets.only(bottom: 2), child: Text.rich(TextSpan(children: [ TextSpan( text: '$label: ', style: const TextStyle(fontWeight: FontWeight.bold), ), TextSpan(text: value), ]), style: Theme.of(context).textTheme.bodySmall), ); } }