From cb55c767eabb6b7d2ea1e937cdf9f3286178e728 Mon Sep 17 00:00:00 2001 From: ErBW_s <94068488+ErBWs@users.noreply.github.com> Date: Thu, 19 Dec 2024 13:56:59 +0800 Subject: [PATCH] show info card airdate on phone devices --- lib/bean/card/bangumi_info_card.dart | 15 ++++++++++----- lib/utils/utils.dart | 10 ++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/bean/card/bangumi_info_card.dart b/lib/bean/card/bangumi_info_card.dart index aab031ab..cce215e6 100644 --- a/lib/bean/card/bangumi_info_card.dart +++ b/lib/bean/card/bangumi_info_card.dart @@ -106,8 +106,8 @@ class _BangumiInfoCardVState extends State { ), backgroundColor: Colors.transparent, ), - child: Text(widget.bangumiItem.type == 2 ? '番剧' : '其他', - style: style), + child: + Text('#${widget.bangumiItem.rank}', style: style), ), const SizedBox(width: 7), FilledButton.tonal( @@ -121,8 +121,12 @@ class _BangumiInfoCardVState extends State { ), backgroundColor: Colors.transparent, ), - child: - Text('#${widget.bangumiItem.rank}', style: style), + child: Text( + Utils.isCompact() + ? Utils.shrinkAirDate( + widget.bangumiItem.airDate) + : widget.bangumiItem.airDate, + style: style), ), Utils.isCompact() ? Container() @@ -140,7 +144,8 @@ class _BangumiInfoCardVState extends State { ), backgroundColor: Colors.transparent, ), - child: Text(widget.bangumiItem.airDate, + child: Text( + widget.bangumiItem.type == 2 ? '番剧' : '其他', style: style), ), ], diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 6ed59056..31cdf17e 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -231,6 +231,16 @@ class Utils { } } + static String shrinkAirDate(String airDate) { + try { + DateTime dateTime = DateTime.parse(airDate); + String dateWithoutDay = "${dateTime.year}-${dateTime.month.toString().padLeft(2, '0')}"; + return dateWithoutDay; + } catch (_) { + return airDate; + } + } + static String jsonToKazumiBase64(String jsonStr) { String base64Str = base64Encode(utf8.encode(jsonStr)); return 'kazumi://$base64Str';