mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-31 16:18:22 +08:00
opt player keyboard event
opt triple opt desktop pip Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -14,7 +14,6 @@ import 'package:PiliPlus/pages/video/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/ugc/widgets/action_item.dart';
|
||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/triple_state.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/num_utils.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
@@ -44,8 +43,7 @@ class PgcIntroPage extends StatefulWidget {
|
||||
State<PgcIntroPage> createState() => _PgcIntroPageState();
|
||||
}
|
||||
|
||||
class _PgcIntroPageState extends TripleState<PgcIntroPage> {
|
||||
@override
|
||||
class _PgcIntroPageState extends State<PgcIntroPage> {
|
||||
late final PgcIntroController introController;
|
||||
late final VideoDetailController videoDetailCtr;
|
||||
|
||||
@@ -412,19 +410,19 @@ class _PgcIntroPageState extends TripleState<PgcIntroPage> {
|
||||
children: [
|
||||
Obx(
|
||||
() => ActionItem(
|
||||
animation: tripleAnimation,
|
||||
animation: introController.tripleAnimation,
|
||||
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
||||
selectStatus: introController.hasLike.value,
|
||||
semanticsLabel: '点赞',
|
||||
text: NumUtils.numFormat(item.stat!.like),
|
||||
onStartTriple: onStartTriple,
|
||||
onCancelTriple: onCancelTriple,
|
||||
onStartTriple: introController.onStartTriple,
|
||||
onCancelTriple: introController.onCancelTriple,
|
||||
),
|
||||
),
|
||||
Obx(
|
||||
() => ActionItem(
|
||||
animation: tripleAnimation,
|
||||
animation: introController.tripleAnimation,
|
||||
icon: const Icon(FontAwesomeIcons.b),
|
||||
selectIcon: const Icon(FontAwesomeIcons.b),
|
||||
onTap: introController.actionCoinVideo,
|
||||
@@ -435,7 +433,7 @@ class _PgcIntroPageState extends TripleState<PgcIntroPage> {
|
||||
),
|
||||
Obx(
|
||||
() => ActionItem(
|
||||
animation: tripleAnimation,
|
||||
animation: introController.tripleAnimation,
|
||||
icon: const Icon(FontAwesomeIcons.star),
|
||||
selectIcon: const Icon(FontAwesomeIcons.solidStar),
|
||||
onTap: () => introController.showFavBottomSheet(context),
|
||||
|
||||
@@ -16,7 +16,6 @@ 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/season.dart';
|
||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/selectable_text.dart';
|
||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/triple_state.dart';
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
import 'package:PiliPlus/utils/date_utils.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
@@ -55,8 +54,7 @@ class UgcIntroPanel extends StatefulWidget {
|
||||
State<UgcIntroPanel> createState() => _UgcIntroPanelState();
|
||||
}
|
||||
|
||||
class _UgcIntroPanelState extends TripleState<UgcIntroPanel> {
|
||||
@override
|
||||
class _UgcIntroPanelState extends State<UgcIntroPanel> {
|
||||
late final UgcIntroController introController;
|
||||
late final VideoDetailController videoDetailCtr =
|
||||
Get.find<VideoDetailController>(tag: widget.heroTag);
|
||||
@@ -514,7 +512,7 @@ class _UgcIntroPanelState extends TripleState<UgcIntroPanel> {
|
||||
children: [
|
||||
Obx(
|
||||
() => ActionItem(
|
||||
animation: tripleAnimation,
|
||||
animation: introController.tripleAnimation,
|
||||
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
||||
selectStatus: introController.hasLike.value,
|
||||
@@ -522,8 +520,8 @@ class _UgcIntroPanelState extends TripleState<UgcIntroPanel> {
|
||||
text: !isLoading
|
||||
? NumUtils.numFormat(videoDetail.stat!.like)
|
||||
: null,
|
||||
onStartTriple: onStartTriple,
|
||||
onCancelTriple: onCancelTriple,
|
||||
onStartTriple: introController.onStartTriple,
|
||||
onCancelTriple: introController.onCancelTriple,
|
||||
),
|
||||
),
|
||||
Obx(
|
||||
@@ -540,7 +538,7 @@ class _UgcIntroPanelState extends TripleState<UgcIntroPanel> {
|
||||
),
|
||||
Obx(
|
||||
() => ActionItem(
|
||||
animation: tripleAnimation,
|
||||
animation: introController.tripleAnimation,
|
||||
icon: const Icon(FontAwesomeIcons.b),
|
||||
selectIcon: const Icon(FontAwesomeIcons.b),
|
||||
onTap: introController.actionCoinVideo,
|
||||
@@ -553,7 +551,7 @@ class _UgcIntroPanelState extends TripleState<UgcIntroPanel> {
|
||||
),
|
||||
Obx(
|
||||
() => ActionItem(
|
||||
animation: tripleAnimation,
|
||||
animation: introController.tripleAnimation,
|
||||
icon: const Icon(FontAwesomeIcons.star),
|
||||
selectIcon: const Icon(FontAwesomeIcons.solidStar),
|
||||
onTap: () => introController.showFavBottomSheet(context),
|
||||
|
||||
@@ -1,15 +1,26 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math' show pi;
|
||||
|
||||
import 'package:PiliPlus/pages/common/common_intro_controller.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
abstract class TripleState<T extends StatefulWidget> extends State<T>
|
||||
with SingleTickerProviderStateMixin {
|
||||
CommonIntroController get introController;
|
||||
mixin TripleMixin on GetxController, TickerProvider {
|
||||
// 是否点赞
|
||||
final RxBool hasLike = false.obs;
|
||||
// 投币数量
|
||||
final RxNum coinNum = RxNum(0);
|
||||
// 是否投币
|
||||
bool get hasCoin => coinNum.value != 0;
|
||||
// 是否收藏
|
||||
final RxBool hasFav = false.obs;
|
||||
|
||||
bool get hasTriple => hasLike.value && hasCoin && hasFav.value;
|
||||
|
||||
void actionTriple();
|
||||
Future<void> actionLikeVideo();
|
||||
|
||||
// no need for pugv
|
||||
AnimationController? _tripleAnimCtr;
|
||||
@@ -34,13 +45,6 @@ abstract class TripleState<T extends StatefulWidget> extends State<T>
|
||||
_timer = null;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_cancelTimer();
|
||||
_tripleAnimCtr?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
static final _duration = Utils.isMobile
|
||||
? const Duration(milliseconds: 200)
|
||||
: const Duration(milliseconds: 230);
|
||||
@@ -48,12 +52,12 @@ abstract class TripleState<T extends StatefulWidget> extends State<T>
|
||||
void onStartTriple() {
|
||||
_timer ??= Timer(_duration, () {
|
||||
HapticFeedback.lightImpact();
|
||||
if (introController.hasTriple) {
|
||||
if (hasTriple) {
|
||||
SmartDialog.showToast('已完成三连');
|
||||
} else {
|
||||
tripleAnimCtr.forward().whenComplete(() {
|
||||
tripleAnimCtr.reset();
|
||||
introController.actionTriple();
|
||||
actionTriple();
|
||||
});
|
||||
}
|
||||
_cancelTimer();
|
||||
@@ -66,8 +70,15 @@ abstract class TripleState<T extends StatefulWidget> extends State<T>
|
||||
} else if (_timer != null && _timer!.tick == 0) {
|
||||
_cancelTimer();
|
||||
if (isTapUp) {
|
||||
introController.actionLikeVideo();
|
||||
actionLikeVideo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
_cancelTimer();
|
||||
_tripleAnimCtr?.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user