Skip to content

Commit

Permalink
Merge pull request #488 from ErBWs/main
Browse files Browse the repository at this point in the history
show info card airdate on phone devices
  • Loading branch information
Predidit authored Dec 19, 2024
2 parents fe1cfb1 + cb55c76 commit 6603b39
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/bean/card/bangumi_info_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ class _BangumiInfoCardVState extends State<BangumiInfoCardV> {
),
backgroundColor: Colors.transparent,
),
child: Text(widget.bangumiItem.type == 2 ? '番剧' : '其他',
style: style),
child:
Text('#${widget.bangumiItem.rank}', style: style),
),
const SizedBox(width: 7),
FilledButton.tonal(
Expand All @@ -121,8 +121,12 @@ class _BangumiInfoCardVState extends State<BangumiInfoCardV> {
),
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()
Expand All @@ -140,7 +144,8 @@ class _BangumiInfoCardVState extends State<BangumiInfoCardV> {
),
backgroundColor: Colors.transparent,
),
child: Text(widget.bangumiItem.airDate,
child: Text(
widget.bangumiItem.type == 2 ? '番剧' : '其他',
style: style),
),
],
Expand Down
10 changes: 10 additions & 0 deletions lib/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 6603b39

Please sign in to comment.