From 98985a7fa4de163c07e1ded9a75f05b64622d985 Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Wed, 14 May 2025 16:36:44 +0800 Subject: [PATCH] episode badge Signed-off-by: bggRGjQaUbCoE --- lib/common/widgets/badge.dart | 5 +++++ lib/models/common/badge_type.dart | 1 + lib/pages/episode_panel/view.dart | 22 +++++++++++----------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/common/widgets/badge.dart b/lib/common/widgets/badge.dart index 8875b8c3..c5c963af 100644 --- a/lib/common/widgets/badge.dart +++ b/lib/common/widgets/badge.dart @@ -1,6 +1,7 @@ import 'package:PiliPlus/models/common/badge_type.dart'; import 'package:PiliPlus/utils/extension.dart'; import 'package:flutter/material.dart'; +import 'package:get/get.dart'; class PBadge extends StatelessWidget { final String? text; @@ -68,6 +69,10 @@ class PBadge extends StatelessWidget { color = theme.secondary; bgColor = Colors.transparent; borderColor = theme.secondary; + case PBadgeType.free: + bgColor = + Get.isDarkMode ? const Color(0xFFD66011) : const Color(0xFFFF7F24); + color = Colors.white; } late EdgeInsets paddingStyle = diff --git a/lib/models/common/badge_type.dart b/lib/models/common/badge_type.dart index 4e2f2e4b..65994173 100644 --- a/lib/models/common/badge_type.dart +++ b/lib/models/common/badge_type.dart @@ -7,6 +7,7 @@ enum PBadgeType { error, line_primary, line_secondary, + free, } enum PBadgeSize { medium, small } diff --git a/lib/pages/episode_panel/view.dart b/lib/pages/episode_panel/view.dart index f7de4040..ba25513a 100644 --- a/lib/pages/episode_panel/view.dart +++ b/lib/pages/episode_panel/view.dart @@ -430,6 +430,17 @@ class _EpisodePanelState extends CommonSlidePageState bottom: 6.0, type: PBadgeType.gray, ), + if (episode.badge != null) + PBadge( + text: episode.badge, + top: 6, + right: 6, + type: switch (episode.badge) { + '会员' => PBadgeType.primary, + '限免' => PBadgeType.free, + _ => PBadgeType.gray, + }, + ), ], ); }, @@ -497,17 +508,6 @@ class _EpisodePanelState extends CommonSlidePageState ], ), ), - if (episode.badge != null) ...[ - if (episode.badge == '会员') - Image.asset( - 'assets/images/big-vip.png', - height: 20, - semanticLabel: "大会员", - ) - else - Text(episode.badge), - const SizedBox(width: 10), - ], ], ), ),