Skip to content

基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。

replace child in PopupMenuButton with icon

ErBW_s3da65cda4ad0
diff --git a/lib/bean/widget/collect_button.dart b/lib/bean/widget/collect_button.dart
index 4de0986a..baa77693 100644
--- a/lib/bean/widget/collect_button.dart
+++ b/lib/bean/widget/collect_button.dart
@@ -6,6 +6,7 @@ import 'package:flutter_modular/flutter_modular.dart';
class CollectButton extends StatefulWidget {
const CollectButton(
{super.key, required this.bangumiItem, this.withRounder = true});
+
final BangumiItem bangumiItem;
final bool withRounder;
@@ -27,7 +28,7 @@ class _CollectButtonState extends State<CollectButton> {
super.initState();
}
- String getTypeStringByInt(int collectType){
+ String getTypeStringByInt(int collectType) {
switch (collectType) {
case 1:
return "在看";
@@ -43,6 +44,7 @@ class _CollectButtonState extends State<CollectButton> {
return "未追";
}
}
+
IconData getIconByInt(int collectType) {
switch (collectType) {
case 1:
@@ -65,16 +67,14 @@ class _CollectButtonState extends State<CollectButton> {
collectType = collectController.getCollectType(widget.bangumiItem);
return PopupMenuButton(
tooltip: '',
- child: widget.withRounder
- ? NonClickableIconButton(
- icon: getIconByInt(collectType),
+ icon: widget.withRounder
+ ? Icon(
+ getIconByInt(collectType),
+ color: Theme.of(context).colorScheme.onSecondaryContainer,
)
- : Padding(
- padding: const EdgeInsets.all(8.0),
- child: Icon(
- getIconByInt(collectType),
- color: Colors.white,
- ),
+ : Icon(
+ getIconByInt(collectType),
+ color: Colors.white,
),
itemBuilder: (context) {
return List.generate(
@@ -100,34 +100,3 @@ class _CollectButtonState extends State<CollectButton> {
);
}
}
-
-class NonClickableIconButton extends StatelessWidget {
- final IconData icon;
- final Color? iconColor;
- final Color? backgroundColor;
- final double padding;
-
- const NonClickableIconButton({
- super.key,
- required this.icon,
- this.iconColor,
- this.backgroundColor,
- this.padding = 8.0,
- });
-
- @override
- Widget build(BuildContext context) {
- final Color effectiveBackgroundColor =
- backgroundColor ?? Theme.of(context).colorScheme.secondaryContainer;
- final Color effectiveIconColor =
- iconColor ?? Theme.of(context).colorScheme.onSecondaryContainer;
- return Container(
- padding: EdgeInsets.all(padding),
- decoration: BoxDecoration(
- color: effectiveBackgroundColor,
- shape: BoxShape.circle,
- ),
- child: Icon(icon, color: effectiveIconColor),
- );
- }
-}