mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: pages
Closes #644 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -5,20 +5,18 @@ import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
|||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
import 'package:PiliPlus/models/common/tab_type.dart';
|
import 'package:PiliPlus/models/common/tab_type.dart';
|
||||||
import 'package:PiliPlus/pages/bangumi/pgc_index/pgc_index_page.dart';
|
import 'package:PiliPlus/pages/bangumi/pgc_index/pgc_index_page.dart';
|
||||||
|
import 'package:PiliPlus/pages/common/common_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPlus/common/constants.dart';
|
import 'package:PiliPlus/common/constants.dart';
|
||||||
import 'package:PiliPlus/common/widgets/http_error.dart';
|
import 'package:PiliPlus/common/widgets/http_error.dart';
|
||||||
import 'package:PiliPlus/pages/home/index.dart';
|
|
||||||
import 'package:PiliPlus/pages/main/index.dart';
|
|
||||||
|
|
||||||
import '../../utils/grid.dart';
|
import '../../utils/grid.dart';
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
import 'widgets/bangumi_card_v.dart';
|
import 'widgets/bangumi_card_v.dart';
|
||||||
import 'package:PiliPlus/common/widgets/scroll_physics.dart';
|
import 'package:PiliPlus/common/widgets/scroll_physics.dart';
|
||||||
|
|
||||||
class BangumiPage extends StatefulWidget {
|
class BangumiPage extends CommonPage {
|
||||||
const BangumiPage({
|
const BangumiPage({
|
||||||
super.key,
|
super.key,
|
||||||
required this.tabType,
|
required this.tabType,
|
||||||
@@ -30,9 +28,10 @@ class BangumiPage extends StatefulWidget {
|
|||||||
State<BangumiPage> createState() => _BangumiPageState();
|
State<BangumiPage> createState() => _BangumiPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _BangumiPageState extends State<BangumiPage>
|
class _BangumiPageState extends CommonPageState<BangumiPage, BangumiController>
|
||||||
with AutomaticKeepAliveClientMixin {
|
with AutomaticKeepAliveClientMixin {
|
||||||
late final BangumiController _bangumiController = Get.put(
|
@override
|
||||||
|
late BangumiController controller = Get.put(
|
||||||
BangumiController(tabType: widget.tabType),
|
BangumiController(tabType: widget.tabType),
|
||||||
tag: widget.tabType.name,
|
tag: widget.tabType.name,
|
||||||
);
|
);
|
||||||
@@ -40,51 +39,23 @@ class _BangumiPageState extends State<BangumiPage>
|
|||||||
@override
|
@override
|
||||||
bool get wantKeepAlive => true;
|
bool get wantKeepAlive => true;
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_bangumiController.scrollController.addListener(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
void listener() {
|
|
||||||
StreamController<bool> mainStream =
|
|
||||||
Get.find<MainController>().bottomBarStream;
|
|
||||||
StreamController<bool> searchBarStream =
|
|
||||||
Get.find<HomeController>().searchBarStream;
|
|
||||||
final ScrollDirection direction =
|
|
||||||
_bangumiController.scrollController.position.userScrollDirection;
|
|
||||||
if (direction == ScrollDirection.forward) {
|
|
||||||
mainStream.add(true);
|
|
||||||
searchBarStream.add(true);
|
|
||||||
} else if (direction == ScrollDirection.reverse) {
|
|
||||||
mainStream.add(false);
|
|
||||||
searchBarStream.add(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_bangumiController.scrollController.removeListener(listener);
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
return refreshIndicator(
|
return refreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
await Future.wait([
|
await Future.wait([
|
||||||
_bangumiController.onRefresh(),
|
controller.onRefresh(),
|
||||||
_bangumiController.queryBangumiFollow(),
|
controller.queryBangumiFollow(),
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
controller: _bangumiController.scrollController,
|
controller: controller.scrollController,
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
slivers: [
|
slivers: [
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: Obx(
|
child: Obx(
|
||||||
() => _bangumiController.isLogin.value
|
() => controller.isLogin.value
|
||||||
? Column(
|
? Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
@@ -93,7 +64,7 @@ class _BangumiPageState extends State<BangumiPage>
|
|||||||
children: [
|
children: [
|
||||||
Obx(
|
Obx(
|
||||||
() => Text(
|
() => Text(
|
||||||
'最近${widget.tabType == TabType.bangumi ? '追番' : '追剧'}${_bangumiController.followCount.value == -1 ? '' : ' ${_bangumiController.followCount.value}'}',
|
'最近${widget.tabType == TabType.bangumi ? '追番' : '追剧'}${controller.followCount.value == -1 ? '' : ' ${controller.followCount.value}'}',
|
||||||
style:
|
style:
|
||||||
Theme.of(context).textTheme.titleMedium,
|
Theme.of(context).textTheme.titleMedium,
|
||||||
),
|
),
|
||||||
@@ -102,7 +73,7 @@ class _BangumiPageState extends State<BangumiPage>
|
|||||||
IconButton(
|
IconButton(
|
||||||
tooltip: '刷新',
|
tooltip: '刷新',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_bangumiController
|
controller
|
||||||
..followPage = 1
|
..followPage = 1
|
||||||
..followEnd = false
|
..followEnd = false
|
||||||
..queryBangumiFollow();
|
..queryBangumiFollow();
|
||||||
@@ -113,7 +84,7 @@ class _BangumiPageState extends State<BangumiPage>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Obx(
|
Obx(
|
||||||
() => _bangumiController.isLogin.value
|
() => controller.isLogin.value
|
||||||
? Padding(
|
? Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 10),
|
horizontal: 10),
|
||||||
@@ -165,8 +136,8 @@ class _BangumiPageState extends State<BangumiPage>
|
|||||||
height: Grid.smallCardWidth / 2 / 0.75 +
|
height: Grid.smallCardWidth / 2 / 0.75 +
|
||||||
MediaQuery.textScalerOf(context).scale(50),
|
MediaQuery.textScalerOf(context).scale(50),
|
||||||
child: Obx(
|
child: Obx(
|
||||||
() => _buildFollowBody(
|
() =>
|
||||||
_bangumiController.followState.value),
|
_buildFollowBody(controller.followState.value),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -251,7 +222,7 @@ class _BangumiPageState extends State<BangumiPage>
|
|||||||
padding: const EdgeInsets.fromLTRB(
|
padding: const EdgeInsets.fromLTRB(
|
||||||
StyleString.safeSpace, 0, StyleString.safeSpace, 0),
|
StyleString.safeSpace, 0, StyleString.safeSpace, 0),
|
||||||
sliver: Obx(
|
sliver: Obx(
|
||||||
() => _buildBody(_bangumiController.loadingState.value),
|
() => _buildBody(controller.loadingState.value),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -277,7 +248,7 @@ class _BangumiPageState extends State<BangumiPage>
|
|||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
(BuildContext context, int index) {
|
(BuildContext context, int index) {
|
||||||
if (index == loadingState.response.length - 1) {
|
if (index == loadingState.response.length - 1) {
|
||||||
_bangumiController.onLoadMore();
|
controller.onLoadMore();
|
||||||
}
|
}
|
||||||
return BangumiCardV(
|
return BangumiCardV(
|
||||||
bangumiItem: loadingState.response[index]);
|
bangumiItem: loadingState.response[index]);
|
||||||
@@ -286,11 +257,11 @@ class _BangumiPageState extends State<BangumiPage>
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
: HttpError(
|
: HttpError(
|
||||||
callback: _bangumiController.onReload,
|
callback: controller.onReload,
|
||||||
),
|
),
|
||||||
Error() => HttpError(
|
Error() => HttpError(
|
||||||
errMsg: loadingState.errMsg,
|
errMsg: loadingState.errMsg,
|
||||||
callback: _bangumiController.onReload,
|
callback: controller.onReload,
|
||||||
),
|
),
|
||||||
LoadingState() => throw UnimplementedError(),
|
LoadingState() => throw UnimplementedError(),
|
||||||
};
|
};
|
||||||
@@ -298,12 +269,12 @@ class _BangumiPageState extends State<BangumiPage>
|
|||||||
|
|
||||||
Widget _buildFollowList(Success loadingState) {
|
Widget _buildFollowList(Success loadingState) {
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
controller: _bangumiController.followController,
|
controller: controller.followController,
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
itemCount: loadingState.response.length,
|
itemCount: loadingState.response.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if (index == loadingState.response.length - 1) {
|
if (index == loadingState.response.length - 1) {
|
||||||
_bangumiController.queryBangumiFollow(false);
|
controller.queryBangumiFollow(false);
|
||||||
}
|
}
|
||||||
return Container(
|
return Container(
|
||||||
width: Grid.smallCardWidth / 2,
|
width: Grid.smallCardWidth / 2,
|
||||||
|
|||||||
49
lib/pages/common/common_page.dart
Normal file
49
lib/pages/common/common_page.dart
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:PiliPlus/pages/common/common_controller.dart';
|
||||||
|
import 'package:PiliPlus/pages/home/controller.dart';
|
||||||
|
import 'package:PiliPlus/pages/main/controller.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
abstract class CommonPage extends StatefulWidget {
|
||||||
|
const CommonPage({super.key});
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class CommonPageState<T extends CommonPage, R extends CommonController>
|
||||||
|
extends State<T> {
|
||||||
|
R get controller;
|
||||||
|
StreamController<bool>? mainStream;
|
||||||
|
StreamController<bool>? searchBarStream;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
try {
|
||||||
|
mainStream = Get.find<MainController>().bottomBarStream;
|
||||||
|
searchBarStream = Get.find<HomeController>().searchBarStream;
|
||||||
|
} catch (_) {}
|
||||||
|
if (mainStream != null || searchBarStream != null) {
|
||||||
|
controller.scrollController.addListener(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void listener() {
|
||||||
|
final ScrollDirection direction =
|
||||||
|
controller.scrollController.position.userScrollDirection;
|
||||||
|
if (direction == ScrollDirection.forward) {
|
||||||
|
mainStream?.add(true);
|
||||||
|
searchBarStream?.add(true);
|
||||||
|
} else if (direction == ScrollDirection.reverse) {
|
||||||
|
mainStream?.add(false);
|
||||||
|
searchBarStream?.add(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
controller.scrollController.removeListener(listener);
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,11 +2,9 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
import 'package:PiliPlus/pages/home/controller.dart';
|
import 'package:PiliPlus/pages/common/common_page.dart';
|
||||||
import 'package:PiliPlus/pages/main/controller.dart';
|
|
||||||
import 'package:PiliPlus/utils/storage.dart';
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPlus/common/constants.dart';
|
import 'package:PiliPlus/common/constants.dart';
|
||||||
import 'package:PiliPlus/common/widgets/http_error.dart';
|
import 'package:PiliPlus/common/widgets/http_error.dart';
|
||||||
@@ -19,7 +17,7 @@ import '../index.dart';
|
|||||||
import '../widgets/dynamic_panel.dart';
|
import '../widgets/dynamic_panel.dart';
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
|
|
||||||
class DynamicsTabPage extends StatefulWidget {
|
class DynamicsTabPage extends CommonPage {
|
||||||
const DynamicsTabPage({super.key, required this.dynamicsType});
|
const DynamicsTabPage({super.key, required this.dynamicsType});
|
||||||
|
|
||||||
final String dynamicsType;
|
final String dynamicsType;
|
||||||
@@ -28,60 +26,40 @@ class DynamicsTabPage extends StatefulWidget {
|
|||||||
State<DynamicsTabPage> createState() => _DynamicsTabPageState();
|
State<DynamicsTabPage> createState() => _DynamicsTabPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DynamicsTabPageState extends State<DynamicsTabPage>
|
class _DynamicsTabPageState
|
||||||
|
extends CommonPageState<DynamicsTabPage, DynamicsTabController>
|
||||||
with AutomaticKeepAliveClientMixin {
|
with AutomaticKeepAliveClientMixin {
|
||||||
late DynamicsTabController _dynamicsTabController;
|
|
||||||
late bool dynamicsWaterfallFlow;
|
late bool dynamicsWaterfallFlow;
|
||||||
late final DynamicsController dynamicsController;
|
|
||||||
StreamSubscription? _listener;
|
StreamSubscription? _listener;
|
||||||
|
|
||||||
|
DynamicsController dynamicsController = Get.put(DynamicsController());
|
||||||
|
@override
|
||||||
|
late DynamicsTabController controller = Get.put(
|
||||||
|
DynamicsTabController(dynamicsType: widget.dynamicsType)
|
||||||
|
..mid = dynamicsController.mid.value,
|
||||||
|
tag: widget.dynamicsType,
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get wantKeepAlive => true;
|
bool get wantKeepAlive => true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
dynamicsController = Get.put(DynamicsController());
|
|
||||||
_dynamicsTabController = Get.put(
|
|
||||||
DynamicsTabController(dynamicsType: widget.dynamicsType)
|
|
||||||
..mid = dynamicsController.mid.value,
|
|
||||||
tag: widget.dynamicsType,
|
|
||||||
);
|
|
||||||
_dynamicsTabController.scrollController.addListener(listener);
|
|
||||||
if (widget.dynamicsType == 'up') {
|
if (widget.dynamicsType == 'up') {
|
||||||
_listener = dynamicsController.mid.listen((mid) {
|
_listener = dynamicsController.mid.listen((mid) {
|
||||||
// debugPrint('midListen: $mid');
|
controller.mid = mid;
|
||||||
_dynamicsTabController.mid = mid;
|
controller.scrollController.jumpTo(0);
|
||||||
_dynamicsTabController.scrollController.jumpTo(0);
|
controller.onReload();
|
||||||
_dynamicsTabController.onReload();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
dynamicsWaterfallFlow = GStorage.setting
|
dynamicsWaterfallFlow = GStorage.setting
|
||||||
.get(SettingBoxKey.dynamicsWaterfallFlow, defaultValue: true);
|
.get(SettingBoxKey.dynamicsWaterfallFlow, defaultValue: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void listener() {
|
|
||||||
try {
|
|
||||||
StreamController<bool> mainStream =
|
|
||||||
Get.find<MainController>().bottomBarStream;
|
|
||||||
StreamController<bool> searchBarStream =
|
|
||||||
Get.find<HomeController>().searchBarStream;
|
|
||||||
final ScrollDirection direction =
|
|
||||||
_dynamicsTabController.scrollController.position.userScrollDirection;
|
|
||||||
if (direction == ScrollDirection.forward) {
|
|
||||||
mainStream.add(true);
|
|
||||||
searchBarStream.add(true);
|
|
||||||
} else if (direction == ScrollDirection.reverse) {
|
|
||||||
mainStream.add(false);
|
|
||||||
searchBarStream.add(false);
|
|
||||||
}
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_listener?.cancel();
|
_listener?.cancel();
|
||||||
_dynamicsTabController.scrollController.removeListener(listener);
|
|
||||||
dynamicsController.mid.close();
|
dynamicsController.mid.close();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
@@ -97,15 +75,15 @@ class _DynamicsTabPageState extends State<DynamicsTabPage>
|
|||||||
dynamicsWaterfallFlow = GStorage.setting
|
dynamicsWaterfallFlow = GStorage.setting
|
||||||
.get(SettingBoxKey.dynamicsWaterfallFlow, defaultValue: true);
|
.get(SettingBoxKey.dynamicsWaterfallFlow, defaultValue: true);
|
||||||
await Future.wait([
|
await Future.wait([
|
||||||
_dynamicsTabController.onRefresh(),
|
controller.onRefresh(),
|
||||||
dynamicsController.queryFollowUp(),
|
dynamicsController.queryFollowUp(),
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
controller: _dynamicsTabController.scrollController,
|
controller: controller.scrollController,
|
||||||
slivers: [
|
slivers: [
|
||||||
Obx(() => _buildBody(_dynamicsTabController.loadingState.value)),
|
Obx(() => _buildBody(controller.loadingState.value)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -161,7 +139,7 @@ class _DynamicsTabPageState extends State<DynamicsTabPage>
|
|||||||
|
|
||||||
lastChildLayoutTypeBuilder: (index) {
|
lastChildLayoutTypeBuilder: (index) {
|
||||||
if (index == loadingState.response.length - 1) {
|
if (index == loadingState.response.length - 1) {
|
||||||
_dynamicsTabController.onLoadMore();
|
controller.onLoadMore();
|
||||||
}
|
}
|
||||||
return index == loadingState.response.length
|
return index == loadingState.response.length
|
||||||
? LastChildLayoutType.foot
|
? LastChildLayoutType.foot
|
||||||
@@ -173,7 +151,7 @@ class _DynamicsTabPageState extends State<DynamicsTabPage>
|
|||||||
for (var i in loadingState.response)
|
for (var i in loadingState.response)
|
||||||
DynamicPanel(
|
DynamicPanel(
|
||||||
item: i,
|
item: i,
|
||||||
onRemove: _dynamicsTabController.onRemove,
|
onRemove: controller.onRemove,
|
||||||
),
|
),
|
||||||
] else ...[
|
] else ...[
|
||||||
for (var i in loadingState.response)
|
for (var i in loadingState.response)
|
||||||
@@ -181,7 +159,7 @@ class _DynamicsTabPageState extends State<DynamicsTabPage>
|
|||||||
.contains(i.modules?.moduleAuthor?.mid))
|
.contains(i.modules?.moduleAuthor?.mid))
|
||||||
DynamicPanel(
|
DynamicPanel(
|
||||||
item: i,
|
item: i,
|
||||||
onRemove: _dynamicsTabController.onRemove,
|
onRemove: controller.onRemove,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@@ -195,7 +173,7 @@ class _DynamicsTabPageState extends State<DynamicsTabPage>
|
|||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
(context, index) {
|
(context, index) {
|
||||||
if (index == loadingState.response.length - 1) {
|
if (index == loadingState.response.length - 1) {
|
||||||
_dynamicsTabController.onLoadMore();
|
controller.onLoadMore();
|
||||||
}
|
}
|
||||||
if ((dynamicsController.tabController.index == 4 &&
|
if ((dynamicsController.tabController.index == 4 &&
|
||||||
dynamicsController.mid.value != -1) ||
|
dynamicsController.mid.value != -1) ||
|
||||||
@@ -204,7 +182,7 @@ class _DynamicsTabPageState extends State<DynamicsTabPage>
|
|||||||
?.moduleAuthor?.mid)) {
|
?.moduleAuthor?.mid)) {
|
||||||
return DynamicPanel(
|
return DynamicPanel(
|
||||||
item: loadingState.response[index],
|
item: loadingState.response[index],
|
||||||
onRemove: _dynamicsTabController.onRemove,
|
onRemove: controller.onRemove,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
@@ -217,11 +195,11 @@ class _DynamicsTabPageState extends State<DynamicsTabPage>
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
: HttpError(
|
: HttpError(
|
||||||
callback: _dynamicsTabController.onReload,
|
callback: controller.onReload,
|
||||||
),
|
),
|
||||||
Error() => HttpError(
|
Error() => HttpError(
|
||||||
errMsg: loadingState.errMsg,
|
errMsg: loadingState.errMsg,
|
||||||
callback: _dynamicsTabController.onReload,
|
callback: controller.onReload,
|
||||||
),
|
),
|
||||||
LoadingState() => throw UnimplementedError(),
|
LoadingState() => throw UnimplementedError(),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -19,8 +19,7 @@ class HomeController extends GetxController
|
|||||||
RxBool isLogin = false.obs;
|
RxBool isLogin = false.obs;
|
||||||
RxString userFace = ''.obs;
|
RxString userFace = ''.obs;
|
||||||
dynamic userInfo;
|
dynamic userInfo;
|
||||||
late final StreamController<bool> searchBarStream =
|
StreamController<bool>? searchBarStream;
|
||||||
StreamController<bool>.broadcast();
|
|
||||||
late bool hideSearchBar;
|
late bool hideSearchBar;
|
||||||
late List defaultTabs;
|
late List defaultTabs;
|
||||||
late List<String> tabbarSort;
|
late List<String> tabbarSort;
|
||||||
@@ -51,6 +50,9 @@ class HomeController extends GetxController
|
|||||||
userFace.value = userInfo != null ? userInfo.face : '';
|
userFace.value = userInfo != null ? userInfo.face : '';
|
||||||
hideSearchBar =
|
hideSearchBar =
|
||||||
GStorage.setting.get(SettingBoxKey.hideSearchBar, defaultValue: true);
|
GStorage.setting.get(SettingBoxKey.hideSearchBar, defaultValue: true);
|
||||||
|
if (hideSearchBar) {
|
||||||
|
searchBarStream = StreamController<bool>.broadcast();
|
||||||
|
}
|
||||||
enableSearchWord = GStorage.setting
|
enableSearchWord = GStorage.setting
|
||||||
.get(SettingBoxKey.enableSearchWord, defaultValue: true);
|
.get(SettingBoxKey.enableSearchWord, defaultValue: true);
|
||||||
if (enableSearchWord) {
|
if (enableSearchWord) {
|
||||||
@@ -117,7 +119,7 @@ class HomeController extends GetxController
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void onClose() {
|
void onClose() {
|
||||||
searchBarStream.close();
|
searchBarStream?.close();
|
||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,9 +155,9 @@ class _HomePageState extends State<HomePage>
|
|||||||
return StreamBuilder(
|
return StreamBuilder(
|
||||||
stream: _homeController.hideSearchBar
|
stream: _homeController.hideSearchBar
|
||||||
? _mainController.navSearchStreamDebounce
|
? _mainController.navSearchStreamDebounce
|
||||||
? _homeController.searchBarStream.stream
|
? _homeController.searchBarStream?.stream
|
||||||
.throttle(const Duration(milliseconds: 500))
|
.throttle(const Duration(milliseconds: 500))
|
||||||
: _homeController.searchBarStream.stream
|
: _homeController.searchBarStream?.stream
|
||||||
: null,
|
: null,
|
||||||
initialData: true,
|
initialData: true,
|
||||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||||
|
|||||||
@@ -1,63 +1,34 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||||
import 'package:PiliPlus/common/widgets/video_card_h.dart';
|
import 'package:PiliPlus/common/widgets/video_card_h.dart';
|
||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
import 'package:PiliPlus/models/common/tab_type.dart';
|
import 'package:PiliPlus/models/common/tab_type.dart';
|
||||||
|
import 'package:PiliPlus/pages/common/common_page.dart';
|
||||||
import 'package:PiliPlus/pages/rank/view.dart';
|
import 'package:PiliPlus/pages/rank/view.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPlus/common/constants.dart';
|
import 'package:PiliPlus/common/constants.dart';
|
||||||
import 'package:PiliPlus/common/skeleton/video_card_h.dart';
|
import 'package:PiliPlus/common/skeleton/video_card_h.dart';
|
||||||
import 'package:PiliPlus/common/widgets/http_error.dart';
|
import 'package:PiliPlus/common/widgets/http_error.dart';
|
||||||
import 'package:PiliPlus/pages/home/index.dart';
|
import 'package:PiliPlus/pages/home/index.dart';
|
||||||
import 'package:PiliPlus/pages/hot/controller.dart';
|
import 'package:PiliPlus/pages/hot/controller.dart';
|
||||||
import 'package:PiliPlus/pages/main/index.dart';
|
|
||||||
|
|
||||||
import '../../utils/grid.dart';
|
import '../../utils/grid.dart';
|
||||||
|
|
||||||
class HotPage extends StatefulWidget {
|
class HotPage extends CommonPage {
|
||||||
const HotPage({super.key});
|
const HotPage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<HotPage> createState() => _HotPageState();
|
State<HotPage> createState() => _HotPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _HotPageState extends State<HotPage> with AutomaticKeepAliveClientMixin {
|
class _HotPageState extends CommonPageState<HotPage, HotController>
|
||||||
final HotController _hotController = Get.put(HotController());
|
with AutomaticKeepAliveClientMixin {
|
||||||
|
@override
|
||||||
|
HotController controller = Get.put(HotController());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get wantKeepAlive => true;
|
bool get wantKeepAlive => true;
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_hotController.scrollController.addListener(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
void listener() {
|
|
||||||
StreamController<bool> mainStream =
|
|
||||||
Get.find<MainController>().bottomBarStream;
|
|
||||||
StreamController<bool> searchBarStream =
|
|
||||||
Get.find<HomeController>().searchBarStream;
|
|
||||||
final ScrollDirection direction =
|
|
||||||
_hotController.scrollController.position.userScrollDirection;
|
|
||||||
if (direction == ScrollDirection.forward) {
|
|
||||||
mainStream.add(true);
|
|
||||||
searchBarStream.add(true);
|
|
||||||
} else if (direction == ScrollDirection.reverse) {
|
|
||||||
mainStream.add(false);
|
|
||||||
searchBarStream.add(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_hotController.scrollController.removeListener(listener);
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildEntranceItem({
|
Widget _buildEntranceItem({
|
||||||
required String iconUrl,
|
required String iconUrl,
|
||||||
required String title,
|
required String title,
|
||||||
@@ -84,15 +55,15 @@ class _HotPageState extends State<HotPage> with AutomaticKeepAliveClientMixin {
|
|||||||
super.build(context);
|
super.build(context);
|
||||||
return refreshIndicator(
|
return refreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
return await _hotController.onRefresh();
|
await controller.onRefresh();
|
||||||
},
|
},
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
controller: _hotController.scrollController,
|
controller: controller.scrollController,
|
||||||
slivers: [
|
slivers: [
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: Obx(
|
child: Obx(
|
||||||
() => _hotController.showHotRcmd.value
|
() => controller.showHotRcmd.value
|
||||||
? Padding(
|
? Padding(
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.only(left: 12, top: 12, right: 12),
|
const EdgeInsets.only(left: 12, top: 12, right: 12),
|
||||||
@@ -165,7 +136,7 @@ class _HotPageState extends State<HotPage> with AutomaticKeepAliveClientMixin {
|
|||||||
bottom: MediaQuery.of(context).padding.bottom + 80,
|
bottom: MediaQuery.of(context).padding.bottom + 80,
|
||||||
),
|
),
|
||||||
sliver: Obx(
|
sliver: Obx(
|
||||||
() => _buildBody(_hotController.loadingState.value),
|
() => _buildBody(controller.loadingState.value),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -202,7 +173,7 @@ class _HotPageState extends State<HotPage> with AutomaticKeepAliveClientMixin {
|
|||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
(context, index) {
|
(context, index) {
|
||||||
if (index == loadingState.response.length - 1) {
|
if (index == loadingState.response.length - 1) {
|
||||||
_hotController.onLoadMore();
|
controller.onLoadMore();
|
||||||
}
|
}
|
||||||
return VideoCardH(
|
return VideoCardH(
|
||||||
videoItem: loadingState.response[index],
|
videoItem: loadingState.response[index],
|
||||||
@@ -213,11 +184,11 @@ class _HotPageState extends State<HotPage> with AutomaticKeepAliveClientMixin {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
: HttpError(
|
: HttpError(
|
||||||
callback: _hotController.onReload,
|
callback: controller.onReload,
|
||||||
),
|
),
|
||||||
Error() => HttpError(
|
Error() => HttpError(
|
||||||
errMsg: loadingState.errMsg,
|
errMsg: loadingState.errMsg,
|
||||||
callback: _hotController.onReload,
|
callback: controller.onReload,
|
||||||
),
|
),
|
||||||
LoadingState() => throw UnimplementedError(),
|
LoadingState() => throw UnimplementedError(),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,67 +1,36 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:PiliPlus/common/widgets/loading_widget.dart';
|
import 'package:PiliPlus/common/widgets/loading_widget.dart';
|
||||||
import 'package:PiliPlus/common/widgets/network_img_layer.dart';
|
import 'package:PiliPlus/common/widgets/network_img_layer.dart';
|
||||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||||
import 'package:PiliPlus/common/widgets/self_sized_horizontal_list.dart';
|
import 'package:PiliPlus/common/widgets/self_sized_horizontal_list.dart';
|
||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
|
import 'package:PiliPlus/pages/common/common_page.dart';
|
||||||
import 'package:PiliPlus/pages/live/controller.dart';
|
import 'package:PiliPlus/pages/live/controller.dart';
|
||||||
import 'package:PiliPlus/pages/live/widgets/live_item.dart';
|
import 'package:PiliPlus/pages/live/widgets/live_item.dart';
|
||||||
import 'package:PiliPlus/pages/live/widgets/live_item_follow.dart';
|
import 'package:PiliPlus/pages/live/widgets/live_item_follow.dart';
|
||||||
import 'package:PiliPlus/utils/utils.dart';
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPlus/common/constants.dart';
|
import 'package:PiliPlus/common/constants.dart';
|
||||||
import 'package:PiliPlus/common/skeleton/video_card_v.dart';
|
import 'package:PiliPlus/common/skeleton/video_card_v.dart';
|
||||||
import 'package:PiliPlus/common/widgets/http_error.dart';
|
import 'package:PiliPlus/common/widgets/http_error.dart';
|
||||||
import 'package:PiliPlus/pages/home/index.dart';
|
|
||||||
import 'package:PiliPlus/pages/main/index.dart';
|
|
||||||
|
|
||||||
import '../../utils/grid.dart';
|
import '../../utils/grid.dart';
|
||||||
|
|
||||||
class LivePage extends StatefulWidget {
|
class LivePage extends CommonPage {
|
||||||
const LivePage({super.key});
|
const LivePage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<LivePage> createState() => _LivePageState();
|
State<LivePage> createState() => _LivePageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _LivePageState extends State<LivePage>
|
class _LivePageState extends CommonPageState<LivePage, LiveController>
|
||||||
with AutomaticKeepAliveClientMixin {
|
with AutomaticKeepAliveClientMixin {
|
||||||
late final _controller = Get.put(LiveController());
|
@override
|
||||||
|
LiveController controller = Get.put(LiveController());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get wantKeepAlive => true;
|
bool get wantKeepAlive => true;
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_controller.scrollController.addListener(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
void listener() {
|
|
||||||
StreamController<bool> mainStream =
|
|
||||||
Get.find<MainController>().bottomBarStream;
|
|
||||||
StreamController<bool> searchBarStream =
|
|
||||||
Get.find<HomeController>().searchBarStream;
|
|
||||||
final ScrollDirection direction =
|
|
||||||
_controller.scrollController.position.userScrollDirection;
|
|
||||||
if (direction == ScrollDirection.forward) {
|
|
||||||
mainStream.add(true);
|
|
||||||
searchBarStream.add(true);
|
|
||||||
} else if (direction == ScrollDirection.reverse) {
|
|
||||||
mainStream.add(false);
|
|
||||||
searchBarStream.add(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_controller.scrollController.removeListener(listener);
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
@@ -74,14 +43,14 @@ class _LivePageState extends State<LivePage>
|
|||||||
),
|
),
|
||||||
child: refreshIndicator(
|
child: refreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
await _controller.onRefresh();
|
await controller.onRefresh();
|
||||||
},
|
},
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
controller: _controller.scrollController,
|
controller: controller.scrollController,
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
slivers: [
|
slivers: [
|
||||||
Obx(
|
Obx(
|
||||||
() => _controller.isLogin.value
|
() => controller.isLogin.value
|
||||||
? SliverPadding(
|
? SliverPadding(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
vertical: StyleString.cardSpace,
|
vertical: StyleString.cardSpace,
|
||||||
@@ -98,14 +67,14 @@ class _LivePageState extends State<LivePage>
|
|||||||
bottom: MediaQuery.paddingOf(context).bottom + 80,
|
bottom: MediaQuery.paddingOf(context).bottom + 80,
|
||||||
),
|
),
|
||||||
sliver: Obx(
|
sliver: Obx(
|
||||||
() => _controller.loadingState.value is Loading ||
|
() => controller.loadingState.value is Loading ||
|
||||||
_controller.loadingState.value is Success
|
controller.loadingState.value is Success
|
||||||
? contentGrid(_controller.loadingState.value)
|
? contentGrid(controller.loadingState.value)
|
||||||
: HttpError(
|
: HttpError(
|
||||||
errMsg: _controller.loadingState.value is Error
|
errMsg: controller.loadingState.value is Error
|
||||||
? (_controller.loadingState.value as Error).errMsg
|
? (controller.loadingState.value as Error).errMsg
|
||||||
: '没有相关数据',
|
: '没有相关数据',
|
||||||
callback: _controller.onReload,
|
callback: controller.onReload,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -131,7 +100,7 @@ class _LivePageState extends State<LivePage>
|
|||||||
(BuildContext context, int index) {
|
(BuildContext context, int index) {
|
||||||
if (loadingState is Success &&
|
if (loadingState is Success &&
|
||||||
index == loadingState.response.length - 1) {
|
index == loadingState.response.length - 1) {
|
||||||
_controller.onLoadMore();
|
controller.onLoadMore();
|
||||||
}
|
}
|
||||||
return loadingState is Success
|
return loadingState is Success
|
||||||
? LiveCardV(
|
? LiveCardV(
|
||||||
@@ -157,7 +126,7 @@ class _LivePageState extends State<LivePage>
|
|||||||
children: [
|
children: [
|
||||||
TextSpan(text: '我的关注 '),
|
TextSpan(text: '我的关注 '),
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: '${_controller.liveCount.value}',
|
text: '${controller.liveCount.value}',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
@@ -198,7 +167,7 @@ class _LivePageState extends State<LivePage>
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Obx(() => _buildFollowBody(_controller.followListState.value)),
|
Obx(() => _buildFollowBody(controller.followListState.value)),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -214,7 +183,7 @@ class _LivePageState extends State<LivePage>
|
|||||||
gapSize: 5,
|
gapSize: 5,
|
||||||
childBuilder: (index) {
|
childBuilder: (index) {
|
||||||
if (index == loadingState.response.length - 1) {
|
if (index == loadingState.response.length - 1) {
|
||||||
_controller.fetchLiveFollowing(false);
|
controller.fetchLiveFollowing(false);
|
||||||
}
|
}
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: 65,
|
width: 65,
|
||||||
@@ -275,7 +244,7 @@ class _LivePageState extends State<LivePage>
|
|||||||
: const SizedBox.shrink(),
|
: const SizedBox.shrink(),
|
||||||
Error() => GestureDetector(
|
Error() => GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_controller.fetchLiveFollowing();
|
controller.fetchLiveFollowing();
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 80,
|
height: 80,
|
||||||
@@ -294,13 +263,13 @@ class _LivePageState extends State<LivePage>
|
|||||||
Widget get _buildFollowListPage => Scaffold(
|
Widget get _buildFollowListPage => Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Obx(
|
title: Obx(
|
||||||
() => Text('${_controller.liveCount.value}人正在直播'),
|
() => Text('${controller.liveCount.value}人正在直播'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: CustomScrollView(
|
body: CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
Obx(
|
Obx(
|
||||||
() => _buildFollowListBody(_controller.followListState.value),
|
() => _buildFollowListBody(controller.followListState.value),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -326,7 +295,7 @@ class _LivePageState extends State<LivePage>
|
|||||||
(BuildContext context, int index) {
|
(BuildContext context, int index) {
|
||||||
if (loadingState is Success &&
|
if (loadingState is Success &&
|
||||||
index == loadingState.response.length - 1) {
|
index == loadingState.response.length - 1) {
|
||||||
_controller.fetchLiveFollowing(false);
|
controller.fetchLiveFollowing(false);
|
||||||
}
|
}
|
||||||
return loadingState is Success
|
return loadingState is Success
|
||||||
? LiveCardVFollow(
|
? LiveCardVFollow(
|
||||||
@@ -342,7 +311,7 @@ class _LivePageState extends State<LivePage>
|
|||||||
Error() => HttpError(
|
Error() => HttpError(
|
||||||
errMsg: loadingState.errMsg,
|
errMsg: loadingState.errMsg,
|
||||||
callback: () {
|
callback: () {
|
||||||
_controller
|
controller
|
||||||
..followListState.value = LoadingState.loading()
|
..followListState.value = LoadingState.loading()
|
||||||
..fetchLiveFollowing();
|
..fetchLiveFollowing();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ class MainController extends GetxController {
|
|||||||
List<Widget> pages = <Widget>[];
|
List<Widget> pages = <Widget>[];
|
||||||
RxList navigationBars = [].obs;
|
RxList navigationBars = [].obs;
|
||||||
|
|
||||||
final StreamController<bool> bottomBarStream =
|
StreamController<bool>? bottomBarStream;
|
||||||
StreamController<bool>.broadcast();
|
|
||||||
late bool hideTabBar;
|
late bool hideTabBar;
|
||||||
late dynamic controller;
|
late dynamic controller;
|
||||||
RxInt selectedIndex = 0.obs;
|
RxInt selectedIndex = 0.obs;
|
||||||
@@ -48,6 +47,9 @@ class MainController extends GetxController {
|
|||||||
}
|
}
|
||||||
hideTabBar =
|
hideTabBar =
|
||||||
GStorage.setting.get(SettingBoxKey.hideTabBar, defaultValue: true);
|
GStorage.setting.get(SettingBoxKey.hideTabBar, defaultValue: true);
|
||||||
|
if (hideTabBar) {
|
||||||
|
bottomBarStream = StreamController<bool>.broadcast();
|
||||||
|
}
|
||||||
isLogin.value = Accounts.main.isLogin;
|
isLogin.value = Accounts.main.isLogin;
|
||||||
dynamicBadgeMode = DynamicBadgeMode.values[GStorage.setting.get(
|
dynamicBadgeMode = DynamicBadgeMode.values[GStorage.setting.get(
|
||||||
SettingBoxKey.dynamicBadgeMode,
|
SettingBoxKey.dynamicBadgeMode,
|
||||||
@@ -217,7 +219,7 @@ class MainController extends GetxController {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void onClose() {
|
void onClose() {
|
||||||
bottomBarStream.close();
|
bottomBarStream?.close();
|
||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,7 +178,8 @@ class _MainAppState extends State<MainApp>
|
|||||||
onPopInvokedWithResult: (bool didPop, Object? result) async {
|
onPopInvokedWithResult: (bool didPop, Object? result) async {
|
||||||
if (_mainController.selectedIndex.value != 0) {
|
if (_mainController.selectedIndex.value != 0) {
|
||||||
setIndex(0);
|
setIndex(0);
|
||||||
_mainController.bottomBarStream.add(true);
|
_mainController.bottomBarStream?.add(true);
|
||||||
|
_homeController.searchBarStream?.add(true);
|
||||||
} else {
|
} else {
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
Utils.channel.invokeMethod('back');
|
Utils.channel.invokeMethod('back');
|
||||||
@@ -265,9 +266,9 @@ class _MainAppState extends State<MainApp>
|
|||||||
: StreamBuilder(
|
: StreamBuilder(
|
||||||
stream: _mainController.hideTabBar
|
stream: _mainController.hideTabBar
|
||||||
? _mainController.navSearchStreamDebounce
|
? _mainController.navSearchStreamDebounce
|
||||||
? _mainController.bottomBarStream.stream
|
? _mainController.bottomBarStream?.stream
|
||||||
.throttle(const Duration(milliseconds: 500))
|
.throttle(const Duration(milliseconds: 500))
|
||||||
: _mainController.bottomBarStream.stream
|
: _mainController.bottomBarStream?.stream
|
||||||
: null,
|
: null,
|
||||||
initialData: true,
|
initialData: true,
|
||||||
builder: (context, AsyncSnapshot snapshot) {
|
builder: (context, AsyncSnapshot snapshot) {
|
||||||
|
|||||||
@@ -1,54 +1,29 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
|
import 'package:PiliPlus/pages/common/common_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPlus/common/widgets/network_img_layer.dart';
|
import 'package:PiliPlus/common/widgets/network_img_layer.dart';
|
||||||
import 'package:PiliPlus/models/user/fav_folder.dart';
|
import 'package:PiliPlus/models/user/fav_folder.dart';
|
||||||
import 'package:PiliPlus/pages/main/index.dart';
|
|
||||||
import 'package:PiliPlus/pages/media/index.dart';
|
import 'package:PiliPlus/pages/media/index.dart';
|
||||||
import 'package:PiliPlus/utils/utils.dart';
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
|
|
||||||
class MediaPage extends StatefulWidget {
|
class MediaPage extends CommonPage {
|
||||||
const MediaPage({super.key});
|
const MediaPage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<MediaPage> createState() => _MediaPageState();
|
State<MediaPage> createState() => _MediaPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MediaPageState extends State<MediaPage>
|
class _MediaPageState extends CommonPageState<MediaPage, MediaController>
|
||||||
with AutomaticKeepAliveClientMixin {
|
with AutomaticKeepAliveClientMixin {
|
||||||
late MediaController mediaController;
|
@override
|
||||||
|
MediaController controller = Get.put(MediaController());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get wantKeepAlive => true;
|
bool get wantKeepAlive => true;
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
mediaController = Get.put(MediaController());
|
|
||||||
mediaController.scrollController.addListener(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
void listener() {
|
|
||||||
StreamController<bool> mainStream =
|
|
||||||
Get.find<MainController>().bottomBarStream;
|
|
||||||
final ScrollDirection direction =
|
|
||||||
mediaController.scrollController.position.userScrollDirection;
|
|
||||||
if (direction == ScrollDirection.forward) {
|
|
||||||
mainStream.add(true);
|
|
||||||
} else if (direction == ScrollDirection.reverse) {
|
|
||||||
mainStream.add(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
mediaController.scrollController.removeListener(listener);
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
@@ -60,7 +35,7 @@ class _MediaPageState extends State<MediaPage>
|
|||||||
),
|
),
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
controller: mediaController.scrollController,
|
controller: controller.scrollController,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
ListTile(
|
ListTile(
|
||||||
@@ -86,7 +61,7 @@ class _MediaPageState extends State<MediaPage>
|
|||||||
size: 20,
|
size: 20,
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
for (var i in mediaController.list) ...[
|
for (var i in controller.list) ...[
|
||||||
ListTile(
|
ListTile(
|
||||||
onTap: () => i['onTap'](),
|
onTap: () => i['onTap'](),
|
||||||
dense: true,
|
dense: true,
|
||||||
@@ -107,7 +82,7 @@ class _MediaPageState extends State<MediaPage>
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
Obx(
|
Obx(
|
||||||
() => mediaController.loadingState.value is Loading
|
() => controller.loadingState.value is Loading
|
||||||
? const SizedBox.shrink()
|
? const SizedBox.shrink()
|
||||||
: favFolder(),
|
: favFolder(),
|
||||||
)
|
)
|
||||||
@@ -128,7 +103,7 @@ class _MediaPageState extends State<MediaPage>
|
|||||||
onTap: () async {
|
onTap: () async {
|
||||||
await Get.toNamed('/fav');
|
await Get.toNamed('/fav');
|
||||||
Future.delayed(const Duration(milliseconds: 150), () {
|
Future.delayed(const Duration(milliseconds: 150), () {
|
||||||
mediaController.onRefresh();
|
controller.onRefresh();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
leading: null,
|
leading: null,
|
||||||
@@ -146,9 +121,9 @@ class _MediaPageState extends State<MediaPage>
|
|||||||
Theme.of(context).textTheme.titleMedium!.fontSize,
|
Theme.of(context).textTheme.titleMedium!.fontSize,
|
||||||
fontWeight: FontWeight.bold),
|
fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
if (mediaController.count.value != -1)
|
if (controller.count.value != -1)
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: "${mediaController.count.value} ",
|
text: "${controller.count.value} ",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize:
|
fontSize:
|
||||||
Theme.of(context).textTheme.titleSmall!.fontSize,
|
Theme.of(context).textTheme.titleSmall!.fontSize,
|
||||||
@@ -168,7 +143,7 @@ class _MediaPageState extends State<MediaPage>
|
|||||||
),
|
),
|
||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
tooltip: '刷新',
|
tooltip: '刷新',
|
||||||
onPressed: mediaController.onRefresh,
|
onPressed: controller.onRefresh,
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.refresh,
|
Icons.refresh,
|
||||||
size: 20,
|
size: 20,
|
||||||
@@ -179,7 +154,7 @@ class _MediaPageState extends State<MediaPage>
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: MediaQuery.textScalerOf(context).scale(200),
|
height: MediaQuery.textScalerOf(context).scale(200),
|
||||||
child: Obx(() => _buildBody(mediaController.loadingState.value)),
|
child: Obx(() => _buildBody(controller.loadingState.value)),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: MediaQuery.paddingOf(context).bottom + 100,
|
height: MediaQuery.paddingOf(context).bottom + 100,
|
||||||
@@ -214,7 +189,7 @@ class _MediaPageState extends State<MediaPage>
|
|||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await Get.toNamed('/fav');
|
await Get.toNamed('/fav');
|
||||||
Future.delayed(const Duration(milliseconds: 150), () {
|
Future.delayed(const Duration(milliseconds: 150), () {
|
||||||
mediaController.onRefresh();
|
controller.onRefresh();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
@@ -242,7 +217,7 @@ class _MediaPageState extends State<MediaPage>
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
Future.delayed(const Duration(milliseconds: 150), () {
|
Future.delayed(const Duration(milliseconds: 150), () {
|
||||||
mediaController.onRefresh();
|
controller.onRefresh();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,21 +1,17 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
|
import 'package:PiliPlus/pages/common/common_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPlus/common/constants.dart';
|
import 'package:PiliPlus/common/constants.dart';
|
||||||
import 'package:PiliPlus/common/skeleton/video_card_h.dart';
|
import 'package:PiliPlus/common/skeleton/video_card_h.dart';
|
||||||
import 'package:PiliPlus/common/widgets/http_error.dart';
|
import 'package:PiliPlus/common/widgets/http_error.dart';
|
||||||
import 'package:PiliPlus/common/widgets/video_card_h.dart';
|
import 'package:PiliPlus/common/widgets/video_card_h.dart';
|
||||||
import 'package:PiliPlus/pages/home/index.dart';
|
|
||||||
import 'package:PiliPlus/pages/main/index.dart';
|
|
||||||
import 'package:PiliPlus/pages/rank/zone/index.dart';
|
import 'package:PiliPlus/pages/rank/zone/index.dart';
|
||||||
|
|
||||||
import '../../../utils/grid.dart';
|
import '../../../utils/grid.dart';
|
||||||
|
|
||||||
class ZonePage extends StatefulWidget {
|
class ZonePage extends CommonPage {
|
||||||
const ZonePage({super.key, required this.rid});
|
const ZonePage({super.key, required this.rid});
|
||||||
|
|
||||||
final int rid;
|
final int rid;
|
||||||
@@ -24,52 +20,26 @@ class ZonePage extends StatefulWidget {
|
|||||||
State<ZonePage> createState() => _ZonePageState();
|
State<ZonePage> createState() => _ZonePageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ZonePageState extends State<ZonePage>
|
class _ZonePageState extends CommonPageState<ZonePage, ZoneController>
|
||||||
with AutomaticKeepAliveClientMixin {
|
with AutomaticKeepAliveClientMixin {
|
||||||
late ZoneController _zoneController;
|
@override
|
||||||
|
late ZoneController controller = Get.put(
|
||||||
|
ZoneController(zoneID: widget.rid),
|
||||||
|
tag: widget.rid.toString(),
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get wantKeepAlive => true;
|
bool get wantKeepAlive => true;
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_zoneController =
|
|
||||||
Get.put(ZoneController(zoneID: widget.rid), tag: widget.rid.toString());
|
|
||||||
_zoneController.scrollController.addListener(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
void listener() {
|
|
||||||
StreamController<bool> mainStream =
|
|
||||||
Get.find<MainController>().bottomBarStream;
|
|
||||||
StreamController<bool> searchBarStream =
|
|
||||||
Get.find<HomeController>().searchBarStream;
|
|
||||||
final ScrollDirection direction =
|
|
||||||
_zoneController.scrollController.position.userScrollDirection;
|
|
||||||
if (direction == ScrollDirection.forward) {
|
|
||||||
mainStream.add(true);
|
|
||||||
searchBarStream.add(true);
|
|
||||||
} else if (direction == ScrollDirection.reverse) {
|
|
||||||
mainStream.add(false);
|
|
||||||
searchBarStream.add(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_zoneController.scrollController.removeListener(listener);
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
return refreshIndicator(
|
return refreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
await _zoneController.onRefresh();
|
await controller.onRefresh();
|
||||||
},
|
},
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
controller: _zoneController.scrollController,
|
controller: controller.scrollController,
|
||||||
slivers: [
|
slivers: [
|
||||||
SliverPadding(
|
SliverPadding(
|
||||||
// 单列布局 EdgeInsets.zero
|
// 单列布局 EdgeInsets.zero
|
||||||
@@ -78,17 +48,15 @@ class _ZonePageState extends State<ZonePage>
|
|||||||
bottom: MediaQuery.of(context).padding.bottom + 80,
|
bottom: MediaQuery.of(context).padding.bottom + 80,
|
||||||
),
|
),
|
||||||
sliver: Obx(
|
sliver: Obx(
|
||||||
() => _zoneController.loadingState.value is Loading
|
() => controller.loadingState.value is Loading
|
||||||
? _buildSkeleton()
|
? _buildSkeleton()
|
||||||
: _zoneController.loadingState.value is Success
|
: controller.loadingState.value is Success
|
||||||
? _buildBody(
|
? _buildBody(controller.loadingState.value as Success)
|
||||||
_zoneController.loadingState.value as Success)
|
|
||||||
: HttpError(
|
: HttpError(
|
||||||
errMsg: _zoneController.loadingState.value is Error
|
errMsg: controller.loadingState.value is Error
|
||||||
? (_zoneController.loadingState.value as Error)
|
? (controller.loadingState.value as Error).errMsg
|
||||||
.errMsg
|
|
||||||
: '没有相关数据',
|
: '没有相关数据',
|
||||||
callback: _zoneController.onReload,
|
callback: controller.onReload,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,62 +1,31 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
|
import 'package:PiliPlus/pages/common/common_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPlus/common/constants.dart';
|
import 'package:PiliPlus/common/constants.dart';
|
||||||
import 'package:PiliPlus/common/skeleton/video_card_v.dart';
|
import 'package:PiliPlus/common/skeleton/video_card_v.dart';
|
||||||
import 'package:PiliPlus/common/widgets/http_error.dart';
|
import 'package:PiliPlus/common/widgets/http_error.dart';
|
||||||
import 'package:PiliPlus/common/widgets/video_card_v.dart';
|
import 'package:PiliPlus/common/widgets/video_card_v.dart';
|
||||||
import 'package:PiliPlus/pages/home/index.dart';
|
|
||||||
import 'package:PiliPlus/pages/main/index.dart';
|
|
||||||
|
|
||||||
import '../../utils/grid.dart';
|
import '../../utils/grid.dart';
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
|
|
||||||
class RcmdPage extends StatefulWidget {
|
class RcmdPage extends CommonPage {
|
||||||
const RcmdPage({super.key});
|
const RcmdPage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<RcmdPage> createState() => _RcmdPageState();
|
State<RcmdPage> createState() => _RcmdPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _RcmdPageState extends State<RcmdPage>
|
class _RcmdPageState extends CommonPageState<RcmdPage, RcmdController>
|
||||||
with AutomaticKeepAliveClientMixin {
|
with AutomaticKeepAliveClientMixin {
|
||||||
late final _controller = Get.put(RcmdController());
|
@override
|
||||||
|
late RcmdController controller = Get.put(RcmdController());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get wantKeepAlive => true;
|
bool get wantKeepAlive => true;
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_controller.scrollController.addListener(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
void listener() {
|
|
||||||
StreamController<bool> mainStream =
|
|
||||||
Get.find<MainController>().bottomBarStream;
|
|
||||||
StreamController<bool> searchBarStream =
|
|
||||||
Get.find<HomeController>().searchBarStream;
|
|
||||||
final ScrollDirection direction =
|
|
||||||
_controller.scrollController.position.userScrollDirection;
|
|
||||||
if (direction == ScrollDirection.forward) {
|
|
||||||
mainStream.add(true);
|
|
||||||
searchBarStream.add(true);
|
|
||||||
} else if (direction == ScrollDirection.reverse) {
|
|
||||||
mainStream.add(false);
|
|
||||||
searchBarStream.add(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_controller.scrollController.removeListener(listener);
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
@@ -69,10 +38,10 @@ class _RcmdPageState extends State<RcmdPage>
|
|||||||
),
|
),
|
||||||
child: refreshIndicator(
|
child: refreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
await _controller.onRefresh();
|
await controller.onRefresh();
|
||||||
},
|
},
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
controller: _controller.scrollController,
|
controller: controller.scrollController,
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
slivers: [
|
slivers: [
|
||||||
SliverPadding(
|
SliverPadding(
|
||||||
@@ -81,14 +50,14 @@ class _RcmdPageState extends State<RcmdPage>
|
|||||||
bottom: MediaQuery.paddingOf(context).bottom,
|
bottom: MediaQuery.paddingOf(context).bottom,
|
||||||
),
|
),
|
||||||
sliver: Obx(
|
sliver: Obx(
|
||||||
() => _controller.loadingState.value is Loading ||
|
() => controller.loadingState.value is Loading ||
|
||||||
_controller.loadingState.value is Success
|
controller.loadingState.value is Success
|
||||||
? contentGrid(_controller.loadingState.value)
|
? contentGrid(controller.loadingState.value)
|
||||||
: HttpError(
|
: HttpError(
|
||||||
errMsg: _controller.loadingState.value is Error
|
errMsg: controller.loadingState.value is Error
|
||||||
? (_controller.loadingState.value as Error).errMsg
|
? (controller.loadingState.value as Error).errMsg
|
||||||
: '没有相关数据',
|
: '没有相关数据',
|
||||||
callback: _controller.onReload,
|
callback: controller.onReload,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -114,15 +83,15 @@ class _RcmdPageState extends State<RcmdPage>
|
|||||||
(BuildContext context, int index) {
|
(BuildContext context, int index) {
|
||||||
if (loadingState is Success &&
|
if (loadingState is Success &&
|
||||||
index == loadingState.response.length - 1) {
|
index == loadingState.response.length - 1) {
|
||||||
_controller.onLoadMore();
|
controller.onLoadMore();
|
||||||
}
|
}
|
||||||
if (loadingState is Success) {
|
if (loadingState is Success) {
|
||||||
if (_controller.lastRefreshAt != null) {
|
if (controller.lastRefreshAt != null) {
|
||||||
if (_controller.lastRefreshAt == index) {
|
if (controller.lastRefreshAt == index) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_controller.animateToTop();
|
controller.animateToTop();
|
||||||
_controller.onRefresh();
|
controller.onRefresh();
|
||||||
},
|
},
|
||||||
child: Card(
|
child: Card(
|
||||||
margin: EdgeInsets.zero,
|
margin: EdgeInsets.zero,
|
||||||
@@ -140,19 +109,19 @@ class _RcmdPageState extends State<RcmdPage>
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
int actualIndex = _controller.lastRefreshAt == null
|
int actualIndex = controller.lastRefreshAt == null
|
||||||
? index
|
? index
|
||||||
: index > _controller.lastRefreshAt!
|
: index > controller.lastRefreshAt!
|
||||||
? index - 1
|
? index - 1
|
||||||
: index;
|
: index;
|
||||||
return VideoCardV(
|
return VideoCardV(
|
||||||
videoItem: loadingState.response[actualIndex],
|
videoItem: loadingState.response[actualIndex],
|
||||||
onRemove: () {
|
onRemove: () {
|
||||||
if (_controller.lastRefreshAt != null &&
|
if (controller.lastRefreshAt != null &&
|
||||||
actualIndex < _controller.lastRefreshAt!) {
|
actualIndex < controller.lastRefreshAt!) {
|
||||||
_controller.lastRefreshAt = _controller.lastRefreshAt! - 1;
|
controller.lastRefreshAt = controller.lastRefreshAt! - 1;
|
||||||
}
|
}
|
||||||
_controller.loadingState.value = LoadingState.success(
|
controller.loadingState.value = LoadingState.success(
|
||||||
(loadingState.response as List)..removeAt(actualIndex));
|
(loadingState.response as List)..removeAt(actualIndex));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -160,7 +129,7 @@ class _RcmdPageState extends State<RcmdPage>
|
|||||||
return VideoCardV(
|
return VideoCardV(
|
||||||
videoItem: loadingState.response[index],
|
videoItem: loadingState.response[index],
|
||||||
onRemove: () {
|
onRemove: () {
|
||||||
_controller.loadingState.value = LoadingState.success(
|
controller.loadingState.value = LoadingState.success(
|
||||||
(loadingState.response as List)..removeAt(index));
|
(loadingState.response as List)..removeAt(index));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -169,7 +138,7 @@ class _RcmdPageState extends State<RcmdPage>
|
|||||||
return const VideoCardVSkeleton();
|
return const VideoCardVSkeleton();
|
||||||
},
|
},
|
||||||
childCount: loadingState is Success
|
childCount: loadingState is Success
|
||||||
? _controller.lastRefreshAt != null
|
? controller.lastRefreshAt != null
|
||||||
? loadingState.response.length + 1
|
? loadingState.response.length + 1
|
||||||
: loadingState.response.length
|
: loadingState.response.length
|
||||||
: 10,
|
: 10,
|
||||||
|
|||||||
Reference in New Issue
Block a user