mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 16:48:16 +08:00
@@ -22,7 +22,6 @@ import 'package:PiliPlus/pages/main_reply/view.dart';
|
|||||||
import 'package:PiliPlus/pages/sponsor_block/block_mixin.dart';
|
import 'package:PiliPlus/pages/sponsor_block/block_mixin.dart';
|
||||||
import 'package:PiliPlus/pages/video/controller.dart';
|
import 'package:PiliPlus/pages/video/controller.dart';
|
||||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/triple_mixin.dart';
|
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/triple_mixin.dart';
|
||||||
import 'package:PiliPlus/pages/video/pay_coins/view.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/models/play_status.dart';
|
import 'package:PiliPlus/plugin/pl_player/models/play_status.dart';
|
||||||
@@ -86,6 +85,7 @@ class AudioController extends GetxController
|
|||||||
|
|
||||||
late final Rx<PlayRepeat> playMode = Pref.audioPlayMode.obs;
|
late final Rx<PlayRepeat> playMode = Pref.audioPlayMode.obs;
|
||||||
|
|
||||||
|
@override
|
||||||
late final isLogin = Accounts.main.isLogin;
|
late final isLogin = Accounts.main.isLogin;
|
||||||
|
|
||||||
Duration? _start;
|
Duration? _start;
|
||||||
@@ -462,36 +462,11 @@ class AudioController extends GetxController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void actionCoinVideo() {
|
@override
|
||||||
final audioItem = this.audioItem.value;
|
int get copyright => audioItem.value?.arc.copyright ?? 1;
|
||||||
if (audioItem == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isLogin) {
|
@override
|
||||||
SmartDialog.showToast('账号未登录');
|
Future<void> onPayCoin(int coin, bool coinWithLike) async {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final int copyright = audioItem.arc.copyright;
|
|
||||||
if ((copyright != 1 && coinNum.value >= 1) || coinNum.value >= 2) {
|
|
||||||
SmartDialog.showToast('达到投币上限啦~');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GlobalData().coins != null && GlobalData().coins! < 1) {
|
|
||||||
SmartDialog.showToast('硬币不足');
|
|
||||||
// return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PayCoinsPage.toPayCoinsPage(
|
|
||||||
onPayCoin: _onPayCoin,
|
|
||||||
hasCoin: coinNum.value == 1,
|
|
||||||
copyright: copyright,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onPayCoin(int coin, bool coinWithLike) async {
|
|
||||||
final res = await AudioGrpc.audioCoinAdd(
|
final res = await AudioGrpc.audioCoinAdd(
|
||||||
oid: oid,
|
oid: oid,
|
||||||
subId: subId,
|
subId: subId,
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ abstract class CommonIntroController extends GetxController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
late final isLogin = Accounts.main.isLogin;
|
late final isLogin = Accounts.main.isLogin;
|
||||||
|
|
||||||
StatDetail? getStat();
|
StatDetail? getStat();
|
||||||
@@ -59,7 +60,6 @@ abstract class CommonIntroController extends GetxController
|
|||||||
bool prevPlay();
|
bool prevPlay();
|
||||||
bool nextPlay();
|
bool nextPlay();
|
||||||
|
|
||||||
void actionCoinVideo();
|
|
||||||
void actionShareVideo(BuildContext context);
|
void actionShareVideo(BuildContext context);
|
||||||
|
|
||||||
// 同时观看
|
// 同时观看
|
||||||
@@ -119,7 +119,8 @@ abstract class CommonIntroController extends GetxController
|
|||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> coinVideo(int coin, [bool selectLike = false]) async {
|
@override
|
||||||
|
Future<void> onPayCoin(int coin, bool coinWithLike) async {
|
||||||
final stat = getStat();
|
final stat = getStat();
|
||||||
if (stat == null) {
|
if (stat == null) {
|
||||||
return;
|
return;
|
||||||
@@ -127,14 +128,14 @@ abstract class CommonIntroController extends GetxController
|
|||||||
final res = await VideoHttp.coinVideo(
|
final res = await VideoHttp.coinVideo(
|
||||||
bvid: bvid,
|
bvid: bvid,
|
||||||
multiply: coin,
|
multiply: coin,
|
||||||
selectLike: selectLike ? 1 : 0,
|
selectLike: coinWithLike ? 1 : 0,
|
||||||
);
|
);
|
||||||
if (res.isSuccess) {
|
if (res.isSuccess) {
|
||||||
SmartDialog.showToast('投币成功');
|
SmartDialog.showToast('投币成功');
|
||||||
coinNum.value += coin;
|
coinNum.value += coin;
|
||||||
GlobalData().afterCoin(coin);
|
GlobalData().afterCoin(coin);
|
||||||
stat.coin += coin;
|
stat.coin += coin;
|
||||||
if (selectLike && !hasLike.value) {
|
if (coinWithLike && !hasLike.value) {
|
||||||
stat.like++;
|
stat.like++;
|
||||||
hasLike.value = true;
|
hasLike.value = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class LocalIntroController extends CommonIntroController {
|
|||||||
void queryVideoIntro() {}
|
void queryVideoIntro() {}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void actionCoinVideo() {}
|
int get copyright => throw UnimplementedError();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void actionLikeVideo() {}
|
void actionLikeVideo() {}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import 'package:PiliPlus/models_new/video/video_detail/episode.dart'
|
|||||||
import 'package:PiliPlus/models_new/video/video_detail/stat_detail.dart';
|
import 'package:PiliPlus/models_new/video/video_detail/stat_detail.dart';
|
||||||
import 'package:PiliPlus/pages/common/common_intro_controller.dart';
|
import 'package:PiliPlus/pages/common/common_intro_controller.dart';
|
||||||
import 'package:PiliPlus/pages/dynamics_repost/view.dart';
|
import 'package:PiliPlus/pages/dynamics_repost/view.dart';
|
||||||
import 'package:PiliPlus/pages/video/pay_coins/view.dart';
|
|
||||||
import 'package:PiliPlus/pages/video/reply/controller.dart';
|
import 'package:PiliPlus/pages/video/reply/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/services/service_locator.dart';
|
import 'package:PiliPlus/services/service_locator.dart';
|
||||||
@@ -114,29 +113,8 @@ class PgcIntroController extends CommonIntroController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 投币
|
|
||||||
@override
|
@override
|
||||||
void actionCoinVideo() {
|
int get copyright => 1;
|
||||||
if (!isLogin) {
|
|
||||||
SmartDialog.showToast('账号未登录');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (coinNum.value >= 2) {
|
|
||||||
SmartDialog.showToast('达到投币上限啦~');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GlobalData().coins != null && GlobalData().coins! < 1) {
|
|
||||||
SmartDialog.showToast('硬币不足');
|
|
||||||
// return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PayCoinsPage.toPayCoinsPage(
|
|
||||||
onPayCoin: coinVideo,
|
|
||||||
hasCoin: coinNum.value == 1,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 分享视频
|
// 分享视频
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import 'package:PiliPlus/models_new/video/video_detail/stat_detail.dart';
|
|||||||
import 'package:PiliPlus/models_new/video/video_detail/ugc_season.dart';
|
import 'package:PiliPlus/models_new/video/video_detail/ugc_season.dart';
|
||||||
import 'package:PiliPlus/pages/common/common_intro_controller.dart';
|
import 'package:PiliPlus/pages/common/common_intro_controller.dart';
|
||||||
import 'package:PiliPlus/pages/dynamics_repost/view.dart';
|
import 'package:PiliPlus/pages/dynamics_repost/view.dart';
|
||||||
import 'package:PiliPlus/pages/video/pay_coins/view.dart';
|
|
||||||
import 'package:PiliPlus/pages/video/related/controller.dart';
|
import 'package:PiliPlus/pages/video/related/controller.dart';
|
||||||
import 'package:PiliPlus/pages/video/reply/controller.dart';
|
import 'package:PiliPlus/pages/video/reply/controller.dart';
|
||||||
import 'package:PiliPlus/plugin/pl_player/models/play_repeat.dart';
|
import 'package:PiliPlus/plugin/pl_player/models/play_repeat.dart';
|
||||||
@@ -276,31 +275,8 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 投币
|
|
||||||
@override
|
@override
|
||||||
void actionCoinVideo() {
|
int get copyright => videoDetail.value.copyright ?? 1;
|
||||||
if (!isLogin) {
|
|
||||||
SmartDialog.showToast('账号未登录');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int copyright = videoDetail.value.copyright ?? 1;
|
|
||||||
if ((copyright != 1 && coinNum.value >= 1) || coinNum.value >= 2) {
|
|
||||||
SmartDialog.showToast('达到投币上限啦~');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GlobalData().coins != null && GlobalData().coins! < 1) {
|
|
||||||
SmartDialog.showToast('硬币不足');
|
|
||||||
// return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PayCoinsPage.toPayCoinsPage(
|
|
||||||
onPayCoin: coinVideo,
|
|
||||||
copyright: copyright,
|
|
||||||
hasCoin: coinNum.value == 1,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
(Object, int) get getFavRidType => (IdUtils.bv2av(bvid), 2);
|
(Object, int) get getFavRidType => (IdUtils.bv2av(bvid), 2);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:PiliPlus/pages/video/pay_coins/view.dart';
|
||||||
|
import 'package:PiliPlus/utils/global_data.dart';
|
||||||
import 'package:PiliPlus/utils/platform_utils.dart';
|
import 'package:PiliPlus/utils/platform_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@@ -18,6 +20,46 @@ mixin TripleMixin on GetxController, TickerProvider {
|
|||||||
|
|
||||||
bool get hasTriple => hasLike.value && hasCoin && hasFav.value;
|
bool get hasTriple => hasLike.value && hasCoin && hasFav.value;
|
||||||
|
|
||||||
|
bool get isLogin;
|
||||||
|
|
||||||
|
bool isHasCopyright(int copyright) {
|
||||||
|
return copyright != 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool reachCoinLimit(bool hasCopyRight, num coinNum) {
|
||||||
|
return (!hasCopyRight && coinNum >= 1) || coinNum >= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get copyright;
|
||||||
|
|
||||||
|
void onPayCoin(int coin, bool coinWithLike);
|
||||||
|
|
||||||
|
void actionCoinVideo() {
|
||||||
|
if (!isLogin) {
|
||||||
|
SmartDialog.showToast('账号未登录');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final coinNum = this.coinNum.value;
|
||||||
|
final copyright = this.copyright;
|
||||||
|
final hasCopyright = isHasCopyright(copyright);
|
||||||
|
if (reachCoinLimit(hasCopyright, coinNum)) {
|
||||||
|
SmartDialog.showToast('达到投币上限啦~');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GlobalData().coins != null && GlobalData().coins! < 1) {
|
||||||
|
SmartDialog.showToast('硬币不足');
|
||||||
|
// return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PayCoinsPage.toPayCoinsPage(
|
||||||
|
onPayCoin: onPayCoin,
|
||||||
|
hasCoin: coinNum == 1,
|
||||||
|
hasCopyright: hasCopyright,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void actionTriple();
|
void actionTriple();
|
||||||
void actionLikeVideo();
|
void actionLikeVideo();
|
||||||
|
|
||||||
|
|||||||
@@ -15,33 +15,35 @@ import 'package:PiliPlus/utils/storage_pref.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
typedef OnPayCoin = Function(int coin, bool coinWithLike);
|
||||||
|
|
||||||
class PayCoinsPage extends StatefulWidget {
|
class PayCoinsPage extends StatefulWidget {
|
||||||
const PayCoinsPage({
|
const PayCoinsPage({
|
||||||
super.key,
|
super.key,
|
||||||
required this.onPayCoin,
|
required this.onPayCoin,
|
||||||
int copyright = 1,
|
required this.hasCoin,
|
||||||
this.hasCoin = false,
|
required this.hasCopyright,
|
||||||
}) : hasCopyright = copyright != 2;
|
});
|
||||||
|
|
||||||
final Function(int coin, bool coinWithLike) onPayCoin;
|
final OnPayCoin onPayCoin;
|
||||||
final bool hasCopyright;
|
|
||||||
final bool hasCoin;
|
final bool hasCoin;
|
||||||
|
final bool hasCopyright;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PayCoinsPage> createState() => _PayCoinsPageState();
|
State<PayCoinsPage> createState() => _PayCoinsPageState();
|
||||||
|
|
||||||
static void toPayCoinsPage({
|
static void toPayCoinsPage({
|
||||||
required Function(int coin, bool coinWithLike) onPayCoin,
|
required OnPayCoin onPayCoin,
|
||||||
int copyright = 1,
|
required bool hasCoin,
|
||||||
bool hasCoin = false,
|
required bool hasCopyright,
|
||||||
}) {
|
}) {
|
||||||
Get.key.currentState!.push(
|
Get.key.currentState!.push(
|
||||||
PublishRoute(
|
PublishRoute(
|
||||||
pageBuilder: (buildContext, animation, secondaryAnimation) {
|
pageBuilder: (buildContext, animation, secondaryAnimation) {
|
||||||
return PayCoinsPage(
|
return PayCoinsPage(
|
||||||
onPayCoin: onPayCoin,
|
onPayCoin: onPayCoin,
|
||||||
copyright: copyright,
|
|
||||||
hasCoin: hasCoin,
|
hasCoin: hasCoin,
|
||||||
|
hasCopyright: hasCopyright,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
transitionDuration: const Duration(milliseconds: 225),
|
transitionDuration: const Duration(milliseconds: 225),
|
||||||
@@ -200,38 +202,38 @@ class _PayCoinsPageState extends State<PayCoinsPage>
|
|||||||
|
|
||||||
Widget _buildCoinWidget(int index, double factor) {
|
Widget _buildCoinWidget(int index, double factor) {
|
||||||
final filter = _getPayFilter(index);
|
final filter = _getPayFilter(index);
|
||||||
|
final boxSize = 70 + (factor * 30);
|
||||||
final coinSize = 35 + (factor * 15);
|
final coinSize = 35 + (factor * 15);
|
||||||
return Center(
|
return Stack(
|
||||||
child: SizedBox.square(
|
alignment: .center,
|
||||||
dimension: 70 + (factor * 30),
|
clipBehavior: .none,
|
||||||
child: ColorFiltered(
|
children: [
|
||||||
colorFilter: ColorFilter.mode(
|
SlideTransition(
|
||||||
filter,
|
position: _boxAnim,
|
||||||
BlendMode.srcATop,
|
child: Image.asset(
|
||||||
),
|
Assets.payBox,
|
||||||
child: Stack(
|
color: filter,
|
||||||
clipBehavior: Clip.none,
|
width: boxSize,
|
||||||
alignment: Alignment.center,
|
height: boxSize,
|
||||||
children: [
|
cacheWidth: 100.cacheSize(context),
|
||||||
SlideTransition(
|
colorBlendMode: .srcATop,
|
||||||
position: _boxAnim,
|
|
||||||
child: Image.asset(Assets.payBox),
|
|
||||||
),
|
|
||||||
SlideTransition(
|
|
||||||
position: _coinSlideAnim,
|
|
||||||
child: FadeTransition(
|
|
||||||
opacity: _coinFadeAnim,
|
|
||||||
child: Image.asset(
|
|
||||||
height: coinSize,
|
|
||||||
width: coinSize,
|
|
||||||
index == 0 ? Assets.coinsOne : Assets.coinsTwo,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
SlideTransition(
|
||||||
|
position: _coinSlideAnim,
|
||||||
|
child: FadeTransition(
|
||||||
|
opacity: _coinFadeAnim,
|
||||||
|
child: Image.asset(
|
||||||
|
height: coinSize,
|
||||||
|
width: coinSize,
|
||||||
|
cacheWidth: 50.cacheSize(context),
|
||||||
|
color: filter,
|
||||||
|
colorBlendMode: .srcATop,
|
||||||
|
index == 0 ? Assets.coinsOne : Assets.coinsTwo,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user