mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
@@ -2,35 +2,52 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
|
||||||
class HttpError extends StatelessWidget {
|
class HttpError extends StatelessWidget {
|
||||||
const HttpError(
|
const HttpError({
|
||||||
{required this.errMsg, required this.fn, this.btnText, super.key});
|
this.isSliver = true,
|
||||||
|
this.errMsg,
|
||||||
|
this.callback,
|
||||||
|
this.btnText,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
final bool isSliver;
|
||||||
final String? errMsg;
|
final String? errMsg;
|
||||||
final Function()? fn;
|
final Function()? callback;
|
||||||
final String? btnText;
|
final String? btnText;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SliverToBoxAdapter(
|
return isSliver
|
||||||
child: Column(
|
? SliverToBoxAdapter(child: content(context))
|
||||||
|
: SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: content(context),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget content(BuildContext context) => Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
const SizedBox(height: 40),
|
||||||
SvgPicture.asset(
|
SvgPicture.asset(
|
||||||
"assets/images/error.svg",
|
"assets/images/error.svg",
|
||||||
height: 200,
|
height: 200,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
Text(
|
Padding(
|
||||||
errMsg ?? '请求异常',
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
child: SelectableText(
|
||||||
|
errMsg ?? '没有数据',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: Theme.of(context).textTheme.titleSmall,
|
style: Theme.of(context).textTheme.titleSmall,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
if (callback != null) ...[
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
FilledButton.tonal(
|
FilledButton.tonal(
|
||||||
onPressed: () {
|
onPressed: callback,
|
||||||
fn!();
|
|
||||||
},
|
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
backgroundColor: WidgetStateProperty.resolveWith((states) {
|
backgroundColor: WidgetStateProperty.resolveWith((states) {
|
||||||
return Theme.of(context).colorScheme.primary.withAlpha(20);
|
return Theme.of(context).colorScheme.primary.withAlpha(20);
|
||||||
@@ -42,7 +59,7 @@ class HttpError extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
SizedBox(height: 40 + MediaQuery.paddingOf(context).bottom),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
10
lib/common/widgets/loading_widget.dart
Normal file
10
lib/common/widgets/loading_widget.dart
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
Widget get loadingWidget => Center(child: CircularProgressIndicator());
|
||||||
|
|
||||||
|
Widget errorWidget({errMsg, callback}) => HttpError(
|
||||||
|
isSliver: false,
|
||||||
|
errMsg: errMsg,
|
||||||
|
callback: callback,
|
||||||
|
);
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
|
||||||
|
|
||||||
class NoData extends StatelessWidget {
|
|
||||||
const NoData({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return SliverToBoxAdapter(
|
|
||||||
child: SizedBox(
|
|
||||||
height: 400,
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
SvgPicture.asset(
|
|
||||||
"assets/images/error.svg",
|
|
||||||
height: 200,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
Text(
|
|
||||||
'没有数据',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: Theme.of(context).textTheme.titleSmall,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/utils/extension.dart';
|
|
||||||
|
|
||||||
import '../models/bangumi/list.dart';
|
import '../models/bangumi/list.dart';
|
||||||
import 'index.dart';
|
import 'index.dart';
|
||||||
@@ -10,11 +9,7 @@ class BangumiHttp {
|
|||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
BangumiListDataModel data =
|
BangumiListDataModel data =
|
||||||
BangumiListDataModel.fromJson(res.data['data']);
|
BangumiListDataModel.fromJson(res.data['data']);
|
||||||
if (!data.list.isNullOrEmpty) {
|
|
||||||
return LoadingState.success(data.list);
|
return LoadingState.success(data.list);
|
||||||
} else {
|
|
||||||
return LoadingState.empty();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return LoadingState.error(res.data['message']);
|
return LoadingState.error(res.data['message']);
|
||||||
}
|
}
|
||||||
@@ -25,11 +20,7 @@ class BangumiHttp {
|
|||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
BangumiListDataModel data =
|
BangumiListDataModel data =
|
||||||
BangumiListDataModel.fromJson(res.data['data']);
|
BangumiListDataModel.fromJson(res.data['data']);
|
||||||
if (!data.list.isNullOrEmpty) {
|
|
||||||
return LoadingState.success(data.list);
|
return LoadingState.success(data.list);
|
||||||
} else {
|
|
||||||
return LoadingState.empty();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return LoadingState.error(res.data['message']);
|
return LoadingState.error(res.data['message']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/utils/extension.dart';
|
|
||||||
|
|
||||||
import '../models/user/black.dart';
|
import '../models/user/black.dart';
|
||||||
import 'index.dart';
|
import 'index.dart';
|
||||||
@@ -15,11 +14,7 @@ class BlackHttp {
|
|||||||
});
|
});
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
BlackListDataModel data = BlackListDataModel.fromJson(res.data['data']);
|
BlackListDataModel data = BlackListDataModel.fromJson(res.data['data']);
|
||||||
if (!data.list.isNullOrEmpty) {
|
|
||||||
return LoadingState.success(data);
|
return LoadingState.success(data);
|
||||||
} else {
|
|
||||||
return LoadingState.empty();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return LoadingState.error(res.data['message']);
|
return LoadingState.error(res.data['message']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/utils/extension.dart';
|
|
||||||
|
|
||||||
import '../models/dynamics/result.dart';
|
import '../models/dynamics/result.dart';
|
||||||
import '../models/dynamics/up.dart';
|
import '../models/dynamics/up.dart';
|
||||||
@@ -25,11 +24,7 @@ class DynamicsHttp {
|
|||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
try {
|
try {
|
||||||
DynamicsDataModel data = DynamicsDataModel.fromJson(res.data['data']);
|
DynamicsDataModel data = DynamicsDataModel.fromJson(res.data['data']);
|
||||||
if (!data.items.isNullOrEmpty) {
|
|
||||||
return LoadingState.success(data);
|
return LoadingState.success(data);
|
||||||
} else {
|
|
||||||
return LoadingState.empty();
|
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return LoadingState.error(err.toString());
|
return LoadingState.error(err.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,7 @@ class LiveHttp {
|
|||||||
List<LiveItemModel> list = res.data['data']['list']
|
List<LiveItemModel> list = res.data['data']['list']
|
||||||
.map<LiveItemModel>((e) => LiveItemModel.fromJson(e))
|
.map<LiveItemModel>((e) => LiveItemModel.fromJson(e))
|
||||||
.toList();
|
.toList();
|
||||||
if (list.isNotEmpty) {
|
|
||||||
return LoadingState.success(list);
|
return LoadingState.success(list);
|
||||||
} else {
|
|
||||||
return LoadingState.empty();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return LoadingState.error(res.data['message']);
|
return LoadingState.error(res.data['message']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ abstract class LoadingState<T> {
|
|||||||
const LoadingState();
|
const LoadingState();
|
||||||
|
|
||||||
factory LoadingState.loading() = Loading;
|
factory LoadingState.loading() = Loading;
|
||||||
factory LoadingState.empty() = Empty;
|
// factory LoadingState.empty() = Empty;
|
||||||
factory LoadingState.success(T response) = Success<T>;
|
factory LoadingState.success(T response) = Success<T>;
|
||||||
factory LoadingState.error(String errMsg) = Error;
|
factory LoadingState.error(String errMsg) = Error;
|
||||||
}
|
}
|
||||||
@@ -11,9 +11,9 @@ class Loading extends LoadingState<Never> {
|
|||||||
const Loading();
|
const Loading();
|
||||||
}
|
}
|
||||||
|
|
||||||
class Empty extends LoadingState<Never> {
|
// class Empty extends LoadingState<Never> {
|
||||||
const Empty();
|
// const Empty();
|
||||||
}
|
// }
|
||||||
|
|
||||||
class Success<T> extends LoadingState<T> {
|
class Success<T> extends LoadingState<T> {
|
||||||
final T response;
|
final T response;
|
||||||
|
|||||||
@@ -55,11 +55,7 @@ class UserHttp {
|
|||||||
'up_mid': mid,
|
'up_mid': mid,
|
||||||
});
|
});
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
if (res.data['data'] != null) {
|
|
||||||
return LoadingState.success(FavFolderData.fromJson(res.data['data']));
|
return LoadingState.success(FavFolderData.fromJson(res.data['data']));
|
||||||
} else {
|
|
||||||
return LoadingState.empty();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return LoadingState.error(res.data['message'] ?? '账号未登录');
|
return LoadingState.error(res.data['message'] ?? '账号未登录');
|
||||||
}
|
}
|
||||||
@@ -153,7 +149,7 @@ class UserHttp {
|
|||||||
var res = await Request().get(Api.seeYouLater);
|
var res = await Request().get(Api.seeYouLater);
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
if (res.data['data']['count'] == 0) {
|
if (res.data['data']['count'] == 0) {
|
||||||
return LoadingState.empty();
|
return LoadingState.success([]);
|
||||||
}
|
}
|
||||||
List<HotVideoItemModel> list = [];
|
List<HotVideoItemModel> list = [];
|
||||||
for (var i in res.data['data']['list']) {
|
for (var i in res.data['data']['list']) {
|
||||||
|
|||||||
@@ -67,11 +67,7 @@ class VideoHttp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (list.isNotEmpty) {
|
|
||||||
return LoadingState.success(list);
|
return LoadingState.success(list);
|
||||||
} else {
|
|
||||||
return LoadingState.empty();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return LoadingState.error(res.data['message']);
|
return LoadingState.error(res.data['message']);
|
||||||
}
|
}
|
||||||
@@ -161,11 +157,7 @@ class VideoHttp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (list.isNotEmpty) {
|
|
||||||
return LoadingState.success(list);
|
return LoadingState.success(list);
|
||||||
} else {
|
|
||||||
return LoadingState.empty();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return LoadingState.error(res.data['message']);
|
return LoadingState.error(res.data['message']);
|
||||||
}
|
}
|
||||||
@@ -189,11 +181,7 @@ class VideoHttp {
|
|||||||
list.add(HotVideoItemModel.fromJson(i));
|
list.add(HotVideoItemModel.fromJson(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (list.isNotEmpty) {
|
|
||||||
return LoadingState.success(list);
|
return LoadingState.success(list);
|
||||||
} else {
|
|
||||||
return LoadingState.empty();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return LoadingState.error(res.data['message']);
|
return LoadingState.error(res.data['message']);
|
||||||
}
|
}
|
||||||
@@ -210,11 +198,7 @@ class VideoHttp {
|
|||||||
list.add(item);
|
list.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (list.isNotEmpty) {
|
|
||||||
return LoadingState.success(list);
|
return LoadingState.success(list);
|
||||||
} else {
|
|
||||||
return LoadingState.empty();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return LoadingState.error(res['msg']);
|
return LoadingState.error(res['msg']);
|
||||||
}
|
}
|
||||||
@@ -357,11 +341,7 @@ class VideoHttp {
|
|||||||
list.add(videoItem);
|
list.add(videoItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (list.isNotEmpty) {
|
|
||||||
return LoadingState.success(list);
|
return LoadingState.success(list);
|
||||||
} else {
|
|
||||||
return LoadingState.empty();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return LoadingState.error(res.data['message']);
|
return LoadingState.error(res.data['message']);
|
||||||
}
|
}
|
||||||
@@ -970,11 +950,7 @@ class VideoHttp {
|
|||||||
list.add(HotVideoItemModel.fromJson(i));
|
list.add(HotVideoItemModel.fromJson(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (list.isNotEmpty) {
|
|
||||||
return LoadingState.success(list);
|
return LoadingState.success(list);
|
||||||
} else {
|
|
||||||
return LoadingState.empty();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return LoadingState.error(res.data['message']);
|
return LoadingState.error(res.data['message']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ class MyApp extends StatelessWidget {
|
|||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
scrolledUnderElevation: 0,
|
scrolledUnderElevation: 0,
|
||||||
backgroundColor: Platform.isIOS ? colorScheme.surface : null,
|
backgroundColor: Platform.isIOS ? colorScheme.surface : null,
|
||||||
titleTextStyle: Theme.of(context).textTheme.titleMedium,
|
titleTextStyle: TextStyle(fontSize: 16, color: colorScheme.onSurface),
|
||||||
),
|
),
|
||||||
navigationBarTheme: NavigationBarThemeData(
|
navigationBarTheme: NavigationBarThemeData(
|
||||||
surfaceTintColor: surfaceTintColor,
|
surfaceTintColor: surfaceTintColor,
|
||||||
|
|||||||
@@ -6,10 +6,5 @@ enum UpPanelPosition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension UpPanelPositionDesc on UpPanelPosition {
|
extension UpPanelPositionDesc on UpPanelPosition {
|
||||||
String get values => ['left_fixed', 'right_fixed', 'left_drawer', 'right_drawer'][index];
|
|
||||||
String get labels => ['左侧常驻', '右侧常驻', '左侧抽屉', '右侧抽屉'][index];
|
String get labels => ['左侧常驻', '右侧常驻', '左侧抽屉', '右侧抽屉'][index];
|
||||||
}
|
}
|
||||||
|
|
||||||
extension UpPanelPositionCode on UpPanelPosition {
|
|
||||||
int get code => [0, 1, 2, 3][index];
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -69,8 +69,16 @@ class _BangumiIntroPanelState extends State<BangumiIntroPanel>
|
|||||||
}
|
}
|
||||||
|
|
||||||
_buildBody(LoadingState loadingState) {
|
_buildBody(LoadingState loadingState) {
|
||||||
return loadingState is Success
|
return switch (loadingState) {
|
||||||
? BangumiInfo(
|
Loading() => BangumiInfo(
|
||||||
|
heroTag: widget.heroTag,
|
||||||
|
loadingStatus: true,
|
||||||
|
bangumiDetail: null,
|
||||||
|
cid: cid,
|
||||||
|
showEpisodes: widget.showEpisodes,
|
||||||
|
showIntroDetail: widget.showIntroDetail,
|
||||||
|
),
|
||||||
|
Success() => BangumiInfo(
|
||||||
heroTag: widget.heroTag,
|
heroTag: widget.heroTag,
|
||||||
loadingStatus: false,
|
loadingStatus: false,
|
||||||
bangumiDetail: loadingState.response,
|
bangumiDetail: loadingState.response,
|
||||||
@@ -80,20 +88,13 @@ class _BangumiIntroPanelState extends State<BangumiIntroPanel>
|
|||||||
loadingState.response,
|
loadingState.response,
|
||||||
bangumiIntroController.videoTags,
|
bangumiIntroController.videoTags,
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
: loadingState is Error
|
Error() => HttpError(
|
||||||
? HttpError(
|
|
||||||
errMsg: loadingState.errMsg,
|
errMsg: loadingState.errMsg,
|
||||||
fn: bangumiIntroController.onReload,
|
callback: bangumiIntroController.onReload,
|
||||||
)
|
),
|
||||||
: BangumiInfo(
|
LoadingState() => throw UnimplementedError(),
|
||||||
heroTag: widget.heroTag,
|
};
|
||||||
loadingStatus: true,
|
|
||||||
bangumiDetail: null,
|
|
||||||
cid: cid,
|
|
||||||
showEpisodes: widget.showEpisodes,
|
|
||||||
showIntroDetail: widget.showIntroDetail,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,17 +109,10 @@ class _BangumiPageState extends State<BangumiPage>
|
|||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: Grid.maxRowWidth * 1,
|
height: Grid.maxRowWidth * 1,
|
||||||
child: Obx(() =>
|
child: Obx(
|
||||||
_bangumiController.followState.value is Empty
|
() => _buildFollowBody(
|
||||||
? const SizedBox(
|
_bangumiController.followState.value),
|
||||||
child: Center(
|
|
||||||
child: Text('还没有追番'),
|
|
||||||
),
|
),
|
||||||
)
|
|
||||||
: _bangumiController.followState.value is Success
|
|
||||||
? _buildFollowList(_bangumiController
|
|
||||||
.followState.value as Success)
|
|
||||||
: const SizedBox()),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -144,19 +137,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(
|
||||||
() => _bangumiController.loadingState.value is Loading
|
() => _buildBody(_bangumiController.loadingState.value),
|
||||||
? contentGrid([])
|
|
||||||
: _bangumiController.loadingState.value is Success
|
|
||||||
? contentGrid(
|
|
||||||
(_bangumiController.loadingState.value as Success)
|
|
||||||
.response)
|
|
||||||
: HttpError(
|
|
||||||
errMsg: _bangumiController.loadingState.value is Error
|
|
||||||
? (_bangumiController.loadingState.value as Error)
|
|
||||||
.errMsg
|
|
||||||
: '没有相关数据',
|
|
||||||
fn: _bangumiController.onReload,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -164,6 +145,40 @@ class _BangumiPageState extends State<BangumiPage>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildBody(LoadingState loadingState) {
|
||||||
|
return switch (loadingState) {
|
||||||
|
Loading() => const SliverToBoxAdapter(),
|
||||||
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
|
? SliverGrid(
|
||||||
|
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
||||||
|
// 行间距
|
||||||
|
mainAxisSpacing: StyleString.cardSpace - 2,
|
||||||
|
// 列间距
|
||||||
|
crossAxisSpacing: StyleString.cardSpace,
|
||||||
|
// 最大宽度
|
||||||
|
maxCrossAxisExtent: Grid.maxRowWidth / 3 * 2,
|
||||||
|
childAspectRatio: 0.65,
|
||||||
|
mainAxisExtent: MediaQuery.textScalerOf(context).scale(60),
|
||||||
|
),
|
||||||
|
delegate: SliverChildBuilderDelegate(
|
||||||
|
(BuildContext context, int index) {
|
||||||
|
return BangumiCardV(
|
||||||
|
bangumiItem: loadingState.response[index]);
|
||||||
|
},
|
||||||
|
childCount: loadingState.response.length,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: HttpError(
|
||||||
|
callback: _bangumiController.onReload,
|
||||||
|
),
|
||||||
|
Error() => HttpError(
|
||||||
|
errMsg: loadingState.errMsg,
|
||||||
|
callback: _bangumiController.onReload,
|
||||||
|
),
|
||||||
|
LoadingState() => throw UnimplementedError(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildFollowList(Success loadingState) {
|
Widget _buildFollowList(Success loadingState) {
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
@@ -185,24 +200,14 @@ class _BangumiPageState extends State<BangumiPage>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget contentGrid(List list) {
|
Widget _buildFollowBody(LoadingState loadingState) {
|
||||||
return SliverGrid(
|
return switch (loadingState) {
|
||||||
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
Loading() => nil,
|
||||||
// 行间距
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
mainAxisSpacing: StyleString.cardSpace - 2,
|
? _buildFollowList(loadingState)
|
||||||
// 列间距
|
: const Center(child: Text('还没有追番')),
|
||||||
crossAxisSpacing: StyleString.cardSpace,
|
Error() => Center(child: Text(loadingState.errMsg)),
|
||||||
// 最大宽度
|
LoadingState() => throw UnimplementedError(),
|
||||||
maxCrossAxisExtent: Grid.maxRowWidth / 3 * 2,
|
};
|
||||||
childAspectRatio: 0.65,
|
|
||||||
mainAxisExtent: MediaQuery.textScalerOf(context).scale(60),
|
|
||||||
),
|
|
||||||
delegate: SliverChildBuilderDelegate(
|
|
||||||
(BuildContext context, int index) {
|
|
||||||
return list.isNotEmpty ? BangumiCardV(bangumiItem: list[index]) : nil;
|
|
||||||
},
|
|
||||||
childCount: list.isNotEmpty ? list.length : 10,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:PiliPalaX/common/widgets/loading_widget.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
||||||
@@ -5,7 +6,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
|
||||||
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
||||||
import 'package:PiliPalaX/http/black.dart';
|
import 'package:PiliPalaX/http/black.dart';
|
||||||
import 'package:PiliPalaX/utils/storage.dart';
|
import 'package:PiliPalaX/utils/storage.dart';
|
||||||
@@ -63,7 +63,9 @@ class _BlackListPageState extends State<BlackListPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBody(LoadingState loadingState) {
|
Widget _buildBody(LoadingState loadingState) {
|
||||||
return loadingState is Success
|
return switch (loadingState) {
|
||||||
|
Loading() => loadingWidget,
|
||||||
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
? ListView.builder(
|
? ListView.builder(
|
||||||
controller: _blackListController.scrollController,
|
controller: _blackListController.scrollController,
|
||||||
itemCount: loadingState.response.length,
|
itemCount: loadingState.response.length,
|
||||||
@@ -98,16 +100,15 @@ class _BlackListPageState extends State<BlackListPage> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: loadingState is Error
|
: errorWidget(
|
||||||
? CustomScrollView(
|
callback: _blackListController.onReload,
|
||||||
slivers: [
|
),
|
||||||
HttpError(
|
Error() => errorWidget(
|
||||||
errMsg: loadingState.errMsg,
|
errMsg: loadingState.errMsg,
|
||||||
fn: _blackListController.onReload,
|
callback: _blackListController.onReload,
|
||||||
)
|
),
|
||||||
],
|
LoadingState() => throw UnimplementedError(),
|
||||||
)
|
};
|
||||||
: const SizedBox();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,9 +131,7 @@ class BlackListController extends CommonController {
|
|||||||
List dataList = currentPage == 1
|
List dataList = currentPage == 1
|
||||||
? response.response.list
|
? response.response.list
|
||||||
: currentList + response.response.list;
|
: currentList + response.response.list;
|
||||||
loadingState.value = dataList.isNotEmpty
|
loadingState.value = LoadingState.success(dataList);
|
||||||
? LoadingState.success(dataList)
|
|
||||||
: LoadingState.empty();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,21 +72,21 @@ abstract class ReplyController extends CommonController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
cursor = replies.cursor;
|
cursor = replies.cursor;
|
||||||
if (replies.replies.isNotEmpty) {
|
|
||||||
noMore.value = '加载中...';
|
|
||||||
if (replies.cursor.isEnd) {
|
|
||||||
noMore.value = '没有更多了';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 未登录状态replies可能返回null
|
|
||||||
noMore.value = currentPage == 1 ? '还没有评论' : '没有更多了';
|
|
||||||
}
|
|
||||||
if (currentPage != 1) {
|
if (currentPage != 1) {
|
||||||
List<ReplyInfo> list = loadingState.value is Success
|
List<ReplyInfo> list = loadingState.value is Success
|
||||||
? (loadingState.value as Success).response.replies
|
? (loadingState.value as Success).response.replies
|
||||||
: <ReplyInfo>[];
|
: <ReplyInfo>[];
|
||||||
replies.replies.insertAll(0, list);
|
replies.replies.insertAll(0, list);
|
||||||
}
|
}
|
||||||
|
if (replies.replies.isNotEmpty) {
|
||||||
|
noMore.value = '加载中...';
|
||||||
|
if (replies.cursor.isEnd || replies.replies.length >= count.value) {
|
||||||
|
noMore.value = '没有更多了';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 未登录状态replies可能返回null
|
||||||
|
noMore.value = currentPage == 1 ? '还没有评论' : '没有更多了';
|
||||||
|
}
|
||||||
loadingState.value = LoadingState.success(replies);
|
loadingState.value = LoadingState.success(replies);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -349,7 +349,16 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget replyList(LoadingState loadingState) {
|
Widget replyList(LoadingState loadingState) {
|
||||||
return loadingState is Success
|
return switch (loadingState) {
|
||||||
|
Loading() => SliverList(
|
||||||
|
delegate: SliverChildBuilderDelegate(
|
||||||
|
(context, index) {
|
||||||
|
return const VideoReplySkeleton();
|
||||||
|
},
|
||||||
|
childCount: 8,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Success() => (loadingState.response.replies as List?)?.isNotEmpty == true
|
||||||
? SliverList(
|
? SliverList(
|
||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
(context, index) {
|
(context, index) {
|
||||||
@@ -393,19 +402,15 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
childCount: loadingState.response.replies.length + 1,
|
childCount: loadingState.response.replies.length + 1,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: loadingState is Error
|
: HttpError(
|
||||||
? HttpError(
|
callback: _dynamicDetailController.onReload,
|
||||||
errMsg: loadingState.errMsg,
|
|
||||||
fn: _dynamicDetailController.onReload,
|
|
||||||
)
|
|
||||||
: SliverList(
|
|
||||||
delegate: SliverChildBuilderDelegate(
|
|
||||||
(context, index) {
|
|
||||||
return const VideoReplySkeleton();
|
|
||||||
},
|
|
||||||
childCount: 8,
|
|
||||||
),
|
),
|
||||||
);
|
Error() => HttpError(
|
||||||
|
errMsg: loadingState.errMsg,
|
||||||
|
callback: _dynamicDetailController.onReload,
|
||||||
|
),
|
||||||
|
LoadingState() => throw UnimplementedError(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,11 +55,7 @@ class DynamicsTabController extends CommonController {
|
|||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
List list = (loadingState.value as Success).response;
|
List list = (loadingState.value as Success).response;
|
||||||
list.removeWhere((item) => item.idStr == dynamicId);
|
list.removeWhere((item) => item.idStr == dynamicId);
|
||||||
if (list.isNotEmpty) {
|
|
||||||
loadingState.value = LoadingState.success(list);
|
loadingState.value = LoadingState.success(list);
|
||||||
} else {
|
|
||||||
loadingState.value = LoadingState.empty();
|
|
||||||
}
|
|
||||||
SmartDialog.showToast('删除成功');
|
SmartDialog.showToast('删除成功');
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast(res['msg']);
|
SmartDialog.showToast(res['msg']);
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import 'package:flutter/rendering.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPalaX/common/constants.dart';
|
import 'package:PiliPalaX/common/constants.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/no_data.dart';
|
|
||||||
import 'package:waterfall_flow/waterfall_flow.dart';
|
import 'package:waterfall_flow/waterfall_flow.dart';
|
||||||
|
|
||||||
import '../../../common/skeleton/dynamic_card.dart';
|
import '../../../common/skeleton/dynamic_card.dart';
|
||||||
@@ -146,7 +145,9 @@ class _DynamicsTabPageState extends State<DynamicsTabPage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBody(LoadingState loadingState) {
|
Widget _buildBody(LoadingState loadingState) {
|
||||||
return loadingState is Success
|
return switch (loadingState) {
|
||||||
|
Loading() => skeleton(),
|
||||||
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
? dynamicsWaterfallFlow
|
? dynamicsWaterfallFlow
|
||||||
? SliverWaterfallFlow.extent(
|
? SliverWaterfallFlow.extent(
|
||||||
maxCrossAxisExtent: Grid.maxRowWidth * 2,
|
maxCrossAxisExtent: Grid.maxRowWidth * 2,
|
||||||
@@ -204,13 +205,14 @@ class _DynamicsTabPageState extends State<DynamicsTabPage>
|
|||||||
const SliverFillRemaining(),
|
const SliverFillRemaining(),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: loadingState is Empty
|
: HttpError(
|
||||||
? const NoData()
|
callback: _dynamicsTabController.onReload,
|
||||||
: loadingState is Error
|
),
|
||||||
? HttpError(
|
Error() => HttpError(
|
||||||
errMsg: loadingState.errMsg,
|
errMsg: loadingState.errMsg,
|
||||||
fn: _dynamicsTabController.onReload,
|
callback: _dynamicsTabController.onReload,
|
||||||
)
|
),
|
||||||
: skeleton();
|
LoadingState() => throw UnimplementedError(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import 'package:PiliPalaX/utils/feed_back.dart';
|
|||||||
import 'package:PiliPalaX/utils/storage.dart';
|
import 'package:PiliPalaX/utils/storage.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:nil/nil.dart';
|
||||||
|
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
import 'widgets/up_panel.dart';
|
import 'widgets/up_panel.dart';
|
||||||
@@ -98,7 +99,7 @@ class _DynamicsPageState extends State<DynamicsPage>
|
|||||||
});
|
});
|
||||||
upPanelPosition = UpPanelPosition.values[setting.get(
|
upPanelPosition = UpPanelPosition.values[setting.get(
|
||||||
SettingBoxKey.upPanelPosition,
|
SettingBoxKey.upPanelPosition,
|
||||||
defaultValue: UpPanelPosition.leftFixed.code)];
|
defaultValue: UpPanelPosition.leftFixed.index)];
|
||||||
debugPrint('upPanelPosition: $upPanelPosition');
|
debugPrint('upPanelPosition: $upPanelPosition');
|
||||||
if (GStorage.setting
|
if (GStorage.setting
|
||||||
.get(SettingBoxKey.dynamicsShowAllFollowedUp, defaultValue: false)) {
|
.get(SettingBoxKey.dynamicsShowAllFollowedUp, defaultValue: false)) {
|
||||||
@@ -128,7 +129,7 @@ class _DynamicsPageState extends State<DynamicsPage>
|
|||||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
child: Container(
|
child: Container(
|
||||||
//抽屉模式增加底色
|
//抽屉模式增加底色
|
||||||
color: upPanelPosition.code > 1
|
color: upPanelPosition.index > 1
|
||||||
? Theme.of(context).colorScheme.surface
|
? Theme.of(context).colorScheme.surface
|
||||||
: Colors.transparent,
|
: Colors.transparent,
|
||||||
width: 56,
|
width: 56,
|
||||||
@@ -137,20 +138,27 @@ class _DynamicsPageState extends State<DynamicsPage>
|
|||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
if (snapshot.data == null) {
|
if (snapshot.data == null) {
|
||||||
return const SizedBox();
|
return nil;
|
||||||
}
|
}
|
||||||
Map data = snapshot.data;
|
Map data = snapshot.data;
|
||||||
if (data['status']) {
|
if (data['status']) {
|
||||||
return Obx(() => UpPanel(_dynamicsController.upData.value,
|
return Obx(() => UpPanel(_dynamicsController.upData.value,
|
||||||
_dynamicsController.scrollController));
|
_dynamicsController.scrollController));
|
||||||
} else {
|
} else {
|
||||||
return const SizedBox();
|
return Center(
|
||||||
|
child: IconButton(
|
||||||
|
icon: Icon(Icons.refresh),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
_futureBuilderFutureUp =
|
||||||
|
_dynamicsController.queryFollowUp();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return const SizedBox(
|
return nil;
|
||||||
width: 56,
|
|
||||||
child: UpPanelSkeleton(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:PiliPalaX/common/widgets/loading_widget.dart';
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/models/video/reply/emote.dart';
|
import 'package:PiliPalaX/models/video/reply/emote.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -28,7 +29,9 @@ class _EmotePanelState extends State<EmotePanel>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBody(LoadingState loadingState) {
|
Widget _buildBody(LoadingState loadingState) {
|
||||||
return loadingState is Success
|
return switch (loadingState) {
|
||||||
|
Loading() => loadingWidget,
|
||||||
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
? Column(
|
? Column(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -72,7 +75,8 @@ class _EmotePanelState extends State<EmotePanel>
|
|||||||
src: e.emote![index].url!,
|
src: e.emote![index].url!,
|
||||||
width: size * 38,
|
width: size * 38,
|
||||||
height: size * 38,
|
height: size * 38,
|
||||||
semanticsLabel: e.emote![index].text!,
|
semanticsLabel:
|
||||||
|
e.emote![index].text!,
|
||||||
type: 'emote',
|
type: 'emote',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -110,8 +114,14 @@ class _EmotePanelState extends State<EmotePanel>
|
|||||||
SizedBox(height: MediaQuery.of(context).padding.bottom),
|
SizedBox(height: MediaQuery.of(context).padding.bottom),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: loadingState is Error
|
: errorWidget(
|
||||||
? Center(child: Text(loadingState.errMsg))
|
callback: _emotePanelController.onReload,
|
||||||
: const Center(child: Text('加载中...'));
|
),
|
||||||
|
Error() => errorWidget(
|
||||||
|
errMsg: loadingState.errMsg,
|
||||||
|
callback: _emotePanelController.onReload,
|
||||||
|
),
|
||||||
|
LoadingState() => throw UnimplementedError(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import 'package:easy_debounce/easy_throttle.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/no_data.dart';
|
|
||||||
|
|
||||||
import '../../common/constants.dart';
|
import '../../common/constants.dart';
|
||||||
import '../../utils/grid.dart';
|
import '../../utils/grid.dart';
|
||||||
@@ -67,8 +66,11 @@ class _FansPageState extends State<FansPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBody(LoadingState loadingState) {
|
Widget _buildBody(LoadingState loadingState) {
|
||||||
return loadingState is Success
|
return switch (loadingState) {
|
||||||
? loadingState.response.isNotEmpty
|
Loading() => HttpError(
|
||||||
|
callback: _fansController.onReload,
|
||||||
|
),
|
||||||
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
? SliverGrid(
|
? SliverGrid(
|
||||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||||
mainAxisSpacing: StyleString.cardSpace,
|
mainAxisSpacing: StyleString.cardSpace,
|
||||||
@@ -80,20 +82,16 @@ class _FansPageState extends State<FansPage> {
|
|||||||
return fanItem(item: loadingState.response[index]);
|
return fanItem(item: loadingState.response[index]);
|
||||||
},
|
},
|
||||||
childCount: loadingState.response.length,
|
childCount: loadingState.response.length,
|
||||||
))
|
),
|
||||||
: const NoData()
|
|
||||||
: loadingState is Error
|
|
||||||
? HttpError(
|
|
||||||
errMsg: loadingState.errMsg,
|
|
||||||
fn: _fansController.onReload,
|
|
||||||
)
|
)
|
||||||
: const SliverToBoxAdapter(
|
: HttpError(
|
||||||
child: SizedBox(
|
callback: _fansController.onReload,
|
||||||
height: 200,
|
|
||||||
child: Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
),
|
),
|
||||||
|
Error() => HttpError(
|
||||||
|
errMsg: loadingState.errMsg,
|
||||||
|
callback: _fansController.onReload,
|
||||||
),
|
),
|
||||||
);
|
LoadingState() => throw UnimplementedError(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,22 @@ class _FavPageState extends State<FavPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBody(LoadingState loadingState) {
|
Widget _buildBody(LoadingState loadingState) {
|
||||||
return loadingState is Success
|
return switch (loadingState) {
|
||||||
|
Loading() => SliverGrid(
|
||||||
|
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
||||||
|
mainAxisSpacing: StyleString.cardSpace,
|
||||||
|
crossAxisSpacing: StyleString.safeSpace,
|
||||||
|
maxCrossAxisExtent: Grid.maxRowWidth * 2,
|
||||||
|
childAspectRatio: StyleString.aspectRatio * 2.4,
|
||||||
|
mainAxisExtent: 0),
|
||||||
|
delegate: SliverChildBuilderDelegate(
|
||||||
|
(BuildContext context, int index) {
|
||||||
|
return const VideoCardHSkeleton();
|
||||||
|
},
|
||||||
|
childCount: 10,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
? SliverGrid(
|
? SliverGrid(
|
||||||
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
||||||
mainAxisSpacing: StyleString.cardSpace,
|
mainAxisSpacing: StyleString.cardSpace,
|
||||||
@@ -147,24 +162,14 @@ class _FavPageState extends State<FavPage> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: loadingState is Error
|
: HttpError(
|
||||||
? HttpError(
|
callback: _favController.onReload,
|
||||||
errMsg: loadingState.errMsg,
|
|
||||||
fn: _favController.onReload,
|
|
||||||
)
|
|
||||||
: SliverGrid(
|
|
||||||
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
|
||||||
mainAxisSpacing: StyleString.cardSpace,
|
|
||||||
crossAxisSpacing: StyleString.safeSpace,
|
|
||||||
maxCrossAxisExtent: Grid.maxRowWidth * 2,
|
|
||||||
childAspectRatio: StyleString.aspectRatio * 2.4,
|
|
||||||
mainAxisExtent: 0),
|
|
||||||
delegate: SliverChildBuilderDelegate(
|
|
||||||
(BuildContext context, int index) {
|
|
||||||
return const VideoCardHSkeleton();
|
|
||||||
},
|
|
||||||
childCount: 10,
|
|
||||||
),
|
),
|
||||||
);
|
Error() => HttpError(
|
||||||
|
errMsg: loadingState.errMsg,
|
||||||
|
callback: _favController.onReload,
|
||||||
|
),
|
||||||
|
LoadingState() => throw UnimplementedError(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,10 +238,24 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBody(LoadingState loadingState) {
|
Widget _buildBody(LoadingState loadingState) {
|
||||||
return loadingState is Success
|
return switch (loadingState) {
|
||||||
? loadingState.response.isEmpty
|
Loading() => SliverGrid(
|
||||||
? const SliverToBoxAdapter(child: SizedBox())
|
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
||||||
: SliverPadding(
|
mainAxisSpacing: StyleString.cardSpace,
|
||||||
|
crossAxisSpacing: StyleString.safeSpace,
|
||||||
|
maxCrossAxisExtent: Grid.maxRowWidth * 2,
|
||||||
|
childAspectRatio: StyleString.aspectRatio * 2.4,
|
||||||
|
mainAxisExtent: 0,
|
||||||
|
),
|
||||||
|
delegate: SliverChildBuilderDelegate(
|
||||||
|
(context, index) {
|
||||||
|
return const VideoCardHSkeleton();
|
||||||
|
},
|
||||||
|
childCount: 10,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
|
? SliverPadding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
bottom: MediaQuery.of(context).padding.bottom),
|
bottom: MediaQuery.of(context).padding.bottom),
|
||||||
sliver: SliverGrid(
|
sliver: SliverGrid(
|
||||||
@@ -278,25 +292,14 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: loadingState is Error
|
: HttpError(
|
||||||
? HttpError(
|
callback: _favDetailController.onReload,
|
||||||
|
),
|
||||||
|
Error() => HttpError(
|
||||||
errMsg: loadingState.errMsg,
|
errMsg: loadingState.errMsg,
|
||||||
fn: _favDetailController.onReload,
|
callback: _favDetailController.onReload,
|
||||||
)
|
|
||||||
: SliverGrid(
|
|
||||||
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
|
||||||
mainAxisSpacing: StyleString.cardSpace,
|
|
||||||
crossAxisSpacing: StyleString.safeSpace,
|
|
||||||
maxCrossAxisExtent: Grid.maxRowWidth * 2,
|
|
||||||
childAspectRatio: StyleString.aspectRatio * 2.4,
|
|
||||||
mainAxisExtent: 0,
|
|
||||||
),
|
),
|
||||||
delegate: SliverChildBuilderDelegate(
|
LoadingState() => throw UnimplementedError(),
|
||||||
(context, index) {
|
};
|
||||||
return const VideoCardHSkeleton();
|
|
||||||
},
|
|
||||||
childCount: 10,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:PiliPalaX/common/constants.dart';
|
import 'package:PiliPalaX/common/constants.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
import 'package:PiliPalaX/common/widgets/loading_widget.dart';
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/pages/follow/widgets/follow_item.dart';
|
import 'package:PiliPalaX/pages/follow/widgets/follow_item.dart';
|
||||||
import 'package:PiliPalaX/pages/history/widgets/item.dart';
|
import 'package:PiliPalaX/pages/history/widgets/item.dart';
|
||||||
@@ -7,7 +7,6 @@ import 'package:PiliPalaX/utils/grid.dart';
|
|||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/no_data.dart';
|
|
||||||
import 'package:PiliPalaX/pages/fav_detail/widget/fav_video_card.dart';
|
import 'package:PiliPalaX/pages/fav_detail/widget/fav_video_card.dart';
|
||||||
|
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
@@ -83,17 +82,10 @@ class _FavSearchPageState extends State<FavSearchPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBody(LoadingState loadingState) {
|
Widget _buildBody(LoadingState loadingState) {
|
||||||
return loadingState is Success
|
return switch (loadingState) {
|
||||||
? loadingState.response.isEmpty
|
Loading() => loadingWidget,
|
||||||
? CustomScrollView(
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
slivers: <Widget>[
|
? _favSearchCtr.searchType == SearchType.fav
|
||||||
HttpError(
|
|
||||||
errMsg: '没有数据',
|
|
||||||
fn: _favSearchCtr.onReload,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
: _favSearchCtr.searchType == SearchType.fav
|
|
||||||
? ListView.builder(
|
? ListView.builder(
|
||||||
controller: _favSearchCtr.scrollController,
|
controller: _favSearchCtr.scrollController,
|
||||||
itemCount: loadingState.response.length + 1,
|
itemCount: loadingState.response.length + 1,
|
||||||
@@ -152,19 +144,14 @@ class _FavSearchPageState extends State<FavSearchPage> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: loadingState is Error
|
: errorWidget(
|
||||||
? CustomScrollView(
|
callback: _favSearchCtr.onReload,
|
||||||
slivers: <Widget>[
|
|
||||||
HttpError(
|
|
||||||
errMsg: loadingState.errMsg,
|
|
||||||
fn: _favSearchCtr.onReload,
|
|
||||||
),
|
),
|
||||||
],
|
Error() => errorWidget(
|
||||||
)
|
errMsg: loadingState.errMsg,
|
||||||
: const CustomScrollView(
|
callback: _favSearchCtr.onReload,
|
||||||
slivers: <Widget>[
|
),
|
||||||
NoData(),
|
LoadingState() => throw UnimplementedError(),
|
||||||
],
|
};
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
|
import 'package:PiliPalaX/common/widgets/loading_widget.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
|
||||||
import 'package:PiliPalaX/common/widgets/no_data.dart';
|
|
||||||
import 'package:PiliPalaX/models/follow/result.dart';
|
import 'package:PiliPalaX/models/follow/result.dart';
|
||||||
import 'package:PiliPalaX/pages/follow/index.dart';
|
import 'package:PiliPalaX/pages/follow/index.dart';
|
||||||
|
|
||||||
@@ -92,16 +91,14 @@ class _FollowListState extends State<FollowList> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: const CustomScrollView(slivers: [NoData()]),
|
: errorWidget(
|
||||||
|
callback: () => widget.ctr.queryFollowings('init'),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return CustomScrollView(
|
return errorWidget(
|
||||||
slivers: [
|
|
||||||
HttpError(
|
|
||||||
errMsg: data['msg'],
|
errMsg: data['msg'],
|
||||||
fn: () => widget.ctr.queryFollowings('init'),
|
callback: () => widget.ctr.queryFollowings('init'),
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
|
import 'package:PiliPalaX/common/widgets/loading_widget.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
|
||||||
import 'package:PiliPalaX/common/widgets/no_data.dart';
|
|
||||||
import 'package:PiliPalaX/http/member.dart';
|
import 'package:PiliPalaX/http/member.dart';
|
||||||
import 'package:PiliPalaX/models/follow/result.dart';
|
import 'package:PiliPalaX/models/follow/result.dart';
|
||||||
import 'package:PiliPalaX/models/member/tags.dart';
|
import 'package:PiliPalaX/models/member/tags.dart';
|
||||||
@@ -110,16 +109,14 @@ class _OwnerFollowListState extends State<OwnerFollowList>
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: const CustomScrollView(slivers: [NoData()]),
|
: errorWidget(
|
||||||
|
callback: () => widget.ctr.queryFollowings('init'),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return CustomScrollView(
|
return errorWidget(
|
||||||
slivers: [
|
|
||||||
HttpError(
|
|
||||||
errMsg: data['msg'],
|
errMsg: data['msg'],
|
||||||
fn: () => widget.ctr.queryFollowings('init'),
|
callback: () => widget.ctr.queryFollowings('init'),
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
|
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
||||||
import 'package:PiliPalaX/pages/fav_search/view.dart' show SearchType;
|
import 'package:PiliPalaX/pages/fav_search/view.dart' show SearchType;
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPalaX/common/skeleton/video_card_h.dart';
|
import 'package:PiliPalaX/common/skeleton/video_card_h.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
|
||||||
import 'package:PiliPalaX/common/widgets/no_data.dart';
|
|
||||||
import 'package:PiliPalaX/pages/history/index.dart';
|
import 'package:PiliPalaX/pages/history/index.dart';
|
||||||
|
|
||||||
import '../../common/constants.dart';
|
import '../../common/constants.dart';
|
||||||
@@ -215,12 +214,20 @@ class _HistoryPageState extends State<HistoryPage> {
|
|||||||
? const SliverToBoxAdapter(
|
? const SliverToBoxAdapter(
|
||||||
child: Center(child: Text('加载中')),
|
child: Center(child: Text('加载中')),
|
||||||
)
|
)
|
||||||
: const NoData(),
|
: HttpError(
|
||||||
|
callback: () => setState(() {
|
||||||
|
_futureBuilderFuture =
|
||||||
|
_historyController.queryHistoryList();
|
||||||
|
}),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return HttpError(
|
return HttpError(
|
||||||
errMsg: data['msg'],
|
errMsg: data['msg'],
|
||||||
fn: () => setState(() {}),
|
callback: () => setState(() {
|
||||||
|
_futureBuilderFuture =
|
||||||
|
_historyController.queryHistoryList();
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ class _HotPageState extends State<HotPage> with AutomaticKeepAliveClientMixin {
|
|||||||
? (_hotController.loadingState.value as Error)
|
? (_hotController.loadingState.value as Error)
|
||||||
.errMsg
|
.errMsg
|
||||||
: '没有相关数据',
|
: '没有相关数据',
|
||||||
fn: _hotController.onReload,
|
callback: _hotController.onReload,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -320,7 +320,14 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget replyList(LoadingState loadingState) {
|
Widget replyList(LoadingState loadingState) {
|
||||||
return loadingState is Success
|
return switch (loadingState) {
|
||||||
|
Loading() => SliverList.builder(
|
||||||
|
itemCount: 5,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return const VideoReplySkeleton();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Success() => (loadingState.response.replies as List?)?.isNotEmpty == true
|
||||||
? SliverList.builder(
|
? SliverList.builder(
|
||||||
itemCount: loadingState.response.replies.length + 1,
|
itemCount: loadingState.response.replies.length + 1,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
@@ -362,17 +369,15 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: loadingState is Error
|
: HttpError(
|
||||||
? HttpError(
|
callback: _htmlRenderCtr.onReload,
|
||||||
|
),
|
||||||
|
Error() => HttpError(
|
||||||
errMsg: loadingState.errMsg,
|
errMsg: loadingState.errMsg,
|
||||||
fn: _htmlRenderCtr.onReload,
|
callback: _htmlRenderCtr.onReload,
|
||||||
)
|
),
|
||||||
: SliverList.builder(
|
LoadingState() => throw UnimplementedError(),
|
||||||
itemCount: 5,
|
};
|
||||||
itemBuilder: (context, index) {
|
|
||||||
return const VideoReplySkeleton();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Container replyHeader() {
|
Container replyHeader() {
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ class LaterController extends CommonController {
|
|||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var res = await UserHttp.toViewClear();
|
var res = await UserHttp.toViewClear();
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
loadingState.value = LoadingState.empty();
|
loadingState.value = LoadingState.success([]);
|
||||||
}
|
}
|
||||||
Get.back();
|
Get.back();
|
||||||
SmartDialog.showToast(res['msg']);
|
SmartDialog.showToast(res['msg']);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPalaX/common/skeleton/video_card_h.dart';
|
import 'package:PiliPalaX/common/skeleton/video_card_h.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/no_data.dart';
|
|
||||||
import 'package:PiliPalaX/common/widgets/video_card_h.dart';
|
import 'package:PiliPalaX/common/widgets/video_card_h.dart';
|
||||||
import 'package:PiliPalaX/pages/later/index.dart';
|
import 'package:PiliPalaX/pages/later/index.dart';
|
||||||
|
|
||||||
@@ -74,7 +73,23 @@ class _LaterPageState extends State<LaterPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBody(LoadingState loadingState) {
|
Widget _buildBody(LoadingState loadingState) {
|
||||||
return loadingState is Success
|
return switch (loadingState) {
|
||||||
|
Loading() => SliverGrid(
|
||||||
|
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
||||||
|
mainAxisSpacing: StyleString.safeSpace,
|
||||||
|
crossAxisSpacing: StyleString.safeSpace,
|
||||||
|
maxCrossAxisExtent: Grid.maxRowWidth * 2,
|
||||||
|
childAspectRatio: StyleString.aspectRatio * 2.4,
|
||||||
|
mainAxisExtent: 0,
|
||||||
|
),
|
||||||
|
delegate: SliverChildBuilderDelegate(
|
||||||
|
(context, index) {
|
||||||
|
return const VideoCardHSkeleton();
|
||||||
|
},
|
||||||
|
childCount: 10,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
? SliverGrid(
|
? SliverGrid(
|
||||||
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
||||||
mainAxisSpacing: StyleString.safeSpace,
|
mainAxisSpacing: StyleString.safeSpace,
|
||||||
@@ -95,27 +110,14 @@ class _LaterPageState extends State<LaterPage> {
|
|||||||
childCount: loadingState.response.length,
|
childCount: loadingState.response.length,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: loadingState is Empty
|
: HttpError(
|
||||||
? const NoData()
|
callback: _laterController.onReload,
|
||||||
: loadingState is Error
|
),
|
||||||
? HttpError(
|
Error() => HttpError(
|
||||||
errMsg: loadingState.errMsg,
|
errMsg: loadingState.errMsg,
|
||||||
fn: _laterController.onReload,
|
callback: _laterController.onReload,
|
||||||
)
|
|
||||||
: SliverGrid(
|
|
||||||
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
|
||||||
mainAxisSpacing: StyleString.safeSpace,
|
|
||||||
crossAxisSpacing: StyleString.safeSpace,
|
|
||||||
maxCrossAxisExtent: Grid.maxRowWidth * 2,
|
|
||||||
childAspectRatio: StyleString.aspectRatio * 2.4,
|
|
||||||
mainAxisExtent: 0,
|
|
||||||
),
|
),
|
||||||
delegate: SliverChildBuilderDelegate(
|
LoadingState() => throw UnimplementedError(),
|
||||||
(context, index) {
|
};
|
||||||
return const VideoCardHSkeleton();
|
|
||||||
},
|
|
||||||
childCount: 10,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:PiliPalaX/common/constants.dart';
|
import 'package:PiliPalaX/common/constants.dart';
|
||||||
|
import 'package:PiliPalaX/common/widgets/loading_widget.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
|
||||||
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/models/space_article/item.dart';
|
import 'package:PiliPalaX/models/space_article/item.dart';
|
||||||
@@ -40,7 +40,9 @@ class _MemberArticleState extends State<MemberArticle>
|
|||||||
}
|
}
|
||||||
|
|
||||||
_buildBody(LoadingState loadingState) {
|
_buildBody(LoadingState loadingState) {
|
||||||
return loadingState is Success
|
return switch (loadingState) {
|
||||||
|
Loading() => loadingWidget,
|
||||||
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
? MediaQuery.removePadding(
|
? MediaQuery.removePadding(
|
||||||
context: context,
|
context: context,
|
||||||
removeTop: true,
|
removeTop: true,
|
||||||
@@ -99,20 +101,14 @@ class _MemberArticleState extends State<MemberArticle>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: loadingState is Error
|
: errorWidget(
|
||||||
? Center(
|
callback: _controller.onReload,
|
||||||
child: CustomScrollView(
|
),
|
||||||
shrinkWrap: true,
|
Error() => errorWidget(
|
||||||
slivers: [
|
|
||||||
HttpError(
|
|
||||||
errMsg: loadingState.errMsg,
|
errMsg: loadingState.errMsg,
|
||||||
fn: _controller.onReload,
|
callback: _controller.onReload,
|
||||||
),
|
),
|
||||||
],
|
LoadingState() => throw UnimplementedError(),
|
||||||
),
|
};
|
||||||
)
|
|
||||||
: Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:PiliPalaX/common/constants.dart';
|
import 'package:PiliPalaX/common/constants.dart';
|
||||||
|
import 'package:PiliPalaX/common/widgets/loading_widget.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/pages/bangumi/widgets/bangumi_card_v_member_home.dart';
|
import 'package:PiliPalaX/pages/bangumi/widgets/bangumi_card_v_member_home.dart';
|
||||||
import 'package:PiliPalaX/pages/member/new/content/member_contribute/content/bangumi/member_bangumi_ctr.dart';
|
import 'package:PiliPalaX/pages/member/new/content/member_contribute/content/bangumi/member_bangumi_ctr.dart';
|
||||||
@@ -42,7 +42,9 @@ class _MemberBangumiState extends State<MemberBangumi>
|
|||||||
}
|
}
|
||||||
|
|
||||||
_buildBody(LoadingState loadingState) {
|
_buildBody(LoadingState loadingState) {
|
||||||
return loadingState is Success
|
return switch (loadingState) {
|
||||||
|
Loading() => loadingWidget,
|
||||||
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
? refreshIndicator(
|
? refreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
await _controller.onRefresh();
|
await _controller.onRefresh();
|
||||||
@@ -82,20 +84,14 @@ class _MemberBangumiState extends State<MemberBangumi>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: loadingState is Error
|
: errorWidget(
|
||||||
? Center(
|
callback: _controller.onReload,
|
||||||
child: CustomScrollView(
|
),
|
||||||
shrinkWrap: true,
|
Error() => errorWidget(
|
||||||
slivers: [
|
|
||||||
HttpError(
|
|
||||||
errMsg: loadingState.errMsg,
|
errMsg: loadingState.errMsg,
|
||||||
fn: _controller.onReload,
|
callback: _controller.onReload,
|
||||||
),
|
),
|
||||||
],
|
LoadingState() => throw UnimplementedError(),
|
||||||
),
|
};
|
||||||
)
|
|
||||||
: Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:PiliPalaX/common/constants.dart';
|
import 'package:PiliPalaX/common/constants.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/badge.dart';
|
import 'package:PiliPalaX/common/widgets/badge.dart';
|
||||||
|
import 'package:PiliPalaX/common/widgets/loading_widget.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
|
||||||
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/models/space_fav/datum.dart';
|
import 'package:PiliPalaX/models/space_fav/datum.dart';
|
||||||
@@ -44,7 +44,9 @@ class _MemberFavoriteState extends State<MemberFavorite>
|
|||||||
}
|
}
|
||||||
|
|
||||||
_buildBody(LoadingState loadingState) {
|
_buildBody(LoadingState loadingState) {
|
||||||
return loadingState is Success
|
return switch (loadingState) {
|
||||||
|
Loading() => loadingWidget,
|
||||||
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
? refreshIndicator(
|
? refreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
await _controller.onRefresh();
|
await _controller.onRefresh();
|
||||||
@@ -77,21 +79,15 @@ class _MemberFavoriteState extends State<MemberFavorite>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: loadingState is Error
|
: errorWidget(
|
||||||
? Center(
|
callback: _controller.onReload,
|
||||||
child: CustomScrollView(
|
),
|
||||||
shrinkWrap: true,
|
Error() => errorWidget(
|
||||||
slivers: [
|
|
||||||
HttpError(
|
|
||||||
errMsg: loadingState.errMsg,
|
errMsg: loadingState.errMsg,
|
||||||
fn: _controller.onReload,
|
callback: _controller.onReload,
|
||||||
),
|
),
|
||||||
],
|
LoadingState() => throw UnimplementedError(),
|
||||||
),
|
};
|
||||||
)
|
|
||||||
: Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_buildItem(Datum data, bool isFirst) {
|
_buildItem(Datum data, bool isFirst) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:PiliPalaX/common/constants.dart';
|
import 'package:PiliPalaX/common/constants.dart';
|
||||||
|
import 'package:PiliPalaX/common/widgets/loading_widget.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
|
||||||
import 'package:PiliPalaX/common/widgets/video_card_h_member_video.dart';
|
import 'package:PiliPalaX/common/widgets/video_card_h_member_video.dart';
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/pages/member/new/content/member_contribute/content/video/member_video_ctr.dart';
|
import 'package:PiliPalaX/pages/member/new/content/member_contribute/content/video/member_video_ctr.dart';
|
||||||
@@ -54,7 +54,9 @@ class _MemberVideoState extends State<MemberVideo>
|
|||||||
}
|
}
|
||||||
|
|
||||||
_buildBody(LoadingState loadingState) {
|
_buildBody(LoadingState loadingState) {
|
||||||
return loadingState is Success && loadingState.response is List
|
return switch (loadingState) {
|
||||||
|
Loading() => loadingWidget,
|
||||||
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
? refreshIndicator(
|
? refreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
await _controller.onRefresh();
|
await _controller.onRefresh();
|
||||||
@@ -138,22 +140,14 @@ class _MemberVideoState extends State<MemberVideo>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: loadingState is Loading
|
: errorWidget(
|
||||||
? Center(
|
callback: _controller.onReload,
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
)
|
|
||||||
: Center(
|
|
||||||
child: CustomScrollView(
|
|
||||||
shrinkWrap: true,
|
|
||||||
slivers: [
|
|
||||||
HttpError(
|
|
||||||
errMsg: loadingState is Error
|
|
||||||
? (loadingState as Error?)?.errMsg
|
|
||||||
: 'EMPTY',
|
|
||||||
fn: _controller.onReload,
|
|
||||||
),
|
),
|
||||||
],
|
Error() => errorWidget(
|
||||||
|
errMsg: loadingState.errMsg,
|
||||||
|
callback: _controller.onReload,
|
||||||
),
|
),
|
||||||
);
|
LoadingState() => throw UnimplementedError(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import 'package:PiliPalaX/common/widgets/loading_widget.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/pages/dynamics/widgets/dynamic_panel_grpc.dart';
|
import 'package:PiliPalaX/pages/dynamics/widgets/dynamic_panel_grpc.dart';
|
||||||
import 'package:PiliPalaX/pages/member/new/content/member_dynamic/member_dynamic_ctr.dart';
|
import 'package:PiliPalaX/pages/member/new/content/member_dynamic/member_dynamic_ctr.dart';
|
||||||
@@ -32,7 +32,9 @@ class _MemberDynamicState extends State<MemberDynamic>
|
|||||||
}
|
}
|
||||||
|
|
||||||
_buildBody(LoadingState loadingState) {
|
_buildBody(LoadingState loadingState) {
|
||||||
return loadingState is Success
|
return switch (loadingState) {
|
||||||
|
Loading() => loadingWidget,
|
||||||
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
? refreshIndicator(
|
? refreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
await _controller.onRefresh();
|
await _controller.onRefresh();
|
||||||
@@ -50,20 +52,14 @@ class _MemberDynamicState extends State<MemberDynamic>
|
|||||||
separatorBuilder: (_, index) => const SizedBox(height: 10),
|
separatorBuilder: (_, index) => const SizedBox(height: 10),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: loadingState is Error
|
: errorWidget(
|
||||||
? Center(
|
callback: _controller.onReload,
|
||||||
child: CustomScrollView(
|
),
|
||||||
shrinkWrap: true,
|
Error() => errorWidget(
|
||||||
slivers: [
|
|
||||||
HttpError(
|
|
||||||
errMsg: loadingState.errMsg,
|
errMsg: loadingState.errMsg,
|
||||||
fn: _controller.onReload,
|
callback: _controller.onReload,
|
||||||
),
|
),
|
||||||
],
|
LoadingState() => throw UnimplementedError(),
|
||||||
),
|
};
|
||||||
)
|
|
||||||
: Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:PiliPalaX/common/constants.dart';
|
import 'package:PiliPalaX/common/constants.dart';
|
||||||
|
import 'package:PiliPalaX/common/widgets/loading_widget.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/video_card_v_member_home.dart';
|
import 'package:PiliPalaX/common/widgets/video_card_v_member_home.dart';
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
@@ -39,10 +40,13 @@ class _MemberHomeState extends State<MemberHome>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBody(LoadingState loadingState) {
|
Widget _buildBody(LoadingState loadingState) {
|
||||||
return loadingState is Success && loadingState.response is Data
|
return switch (loadingState) {
|
||||||
|
Loading() => loadingWidget,
|
||||||
|
Success() => loadingState.response is Data
|
||||||
? CustomScrollView(
|
? CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
if (loadingState.response?.archive?.item?.isNotEmpty == true) ...[
|
if (loadingState.response?.archive?.item?.isNotEmpty ==
|
||||||
|
true) ...[
|
||||||
_videoHeader(
|
_videoHeader(
|
||||||
title: '视频',
|
title: '视频',
|
||||||
param: 'contribute',
|
param: 'contribute',
|
||||||
@@ -65,7 +69,8 @@ class _MemberHomeState extends State<MemberHome>
|
|||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
(context, index) {
|
(context, index) {
|
||||||
return VideoCardVMemberHome(
|
return VideoCardVMemberHome(
|
||||||
videoItem: loadingState.response.archive.item[index],
|
videoItem:
|
||||||
|
loadingState.response.archive.item[index],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
childCount:
|
childCount:
|
||||||
@@ -101,7 +106,8 @@ class _MemberHomeState extends State<MemberHome>
|
|||||||
),
|
),
|
||||||
// TODO
|
// TODO
|
||||||
],
|
],
|
||||||
if (loadingState.response?.article?.item?.isNotEmpty == true) ...[
|
if (loadingState.response?.article?.item?.isNotEmpty ==
|
||||||
|
true) ...[
|
||||||
_videoHeader(
|
_videoHeader(
|
||||||
title: '专栏',
|
title: '专栏',
|
||||||
param: 'contribute',
|
param: 'contribute',
|
||||||
@@ -113,7 +119,8 @@ class _MemberHomeState extends State<MemberHome>
|
|||||||
dense: true,
|
dense: true,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
PiliScheme.routePush(Uri.parse(
|
PiliScheme.routePush(Uri.parse(
|
||||||
loadingState.response.article.item.first.uri ?? ''));
|
loadingState.response.article.item.first.uri ??
|
||||||
|
''));
|
||||||
},
|
},
|
||||||
leading: loadingState.response.article.item.first
|
leading: loadingState.response.article.item.first
|
||||||
.originImageUrls?.isNotEmpty ==
|
.originImageUrls?.isNotEmpty ==
|
||||||
@@ -124,8 +131,8 @@ class _MemberHomeState extends State<MemberHome>
|
|||||||
builder: (_, constraints) {
|
builder: (_, constraints) {
|
||||||
return NetworkImgLayer(
|
return NetworkImgLayer(
|
||||||
radius: 6,
|
radius: 6,
|
||||||
src: loadingState.response.article.item.first
|
src: loadingState.response.article.item
|
||||||
.originImageUrls!.first,
|
.first.originImageUrls!.first,
|
||||||
width: constraints.maxHeight *
|
width: constraints.maxHeight *
|
||||||
StyleString.aspectRatio,
|
StyleString.aspectRatio,
|
||||||
height: constraints.maxHeight,
|
height: constraints.maxHeight,
|
||||||
@@ -156,7 +163,8 @@ class _MemberHomeState extends State<MemberHome>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
if (loadingState.response?.audios?.item?.isNotEmpty == true) ...[
|
if (loadingState.response?.audios?.item?.isNotEmpty ==
|
||||||
|
true) ...[
|
||||||
_videoHeader(
|
_videoHeader(
|
||||||
title: '音频',
|
title: '音频',
|
||||||
param: 'contribute',
|
param: 'contribute',
|
||||||
@@ -165,7 +173,8 @@ class _MemberHomeState extends State<MemberHome>
|
|||||||
),
|
),
|
||||||
// TODO
|
// TODO
|
||||||
],
|
],
|
||||||
if (loadingState.response?.season?.item?.isNotEmpty == true) ...[
|
if (loadingState.response?.season?.item?.isNotEmpty ==
|
||||||
|
true) ...[
|
||||||
_videoHeader(
|
_videoHeader(
|
||||||
title: '追番',
|
title: '追番',
|
||||||
param: 'bangumi',
|
param: 'bangumi',
|
||||||
@@ -187,7 +196,8 @@ class _MemberHomeState extends State<MemberHome>
|
|||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
(context, index) {
|
(context, index) {
|
||||||
return BangumiCardVMemberHome(
|
return BangumiCardVMemberHome(
|
||||||
bangumiItem: loadingState.response.season.item[index],
|
bangumiItem:
|
||||||
|
loadingState.response.season.item[index],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
childCount:
|
childCount:
|
||||||
@@ -203,7 +213,10 @@ class _MemberHomeState extends State<MemberHome>
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: const SizedBox.shrink();
|
: errorWidget(),
|
||||||
|
Error() => errorWidget(),
|
||||||
|
LoadingState() => throw UnimplementedError(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _videoHeader({
|
Widget _videoHeader({
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:PiliPalaX/common/widgets/dynamic_sliver_appbar.dart';
|
import 'package:PiliPalaX/common/widgets/dynamic_sliver_appbar.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
import 'package:PiliPalaX/common/widgets/loading_widget.dart';
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/pages/member/new/content/member_contribute/content/bangumi/member_bangumi.dart';
|
import 'package:PiliPalaX/pages/member/new/content/member_contribute/content/bangumi/member_bangumi.dart';
|
||||||
import 'package:PiliPalaX/pages/member/new/content/member_contribute/content/favorite/member_favorite.dart';
|
import 'package:PiliPalaX/pages/member/new/content/member_contribute/content/favorite/member_favorite.dart';
|
||||||
@@ -291,28 +291,19 @@ class _MemberPageNewState extends State<MemberPageNew>
|
|||||||
);
|
);
|
||||||
|
|
||||||
Widget _errorWidget(msg) {
|
Widget _errorWidget(msg) {
|
||||||
return CustomScrollView(
|
return errorWidget(
|
||||||
shrinkWrap: true,
|
|
||||||
slivers: [
|
|
||||||
HttpError(
|
|
||||||
errMsg: msg,
|
errMsg: msg,
|
||||||
fn: () {
|
callback: () {
|
||||||
_userController.loadingState.value = LoadingState.loading();
|
_userController.loadingState.value = LoadingState.loading();
|
||||||
_userController.onRefresh();
|
_userController.onRefresh();
|
||||||
},
|
},
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildUserInfo(LoadingState userState, [bool isV = true]) {
|
Widget _buildUserInfo(LoadingState userState, [bool isV = true]) {
|
||||||
switch (userState) {
|
return switch (userState) {
|
||||||
case Empty():
|
Loading() => const CircularProgressIndicator(),
|
||||||
return _errorWidget('EMPTY');
|
Success() => Obx(
|
||||||
case Error():
|
|
||||||
return _errorWidget(userState.errMsg);
|
|
||||||
case Success():
|
|
||||||
return Obx(
|
|
||||||
() => Padding(
|
() => Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
bottom: (_userController.tab2?.length ?? 0) > 1 ? 48 : 0),
|
bottom: (_userController.tab2?.length ?? 0) > 1 ? 48 : 0),
|
||||||
@@ -326,8 +317,9 @@ class _MemberPageNewState extends State<MemberPageNew>
|
|||||||
onFollow: () => _userController.onFollow(context),
|
onFollow: () => _userController.onFollow(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
}
|
Error() => _errorWidget(userState.errMsg),
|
||||||
return const CircularProgressIndicator();
|
LoadingState() => throw UnimplementedError(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:PiliPalaX/common/constants.dart';
|
import 'package:PiliPalaX/common/constants.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
import 'package:PiliPalaX/common/widgets/loading_widget.dart';
|
||||||
import 'package:PiliPalaX/http/constants.dart';
|
import 'package:PiliPalaX/http/constants.dart';
|
||||||
import 'package:PiliPalaX/http/index.dart';
|
import 'package:PiliPalaX/http/index.dart';
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
@@ -99,19 +99,9 @@ class _EditProfilePageState extends State<EditProfilePage> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
Widget _buildBody(LoadingState loadingState) {
|
Widget _buildBody(LoadingState loadingState) {
|
||||||
switch (loadingState) {
|
return switch (loadingState) {
|
||||||
case Error():
|
Loading() => loadingWidget,
|
||||||
return CustomScrollView(
|
Success() => SingleChildScrollView(
|
||||||
shrinkWrap: true,
|
|
||||||
slivers: [
|
|
||||||
HttpError(
|
|
||||||
errMsg: loadingState.errMsg,
|
|
||||||
fn: _getInfo,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
case Success():
|
|
||||||
return SingleChildScrollView(
|
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
_item(
|
_item(
|
||||||
@@ -226,11 +216,13 @@ class _EditProfilePageState extends State<EditProfilePage> {
|
|||||||
_divider,
|
_divider,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
}
|
Error() => errorWidget(
|
||||||
return Center(
|
errMsg: loadingState.errMsg,
|
||||||
child: CircularProgressIndicator(),
|
callback: _getInfo,
|
||||||
);
|
),
|
||||||
|
LoadingState() => throw UnimplementedError(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _sexDialog(int current) {
|
Widget _sexDialog(int current) {
|
||||||
|
|||||||
@@ -109,13 +109,13 @@ class _MemberArchivePageState extends State<MemberArchivePage> {
|
|||||||
} else {
|
} else {
|
||||||
return HttpError(
|
return HttpError(
|
||||||
errMsg: snapshot.data['msg'],
|
errMsg: snapshot.data['msg'],
|
||||||
fn: () {},
|
callback: () {},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return HttpError(
|
return HttpError(
|
||||||
errMsg: "投稿页出现错误",
|
errMsg: "投稿页出现错误",
|
||||||
fn: () {},
|
callback: () {},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -72,7 +72,11 @@ class _MemberDynamicsPageState extends State<MemberDynamicsPage>
|
|||||||
);
|
);
|
||||||
|
|
||||||
_buildContent(LoadingState loadingState) {
|
_buildContent(LoadingState loadingState) {
|
||||||
return loadingState is Success
|
return switch (loadingState) {
|
||||||
|
Loading() => HttpError(
|
||||||
|
callback: _memberDynamicController.onReload,
|
||||||
|
),
|
||||||
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
? SliverPadding(
|
? SliverPadding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
bottom: MediaQuery.paddingOf(context).bottom,
|
bottom: MediaQuery.paddingOf(context).bottom,
|
||||||
@@ -134,10 +138,13 @@ class _MemberDynamicsPageState extends State<MemberDynamicsPage>
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
: HttpError(
|
: HttpError(
|
||||||
errMsg: loadingState is Error ? loadingState.errMsg : null,
|
callback: _memberDynamicController.onReload,
|
||||||
fn: () {
|
),
|
||||||
_memberDynamicController.onReload();
|
Error() => HttpError(
|
||||||
},
|
errMsg: loadingState.errMsg,
|
||||||
);
|
callback: _memberDynamicController.onReload,
|
||||||
|
),
|
||||||
|
LoadingState() => throw UnimplementedError(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPalaX/common/skeleton/video_card_h.dart';
|
import 'package:PiliPalaX/common/skeleton/video_card_h.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/no_data.dart';
|
|
||||||
import 'package:PiliPalaX/common/widgets/video_card_h.dart';
|
import 'package:PiliPalaX/common/widgets/video_card_h.dart';
|
||||||
|
|
||||||
import '../../common/constants.dart';
|
import '../../common/constants.dart';
|
||||||
@@ -148,12 +147,14 @@ class _MemberSearchPageState extends State<MemberSearchPage>
|
|||||||
(context, index) {
|
(context, index) {
|
||||||
return const VideoCardHSkeleton();
|
return const VideoCardHSkeleton();
|
||||||
}, childCount: 10))
|
}, childCount: 10))
|
||||||
: const NoData(),
|
: HttpError(
|
||||||
|
callback: () => setState(() {}),
|
||||||
|
),
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
return HttpError(
|
return HttpError(
|
||||||
errMsg: data['msg'],
|
errMsg: data['msg'],
|
||||||
fn: () => setState(() {}),
|
callback: () => setState(() {}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ class _ZonePageState extends State<ZonePage>
|
|||||||
? (_zoneController.loadingState.value as Error)
|
? (_zoneController.loadingState.value as Error)
|
||||||
.errMsg
|
.errMsg
|
||||||
: '没有相关数据',
|
: '没有相关数据',
|
||||||
fn: _zoneController.onReload,
|
callback: _zoneController.onReload,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ class _RcmdPageState extends State<RcmdPage>
|
|||||||
errMsg: _controller.loadingState.value is Error
|
errMsg: _controller.loadingState.value is Error
|
||||||
? (_controller.loadingState.value as Error).errMsg
|
? (_controller.loadingState.value as Error).errMsg
|
||||||
: '没有相关数据',
|
: '没有相关数据',
|
||||||
fn: _controller.onReload,
|
callback: _controller.onReload,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
|||||||
slivers: [
|
slivers: [
|
||||||
HttpError(
|
HttpError(
|
||||||
errMsg: data['msg'],
|
errMsg: data['msg'],
|
||||||
fn: () => setState(() {
|
callback: () => setState(() {
|
||||||
_futureBuilderFuture =
|
_futureBuilderFuture =
|
||||||
_searchController.queryHotSearchList();
|
_searchController.queryHotSearchList();
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -45,14 +45,14 @@ class SearchPanelController extends CommonController {
|
|||||||
if (dataList.isNotEmpty) {
|
if (dataList.isNotEmpty) {
|
||||||
loadingState.value = LoadingState.success(dataList);
|
loadingState.value = LoadingState.success(dataList);
|
||||||
} else {
|
} else {
|
||||||
loadingState.value = LoadingState.empty();
|
loadingState.value = LoadingState.success([]);
|
||||||
}
|
}
|
||||||
if (currentPage == 1) {
|
if (currentPage == 1) {
|
||||||
onPushDetail(response.response.list);
|
onPushDetail(response.response.list);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (currentPage == 1) {
|
if (currentPage == 1) {
|
||||||
loadingState.value = LoadingState.empty();
|
loadingState.value = LoadingState.success([]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ Widget searchArticlePanel(BuildContext context, searchPanelCtr, loadingState) {
|
|||||||
)
|
)
|
||||||
: HttpError(
|
: HttpError(
|
||||||
errMsg: loadingState is Error ? loadingState.errMsg : '没有相关数据',
|
errMsg: loadingState is Error ? loadingState.errMsg : '没有相关数据',
|
||||||
fn: searchPanelCtr.onReload,
|
callback: searchPanelCtr.onReload,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
import 'package:PiliPalaX/common/widgets/loading_widget.dart';
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -8,8 +8,10 @@ import 'package:PiliPalaX/utils/utils.dart';
|
|||||||
|
|
||||||
import '../../../utils/grid.dart';
|
import '../../../utils/grid.dart';
|
||||||
|
|
||||||
Widget searchLivePanel(BuildContext context, ctr, loadingState) {
|
Widget searchLivePanel(BuildContext context, ctr, LoadingState loadingState) {
|
||||||
return loadingState is Success
|
return switch (loadingState) {
|
||||||
|
Loading() => loadingWidget,
|
||||||
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
? GridView.builder(
|
? GridView.builder(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: StyleString.safeSpace,
|
left: StyleString.safeSpace,
|
||||||
@@ -30,14 +32,15 @@ Widget searchLivePanel(BuildContext context, ctr, loadingState) {
|
|||||||
return LiveItem(liveItem: loadingState.response[index]);
|
return LiveItem(liveItem: loadingState.response[index]);
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: CustomScrollView(
|
: errorWidget(
|
||||||
slivers: [
|
callback: ctr.onReload,
|
||||||
HttpError(
|
|
||||||
errMsg: loadingState is Error ? loadingState.errMsg : '没有相关数据',
|
|
||||||
fn: ctr.onReload,
|
|
||||||
),
|
),
|
||||||
],
|
Error() => errorWidget(
|
||||||
);
|
errMsg: loadingState.errMsg,
|
||||||
|
callback: ctr.onReload,
|
||||||
|
),
|
||||||
|
LoadingState() => throw UnimplementedError(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class LiveItem extends StatelessWidget {
|
class LiveItem extends StatelessWidget {
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ Widget searchBangumiPanel(BuildContext context, ctr, loadingState) {
|
|||||||
)
|
)
|
||||||
: HttpError(
|
: HttpError(
|
||||||
errMsg: loadingState is Error ? loadingState.errMsg : '没有相关数据',
|
errMsg: loadingState is Error ? loadingState.errMsg : '没有相关数据',
|
||||||
fn: ctr.onReload,
|
callback: ctr.onReload,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ Widget searchUserPanel(BuildContext context, searchPanelCtr, loadingState) {
|
|||||||
)
|
)
|
||||||
: HttpError(
|
: HttpError(
|
||||||
errMsg: loadingState is Error ? loadingState.errMsg : '没有相关数据',
|
errMsg: loadingState is Error ? loadingState.errMsg : '没有相关数据',
|
||||||
fn: searchPanelCtr.onReload,
|
callback: searchPanelCtr.onReload,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class SearchVideoPanel extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
: HttpError(
|
: HttpError(
|
||||||
errMsg: loadingState is Error ? loadingState.errMsg : '没有相关数据',
|
errMsg: loadingState is Error ? loadingState.errMsg : '没有相关数据',
|
||||||
fn: ctr.onReload,
|
callback: ctr.onReload,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ class _SearchResultPageState extends State<SearchResultPage>
|
|||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Container(
|
Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
padding: const EdgeInsets.only(left: 8),
|
|
||||||
color: Theme.of(context).colorScheme.surface,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
child: Theme(
|
child: Theme(
|
||||||
data: ThemeData(
|
data: ThemeData(
|
||||||
@@ -72,6 +71,7 @@ class _SearchResultPageState extends State<SearchResultPage>
|
|||||||
highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明
|
highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明
|
||||||
),
|
),
|
||||||
child: TabBar(
|
child: TabBar(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
controller: _tabController,
|
controller: _tabController,
|
||||||
tabs: SearchType.values
|
tabs: SearchType.values
|
||||||
.map(
|
.map(
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'package:PiliPalaX/common/widgets/loading_widget.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/no_data.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
import '../../../services/loggeer.dart';
|
import '../../../services/loggeer.dart';
|
||||||
|
|
||||||
@@ -194,11 +194,7 @@ class _LogsPageState extends State<LogsPage> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: const CustomScrollView(
|
: errorWidget(),
|
||||||
slivers: <Widget>[
|
|
||||||
NoData(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ class _RecommendSettingState extends State<RecommendSetting> {
|
|||||||
leading: Icon(Icons.refresh),
|
leading: Icon(Icons.refresh),
|
||||||
setKey: SettingBoxKey.enableSaveLastData,
|
setKey: SettingBoxKey.enableSaveLastData,
|
||||||
defaultVal: false,
|
defaultVal: false,
|
||||||
|
needReboot: true,
|
||||||
),
|
),
|
||||||
// 分割线
|
// 分割线
|
||||||
const Divider(height: 1),
|
const Divider(height: 1),
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class _StyleSettingState extends State<StyleSetting> {
|
|||||||
setting.get(SettingBoxKey.maxRowWidth, defaultValue: 240.0) as double;
|
setting.get(SettingBoxKey.maxRowWidth, defaultValue: 240.0) as double;
|
||||||
upPanelPosition = UpPanelPosition.values[setting.get(
|
upPanelPosition = UpPanelPosition.values[setting.get(
|
||||||
SettingBoxKey.upPanelPosition,
|
SettingBoxKey.upPanelPosition,
|
||||||
defaultValue: UpPanelPosition.leftFixed.code)];
|
defaultValue: UpPanelPosition.leftFixed.index)];
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -67,10 +67,10 @@ class _StyleSettingState extends State<StyleSetting> {
|
|||||||
callFn: (value) {
|
callFn: (value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
autoScreen();
|
autoScreen();
|
||||||
SmartDialog.showToast('已开启横屏适配');
|
// SmartDialog.showToast('已开启横屏适配');
|
||||||
} else {
|
} else {
|
||||||
AutoOrientation.portraitUpMode();
|
AutoOrientation.portraitUpMode();
|
||||||
SmartDialog.showToast('已关闭横屏适配');
|
// SmartDialog.showToast('已关闭横屏适配');
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
const SetSwitchItem(
|
const SetSwitchItem(
|
||||||
@@ -171,7 +171,7 @@ class _StyleSettingState extends State<StyleSetting> {
|
|||||||
);
|
);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
upPanelPosition = result;
|
upPanelPosition = result;
|
||||||
setting.put(SettingBoxKey.upPanelPosition, result.code);
|
setting.put(SettingBoxKey.upPanelPosition, result.index);
|
||||||
SmartDialog.showToast('重启生效');
|
SmartDialog.showToast('重启生效');
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
@@ -307,7 +307,7 @@ class _StyleSettingState extends State<StyleSetting> {
|
|||||||
if (result != null) {
|
if (result != null) {
|
||||||
_tempThemeValue = result;
|
_tempThemeValue = result;
|
||||||
settingController.themeType.value = result;
|
settingController.themeType.value = result;
|
||||||
setting.put(SettingBoxKey.themeMode, result.code);
|
setting.put(SettingBoxKey.themeMode, result.index);
|
||||||
Get.forceAppUpdate();
|
Get.forceAppUpdate();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class _SubPageState extends State<SubPage> {
|
|||||||
slivers: [
|
slivers: [
|
||||||
HttpError(
|
HttpError(
|
||||||
errMsg: data?['msg'],
|
errMsg: data?['msg'],
|
||||||
fn: () => setState(() {}),
|
callback: () => setState(() {}),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import 'package:get/get.dart';
|
|||||||
import 'package:PiliPalaX/common/skeleton/video_card_h.dart';
|
import 'package:PiliPalaX/common/skeleton/video_card_h.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/no_data.dart';
|
|
||||||
|
|
||||||
import '../../models/user/sub_folder.dart';
|
import '../../models/user/sub_folder.dart';
|
||||||
import '../../utils/utils.dart';
|
import '../../utils/utils.dart';
|
||||||
@@ -206,7 +205,12 @@ class _SubDetailPageState extends State<SubDetailPage> {
|
|||||||
Map data = snapshot.data;
|
Map data = snapshot.data;
|
||||||
if (data['status']) {
|
if (data['status']) {
|
||||||
if (_subDetailController.item.mediaCount == 0) {
|
if (_subDetailController.item.mediaCount == 0) {
|
||||||
return const NoData();
|
return HttpError(
|
||||||
|
callback: () => setState(() {
|
||||||
|
_futureBuilderFuture =
|
||||||
|
_subDetailController.queryUserSubFolderDetail();
|
||||||
|
}),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
List subList = _subDetailController.subList;
|
List subList = _subDetailController.subList;
|
||||||
return Obx(
|
return Obx(
|
||||||
@@ -225,7 +229,10 @@ class _SubDetailPageState extends State<SubDetailPage> {
|
|||||||
} else {
|
} else {
|
||||||
return HttpError(
|
return HttpError(
|
||||||
errMsg: data['msg'],
|
errMsg: data['msg'],
|
||||||
fn: () => setState(() {}),
|
callback: () => setState(() {
|
||||||
|
_futureBuilderFuture =
|
||||||
|
_subDetailController.queryUserSubFolderDetail();
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -699,7 +699,10 @@ class VideoIntroController extends GetxController
|
|||||||
late RelatedController relatedCtr;
|
late RelatedController relatedCtr;
|
||||||
try {
|
try {
|
||||||
relatedCtr = Get.find<RelatedController>(tag: heroTag);
|
relatedCtr = Get.find<RelatedController>(tag: heroTag);
|
||||||
if (relatedCtr.loadingState.value is Empty) {
|
if (relatedCtr.loadingState.value is! Success) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ((relatedCtr.loadingState.value as Success).response.isEmpty == true) {
|
||||||
SmartDialog.showToast('暂无相关视频,停止连播');
|
SmartDialog.showToast('暂无相关视频,停止连播');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
|||||||
slivers: [
|
slivers: [
|
||||||
HttpError(
|
HttpError(
|
||||||
errMsg: _errMsg,
|
errMsg: _errMsg,
|
||||||
fn: _getFolderInfo,
|
callback: _getFolderInfo,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ class _FavPanelState extends State<FavPanel> {
|
|||||||
slivers: [
|
slivers: [
|
||||||
HttpError(
|
HttpError(
|
||||||
errMsg: data['msg'],
|
errMsg: data['msg'],
|
||||||
fn: () => setState(() {
|
callback: () => setState(() {
|
||||||
_futureBuilderFuture =
|
_futureBuilderFuture =
|
||||||
widget.ctr!.queryVideoInFolder();
|
widget.ctr!.queryVideoInFolder();
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ class _GroupPanelState extends State<GroupPanel> {
|
|||||||
slivers: [
|
slivers: [
|
||||||
HttpError(
|
HttpError(
|
||||||
errMsg: data['msg'],
|
errMsg: data['msg'],
|
||||||
fn: () => setState(() {}),
|
callback: () => setState(() {}),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -43,7 +43,22 @@ class _RelatedVideoPanelState extends State<RelatedVideoPanel>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBody(LoadingState loadingState) {
|
Widget _buildBody(LoadingState loadingState) {
|
||||||
return loadingState is Success
|
return switch (loadingState) {
|
||||||
|
Loading() => SliverGrid(
|
||||||
|
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
||||||
|
mainAxisSpacing: StyleString.safeSpace,
|
||||||
|
crossAxisSpacing: StyleString.safeSpace,
|
||||||
|
maxCrossAxisExtent: Grid.maxRowWidth * 2,
|
||||||
|
childAspectRatio: StyleString.aspectRatio * 2.4,
|
||||||
|
mainAxisExtent: 0),
|
||||||
|
delegate: SliverChildBuilderDelegate(
|
||||||
|
(context, index) {
|
||||||
|
return const VideoCardHSkeleton();
|
||||||
|
},
|
||||||
|
childCount: 5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
? SliverGrid(
|
? SliverGrid(
|
||||||
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
||||||
mainAxisSpacing: StyleString.safeSpace,
|
mainAxisSpacing: StyleString.safeSpace,
|
||||||
@@ -53,7 +68,8 @@ class _RelatedVideoPanelState extends State<RelatedVideoPanel>
|
|||||||
mainAxisExtent: 0),
|
mainAxisExtent: 0),
|
||||||
delegate: SliverChildBuilderDelegate((context, index) {
|
delegate: SliverChildBuilderDelegate((context, index) {
|
||||||
if (index == loadingState.response.length) {
|
if (index == loadingState.response.length) {
|
||||||
return SizedBox(height: MediaQuery.of(context).padding.bottom);
|
return SizedBox(
|
||||||
|
height: MediaQuery.of(context).padding.bottom);
|
||||||
} else {
|
} else {
|
||||||
return Material(
|
return Material(
|
||||||
child: VideoCardH(
|
child: VideoCardH(
|
||||||
@@ -71,26 +87,14 @@ class _RelatedVideoPanelState extends State<RelatedVideoPanel>
|
|||||||
}
|
}
|
||||||
}, childCount: loadingState.response.length + 1),
|
}, childCount: loadingState.response.length + 1),
|
||||||
)
|
)
|
||||||
: loadingState is Error
|
: HttpError(
|
||||||
? HttpError(
|
callback: _relatedController.onReload,
|
||||||
errMsg: '出错了',
|
|
||||||
fn: _relatedController.onReload,
|
|
||||||
)
|
|
||||||
: loadingState is Empty
|
|
||||||
? const SliverToBoxAdapter(child: SizedBox.shrink())
|
|
||||||
: SliverGrid(
|
|
||||||
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
|
||||||
mainAxisSpacing: StyleString.safeSpace,
|
|
||||||
crossAxisSpacing: StyleString.safeSpace,
|
|
||||||
maxCrossAxisExtent: Grid.maxRowWidth * 2,
|
|
||||||
childAspectRatio: StyleString.aspectRatio * 2.4,
|
|
||||||
mainAxisExtent: 0),
|
|
||||||
delegate: SliverChildBuilderDelegate(
|
|
||||||
(context, index) {
|
|
||||||
return const VideoCardHSkeleton();
|
|
||||||
},
|
|
||||||
childCount: 5,
|
|
||||||
),
|
),
|
||||||
);
|
Error() => HttpError(
|
||||||
|
errMsg: loadingState.errMsg,
|
||||||
|
callback: _relatedController.onReload,
|
||||||
|
),
|
||||||
|
LoadingState() => throw UnimplementedError(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,7 +200,16 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBody(LoadingState loadingState) {
|
Widget _buildBody(LoadingState loadingState) {
|
||||||
return loadingState is Success
|
return switch (loadingState) {
|
||||||
|
Loading() => SliverList(
|
||||||
|
delegate: SliverChildBuilderDelegate(
|
||||||
|
(BuildContext context, index) {
|
||||||
|
return const VideoReplySkeleton();
|
||||||
|
},
|
||||||
|
childCount: 5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Success() => (loadingState.response.replies as List?)?.isNotEmpty == true
|
||||||
? SliverList(
|
? SliverList(
|
||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
(BuildContext context, index) {
|
(BuildContext context, index) {
|
||||||
@@ -244,19 +253,15 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
|||||||
childCount: loadingState.response.replies.length + 1,
|
childCount: loadingState.response.replies.length + 1,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: loadingState is Error
|
: HttpError(
|
||||||
? HttpError(
|
callback: _videoReplyController.onReload,
|
||||||
errMsg: loadingState.errMsg,
|
|
||||||
fn: _videoReplyController.onReload,
|
|
||||||
)
|
|
||||||
: SliverList(
|
|
||||||
delegate: SliverChildBuilderDelegate(
|
|
||||||
(BuildContext context, index) {
|
|
||||||
return const VideoReplySkeleton();
|
|
||||||
},
|
|
||||||
childCount: 5,
|
|
||||||
),
|
),
|
||||||
);
|
Error() => HttpError(
|
||||||
|
errMsg: loadingState.errMsg,
|
||||||
|
callback: _videoReplyController.onReload,
|
||||||
|
),
|
||||||
|
LoadingState() => throw UnimplementedError(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -146,10 +146,20 @@ class VideoReplyReplyController extends CommonController
|
|||||||
}
|
}
|
||||||
upMid ??= replies.subjectControl.upMid.toInt();
|
upMid ??= replies.subjectControl.upMid.toInt();
|
||||||
cursor = replies.cursor;
|
cursor = replies.cursor;
|
||||||
|
if (currentPage != 1) {
|
||||||
|
List<ReplyInfo> list = loadingState.value is Success
|
||||||
|
? (loadingState.value as Success).response
|
||||||
|
: <ReplyInfo>[];
|
||||||
|
if (isDialogue) {
|
||||||
|
replies.replies.insertAll(0, list);
|
||||||
|
} else {
|
||||||
|
replies.root.replies.insertAll(0, list);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (isDialogue) {
|
if (isDialogue) {
|
||||||
if (replies.replies.isNotEmpty) {
|
if (replies.replies.isNotEmpty) {
|
||||||
noMore.value = '加载中...';
|
noMore.value = '加载中...';
|
||||||
if (replies.cursor.isEnd) {
|
if (replies.cursor.isEnd || count.value >= replies.replies.length) {
|
||||||
noMore.value = '没有更多了';
|
noMore.value = '没有更多了';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -159,7 +169,8 @@ class VideoReplyReplyController extends CommonController
|
|||||||
} else {
|
} else {
|
||||||
if (replies.root.replies.isNotEmpty) {
|
if (replies.root.replies.isNotEmpty) {
|
||||||
noMore.value = '加载中...';
|
noMore.value = '加载中...';
|
||||||
if (replies.cursor.isEnd) {
|
if (replies.cursor.isEnd ||
|
||||||
|
count.value >= replies.root.replies.length) {
|
||||||
noMore.value = '没有更多了';
|
noMore.value = '没有更多了';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -167,16 +178,6 @@ class VideoReplyReplyController extends CommonController
|
|||||||
noMore.value = currentPage == 1 ? '还没有评论' : '没有更多了';
|
noMore.value = currentPage == 1 ? '还没有评论' : '没有更多了';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentPage != 1) {
|
|
||||||
List<ReplyInfo> list = loadingState.value is Success
|
|
||||||
? (loadingState.value as Success).response
|
|
||||||
: <ReplyInfo>[];
|
|
||||||
if (isDialogue) {
|
|
||||||
replies.replies.insertAll(0, list);
|
|
||||||
} else {
|
|
||||||
replies.root.replies.insertAll(0, list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isDialogue) {
|
if (isDialogue) {
|
||||||
loadingState.value = LoadingState.success(replies.replies);
|
loadingState.value = LoadingState.success(replies.replies);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -333,7 +333,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
slivers: [
|
slivers: [
|
||||||
HttpError(
|
HttpError(
|
||||||
errMsg: loadingState.errMsg,
|
errMsg: loadingState.errMsg,
|
||||||
fn: _videoReplyReplyController.onReload,
|
callback: _videoReplyReplyController.onReload,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user