Skip to content

Commit

Permalink
feat: 接收自定义组件传入
Browse files Browse the repository at this point in the history
  • Loading branch information
guozhigq committed Mar 23, 2024
1 parent 7b15f19 commit b5a46d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/plugin/pl_player/models/bottom_control_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ enum BottomControlType {
fit,
speed,
fullscreen,
custom,
}
19 changes: 17 additions & 2 deletions lib/plugin/pl_player/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class PLVideoPlayer extends StatefulWidget {
this.bottomControl,
this.danmuWidget,
this.bottomList,
this.customWidget,
this.customWidgets,
super.key,
});

Expand All @@ -43,6 +45,10 @@ class PLVideoPlayer extends StatefulWidget {
final PreferredSizeWidget? bottomControl;
final Widget? danmuWidget;
final List<BottomControlType>? bottomList;
// List<Widget> or Widget

final Widget? customWidget;
final List<Widget>? customWidgets;

@override
State<PLVideoPlayer> createState() => _PLVideoPlayerState();
Expand Down Expand Up @@ -311,7 +317,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
),
};
final List<Widget> list = [];
var userSpecifyItem = widget.bottomList ??
List<BottomControlType> userSpecifyItem = widget.bottomList ??
[
BottomControlType.playOrPause,
BottomControlType.time,
Expand All @@ -320,7 +326,16 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
BottomControlType.fullscreen,
];
for (var i = 0; i < userSpecifyItem.length; i++) {
list.add(videoProgressWidgets[userSpecifyItem[i]]!);
if (userSpecifyItem[i] == BottomControlType.custom) {
if (widget.customWidget != null && widget.customWidget is Widget) {
list.add(widget.customWidget!);
}
if (widget.customWidgets != null && widget.customWidgets!.isNotEmpty) {
list.addAll(widget.customWidgets!);
}
} else {
list.add(videoProgressWidgets[userSpecifyItem[i]]!);
}
}
return list;
}
Expand Down

0 comments on commit b5a46d1

Please sign in to comment.