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:
Ponshu Developer 2026-04-16 14:01:17 +09:00
parent fad896e817
commit 68723a884e
2 changed files with 54 additions and 0 deletions

View File

@ -8,6 +8,10 @@ import '../../../constants/app_constants.dart';
import '../../../providers/theme_provider.dart'; import '../../../providers/theme_provider.dart';
import '../../../services/mbti_compatibility_service.dart'; import '../../../services/mbti_compatibility_service.dart';
String _formatRecordedDate(DateTime date) {
return '${date.year}${date.month}${date.day}日に記録';
}
/// /AI確信度バッジMBTI相性バッジ /// /AI確信度バッジMBTI相性バッジ
class SakeBasicInfoSection extends ConsumerWidget { class SakeBasicInfoSection extends ConsumerWidget {
final SakeItem sake; 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), const SizedBox(height: 20),
// 調 // 調

View File

@ -188,6 +188,8 @@ class SakeListItem extends ConsumerWidget {
if (!isMenuMode && sake.itemType != ItemType.set) ...[ if (!isMenuMode && sake.itemType != ItemType.set) ...[
const SizedBox(height: 6), const SizedBox(height: 6),
_buildSpecLine(context, appColors), _buildSpecLine(context, appColors),
const SizedBox(height: 4),
_buildRecordedDate(appColors),
], ],
], ],
), ),
@ -200,6 +202,36 @@ class SakeListItem extends ConsumerWidget {
); // Pressable ); // 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) { Widget _buildSpecLine(BuildContext context, AppColors appColors) {
final type = sake.hiddenSpecs.type; final type = sake.hiddenSpecs.type;