mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-31 16:18:22 +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/video/controller.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/models/play_repeat.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;
|
||||
|
||||
@override
|
||||
late final isLogin = Accounts.main.isLogin;
|
||||
|
||||
Duration? _start;
|
||||
@@ -462,36 +462,11 @@ class AudioController extends GetxController
|
||||
}
|
||||
}
|
||||
|
||||
void actionCoinVideo() {
|
||||
final audioItem = this.audioItem.value;
|
||||
if (audioItem == null) {
|
||||
return;
|
||||
}
|
||||
@override
|
||||
int get copyright => audioItem.value?.arc.copyright ?? 1;
|
||||
|
||||
if (!isLogin) {
|
||||
SmartDialog.showToast('账号未登录');
|
||||
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 {
|
||||
@override
|
||||
Future<void> onPayCoin(int coin, bool coinWithLike) async {
|
||||
final res = await AudioGrpc.audioCoinAdd(
|
||||
oid: oid,
|
||||
subId: subId,
|
||||
|
||||
@@ -43,6 +43,7 @@ abstract class CommonIntroController extends GetxController
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
late final isLogin = Accounts.main.isLogin;
|
||||
|
||||
StatDetail? getStat();
|
||||
@@ -59,7 +60,6 @@ abstract class CommonIntroController extends GetxController
|
||||
bool prevPlay();
|
||||
bool nextPlay();
|
||||
|
||||
void actionCoinVideo();
|
||||
void actionShareVideo(BuildContext context);
|
||||
|
||||
// 同时观看
|
||||
@@ -119,7 +119,8 @@ abstract class CommonIntroController extends GetxController
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
Future<void> coinVideo(int coin, [bool selectLike = false]) async {
|
||||
@override
|
||||
Future<void> onPayCoin(int coin, bool coinWithLike) async {
|
||||
final stat = getStat();
|
||||
if (stat == null) {
|
||||
return;
|
||||
@@ -127,14 +128,14 @@ abstract class CommonIntroController extends GetxController
|
||||
final res = await VideoHttp.coinVideo(
|
||||
bvid: bvid,
|
||||
multiply: coin,
|
||||
selectLike: selectLike ? 1 : 0,
|
||||
selectLike: coinWithLike ? 1 : 0,
|
||||
);
|
||||
if (res.isSuccess) {
|
||||
SmartDialog.showToast('投币成功');
|
||||
coinNum.value += coin;
|
||||
GlobalData().afterCoin(coin);
|
||||
stat.coin += coin;
|
||||
if (selectLike && !hasLike.value) {
|
||||
if (coinWithLike && !hasLike.value) {
|
||||
stat.like++;
|
||||
hasLike.value = true;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class LocalIntroController extends CommonIntroController {
|
||||
void queryVideoIntro() {}
|
||||
|
||||
@override
|
||||
void actionCoinVideo() {}
|
||||
int get copyright => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
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/pages/common/common_intro_controller.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/plugin/pl_player/models/play_repeat.dart';
|
||||
import 'package:PiliPlus/services/service_locator.dart';
|
||||
@@ -114,29 +113,8 @@ class PgcIntroController extends CommonIntroController {
|
||||
}
|
||||
}
|
||||
|
||||
// 投币
|
||||
@override
|
||||
void actionCoinVideo() {
|
||||
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,
|
||||
);
|
||||
}
|
||||
int get copyright => 1;
|
||||
|
||||
// 分享视频
|
||||
@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/pages/common/common_intro_controller.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/reply/controller.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/play_repeat.dart';
|
||||
@@ -276,31 +275,8 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
||||
}
|
||||
}
|
||||
|
||||
// 投币
|
||||
@override
|
||||
void actionCoinVideo() {
|
||||
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,
|
||||
);
|
||||
}
|
||||
int get copyright => videoDetail.value.copyright ?? 1;
|
||||
|
||||
@override
|
||||
(Object, int) get getFavRidType => (IdUtils.bv2av(bvid), 2);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
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:flutter/material.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 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 actionLikeVideo();
|
||||
|
||||
|
||||
@@ -15,33 +15,35 @@ import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
typedef OnPayCoin = Function(int coin, bool coinWithLike);
|
||||
|
||||
class PayCoinsPage extends StatefulWidget {
|
||||
const PayCoinsPage({
|
||||
super.key,
|
||||
required this.onPayCoin,
|
||||
int copyright = 1,
|
||||
this.hasCoin = false,
|
||||
}) : hasCopyright = copyright != 2;
|
||||
required this.hasCoin,
|
||||
required this.hasCopyright,
|
||||
});
|
||||
|
||||
final Function(int coin, bool coinWithLike) onPayCoin;
|
||||
final bool hasCopyright;
|
||||
final OnPayCoin onPayCoin;
|
||||
final bool hasCoin;
|
||||
final bool hasCopyright;
|
||||
|
||||
@override
|
||||
State<PayCoinsPage> createState() => _PayCoinsPageState();
|
||||
|
||||
static void toPayCoinsPage({
|
||||
required Function(int coin, bool coinWithLike) onPayCoin,
|
||||
int copyright = 1,
|
||||
bool hasCoin = false,
|
||||
required OnPayCoin onPayCoin,
|
||||
required bool hasCoin,
|
||||
required bool hasCopyright,
|
||||
}) {
|
||||
Get.key.currentState!.push(
|
||||
PublishRoute(
|
||||
pageBuilder: (buildContext, animation, secondaryAnimation) {
|
||||
return PayCoinsPage(
|
||||
onPayCoin: onPayCoin,
|
||||
copyright: copyright,
|
||||
hasCoin: hasCoin,
|
||||
hasCopyright: hasCopyright,
|
||||
);
|
||||
},
|
||||
transitionDuration: const Duration(milliseconds: 225),
|
||||
@@ -200,38 +202,38 @@ class _PayCoinsPageState extends State<PayCoinsPage>
|
||||
|
||||
Widget _buildCoinWidget(int index, double factor) {
|
||||
final filter = _getPayFilter(index);
|
||||
final boxSize = 70 + (factor * 30);
|
||||
final coinSize = 35 + (factor * 15);
|
||||
return Center(
|
||||
child: SizedBox.square(
|
||||
dimension: 70 + (factor * 30),
|
||||
child: ColorFiltered(
|
||||
colorFilter: ColorFilter.mode(
|
||||
filter,
|
||||
BlendMode.srcATop,
|
||||
),
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
SlideTransition(
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
return Stack(
|
||||
alignment: .center,
|
||||
clipBehavior: .none,
|
||||
children: [
|
||||
SlideTransition(
|
||||
position: _boxAnim,
|
||||
child: Image.asset(
|
||||
Assets.payBox,
|
||||
color: filter,
|
||||
width: boxSize,
|
||||
height: boxSize,
|
||||
cacheWidth: 100.cacheSize(context),
|
||||
colorBlendMode: .srcATop,
|
||||
),
|
||||
),
|
||||
),
|
||||
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