mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-08-05 18:20:10 +08:00
opt: ActionItem (#974)
This commit is contained in:
committed by
GitHub
parent
fac37e59aa
commit
aaad7fc6dc
@@ -1,4 +1,4 @@
|
|||||||
import 'dart:async' show Timer;
|
import 'dart:async' show FutureOr, Timer;
|
||||||
|
|
||||||
import 'package:PiliPlus/http/fav.dart';
|
import 'package:PiliPlus/http/fav.dart';
|
||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
@@ -38,6 +38,17 @@ abstract class CommonIntroController extends GetxController {
|
|||||||
|
|
||||||
final Rx<List<VideoTagItem>?> videoTags = Rx<List<VideoTagItem>?>(null);
|
final Rx<List<VideoTagItem>?> videoTags = Rx<List<VideoTagItem>?>(null);
|
||||||
|
|
||||||
|
bool get hasTriple => hasLike.value && hasCoin && hasFav.value;
|
||||||
|
|
||||||
|
bool isProcessing = false;
|
||||||
|
Future<void> handleAction(FutureOr Function() action) async {
|
||||||
|
if (!isProcessing) {
|
||||||
|
isProcessing = true;
|
||||||
|
await action();
|
||||||
|
isProcessing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Set? favIds;
|
Set? favIds;
|
||||||
final Rx<FavFolderData> favFolderData = FavFolderData().obs;
|
final Rx<FavFolderData> favFolderData = FavFolderData().obs;
|
||||||
|
|
||||||
@@ -54,7 +65,7 @@ abstract class CommonIntroController extends GetxController {
|
|||||||
bool prevPlay();
|
bool prevPlay();
|
||||||
bool nextPlay();
|
bool nextPlay();
|
||||||
|
|
||||||
void actionLikeVideo();
|
Future<void> actionLikeVideo();
|
||||||
void actionCoinVideo();
|
void actionCoinVideo();
|
||||||
void actionTriple();
|
void actionTriple();
|
||||||
void actionShareVideo(BuildContext context);
|
void actionShareVideo(BuildContext context);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import 'package:PiliPlus/http/loading_state.dart';
|
|||||||
import 'package:PiliPlus/models_new/dynamic/dyn_mention/group.dart';
|
import 'package:PiliPlus/models_new/dynamic/dyn_mention/group.dart';
|
||||||
import 'package:PiliPlus/pages/dynamics_mention/controller.dart';
|
import 'package:PiliPlus/pages/dynamics_mention/controller.dart';
|
||||||
import 'package:PiliPlus/pages/dynamics_mention/widgets/item.dart';
|
import 'package:PiliPlus/pages/dynamics_mention/widgets/item.dart';
|
||||||
import 'package:PiliPlus/pages/search/controller.dart' show SearchKeywordMixin;
|
import 'package:PiliPlus/pages/search/controller.dart' show SearchState;
|
||||||
import 'package:PiliPlus/utils/context_ext.dart';
|
import 'package:PiliPlus/utils/context_ext.dart';
|
||||||
import 'package:PiliPlus/utils/extension.dart';
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -58,8 +58,7 @@ class DynMentionPanel extends StatefulWidget {
|
|||||||
State<DynMentionPanel> createState() => _DynMentionPanelState();
|
State<DynMentionPanel> createState() => _DynMentionPanelState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DynMentionPanelState extends State<DynMentionPanel>
|
class _DynMentionPanelState extends SearchState<DynMentionPanel> {
|
||||||
with SearchKeywordMixin {
|
|
||||||
final _controller = Get.put(DynMentionController());
|
final _controller = Get.put(DynMentionController());
|
||||||
@override
|
@override
|
||||||
Duration get duration => const Duration(milliseconds: 300);
|
Duration get duration => const Duration(milliseconds: 300);
|
||||||
@@ -70,13 +69,6 @@ class _DynMentionPanelState extends State<DynMentionPanel>
|
|||||||
if (_controller.loadingState.value is Error) {
|
if (_controller.loadingState.value is Error) {
|
||||||
_controller.onReload();
|
_controller.onReload();
|
||||||
}
|
}
|
||||||
subInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
subDispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import 'package:PiliPlus/http/loading_state.dart';
|
|||||||
import 'package:PiliPlus/models_new/dynamic/dyn_topic_top/topic_item.dart';
|
import 'package:PiliPlus/models_new/dynamic/dyn_topic_top/topic_item.dart';
|
||||||
import 'package:PiliPlus/pages/dynamics_select_topic/controller.dart';
|
import 'package:PiliPlus/pages/dynamics_select_topic/controller.dart';
|
||||||
import 'package:PiliPlus/pages/dynamics_select_topic/widgets/item.dart';
|
import 'package:PiliPlus/pages/dynamics_select_topic/widgets/item.dart';
|
||||||
import 'package:PiliPlus/pages/search/controller.dart' show SearchKeywordMixin;
|
import 'package:PiliPlus/pages/search/controller.dart' show SearchState;
|
||||||
import 'package:PiliPlus/utils/context_ext.dart';
|
import 'package:PiliPlus/utils/context_ext.dart';
|
||||||
import 'package:PiliPlus/utils/extension.dart';
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -56,8 +56,7 @@ class SelectTopicPanel extends StatefulWidget {
|
|||||||
State<SelectTopicPanel> createState() => _SelectTopicPanelState();
|
State<SelectTopicPanel> createState() => _SelectTopicPanelState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SelectTopicPanelState extends State<SelectTopicPanel>
|
class _SelectTopicPanelState extends SearchState<SelectTopicPanel> {
|
||||||
with SearchKeywordMixin {
|
|
||||||
final _controller = Get.put(SelectTopicController());
|
final _controller = Get.put(SelectTopicController());
|
||||||
@override
|
@override
|
||||||
Duration get duration => const Duration(milliseconds: 300);
|
Duration get duration => const Duration(milliseconds: 300);
|
||||||
@@ -68,13 +67,6 @@ class _SelectTopicPanelState extends State<SelectTopicPanel>
|
|||||||
if (_controller.loadingState.value is Error) {
|
if (_controller.loadingState.value is Error) {
|
||||||
_controller.onReload();
|
_controller.onReload();
|
||||||
}
|
}
|
||||||
subInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
subDispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -30,6 +30,23 @@ mixin SearchKeywordMixin {
|
|||||||
void subDispose() {
|
void subDispose() {
|
||||||
sub?.cancel();
|
sub?.cancel();
|
||||||
ctr?.close();
|
ctr?.close();
|
||||||
|
sub = null;
|
||||||
|
ctr = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class SearchState<T extends StatefulWidget> extends State<T>
|
||||||
|
with SearchKeywordMixin {
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
subDispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
subInit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||||
import 'package:PiliPlus/pages/search/controller.dart' show SearchKeywordMixin;
|
import 'package:PiliPlus/pages/search/controller.dart' show SearchState;
|
||||||
import 'package:PiliPlus/pages/setting/models/extra_settings.dart';
|
import 'package:PiliPlus/pages/setting/models/extra_settings.dart';
|
||||||
import 'package:PiliPlus/pages/setting/models/model.dart';
|
import 'package:PiliPlus/pages/setting/models/model.dart';
|
||||||
import 'package:PiliPlus/pages/setting/models/play_settings.dart';
|
import 'package:PiliPlus/pages/setting/models/play_settings.dart';
|
||||||
@@ -19,8 +19,7 @@ class SettingsSearchPage extends StatefulWidget {
|
|||||||
State<SettingsSearchPage> createState() => _SettingsSearchPageState();
|
State<SettingsSearchPage> createState() => _SettingsSearchPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SettingsSearchPageState extends State<SettingsSearchPage>
|
class _SettingsSearchPageState extends SearchState<SettingsSearchPage> {
|
||||||
with SearchKeywordMixin {
|
|
||||||
final _textEditingController = TextEditingController();
|
final _textEditingController = TextEditingController();
|
||||||
final RxList<SettingsModel> _list = <SettingsModel>[].obs;
|
final RxList<SettingsModel> _list = <SettingsModel>[].obs;
|
||||||
late final _settings = [
|
late final _settings = [
|
||||||
@@ -32,12 +31,6 @@ class _SettingsSearchPageState extends State<SettingsSearchPage>
|
|||||||
...styleSettings,
|
...styleSettings,
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
subInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onKeywordChanged(String value) {
|
void onKeywordChanged(String value) {
|
||||||
if (value.isEmpty) {
|
if (value.isEmpty) {
|
||||||
@@ -58,7 +51,6 @@ class _SettingsSearchPageState extends State<SettingsSearchPage>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
subDispose();
|
|
||||||
_textEditingController.dispose();
|
_textEditingController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import 'package:PiliPlus/pages/video/controller.dart';
|
|||||||
import 'package:PiliPlus/pages/video/introduction/pgc/controller.dart';
|
import 'package:PiliPlus/pages/video/introduction/pgc/controller.dart';
|
||||||
import 'package:PiliPlus/pages/video/introduction/pgc/widgets/pgc_panel.dart';
|
import 'package:PiliPlus/pages/video/introduction/pgc/widgets/pgc_panel.dart';
|
||||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/action_item.dart';
|
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/action_item.dart';
|
||||||
|
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/triple_state.dart';
|
||||||
import 'package:PiliPlus/utils/num_util.dart';
|
import 'package:PiliPlus/utils/num_util.dart';
|
||||||
import 'package:PiliPlus/utils/page_utils.dart';
|
import 'package:PiliPlus/utils/page_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -39,11 +40,7 @@ class PgcIntroPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _PgcIntroPageState extends State<PgcIntroPage>
|
class _PgcIntroPageState extends State<PgcIntroPage>
|
||||||
with
|
with AutomaticKeepAliveClientMixin {
|
||||||
AutomaticKeepAliveClientMixin,
|
|
||||||
SingleTickerProviderStateMixin,
|
|
||||||
TripleAnimMixin {
|
|
||||||
@override
|
|
||||||
late PgcIntroController introController;
|
late PgcIntroController introController;
|
||||||
late VideoDetailController videoDetailCtr;
|
late VideoDetailController videoDetailCtr;
|
||||||
|
|
||||||
@@ -407,68 +404,75 @@ class _PgcIntroPageState extends State<PgcIntroPage>
|
|||||||
) {
|
) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: 48,
|
height: 48,
|
||||||
child: Row(
|
child: TripleBuilder(
|
||||||
children: [
|
introController: introController,
|
||||||
Obx(
|
builder: (context, tripleAnimation, onStartTriple, onCancelTriple) {
|
||||||
() => ActionItem(
|
return Row(
|
||||||
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
children: [
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
Obx(
|
||||||
onTap: () => handleAction(introController.actionLikeVideo),
|
() => ActionItem(
|
||||||
selectStatus: introController.hasLike.value,
|
animation: tripleAnimation,
|
||||||
semanticsLabel: '点赞',
|
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||||
text: NumUtil.numFormat(item.stat!.like),
|
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
||||||
controller: animController,
|
onTap: () => introController.handleAction(
|
||||||
animation: animation,
|
introController.actionLikeVideo,
|
||||||
onStartTriple: onStartTriple,
|
),
|
||||||
onCancelTriple: onCancelTriple,
|
selectStatus: introController.hasLike.value,
|
||||||
),
|
semanticsLabel: '点赞',
|
||||||
),
|
text: NumUtil.numFormat(item.stat!.like),
|
||||||
Obx(
|
onStartTriple: onStartTriple,
|
||||||
() => ActionItem(
|
onCancelTriple: onCancelTriple,
|
||||||
icon: const Icon(FontAwesomeIcons.b),
|
),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.b),
|
|
||||||
onTap: introController.actionCoinVideo,
|
|
||||||
selectStatus: introController.hasCoin,
|
|
||||||
semanticsLabel: '投币',
|
|
||||||
text: NumUtil.numFormat(item.stat!.coin),
|
|
||||||
controller: animController,
|
|
||||||
animation: animation,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Obx(
|
|
||||||
() => ActionItem(
|
|
||||||
icon: const Icon(FontAwesomeIcons.star),
|
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidStar),
|
|
||||||
onTap: () => introController.showFavBottomSheet(context),
|
|
||||||
onLongPress: () => introController.showFavBottomSheet(
|
|
||||||
context,
|
|
||||||
isLongPress: true,
|
|
||||||
),
|
),
|
||||||
selectStatus: introController.hasFav.value,
|
Obx(
|
||||||
semanticsLabel: '收藏',
|
() => ActionItem(
|
||||||
text: NumUtil.numFormat(item.stat!.favorite),
|
animation: tripleAnimation,
|
||||||
controller: animController,
|
icon: const Icon(FontAwesomeIcons.b),
|
||||||
animation: animation,
|
selectIcon: const Icon(FontAwesomeIcons.b),
|
||||||
),
|
onTap: () => introController.handleAction(
|
||||||
),
|
introController.actionCoinVideo,
|
||||||
Obx(
|
),
|
||||||
() => ActionItem(
|
selectStatus: introController.hasCoin,
|
||||||
icon: const Icon(FontAwesomeIcons.clock),
|
semanticsLabel: '投币',
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidClock),
|
text: NumUtil.numFormat(item.stat!.coin),
|
||||||
onTap: () => handleAction(introController.viewLater),
|
),
|
||||||
selectStatus: introController.hasLater.value,
|
),
|
||||||
semanticsLabel: '再看',
|
Obx(
|
||||||
text: '再看',
|
() => ActionItem(
|
||||||
),
|
animation: tripleAnimation,
|
||||||
),
|
icon: const Icon(FontAwesomeIcons.star),
|
||||||
ActionItem(
|
selectIcon: const Icon(FontAwesomeIcons.solidStar),
|
||||||
icon: const Icon(FontAwesomeIcons.shareFromSquare),
|
onTap: () => introController.showFavBottomSheet(context),
|
||||||
onTap: () => introController.actionShareVideo(context),
|
onLongPress: () => introController.showFavBottomSheet(
|
||||||
selectStatus: false,
|
context,
|
||||||
semanticsLabel: '转发',
|
isLongPress: true,
|
||||||
text: NumUtil.numFormat(item.stat!.share),
|
),
|
||||||
),
|
selectStatus: introController.hasFav.value,
|
||||||
],
|
semanticsLabel: '收藏',
|
||||||
|
text: NumUtil.numFormat(item.stat!.favorite),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Obx(
|
||||||
|
() => ActionItem(
|
||||||
|
icon: const Icon(FontAwesomeIcons.clock),
|
||||||
|
selectIcon: const Icon(FontAwesomeIcons.solidClock),
|
||||||
|
onTap: () =>
|
||||||
|
introController.handleAction(introController.viewLater),
|
||||||
|
selectStatus: introController.hasLater.value,
|
||||||
|
semanticsLabel: '再看',
|
||||||
|
text: '再看',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ActionItem(
|
||||||
|
icon: const Icon(FontAwesomeIcons.shareFromSquare),
|
||||||
|
onTap: () => introController.actionShareVideo(context),
|
||||||
|
selectStatus: false,
|
||||||
|
semanticsLabel: '转发',
|
||||||
|
text: NumUtil.numFormat(item.stat!.share),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
|||||||
|
|
||||||
// 投币
|
// 投币
|
||||||
@override
|
@override
|
||||||
void actionCoinVideo() {
|
Future<void> actionCoinVideo() async {
|
||||||
if (!accountService.isLogin.value) {
|
if (!accountService.isLogin.value) {
|
||||||
SmartDialog.showToast('账号未登录');
|
SmartDialog.showToast('账号未登录');
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import 'package:PiliPlus/pages/video/introduction/ugc/controller.dart';
|
|||||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/action_item.dart';
|
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/action_item.dart';
|
||||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/page.dart';
|
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/page.dart';
|
||||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/season.dart';
|
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/season.dart';
|
||||||
|
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/triple_state.dart';
|
||||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||||
import 'package:PiliPlus/utils/context_ext.dart';
|
import 'package:PiliPlus/utils/context_ext.dart';
|
||||||
import 'package:PiliPlus/utils/date_util.dart';
|
import 'package:PiliPlus/utils/date_util.dart';
|
||||||
@@ -51,11 +52,7 @@ class UgcIntroPanel extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _UgcIntroPanelState extends State<UgcIntroPanel>
|
class _UgcIntroPanelState extends State<UgcIntroPanel>
|
||||||
with
|
with AutomaticKeepAliveClientMixin {
|
||||||
AutomaticKeepAliveClientMixin,
|
|
||||||
SingleTickerProviderStateMixin,
|
|
||||||
TripleAnimMixin {
|
|
||||||
@override
|
|
||||||
late UgcIntroController introController;
|
late UgcIntroController introController;
|
||||||
late final VideoDetailController videoDetailCtr =
|
late final VideoDetailController videoDetailCtr =
|
||||||
Get.find<VideoDetailController>(tag: widget.heroTag);
|
Get.find<VideoDetailController>(tag: widget.heroTag);
|
||||||
@@ -509,86 +506,95 @@ class _UgcIntroPanelState extends State<UgcIntroPanel>
|
|||||||
) {
|
) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: 48,
|
height: 48,
|
||||||
child: Row(
|
child: TripleBuilder(
|
||||||
children: [
|
introController: introController,
|
||||||
Obx(
|
builder: (context, tripleAnimation, onStartTriple, onCancelTriple) {
|
||||||
() => ActionItem(
|
return Row(
|
||||||
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
children: [
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
Obx(
|
||||||
onTap: () => handleAction(introController.actionLikeVideo),
|
() => ActionItem(
|
||||||
selectStatus: introController.hasLike.value,
|
animation: tripleAnimation,
|
||||||
semanticsLabel: '点赞',
|
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||||
text: !isLoading
|
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
||||||
? NumUtil.numFormat(videoDetail.stat!.like)
|
onTap: () => introController.handleAction(
|
||||||
: null,
|
introController.actionLikeVideo,
|
||||||
controller: animController,
|
),
|
||||||
animation: animation,
|
selectStatus: introController.hasLike.value,
|
||||||
onStartTriple: onStartTriple,
|
semanticsLabel: '点赞',
|
||||||
onCancelTriple: onCancelTriple,
|
text: !isLoading
|
||||||
),
|
? NumUtil.numFormat(videoDetail.stat!.like)
|
||||||
),
|
: null,
|
||||||
Obx(
|
onStartTriple: onStartTriple,
|
||||||
() => ActionItem(
|
onCancelTriple: onCancelTriple,
|
||||||
icon: const Icon(FontAwesomeIcons.thumbsDown),
|
),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidThumbsDown),
|
|
||||||
onTap: () => handleAction(introController.actionDislikeVideo),
|
|
||||||
selectStatus: introController.hasDislike.value,
|
|
||||||
semanticsLabel: '点踩',
|
|
||||||
text: "点踩",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Obx(
|
|
||||||
() => ActionItem(
|
|
||||||
icon: const Icon(FontAwesomeIcons.b),
|
|
||||||
selectIcon: const Icon(FontAwesomeIcons.b),
|
|
||||||
onTap: introController.actionCoinVideo,
|
|
||||||
selectStatus: introController.hasCoin,
|
|
||||||
semanticsLabel: '投币',
|
|
||||||
text: !isLoading
|
|
||||||
? NumUtil.numFormat(videoDetail.stat!.coin)
|
|
||||||
: null,
|
|
||||||
controller: animController,
|
|
||||||
animation: animation,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Obx(
|
|
||||||
() => ActionItem(
|
|
||||||
icon: const Icon(FontAwesomeIcons.star),
|
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidStar),
|
|
||||||
onTap: () => introController.showFavBottomSheet(context),
|
|
||||||
onLongPress: () => introController.showFavBottomSheet(
|
|
||||||
context,
|
|
||||||
isLongPress: true,
|
|
||||||
),
|
),
|
||||||
selectStatus: introController.hasFav.value,
|
Obx(
|
||||||
semanticsLabel: '收藏',
|
() => ActionItem(
|
||||||
text: !isLoading
|
icon: const Icon(FontAwesomeIcons.thumbsDown),
|
||||||
? NumUtil.numFormat(videoDetail.stat!.favorite)
|
selectIcon: const Icon(FontAwesomeIcons.solidThumbsDown),
|
||||||
: null,
|
onTap: () => introController.handleAction(
|
||||||
controller: animController,
|
introController.actionDislikeVideo,
|
||||||
animation: animation,
|
),
|
||||||
),
|
selectStatus: introController.hasDislike.value,
|
||||||
),
|
semanticsLabel: '点踩',
|
||||||
Obx(
|
text: "点踩",
|
||||||
() => ActionItem(
|
),
|
||||||
icon: const Icon(FontAwesomeIcons.clock),
|
),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidClock),
|
Obx(
|
||||||
onTap: () => handleAction(introController.viewLater),
|
() => ActionItem(
|
||||||
selectStatus: introController.hasLater.value,
|
animation: tripleAnimation,
|
||||||
semanticsLabel: '再看',
|
icon: const Icon(FontAwesomeIcons.b),
|
||||||
text: '再看',
|
selectIcon: const Icon(FontAwesomeIcons.b),
|
||||||
),
|
onTap: () => introController.handleAction(
|
||||||
),
|
introController.actionCoinVideo,
|
||||||
ActionItem(
|
),
|
||||||
icon: const Icon(FontAwesomeIcons.shareFromSquare),
|
selectStatus: introController.hasCoin,
|
||||||
onTap: () => introController.actionShareVideo(context),
|
semanticsLabel: '投币',
|
||||||
selectStatus: false,
|
text: !isLoading
|
||||||
semanticsLabel: '分享',
|
? NumUtil.numFormat(videoDetail.stat!.coin)
|
||||||
text: !isLoading
|
: null,
|
||||||
? NumUtil.numFormat(videoDetail.stat!.share!)
|
),
|
||||||
: null,
|
),
|
||||||
),
|
Obx(
|
||||||
],
|
() => ActionItem(
|
||||||
|
animation: tripleAnimation,
|
||||||
|
icon: const Icon(FontAwesomeIcons.star),
|
||||||
|
selectIcon: const Icon(FontAwesomeIcons.solidStar),
|
||||||
|
onTap: () => introController.showFavBottomSheet(context),
|
||||||
|
onLongPress: () => introController.showFavBottomSheet(
|
||||||
|
context,
|
||||||
|
isLongPress: true,
|
||||||
|
),
|
||||||
|
selectStatus: introController.hasFav.value,
|
||||||
|
semanticsLabel: '收藏',
|
||||||
|
text: !isLoading
|
||||||
|
? NumUtil.numFormat(videoDetail.stat!.favorite)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Obx(
|
||||||
|
() => ActionItem(
|
||||||
|
icon: const Icon(FontAwesomeIcons.clock),
|
||||||
|
selectIcon: const Icon(FontAwesomeIcons.solidClock),
|
||||||
|
onTap: () =>
|
||||||
|
introController.handleAction(introController.viewLater),
|
||||||
|
selectStatus: introController.hasLater.value,
|
||||||
|
semanticsLabel: '再看',
|
||||||
|
text: '再看',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ActionItem(
|
||||||
|
icon: const Icon(FontAwesomeIcons.shareFromSquare),
|
||||||
|
onTap: () => introController.actionShareVideo(context),
|
||||||
|
selectStatus: false,
|
||||||
|
semanticsLabel: '分享',
|
||||||
|
text: !isLoading
|
||||||
|
? NumUtil.numFormat(videoDetail.stat!.share!)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,95 +1,6 @@
|
|||||||
import 'dart:async' show Timer, FutureOr;
|
|
||||||
import 'dart:math' show pi;
|
import 'dart:math' show pi;
|
||||||
|
|
||||||
import 'package:PiliPlus/pages/common/common_intro_controller.dart';
|
|
||||||
import 'package:PiliPlus/utils/feed_back.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart' show HapticFeedback;
|
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
||||||
|
|
||||||
mixin TripleAnimMixin<T extends StatefulWidget>
|
|
||||||
on SingleTickerProviderStateMixin<T> {
|
|
||||||
CommonIntroController get introController;
|
|
||||||
late AnimationController animController;
|
|
||||||
late Animation<double> animation;
|
|
||||||
|
|
||||||
late int _lastTime;
|
|
||||||
Timer? _timer;
|
|
||||||
|
|
||||||
bool get _hasTriple =>
|
|
||||||
introController.hasLike.value &&
|
|
||||||
introController.hasCoin &&
|
|
||||||
introController.hasFav.value;
|
|
||||||
|
|
||||||
bool isProcessing = false;
|
|
||||||
Future<void> handleAction(FutureOr Function() action) async {
|
|
||||||
if (!isProcessing) {
|
|
||||||
isProcessing = true;
|
|
||||||
await action();
|
|
||||||
isProcessing = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
animController = AnimationController(
|
|
||||||
vsync: this,
|
|
||||||
duration: const Duration(milliseconds: 1500),
|
|
||||||
reverseDuration: const Duration(milliseconds: 400),
|
|
||||||
);
|
|
||||||
|
|
||||||
animation = Tween<double>(begin: 0, end: -2 * pi).animate(
|
|
||||||
CurvedAnimation(
|
|
||||||
parent: animController,
|
|
||||||
curve: Curves.easeInOut,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void onStartTriple() {
|
|
||||||
_lastTime = DateTime.now().millisecondsSinceEpoch;
|
|
||||||
_timer ??= Timer(const Duration(milliseconds: 200), () {
|
|
||||||
HapticFeedback.lightImpact();
|
|
||||||
if (_hasTriple) {
|
|
||||||
SmartDialog.showToast('已经完成三连');
|
|
||||||
} else {
|
|
||||||
animController.forward().whenComplete(() {
|
|
||||||
animController.reset();
|
|
||||||
handleAction(introController.actionTriple);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
cancelTimer();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void onCancelTriple(bool isCancel) {
|
|
||||||
int duration = DateTime.now().millisecondsSinceEpoch - _lastTime;
|
|
||||||
if (duration >= 200 && duration < 1500) {
|
|
||||||
if (!_hasTriple) {
|
|
||||||
animController.reverse();
|
|
||||||
}
|
|
||||||
} else if (duration < 200) {
|
|
||||||
cancelTimer();
|
|
||||||
if (!isCancel) {
|
|
||||||
feedBack();
|
|
||||||
handleAction(introController.actionLikeVideo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cancelTimer() {
|
|
||||||
_timer?.cancel();
|
|
||||||
_timer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
cancelTimer();
|
|
||||||
animController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ActionItem extends StatelessWidget {
|
class ActionItem extends StatelessWidget {
|
||||||
const ActionItem({
|
const ActionItem({
|
||||||
@@ -102,11 +13,11 @@ class ActionItem extends StatelessWidget {
|
|||||||
this.selectStatus = false,
|
this.selectStatus = false,
|
||||||
required this.semanticsLabel,
|
required this.semanticsLabel,
|
||||||
this.expand = true,
|
this.expand = true,
|
||||||
this.controller,
|
|
||||||
this.animation,
|
this.animation,
|
||||||
this.onStartTriple,
|
this.onStartTriple,
|
||||||
this.onCancelTriple,
|
this.onCancelTriple,
|
||||||
}) : isThumbsUp = onStartTriple != null;
|
}) : assert(!selectStatus || selectIcon != null),
|
||||||
|
_isThumbsUp = onStartTriple != null;
|
||||||
|
|
||||||
final Icon icon;
|
final Icon icon;
|
||||||
final Icon? selectIcon;
|
final Icon? selectIcon;
|
||||||
@@ -116,87 +27,85 @@ class ActionItem extends StatelessWidget {
|
|||||||
final bool selectStatus;
|
final bool selectStatus;
|
||||||
final String semanticsLabel;
|
final String semanticsLabel;
|
||||||
final bool expand;
|
final bool expand;
|
||||||
final AnimationController? controller;
|
|
||||||
final Animation<double>? animation;
|
final Animation<double>? animation;
|
||||||
final VoidCallback? onStartTriple;
|
final VoidCallback? onStartTriple;
|
||||||
final ValueChanged<bool>? onCancelTriple;
|
final void Function([bool])? onCancelTriple;
|
||||||
final bool isThumbsUp;
|
final bool _isThumbsUp;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
Widget? textWidget;
|
Widget child = Icon(
|
||||||
if (expand) {
|
selectStatus ? selectIcon!.icon! : icon.icon,
|
||||||
final hasText = text != null;
|
size: 18,
|
||||||
textWidget = Text(
|
color: selectStatus
|
||||||
hasText ? text! : '-',
|
? theme.colorScheme.primary
|
||||||
key: hasText ? ValueKey(text!) : null,
|
: icon.color ?? theme.colorScheme.outline,
|
||||||
style: TextStyle(
|
);
|
||||||
color: selectStatus
|
|
||||||
? theme.colorScheme.primary
|
if (animation != null) {
|
||||||
: theme.colorScheme.outline,
|
child = Stack(
|
||||||
fontSize: theme.textTheme.labelSmall!.fontSize,
|
clipBehavior: Clip.none,
|
||||||
),
|
alignment: Alignment.center,
|
||||||
);
|
children: [
|
||||||
if (hasText) {
|
AnimatedBuilder(
|
||||||
textWidget = AnimatedSwitcher(
|
animation: animation!,
|
||||||
duration: const Duration(milliseconds: 300),
|
builder: (context, child) => CustomPaint(
|
||||||
transitionBuilder: (Widget child, Animation<double> animation) {
|
size: const Size.square(28),
|
||||||
return ScaleTransition(scale: animation, child: child);
|
painter: _ArcPainter(
|
||||||
},
|
color: theme.colorScheme.primary,
|
||||||
child: textWidget,
|
sweepAngle: animation!.value,
|
||||||
);
|
),
|
||||||
}
|
|
||||||
}
|
|
||||||
final child = Material(
|
|
||||||
type: MaterialType.transparency,
|
|
||||||
child: InkWell(
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(6)),
|
|
||||||
onTap: isThumbsUp
|
|
||||||
? null
|
|
||||||
: () {
|
|
||||||
feedBack();
|
|
||||||
onTap?.call();
|
|
||||||
},
|
|
||||||
onLongPress: isThumbsUp ? null : onLongPress,
|
|
||||||
onTapDown: isThumbsUp ? (details) => onStartTriple!() : null,
|
|
||||||
onTapUp: isThumbsUp ? (details) => onCancelTriple!(false) : null,
|
|
||||||
onTapCancel: isThumbsUp ? () => onCancelTriple!(true) : null,
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Stack(
|
|
||||||
clipBehavior: Clip.none,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
children: [
|
|
||||||
if (animation != null)
|
|
||||||
AnimatedBuilder(
|
|
||||||
animation: animation!,
|
|
||||||
builder: (context, child) => CustomPaint(
|
|
||||||
size: const Size(28, 28),
|
|
||||||
painter: _ArcPainter(
|
|
||||||
color: theme.colorScheme.primary,
|
|
||||||
sweepAngle: animation!.value,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
else
|
|
||||||
const SizedBox(width: 28, height: 28),
|
|
||||||
Icon(
|
|
||||||
selectStatus ? selectIcon!.icon! : icon.icon,
|
|
||||||
size: 18,
|
|
||||||
color: selectStatus
|
|
||||||
? theme.colorScheme.primary
|
|
||||||
: icon.color ?? theme.colorScheme.outline,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
?textWidget,
|
),
|
||||||
],
|
child,
|
||||||
),
|
],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
child = SizedBox.square(dimension: 28, child: child);
|
||||||
|
}
|
||||||
|
|
||||||
|
child = InkWell(
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(6)),
|
||||||
|
onTap: _isThumbsUp ? null : onTap,
|
||||||
|
onLongPress: _isThumbsUp ? null : onLongPress,
|
||||||
|
onTapDown: _isThumbsUp ? (_) => onStartTriple!() : null,
|
||||||
|
onTapUp: _isThumbsUp ? (_) => onCancelTriple!(true) : null,
|
||||||
|
onTapCancel: _isThumbsUp ? onCancelTriple : null,
|
||||||
|
child: expand
|
||||||
|
? Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [child, _buildText(theme)],
|
||||||
|
)
|
||||||
|
: child,
|
||||||
|
);
|
||||||
|
return expand
|
||||||
|
? Expanded(child: child)
|
||||||
|
: Material(type: MaterialType.transparency, child: child);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildText(ThemeData theme) {
|
||||||
|
final hasText = text != null;
|
||||||
|
final child = Text(
|
||||||
|
hasText ? text! : '-',
|
||||||
|
key: hasText ? ValueKey(text!) : null,
|
||||||
|
style: TextStyle(
|
||||||
|
color: selectStatus
|
||||||
|
? theme.colorScheme.primary
|
||||||
|
: theme.colorScheme.outline,
|
||||||
|
fontSize: theme.textTheme.labelSmall!.fontSize,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return expand ? Expanded(child: child) : child;
|
if (hasText) {
|
||||||
|
return AnimatedSwitcher(
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
transitionBuilder: (Widget child, Animation<double> animation) {
|
||||||
|
return ScaleTransition(scale: animation, child: child);
|
||||||
|
},
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return child;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class ActionRowLineItem extends StatelessWidget {
|
|||||||
});
|
});
|
||||||
final bool selectStatus;
|
final bool selectStatus;
|
||||||
final Function? onTap;
|
final Function? onTap;
|
||||||
final bool? isLoading;
|
final bool isLoading;
|
||||||
final String? text;
|
final String? text;
|
||||||
final IconData? iconData;
|
final IconData? iconData;
|
||||||
final Widget? icon;
|
final Widget? icon;
|
||||||
@@ -55,7 +55,7 @@ class ActionRowLineItem extends StatelessWidget {
|
|||||||
else if (icon != null)
|
else if (icon != null)
|
||||||
icon!,
|
icon!,
|
||||||
AnimatedOpacity(
|
AnimatedOpacity(
|
||||||
opacity: isLoading! ? 0 : 1,
|
opacity: isLoading ? 0 : 1,
|
||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 200),
|
||||||
child: Text(
|
child: Text(
|
||||||
text!,
|
text!,
|
||||||
|
|||||||
109
lib/pages/video/introduction/ugc/widgets/triple_state.dart
Normal file
109
lib/pages/video/introduction/ugc/widgets/triple_state.dart
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:math' show pi;
|
||||||
|
|
||||||
|
import 'package:PiliPlus/pages/common/common_intro_controller.dart';
|
||||||
|
import 'package:PiliPlus/utils/feed_back.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
|
||||||
|
abstract class TripleState<T extends StatefulWidget> extends State<T>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
|
late final tripleAnimCtr = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: const Duration(milliseconds: 1000),
|
||||||
|
reverseDuration: const Duration(milliseconds: 400),
|
||||||
|
);
|
||||||
|
|
||||||
|
late final tripleAnimation = Tween<double>(
|
||||||
|
begin: 0,
|
||||||
|
end: -2 * pi,
|
||||||
|
).animate(CurvedAnimation(parent: tripleAnimCtr, curve: Curves.easeInOut));
|
||||||
|
|
||||||
|
CommonIntroController get introController;
|
||||||
|
|
||||||
|
Timer? _timer;
|
||||||
|
|
||||||
|
// @mustCallSuper
|
||||||
|
// void tripleListener(AnimationStatus status) {
|
||||||
|
// if (status == AnimationStatus.completed) {
|
||||||
|
// tripleAnimCtr.reset();
|
||||||
|
// onTriple();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
void _cancelTimer() {
|
||||||
|
_timer?.cancel();
|
||||||
|
_timer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_cancelTimer();
|
||||||
|
tripleAnimCtr.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void onStartTriple() {
|
||||||
|
_timer ??= Timer(const Duration(milliseconds: 200), () {
|
||||||
|
if (introController.hasTriple) {
|
||||||
|
HapticFeedback.lightImpact();
|
||||||
|
SmartDialog.showToast('已完成三连');
|
||||||
|
} else {
|
||||||
|
tripleAnimCtr.forward().whenComplete(() {
|
||||||
|
tripleAnimCtr.reset();
|
||||||
|
introController.actionTriple();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
_cancelTimer();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void onCancelTriple([bool isTapUp = false]) {
|
||||||
|
if (tripleAnimCtr.status == AnimationStatus.forward) {
|
||||||
|
tripleAnimCtr.reverse();
|
||||||
|
} else if (_timer != null && _timer!.tick == 0) {
|
||||||
|
_cancelTimer();
|
||||||
|
if (isTapUp) {
|
||||||
|
feedBack();
|
||||||
|
introController.actionLikeVideo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TripleBuilder extends StatefulWidget {
|
||||||
|
const TripleBuilder({
|
||||||
|
super.key,
|
||||||
|
required this.builder,
|
||||||
|
required this.introController,
|
||||||
|
// this.tripleListener,
|
||||||
|
});
|
||||||
|
final CommonIntroController introController;
|
||||||
|
final Widget Function(
|
||||||
|
BuildContext context,
|
||||||
|
Animation<double> tripleAnimation,
|
||||||
|
void Function() onStartTriple,
|
||||||
|
void Function([bool]) onCancelTriple,
|
||||||
|
)
|
||||||
|
builder;
|
||||||
|
// final AnimationStatusListener? tripleListener;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<TripleBuilder> createState() => _TripleBuilderState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TripleBuilderState extends TripleState<TripleBuilder> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) =>
|
||||||
|
widget.builder(context, tripleAnimation, onStartTriple, onCancelTriple);
|
||||||
|
|
||||||
|
@override
|
||||||
|
late final CommonIntroController introController = widget.introController;
|
||||||
|
|
||||||
|
// @override
|
||||||
|
// void tripleListener(AnimationStatus status) {
|
||||||
|
// super.tripleListener(status);
|
||||||
|
// widget.tripleListener?.call(status);
|
||||||
|
// }
|
||||||
|
}
|
||||||
@@ -1366,11 +1366,8 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
|||||||
key: playerKey,
|
key: playerKey,
|
||||||
plPlayerController: plPlayerController!,
|
plPlayerController: plPlayerController!,
|
||||||
videoDetailController: videoDetailController,
|
videoDetailController: videoDetailController,
|
||||||
ugcIntroController: videoDetailController.isUgc
|
introController: videoDetailController.isUgc
|
||||||
? ugcIntroController
|
? ugcIntroController
|
||||||
: null,
|
|
||||||
pgcIntroController: videoDetailController.isUgc
|
|
||||||
? null
|
|
||||||
: pgcIntroController,
|
: pgcIntroController,
|
||||||
headerControl: HeaderControl(
|
headerControl: HeaderControl(
|
||||||
key: videoDetailController.headerCtrKey,
|
key: videoDetailController.headerCtrKey,
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import 'package:PiliPlus/pages/video/introduction/pgc/controller.dart';
|
|||||||
import 'package:PiliPlus/pages/video/introduction/ugc/controller.dart';
|
import 'package:PiliPlus/pages/video/introduction/ugc/controller.dart';
|
||||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/action_item.dart';
|
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/action_item.dart';
|
||||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/menu_row.dart';
|
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/menu_row.dart';
|
||||||
|
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/triple_state.dart';
|
||||||
import 'package:PiliPlus/plugin/pl_player/controller.dart';
|
import 'package:PiliPlus/plugin/pl_player/controller.dart';
|
||||||
import 'package:PiliPlus/plugin/pl_player/models/play_repeat.dart';
|
import 'package:PiliPlus/plugin/pl_player/models/play_repeat.dart';
|
||||||
import 'package:PiliPlus/plugin/pl_player/utils/fullscreen.dart';
|
import 'package:PiliPlus/plugin/pl_player/utils/fullscreen.dart';
|
||||||
@@ -62,8 +63,7 @@ class HeaderControl extends StatefulWidget {
|
|||||||
State<HeaderControl> createState() => HeaderControlState();
|
State<HeaderControl> createState() => HeaderControlState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class HeaderControlState extends State<HeaderControl>
|
class HeaderControlState extends State<HeaderControl> {
|
||||||
with SingleTickerProviderStateMixin, TripleAnimMixin {
|
|
||||||
late final PlPlayerController plPlayerController = widget.controller;
|
late final PlPlayerController plPlayerController = widget.controller;
|
||||||
late final VideoDetailController videoDetailCtr = widget.videoDetailCtr;
|
late final VideoDetailController videoDetailCtr = widget.videoDetailCtr;
|
||||||
late final PlayUrlModel videoInfo = videoDetailCtr.data;
|
late final PlayUrlModel videoInfo = videoDetailCtr.data;
|
||||||
@@ -72,8 +72,7 @@ class HeaderControlState extends State<HeaderControl>
|
|||||||
String get heroTag => widget.heroTag;
|
String get heroTag => widget.heroTag;
|
||||||
late final UgcIntroController ugcIntroController;
|
late final UgcIntroController ugcIntroController;
|
||||||
late final PgcIntroController pgcIntroController;
|
late final PgcIntroController pgcIntroController;
|
||||||
@override
|
late CommonIntroController introController = videoDetailCtr.isUgc
|
||||||
late final CommonIntroController introController = videoDetailCtr.isUgc
|
|
||||||
? ugcIntroController
|
? ugcIntroController
|
||||||
: pgcIntroController;
|
: pgcIntroController;
|
||||||
bool get horizontalScreen => videoDetailCtr.horizontalScreen;
|
bool get horizontalScreen => videoDetailCtr.horizontalScreen;
|
||||||
@@ -86,9 +85,9 @@ class HeaderControlState extends State<HeaderControl>
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
if (videoDetailCtr.isUgc) {
|
if (videoDetailCtr.isUgc) {
|
||||||
ugcIntroController = Get.find<UgcIntroController>(tag: heroTag);
|
introController = Get.find<UgcIntroController>(tag: heroTag);
|
||||||
} else {
|
} else {
|
||||||
pgcIntroController = Get.find<PgcIntroController>(tag: heroTag);
|
introController = Get.find<PgcIntroController>(tag: heroTag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -938,7 +937,7 @@ class HeaderControlState extends State<HeaderControl>
|
|||||||
|
|
||||||
final sliderTheme = SliderThemeData(
|
final sliderTheme = SliderThemeData(
|
||||||
trackHeight: 10,
|
trackHeight: 10,
|
||||||
trackShape: MSliderTrackShape(),
|
trackShape: const MSliderTrackShape(),
|
||||||
thumbColor: theme.colorScheme.primary,
|
thumbColor: theme.colorScheme.primary,
|
||||||
activeTrackColor: theme.colorScheme.primary,
|
activeTrackColor: theme.colorScheme.primary,
|
||||||
inactiveTrackColor: theme.colorScheme.onInverseSurface,
|
inactiveTrackColor: theme.colorScheme.onInverseSurface,
|
||||||
@@ -1227,7 +1226,7 @@ class HeaderControlState extends State<HeaderControl>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget resetBtn(ThemeData theme, def, VoidCallback onPressed) {
|
Widget resetBtn(ThemeData theme, Object def, VoidCallback onPressed) {
|
||||||
return iconButton(
|
return iconButton(
|
||||||
context: context,
|
context: context,
|
||||||
tooltip: '默认值: $def',
|
tooltip: '默认值: $def',
|
||||||
@@ -1279,7 +1278,7 @@ class HeaderControlState extends State<HeaderControl>
|
|||||||
|
|
||||||
final sliderTheme = SliderThemeData(
|
final sliderTheme = SliderThemeData(
|
||||||
trackHeight: 10,
|
trackHeight: 10,
|
||||||
trackShape: MSliderTrackShape(),
|
trackShape: const MSliderTrackShape(),
|
||||||
thumbColor: theme.colorScheme.primary,
|
thumbColor: theme.colorScheme.primary,
|
||||||
activeTrackColor: theme.colorScheme.primary,
|
activeTrackColor: theme.colorScheme.primary,
|
||||||
inactiveTrackColor: theme.colorScheme.onInverseSurface,
|
inactiveTrackColor: theme.colorScheme.onInverseSurface,
|
||||||
@@ -2218,11 +2217,43 @@ class HeaderControlState extends State<HeaderControl>
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (showFSActionItem)
|
if (showFSActionItem && isFullScreen)
|
||||||
isFullScreen
|
TripleBuilder(
|
||||||
? Row(
|
introController: introController,
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
builder: (context, tripleAnimation, onStartTriple, onCancelTriple) {
|
||||||
children: [
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: 42,
|
||||||
|
height: 34,
|
||||||
|
child: Obx(
|
||||||
|
() => ActionItem(
|
||||||
|
expand: false,
|
||||||
|
icon: const Icon(
|
||||||
|
FontAwesomeIcons.thumbsUp,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
selectIcon: const Icon(
|
||||||
|
FontAwesomeIcons.solidThumbsUp,
|
||||||
|
),
|
||||||
|
selectStatus: introController.hasLike.value,
|
||||||
|
semanticsLabel: '点赞',
|
||||||
|
animation: tripleAnimation,
|
||||||
|
onStartTriple: () {
|
||||||
|
plPlayerController.tripling = true;
|
||||||
|
onStartTriple();
|
||||||
|
},
|
||||||
|
onCancelTriple: ([bool isTap = false]) {
|
||||||
|
plPlayerController
|
||||||
|
..tripling = false
|
||||||
|
..hideTaskControls();
|
||||||
|
onCancelTriple(isTap);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (introController case UgcIntroController ugc)
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 42,
|
width: 42,
|
||||||
height: 34,
|
height: 34,
|
||||||
@@ -2230,112 +2261,76 @@ class HeaderControlState extends State<HeaderControl>
|
|||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
expand: false,
|
expand: false,
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
FontAwesomeIcons.thumbsUp,
|
FontAwesomeIcons.thumbsDown,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
selectIcon: const Icon(
|
selectIcon: const Icon(
|
||||||
FontAwesomeIcons.solidThumbsUp,
|
FontAwesomeIcons.solidThumbsDown,
|
||||||
),
|
),
|
||||||
onTap: () =>
|
onTap: ugc.actionDislikeVideo,
|
||||||
handleAction(introController.actionLikeVideo),
|
selectStatus: ugc.hasDislike.value,
|
||||||
selectStatus: introController.hasLike.value,
|
semanticsLabel: '点踩',
|
||||||
semanticsLabel: '点赞',
|
|
||||||
controller: animController,
|
|
||||||
animation: animation,
|
|
||||||
onStartTriple: () {
|
|
||||||
plPlayerController.isTriple = true;
|
|
||||||
onStartTriple();
|
|
||||||
},
|
|
||||||
onCancelTriple: (value) {
|
|
||||||
plPlayerController
|
|
||||||
..isTriple = null
|
|
||||||
..hideTaskControls();
|
|
||||||
onCancelTriple(value);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (videoDetailCtr.isUgc)
|
SizedBox(
|
||||||
SizedBox(
|
width: 42,
|
||||||
width: 42,
|
height: 34,
|
||||||
height: 34,
|
child: Obx(
|
||||||
child: Obx(
|
() => ActionItem(
|
||||||
() => ActionItem(
|
|
||||||
expand: false,
|
|
||||||
icon: const Icon(
|
|
||||||
FontAwesomeIcons.thumbsDown,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
selectIcon: const Icon(
|
|
||||||
FontAwesomeIcons.solidThumbsDown,
|
|
||||||
),
|
|
||||||
onTap: () => handleAction(
|
|
||||||
ugcIntroController.actionDislikeVideo,
|
|
||||||
),
|
|
||||||
selectStatus: ugcIntroController.hasDislike.value,
|
|
||||||
semanticsLabel: '点踩',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 42,
|
|
||||||
height: 34,
|
|
||||||
child: Obx(
|
|
||||||
() => ActionItem(
|
|
||||||
expand: false,
|
|
||||||
icon: const Icon(
|
|
||||||
FontAwesomeIcons.b,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
selectIcon: const Icon(FontAwesomeIcons.b),
|
|
||||||
onTap: introController.actionCoinVideo,
|
|
||||||
selectStatus: introController.hasCoin,
|
|
||||||
semanticsLabel: '投币',
|
|
||||||
controller: animController,
|
|
||||||
animation: animation,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 42,
|
|
||||||
height: 34,
|
|
||||||
child: Obx(
|
|
||||||
() => ActionItem(
|
|
||||||
expand: false,
|
|
||||||
icon: const Icon(
|
|
||||||
FontAwesomeIcons.star,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidStar),
|
|
||||||
onTap: () =>
|
|
||||||
introController.showFavBottomSheet(context),
|
|
||||||
onLongPress: () => introController.showFavBottomSheet(
|
|
||||||
context,
|
|
||||||
isLongPress: true,
|
|
||||||
),
|
|
||||||
selectStatus: introController.hasFav.value,
|
|
||||||
semanticsLabel: '收藏',
|
|
||||||
controller: animController,
|
|
||||||
animation: animation,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 42,
|
|
||||||
height: 34,
|
|
||||||
child: ActionItem(
|
|
||||||
expand: false,
|
expand: false,
|
||||||
|
animation: tripleAnimation,
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
FontAwesomeIcons.shareFromSquare,
|
FontAwesomeIcons.b,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
onTap: () => introController.actionShareVideo(context),
|
selectIcon: const Icon(FontAwesomeIcons.b),
|
||||||
semanticsLabel: '分享',
|
onTap: introController.actionCoinVideo,
|
||||||
|
selectStatus: introController.hasCoin,
|
||||||
|
semanticsLabel: '投币',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
)
|
SizedBox(
|
||||||
: const SizedBox.shrink(),
|
width: 42,
|
||||||
|
height: 34,
|
||||||
|
child: Obx(
|
||||||
|
() => ActionItem(
|
||||||
|
expand: false,
|
||||||
|
animation: tripleAnimation,
|
||||||
|
icon: const Icon(
|
||||||
|
FontAwesomeIcons.star,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
selectIcon: const Icon(FontAwesomeIcons.solidStar),
|
||||||
|
onTap: () =>
|
||||||
|
introController.showFavBottomSheet(context),
|
||||||
|
onLongPress: () => introController.showFavBottomSheet(
|
||||||
|
context,
|
||||||
|
isLongPress: true,
|
||||||
|
),
|
||||||
|
selectStatus: introController.hasFav.value,
|
||||||
|
semanticsLabel: '收藏',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 42,
|
||||||
|
height: 34,
|
||||||
|
child: ActionItem(
|
||||||
|
expand: false,
|
||||||
|
icon: const Icon(
|
||||||
|
FontAwesomeIcons.shareFromSquare,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
onTap: () => introController.actionShareVideo(context),
|
||||||
|
semanticsLabel: '分享',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -2349,6 +2344,8 @@ class HeaderControlState extends State<HeaderControl>
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MSliderTrackShape extends RoundedRectSliderTrackShape {
|
class MSliderTrackShape extends RoundedRectSliderTrackShape {
|
||||||
|
const MSliderTrackShape();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Rect getPreferredRect({
|
Rect getPreferredRect({
|
||||||
required RenderBox parentBox,
|
required RenderBox parentBox,
|
||||||
|
|||||||
@@ -1160,7 +1160,7 @@ class PlPlayerController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool? isTriple;
|
bool tripling = false;
|
||||||
|
|
||||||
/// 隐藏控制条
|
/// 隐藏控制条
|
||||||
void hideTaskControls() {
|
void hideTaskControls() {
|
||||||
@@ -1169,7 +1169,7 @@ class PlPlayerController {
|
|||||||
}
|
}
|
||||||
Duration waitingTime = Duration(seconds: enableLongShowControl ? 30 : 3);
|
Duration waitingTime = Duration(seconds: enableLongShowControl ? 30 : 3);
|
||||||
_timer = Timer(waitingTime, () {
|
_timer = Timer(waitingTime, () {
|
||||||
if (!isSliderMoving.value && isTriple != true) {
|
if (!isSliderMoving.value && !tripling) {
|
||||||
controls = false;
|
controls = false;
|
||||||
}
|
}
|
||||||
_timer = null;
|
_timer = null;
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import 'package:PiliPlus/models_new/video/video_shot/data.dart';
|
|||||||
import 'package:PiliPlus/pages/common/common_intro_controller.dart';
|
import 'package:PiliPlus/pages/common/common_intro_controller.dart';
|
||||||
import 'package:PiliPlus/pages/video/controller.dart';
|
import 'package:PiliPlus/pages/video/controller.dart';
|
||||||
import 'package:PiliPlus/pages/video/introduction/pgc/controller.dart';
|
import 'package:PiliPlus/pages/video/introduction/pgc/controller.dart';
|
||||||
import 'package:PiliPlus/pages/video/introduction/ugc/controller.dart';
|
|
||||||
import 'package:PiliPlus/plugin/pl_player/controller.dart';
|
import 'package:PiliPlus/plugin/pl_player/controller.dart';
|
||||||
import 'package:PiliPlus/plugin/pl_player/models/bottom_control_type.dart';
|
import 'package:PiliPlus/plugin/pl_player/models/bottom_control_type.dart';
|
||||||
import 'package:PiliPlus/plugin/pl_player/models/bottom_progress_behavior.dart';
|
import 'package:PiliPlus/plugin/pl_player/models/bottom_progress_behavior.dart';
|
||||||
@@ -49,8 +48,7 @@ class PLVideoPlayer extends StatefulWidget {
|
|||||||
const PLVideoPlayer({
|
const PLVideoPlayer({
|
||||||
required this.plPlayerController,
|
required this.plPlayerController,
|
||||||
this.videoDetailController,
|
this.videoDetailController,
|
||||||
this.ugcIntroController,
|
this.introController,
|
||||||
this.pgcIntroController,
|
|
||||||
required this.headerControl,
|
required this.headerControl,
|
||||||
this.bottomControl,
|
this.bottomControl,
|
||||||
this.danmuWidget,
|
this.danmuWidget,
|
||||||
@@ -65,8 +63,7 @@ class PLVideoPlayer extends StatefulWidget {
|
|||||||
|
|
||||||
final PlPlayerController plPlayerController;
|
final PlPlayerController plPlayerController;
|
||||||
final VideoDetailController? videoDetailController;
|
final VideoDetailController? videoDetailController;
|
||||||
final UgcIntroController? ugcIntroController;
|
final CommonIntroController? introController;
|
||||||
final PgcIntroController? pgcIntroController;
|
|
||||||
final Widget headerControl;
|
final Widget headerControl;
|
||||||
final Widget? bottomControl;
|
final Widget? bottomControl;
|
||||||
final Widget? danmuWidget;
|
final Widget? danmuWidget;
|
||||||
@@ -87,12 +84,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
with TickerProviderStateMixin {
|
with TickerProviderStateMixin {
|
||||||
late AnimationController animationController;
|
late AnimationController animationController;
|
||||||
late VideoController videoController;
|
late VideoController videoController;
|
||||||
UgcIntroController? ugcIntroController;
|
late final CommonIntroController introController = widget.introController!;
|
||||||
PgcIntroController? pgcIntroController;
|
|
||||||
late final CommonIntroController introController =
|
|
||||||
widget.videoDetailController!.isUgc
|
|
||||||
? ugcIntroController!
|
|
||||||
: pgcIntroController!;
|
|
||||||
|
|
||||||
final GlobalKey _playerKey = GlobalKey();
|
final GlobalKey _playerKey = GlobalKey();
|
||||||
final GlobalKey<VideoState> key = GlobalKey<VideoState>();
|
final GlobalKey<VideoState> key = GlobalKey<VideoState>();
|
||||||
@@ -175,8 +167,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
duration: const Duration(milliseconds: 100),
|
duration: const Duration(milliseconds: 100),
|
||||||
);
|
);
|
||||||
videoController = plPlayerController.videoController!;
|
videoController = plPlayerController.videoController!;
|
||||||
ugcIntroController = widget.ugcIntroController;
|
|
||||||
pgcIntroController = widget.pgcIntroController;
|
|
||||||
Future.microtask(() async {
|
Future.microtask(() async {
|
||||||
try {
|
try {
|
||||||
FlutterVolumeController.updateShowSystemUI(true);
|
FlutterVolumeController.updateShowSystemUI(true);
|
||||||
@@ -258,15 +248,18 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
final videoDetail = introController.videoDetail.value;
|
final videoDetail = introController.videoDetail.value;
|
||||||
final isSeason = videoDetail.ugcSeason != null;
|
final isSeason = videoDetail.ugcSeason != null;
|
||||||
final isPart = videoDetail.pages != null && videoDetail.pages!.length > 1;
|
final isPart = videoDetail.pages != null && videoDetail.pages!.length > 1;
|
||||||
final isPgc = pgcIntroController != null;
|
final isPgc = !widget.videoDetailController!.isUgc;
|
||||||
final anySeason = isSeason || isPart || isPgc;
|
final anySeason = isSeason || isPart || isPgc;
|
||||||
final isPlayAll = widget.videoDetailController?.isPlayAll == true;
|
final isPlayAll =
|
||||||
|
anySeason || widget.videoDetailController?.isPlayAll == true;
|
||||||
|
|
||||||
final double widgetWidth = isFullScreen && context.isLandscape ? 42 : 35;
|
final double widgetWidth = isFullScreen && context.isLandscape ? 42 : 35;
|
||||||
|
|
||||||
Map<BottomControlType, Widget> videoProgressWidgets = {
|
Widget progressWidget(
|
||||||
|
BottomControlType bottomControl,
|
||||||
|
) => switch (bottomControl) {
|
||||||
/// 上一集
|
/// 上一集
|
||||||
BottomControlType.pre: Container(
|
BottomControlType.pre => Container(
|
||||||
width: widgetWidth,
|
width: widgetWidth,
|
||||||
height: 30,
|
height: 30,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
@@ -286,12 +279,12 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
),
|
),
|
||||||
|
|
||||||
/// 播放暂停
|
/// 播放暂停
|
||||||
BottomControlType.playOrPause: PlayOrPauseButton(
|
BottomControlType.playOrPause => PlayOrPauseButton(
|
||||||
plPlayerController: plPlayerController,
|
plPlayerController: plPlayerController,
|
||||||
),
|
),
|
||||||
|
|
||||||
/// 下一集
|
/// 下一集
|
||||||
BottomControlType.next: Container(
|
BottomControlType.next => Container(
|
||||||
width: widgetWidth,
|
width: widgetWidth,
|
||||||
height: 30,
|
height: 30,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
@@ -311,7 +304,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
),
|
),
|
||||||
|
|
||||||
/// 时间进度
|
/// 时间进度
|
||||||
BottomControlType.time: Column(
|
BottomControlType.time => Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
@@ -346,7 +339,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
),
|
),
|
||||||
|
|
||||||
/// 高能进度条
|
/// 高能进度条
|
||||||
BottomControlType.dmChart: Obx(
|
BottomControlType.dmChart => Obx(
|
||||||
() => plPlayerController.dmTrend.isEmpty
|
() => plPlayerController.dmTrend.isEmpty
|
||||||
? const SizedBox.shrink()
|
? const SizedBox.shrink()
|
||||||
: Container(
|
: Container(
|
||||||
@@ -383,46 +376,47 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
),
|
),
|
||||||
|
|
||||||
/// 超分辨率
|
/// 超分辨率
|
||||||
BottomControlType.superResolution: plPlayerController.isAnim
|
BottomControlType.superResolution =>
|
||||||
? Container(
|
plPlayerController.isAnim
|
||||||
height: 30,
|
? Container(
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 10),
|
height: 30,
|
||||||
alignment: Alignment.center,
|
margin: const EdgeInsets.symmetric(horizontal: 10),
|
||||||
child: PopupMenuButton<SuperResolutionType>(
|
alignment: Alignment.center,
|
||||||
initialValue: SuperResolutionType
|
child: PopupMenuButton<SuperResolutionType>(
|
||||||
.values[plPlayerController.superResolutionType],
|
initialValue: SuperResolutionType
|
||||||
color: Colors.black.withValues(alpha: 0.8),
|
.values[plPlayerController.superResolutionType],
|
||||||
itemBuilder: (BuildContext context) {
|
color: Colors.black.withValues(alpha: 0.8),
|
||||||
return SuperResolutionType.values.map((
|
itemBuilder: (BuildContext context) {
|
||||||
SuperResolutionType type,
|
return SuperResolutionType.values.map((
|
||||||
) {
|
SuperResolutionType type,
|
||||||
return PopupMenuItem<SuperResolutionType>(
|
) {
|
||||||
height: 35,
|
return PopupMenuItem<SuperResolutionType>(
|
||||||
padding: const EdgeInsets.only(left: 30),
|
height: 35,
|
||||||
value: type,
|
padding: const EdgeInsets.only(left: 30),
|
||||||
onTap: () => plPlayerController.setShader(type.index),
|
value: type,
|
||||||
child: Text(
|
onTap: () => plPlayerController.setShader(type.index),
|
||||||
type.title,
|
child: Text(
|
||||||
style: const TextStyle(
|
type.title,
|
||||||
color: Colors.white,
|
style: const TextStyle(
|
||||||
fontSize: 13,
|
color: Colors.white,
|
||||||
|
fontSize: 13,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
}).toList();
|
||||||
}).toList();
|
},
|
||||||
},
|
child: Text(
|
||||||
child: Text(
|
SuperResolutionType
|
||||||
SuperResolutionType
|
.values[plPlayerController.superResolutionType]
|
||||||
.values[plPlayerController.superResolutionType]
|
.title,
|
||||||
.title,
|
style: const TextStyle(color: Colors.white, fontSize: 13),
|
||||||
style: const TextStyle(color: Colors.white, fontSize: 13),
|
),
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
)
|
: const SizedBox.shrink(),
|
||||||
: const SizedBox.shrink(),
|
|
||||||
|
|
||||||
/// 分段信息
|
/// 分段信息
|
||||||
BottomControlType.viewPoints: Obx(
|
BottomControlType.viewPoints => Obx(
|
||||||
() => plPlayerController.viewPointList.isEmpty
|
() => plPlayerController.viewPointList.isEmpty
|
||||||
? const SizedBox.shrink()
|
? const SizedBox.shrink()
|
||||||
: Container(
|
: Container(
|
||||||
@@ -450,7 +444,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
),
|
),
|
||||||
|
|
||||||
/// 选集
|
/// 选集
|
||||||
BottomControlType.episode: Container(
|
BottomControlType.episode => Container(
|
||||||
width: widgetWidth,
|
width: widgetWidth,
|
||||||
height: 30,
|
height: 30,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
@@ -487,7 +481,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
} else if (isPart) {
|
} else if (isPart) {
|
||||||
episodes = videoDetail.pages!;
|
episodes = videoDetail.pages!;
|
||||||
} else if (isPgc) {
|
} else if (isPgc) {
|
||||||
episodes = pgcIntroController!.pgcItem.episodes!;
|
episodes =
|
||||||
|
(introController as PgcIntroController).pgcItem.episodes!;
|
||||||
}
|
}
|
||||||
widget.showEpisodes?.call(
|
widget.showEpisodes?.call(
|
||||||
index,
|
index,
|
||||||
@@ -504,7 +499,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
),
|
),
|
||||||
|
|
||||||
/// 画面比例
|
/// 画面比例
|
||||||
BottomControlType.fit: Container(
|
BottomControlType.fit => Container(
|
||||||
height: 30,
|
height: 30,
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 10),
|
margin: const EdgeInsets.symmetric(horizontal: 10),
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
@@ -533,7 +528,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
),
|
),
|
||||||
|
|
||||||
/// 字幕
|
/// 字幕
|
||||||
BottomControlType.subtitle: Obx(
|
BottomControlType.subtitle => Obx(
|
||||||
() => widget.videoDetailController?.subtitles.isEmpty == true
|
() => widget.videoDetailController?.subtitles.isEmpty == true
|
||||||
? const SizedBox.shrink()
|
? const SizedBox.shrink()
|
||||||
: SizedBox(
|
: SizedBox(
|
||||||
@@ -590,7 +585,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
),
|
),
|
||||||
|
|
||||||
/// 播放速度
|
/// 播放速度
|
||||||
BottomControlType.speed: Obx(
|
BottomControlType.speed => Obx(
|
||||||
() => Container(
|
() => Container(
|
||||||
height: 30,
|
height: 30,
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 10),
|
margin: const EdgeInsets.symmetric(horizontal: 10),
|
||||||
@@ -623,7 +618,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
),
|
),
|
||||||
|
|
||||||
/// 全屏
|
/// 全屏
|
||||||
BottomControlType.fullscreen: SizedBox(
|
BottomControlType.fullscreen => SizedBox(
|
||||||
width: widgetWidth,
|
width: widgetWidth,
|
||||||
height: 30,
|
height: 30,
|
||||||
child: Obx(
|
child: Obx(
|
||||||
@@ -644,7 +639,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
List<BottomControlType> userSpecifyItemLeft = [
|
List<BottomControlType> userSpecifyItemLeft = [
|
||||||
BottomControlType.playOrPause,
|
BottomControlType.playOrPause,
|
||||||
BottomControlType.time,
|
BottomControlType.time,
|
||||||
if (anySeason || isPlayAll) ...[
|
if (isPlayAll) ...[
|
||||||
BottomControlType.pre,
|
BottomControlType.pre,
|
||||||
BottomControlType.next,
|
BottomControlType.next,
|
||||||
],
|
],
|
||||||
@@ -654,7 +649,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
BottomControlType.dmChart,
|
BottomControlType.dmChart,
|
||||||
BottomControlType.superResolution,
|
BottomControlType.superResolution,
|
||||||
BottomControlType.viewPoints,
|
BottomControlType.viewPoints,
|
||||||
if (anySeason || isPlayAll) BottomControlType.episode,
|
if (isPlayAll) BottomControlType.episode,
|
||||||
if (isFullScreen) BottomControlType.fit,
|
if (isFullScreen) BottomControlType.fit,
|
||||||
BottomControlType.subtitle,
|
BottomControlType.subtitle,
|
||||||
BottomControlType.speed,
|
BottomControlType.speed,
|
||||||
@@ -663,7 +658,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
|
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
...userSpecifyItemLeft.map((item) => videoProgressWidgets[item]!),
|
...userSpecifyItemLeft.map(progressWidget),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (context, constraints) => FittedBox(
|
builder: (context, constraints) => FittedBox(
|
||||||
@@ -673,9 +668,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: userSpecifyItemRight
|
children: userSpecifyItemRight.map(progressWidget).toList(),
|
||||||
.map((item) => videoProgressWidgets[item]!)
|
|
||||||
.toList(),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -810,7 +803,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
curSliderPosition +
|
curSliderPosition +
|
||||||
(plPlayerController.sliderScale * delta.dx / maxWidth)
|
(plPlayerController.sliderScale * delta.dx / maxWidth)
|
||||||
.round(),
|
.round(),
|
||||||
); // TODO
|
);
|
||||||
final Duration result = pos.clamp(
|
final Duration result = pos.clamp(
|
||||||
Duration.zero,
|
Duration.zero,
|
||||||
plPlayerController.duration.value,
|
plPlayerController.duration.value,
|
||||||
|
|||||||
Reference in New Issue
Block a user