mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-08 12:04:50 +08:00
40
lib/pages/common/play_all_btn_mixin.dart
Normal file
40
lib/pages/common/play_all_btn_mixin.dart
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
|
import 'package:PiliPlus/utils/storage_key.dart';
|
||||||
|
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get_rx/get_rx.dart';
|
||||||
|
|
||||||
|
mixin PlayAllBtnMixin {
|
||||||
|
late double dx = 0;
|
||||||
|
late final RxBool isPlayAll = Pref.enablePlayAll.obs;
|
||||||
|
|
||||||
|
void setIsPlayAll(bool isPlayAll) {
|
||||||
|
if (this.isPlayAll.value == isPlayAll) return;
|
||||||
|
this.isPlayAll.value = isPlayAll;
|
||||||
|
GStorage.setting.put(SettingBoxKey.enablePlayAll, isPlayAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget playAllBtn(VoidCallback onPlayAll) {
|
||||||
|
return AnimatedSlide(
|
||||||
|
offset: isPlayAll.value ? Offset.zero : const Offset(0.75, 0),
|
||||||
|
duration: const Duration(milliseconds: 120),
|
||||||
|
child: GestureDetector(
|
||||||
|
onHorizontalDragDown: (details) => dx = details.localPosition.dx,
|
||||||
|
onHorizontalDragStart: (details) => setIsPlayAll(
|
||||||
|
details.localPosition.dx < dx,
|
||||||
|
),
|
||||||
|
child: FloatingActionButton.extended(
|
||||||
|
onPressed: () {
|
||||||
|
if (isPlayAll.value) {
|
||||||
|
onPlayAll();
|
||||||
|
} else {
|
||||||
|
setIsPlayAll(true);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
label: const Text('播放全部'),
|
||||||
|
icon: const Icon(Icons.playlist_play),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,13 +12,11 @@ import 'package:PiliPlus/models_new/video/video_detail/page.dart';
|
|||||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||||
import 'package:PiliPlus/pages/common/multi_select/base.dart';
|
import 'package:PiliPlus/pages/common/multi_select/base.dart';
|
||||||
import 'package:PiliPlus/pages/common/multi_select/multi_select_controller.dart';
|
import 'package:PiliPlus/pages/common/multi_select/multi_select_controller.dart';
|
||||||
|
import 'package:PiliPlus/pages/common/play_all_btn_mixin.dart';
|
||||||
import 'package:PiliPlus/pages/fav_sort/view.dart';
|
import 'package:PiliPlus/pages/fav_sort/view.dart';
|
||||||
import 'package:PiliPlus/utils/accounts.dart';
|
import 'package:PiliPlus/utils/accounts.dart';
|
||||||
import 'package:PiliPlus/utils/extension/scroll_controller_ext.dart';
|
import 'package:PiliPlus/utils/extension/scroll_controller_ext.dart';
|
||||||
import 'package:PiliPlus/utils/page_utils.dart';
|
import 'package:PiliPlus/utils/page_utils.dart';
|
||||||
import 'package:PiliPlus/utils/storage.dart';
|
|
||||||
import 'package:PiliPlus/utils/storage_key.dart';
|
|
||||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/widgets.dart' show Text, ValueChanged;
|
import 'package:flutter/widgets.dart' show Text, ValueChanged;
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
@@ -79,7 +77,7 @@ mixin BaseFavController
|
|||||||
|
|
||||||
class FavDetailController
|
class FavDetailController
|
||||||
extends MultiSelectController<FavDetailData, FavDetailItemModel>
|
extends MultiSelectController<FavDetailData, FavDetailItemModel>
|
||||||
with BaseFavController {
|
with BaseFavController, PlayAllBtnMixin {
|
||||||
@override
|
@override
|
||||||
late int mediaId;
|
late int mediaId;
|
||||||
final Rx<FavFolderInfo> folderInfo = FavFolderInfo().obs;
|
final Rx<FavFolderInfo> folderInfo = FavFolderInfo().obs;
|
||||||
@@ -91,15 +89,6 @@ class FavDetailController
|
|||||||
|
|
||||||
late final account = Accounts.main;
|
late final account = Accounts.main;
|
||||||
|
|
||||||
late double dx = 0;
|
|
||||||
late final RxBool isPlayAll = Pref.enablePlayAll.obs;
|
|
||||||
|
|
||||||
void setIsPlayAll(bool isPlayAll) {
|
|
||||||
if (this.isPlayAll.value == isPlayAll) return;
|
|
||||||
this.isPlayAll.value = isPlayAll;
|
|
||||||
GStorage.setting.put(SettingBoxKey.enablePlayAll, isPlayAll);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
|
|||||||
@@ -93,32 +93,8 @@ class _FavDetailPageState extends State<FavDetailPage> with GridMixin {
|
|||||||
padding: const .only(right: kFloatingActionButtonMargin),
|
padding: const .only(right: kFloatingActionButtonMargin),
|
||||||
child: Obx(
|
child: Obx(
|
||||||
() => _favDetailController.folderInfo.value.mediaCount > 0
|
() => _favDetailController.folderInfo.value.mediaCount > 0
|
||||||
? AnimatedSlide(
|
? _favDetailController.playAllBtn(
|
||||||
offset: _favDetailController.isPlayAll.value
|
_favDetailController.toViewPlayAll,
|
||||||
? Offset.zero
|
|
||||||
: const Offset(0.75, 0),
|
|
||||||
duration: const Duration(milliseconds: 120),
|
|
||||||
child: GestureDetector(
|
|
||||||
onHorizontalDragDown: (details) =>
|
|
||||||
_favDetailController.dx =
|
|
||||||
details.localPosition.dx,
|
|
||||||
onHorizontalDragStart: (details) =>
|
|
||||||
_favDetailController.setIsPlayAll(
|
|
||||||
details.localPosition.dx <
|
|
||||||
_favDetailController.dx,
|
|
||||||
),
|
|
||||||
child: FloatingActionButton.extended(
|
|
||||||
onPressed: () {
|
|
||||||
if (_favDetailController.isPlayAll.value) {
|
|
||||||
_favDetailController.toViewPlayAll();
|
|
||||||
} else {
|
|
||||||
_favDetailController.setIsPlayAll(true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
label: const Text('播放全部'),
|
|
||||||
icon: const Icon(Icons.playlist_play),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
: const SizedBox.shrink(),
|
: const SizedBox.shrink(),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,21 +1,10 @@
|
|||||||
import 'package:PiliPlus/models/common/later_view_type.dart';
|
import 'package:PiliPlus/models/common/later_view_type.dart';
|
||||||
import 'package:PiliPlus/utils/storage.dart';
|
import 'package:PiliPlus/pages/common/play_all_btn_mixin.dart';
|
||||||
import 'package:PiliPlus/utils/storage_key.dart';
|
|
||||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
class LaterBaseController extends GetxController {
|
class LaterBaseController extends GetxController with PlayAllBtnMixin {
|
||||||
RxBool enableMultiSelect = false.obs;
|
RxBool enableMultiSelect = false.obs;
|
||||||
RxInt checkedCount = 0.obs;
|
RxInt checkedCount = 0.obs;
|
||||||
|
|
||||||
RxList<int> counts = List.filled(LaterViewType.values.length, -1).obs;
|
RxList<int> counts = List.filled(LaterViewType.values.length, -1).obs;
|
||||||
|
|
||||||
late double dx = 0;
|
|
||||||
late final RxBool isPlayAll = Pref.enablePlayAll.obs;
|
|
||||||
|
|
||||||
void setIsPlayAll(bool isPlayAll) {
|
|
||||||
if (this.isPlayAll.value == isPlayAll) return;
|
|
||||||
this.isPlayAll.value = isPlayAll;
|
|
||||||
GStorage.setting.put(SettingBoxKey.enablePlayAll, isPlayAll);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,31 +126,7 @@ class _LaterPageState extends State<LaterPage>
|
|||||||
padding: const .only(right: kFloatingActionButtonMargin),
|
padding: const .only(right: kFloatingActionButtonMargin),
|
||||||
child: Obx(
|
child: Obx(
|
||||||
() => currCtr().loadingState.value.isSuccess
|
() => currCtr().loadingState.value.isSuccess
|
||||||
? AnimatedSlide(
|
? _baseCtr.playAllBtn(currCtr().toViewPlayAll)
|
||||||
offset: _baseCtr.isPlayAll.value
|
|
||||||
? Offset.zero
|
|
||||||
: const Offset(0.75, 0),
|
|
||||||
duration: const Duration(milliseconds: 120),
|
|
||||||
child: GestureDetector(
|
|
||||||
onHorizontalDragDown: (details) =>
|
|
||||||
_baseCtr.dx = details.localPosition.dx,
|
|
||||||
onHorizontalDragStart: (details) =>
|
|
||||||
_baseCtr.setIsPlayAll(
|
|
||||||
details.localPosition.dx < _baseCtr.dx,
|
|
||||||
),
|
|
||||||
child: FloatingActionButton.extended(
|
|
||||||
onPressed: () {
|
|
||||||
if (_baseCtr.isPlayAll.value) {
|
|
||||||
currCtr().toViewPlayAll();
|
|
||||||
} else {
|
|
||||||
_baseCtr.setIsPlayAll(true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
label: const Text('播放全部'),
|
|
||||||
icon: const Icon(Icons.playlist_play),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: const SizedBox.shrink(),
|
: const SizedBox.shrink(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:PiliPlus/common/widgets/view_sliver_safe_area.dart';
|
|||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
import 'package:PiliPlus/models/common/video/source_type.dart';
|
import 'package:PiliPlus/models/common/video/source_type.dart';
|
||||||
import 'package:PiliPlus/models/model_hot_video_item.dart';
|
import 'package:PiliPlus/models/model_hot_video_item.dart';
|
||||||
|
import 'package:PiliPlus/pages/common/play_all_btn_mixin.dart';
|
||||||
import 'package:PiliPlus/pages/popular_precious/controller.dart';
|
import 'package:PiliPlus/pages/popular_precious/controller.dart';
|
||||||
import 'package:PiliPlus/utils/grid.dart';
|
import 'package:PiliPlus/utils/grid.dart';
|
||||||
import 'package:PiliPlus/utils/page_utils.dart';
|
import 'package:PiliPlus/utils/page_utils.dart';
|
||||||
@@ -20,14 +21,18 @@ class PopularPreciousPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _PopularPreciousPageState extends State<PopularPreciousPage>
|
class _PopularPreciousPageState extends State<PopularPreciousPage>
|
||||||
with GridMixin {
|
with GridMixin, PlayAllBtnMixin {
|
||||||
final _controller = Get.put(PopularPreciousController());
|
final _controller = Get.put(PopularPreciousController());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final padding = MediaQuery.viewPaddingOf(context);
|
||||||
return scaffold(
|
return scaffold(
|
||||||
appBar: AppBar(title: const Text('入站必刷')),
|
appBar: AppBar(title: const Text('入站必刷')),
|
||||||
body: refreshIndicator(
|
body: Stack(
|
||||||
|
clipBehavior: .none,
|
||||||
|
children: [
|
||||||
|
refreshIndicator(
|
||||||
onRefresh: _controller.onRefresh,
|
onRefresh: _controller.onRefresh,
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
@@ -38,6 +43,45 @@ class _PopularPreciousPageState extends State<PopularPreciousPage>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Positioned(
|
||||||
|
right: padding.right,
|
||||||
|
bottom: padding.bottom + kFloatingActionButtonMargin,
|
||||||
|
child: Padding(
|
||||||
|
padding: const .only(right: kFloatingActionButtonMargin),
|
||||||
|
child: Obx(() {
|
||||||
|
if (_controller.loadingState.value case Success(
|
||||||
|
:final response,
|
||||||
|
)) {
|
||||||
|
return playAllBtn(() => toVideoPage(response!.first));
|
||||||
|
}
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void toVideoPage(
|
||||||
|
HotVideoItemModel item, {
|
||||||
|
int index = 0,
|
||||||
|
bool isPlayAll = true,
|
||||||
|
}) {
|
||||||
|
PageUtils.toVideoPage(
|
||||||
|
bvid: item.bvid,
|
||||||
|
cid: item.cid!,
|
||||||
|
dimension: item.dimension,
|
||||||
|
extraArguments: isPlayAll
|
||||||
|
? {
|
||||||
|
'sourceType': SourceType.playlist,
|
||||||
|
'favTitle': '入站必刷',
|
||||||
|
'mediaId': _controller.mediaId,
|
||||||
|
'desc': true,
|
||||||
|
'oid': item.aid,
|
||||||
|
'isContinuePlaying': index != 0,
|
||||||
|
}
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,21 +97,11 @@ class _PopularPreciousPageState extends State<PopularPreciousPage>
|
|||||||
final item = response[index];
|
final item = response[index];
|
||||||
return VideoCardH(
|
return VideoCardH(
|
||||||
videoItem: item,
|
videoItem: item,
|
||||||
onTap: () {
|
onTap: () => toVideoPage(
|
||||||
PageUtils.toVideoPage(
|
item,
|
||||||
bvid: item.bvid,
|
index: index,
|
||||||
cid: item.cid!,
|
isPlayAll: isPlayAll.value,
|
||||||
dimension: item.dimension,
|
),
|
||||||
extraArguments: {
|
|
||||||
'sourceType': SourceType.playlist,
|
|
||||||
'favTitle': '入站必刷',
|
|
||||||
'mediaId': _controller.mediaId,
|
|
||||||
'desc': true,
|
|
||||||
'oid': item.aid,
|
|
||||||
'isContinuePlaying': index != 0,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import 'package:PiliPlus/http/loading_state.dart';
|
|||||||
import 'package:PiliPlus/models/common/video/source_type.dart';
|
import 'package:PiliPlus/models/common/video/source_type.dart';
|
||||||
import 'package:PiliPlus/models/model_hot_video_item.dart';
|
import 'package:PiliPlus/models/model_hot_video_item.dart';
|
||||||
import 'package:PiliPlus/models_new/popular/popular_series_one/config.dart';
|
import 'package:PiliPlus/models_new/popular/popular_series_one/config.dart';
|
||||||
|
import 'package:PiliPlus/pages/common/play_all_btn_mixin.dart';
|
||||||
import 'package:PiliPlus/pages/popular_series/controller.dart';
|
import 'package:PiliPlus/pages/popular_series/controller.dart';
|
||||||
import 'package:PiliPlus/utils/grid.dart';
|
import 'package:PiliPlus/utils/grid.dart';
|
||||||
import 'package:PiliPlus/utils/page_utils.dart';
|
import 'package:PiliPlus/utils/page_utils.dart';
|
||||||
@@ -24,11 +25,13 @@ class PopularSeriesPage extends StatefulWidget {
|
|||||||
State<PopularSeriesPage> createState() => _PopularSeriesPageState();
|
State<PopularSeriesPage> createState() => _PopularSeriesPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PopularSeriesPageState extends State<PopularSeriesPage> with GridMixin {
|
class _PopularSeriesPageState extends State<PopularSeriesPage>
|
||||||
|
with GridMixin, PlayAllBtnMixin {
|
||||||
final _controller = Get.put(PopularSeriesController());
|
final _controller = Get.put(PopularSeriesController());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final padding = MediaQuery.viewPaddingOf(context);
|
||||||
return scaffold(
|
return scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Obx(() {
|
title: Obx(() {
|
||||||
@@ -39,7 +42,10 @@ class _PopularSeriesPageState extends State<PopularSeriesPage> with GridMixin {
|
|||||||
return const Text('每周必看');
|
return const Text('每周必看');
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
body: refreshIndicator(
|
body: Stack(
|
||||||
|
clipBehavior: .none,
|
||||||
|
children: [
|
||||||
|
refreshIndicator(
|
||||||
onRefresh: _controller.onRefresh,
|
onRefresh: _controller.onRefresh,
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
physics: ReloadScrollPhysics(controller: _controller),
|
physics: ReloadScrollPhysics(controller: _controller),
|
||||||
@@ -50,6 +56,46 @@ class _PopularSeriesPageState extends State<PopularSeriesPage> with GridMixin {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Positioned(
|
||||||
|
right: padding.right,
|
||||||
|
bottom: padding.bottom + kFloatingActionButtonMargin,
|
||||||
|
child: Padding(
|
||||||
|
padding: const .only(right: kFloatingActionButtonMargin),
|
||||||
|
child: Obx(() {
|
||||||
|
if (_controller.loadingState.value case Success(
|
||||||
|
:final response,
|
||||||
|
)) {
|
||||||
|
return playAllBtn(() => toVideoPage(response!.first));
|
||||||
|
}
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void toVideoPage(
|
||||||
|
HotVideoItemModel item, {
|
||||||
|
int index = 0,
|
||||||
|
bool isPlayAll = true,
|
||||||
|
}) {
|
||||||
|
final config = _controller.config.value;
|
||||||
|
PageUtils.toVideoPage(
|
||||||
|
bvid: item.bvid,
|
||||||
|
cid: item.cid!,
|
||||||
|
dimension: item.dimension,
|
||||||
|
extraArguments: isPlayAll
|
||||||
|
? {
|
||||||
|
'sourceType': SourceType.playlist,
|
||||||
|
'favTitle': '每周必看 ${config?.label ?? ''}',
|
||||||
|
'mediaId': config?.mediaId,
|
||||||
|
'desc': true,
|
||||||
|
'oid': item.aid,
|
||||||
|
'isContinuePlaying': index != 0,
|
||||||
|
}
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,22 +113,8 @@ class _PopularSeriesPageState extends State<PopularSeriesPage> with GridMixin {
|
|||||||
final item = response[index];
|
final item = response[index];
|
||||||
return VideoCardH(
|
return VideoCardH(
|
||||||
videoItem: item,
|
videoItem: item,
|
||||||
onTap: () {
|
onTap: () =>
|
||||||
final config = _controller.config.value;
|
toVideoPage(item, index: index, isPlayAll: isPlayAll.value),
|
||||||
PageUtils.toVideoPage(
|
|
||||||
bvid: item.bvid,
|
|
||||||
cid: item.cid!,
|
|
||||||
dimension: item.dimension,
|
|
||||||
extraArguments: {
|
|
||||||
'sourceType': SourceType.playlist,
|
|
||||||
'favTitle': '每周必看 ${config?.label ?? ''}',
|
|
||||||
'mediaId': config?.mediaId,
|
|
||||||
'desc': true,
|
|
||||||
'oid': item.aid,
|
|
||||||
'isContinuePlaying': index != 0,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user