feat: 記録日時を一覧カードと詳細画面に表示
- sake_list_item: カード末尾に相対日付を追加 今日 / 昨日 / N日前 / M/D / YYYY/M/D - sake_basic_info_section: 蔵元行直下にカレンダーアイコン + 「YYYY年M月D日に記録」を追加 セット商品は非表示 - metadata.createdAt(非null保証)を使用、追加フィールド不要 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
fad896e817
commit
68723a884e
|
|
@ -8,6 +8,10 @@ import '../../../constants/app_constants.dart';
|
|||
import '../../../providers/theme_provider.dart';
|
||||
import '../../../services/mbti_compatibility_service.dart';
|
||||
|
||||
String _formatRecordedDate(DateTime date) {
|
||||
return '${date.year}年${date.month}月${date.day}日に記録';
|
||||
}
|
||||
|
||||
/// 銘柄名・蔵元/都道府県・タグ・AI確信度バッジ・MBTI相性バッジ・キャッチコピーを表示するセクション
|
||||
class SakeBasicInfoSection extends ConsumerWidget {
|
||||
final SakeItem sake;
|
||||
|
|
@ -161,6 +165,24 @@ class SakeBasicInfoSection extends ConsumerWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// 記録日
|
||||
if (sake.itemType != ItemType.set)
|
||||
Center(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(LucideIcons.calendarDays, size: 11, color: appColors.textTertiary),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
_formatRecordedDate(sake.metadata.createdAt),
|
||||
style: TextStyle(fontSize: 11, color: appColors.textTertiary),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// キャッチコピー(位置を銘柄名直下に移動して存在感を強調)
|
||||
|
|
|
|||
|
|
@ -188,6 +188,8 @@ class SakeListItem extends ConsumerWidget {
|
|||
if (!isMenuMode && sake.itemType != ItemType.set) ...[
|
||||
const SizedBox(height: 6),
|
||||
_buildSpecLine(context, appColors),
|
||||
const SizedBox(height: 4),
|
||||
_buildRecordedDate(appColors),
|
||||
],
|
||||
],
|
||||
),
|
||||
|
|
@ -200,6 +202,36 @@ class SakeListItem extends ConsumerWidget {
|
|||
); // Pressable
|
||||
}
|
||||
|
||||
/// 記録日(相対表示)
|
||||
Widget _buildRecordedDate(AppColors appColors) {
|
||||
final date = sake.metadata.createdAt;
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
final itemDay = DateTime(date.year, date.month, date.day);
|
||||
final diff = today.difference(itemDay).inDays;
|
||||
|
||||
final String label;
|
||||
if (diff == 0) {
|
||||
label = '今日';
|
||||
} else if (diff == 1) {
|
||||
label = '昨日';
|
||||
} else if (diff < 7) {
|
||||
label = '$diff日前';
|
||||
} else if (date.year == now.year) {
|
||||
label = '${date.month}/${date.day}';
|
||||
} else {
|
||||
label = '${date.year}/${date.month}/${date.day}';
|
||||
}
|
||||
|
||||
return Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: appColors.textTertiary,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 特定名称 + アルコール度数(どちらもある場合は両方、片方のみも対応)
|
||||
Widget _buildSpecLine(BuildContext context, AppColors appColors) {
|
||||
final type = sake.hiddenSpecs.type;
|
||||
|
|
|
|||
Loading…
Reference in New Issue