mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-25 04:45:54 +08:00
refa: query data (#659)
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -16,8 +16,10 @@ import 'package:PiliPlus/utils/utils.dart';
|
||||
|
||||
import '../../../utils/grid.dart';
|
||||
|
||||
Widget searchArticlePanel(BuildContext context,
|
||||
SearchPanelController searchPanelCtr, LoadingState loadingState) {
|
||||
Widget searchArticlePanel(
|
||||
BuildContext context,
|
||||
SearchPanelController searchPanelCtr,
|
||||
LoadingState<List<dynamic>?> loadingState) {
|
||||
TextStyle textStyle = TextStyle(
|
||||
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize,
|
||||
color: Theme.of(context).colorScheme.outline);
|
||||
@@ -80,7 +82,7 @@ Widget searchArticlePanel(BuildContext context,
|
||||
),
|
||||
switch (loadingState) {
|
||||
Loading() => errorWidget(),
|
||||
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||
Success() => loadingState.response?.isNotEmpty == true
|
||||
? SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: StyleString.safeSpace +
|
||||
@@ -94,26 +96,26 @@ Widget searchArticlePanel(BuildContext context,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
if (index == loadingState.response.length - 1) {
|
||||
if (index == loadingState.response!.length - 1) {
|
||||
searchPanelCtr.onLoadMore();
|
||||
}
|
||||
final item = loadingState.response![index];
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Get.toNamed('/htmlRender', parameters: {
|
||||
'url':
|
||||
'www.bilibili.com/read/cv${loadingState.response[index].id}',
|
||||
'title': loadingState.response[index].subTitle,
|
||||
'id': 'cv${loadingState.response[index].id}',
|
||||
'url': 'www.bilibili.com/read/cv${item.id}',
|
||||
'title': item.subTitle,
|
||||
'id': 'cv${item.id}',
|
||||
'dynamicType': 'read'
|
||||
});
|
||||
},
|
||||
onLongPress: () => imageSaveDialog(
|
||||
context: context,
|
||||
title: (loadingState.response[index].title as List?)
|
||||
title: (item.title as List?)
|
||||
?.map((item) => item['text'])
|
||||
.join() ??
|
||||
'',
|
||||
cover: loadingState.response[index].imageUrls.first,
|
||||
cover: item.imageUrls.first,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
@@ -135,11 +137,8 @@ Widget searchArticlePanel(BuildContext context,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
if (loadingState
|
||||
.response[index].imageUrls !=
|
||||
null &&
|
||||
loadingState.response[index].imageUrls
|
||||
.isNotEmpty)
|
||||
if (item.imageUrls != null &&
|
||||
item.imageUrls.isNotEmpty)
|
||||
AspectRatio(
|
||||
aspectRatio: StyleString.aspectRatio,
|
||||
child: LayoutBuilder(
|
||||
@@ -151,8 +150,7 @@ Widget searchArticlePanel(BuildContext context,
|
||||
return NetworkImgLayer(
|
||||
width: maxWidth,
|
||||
height: maxHeight,
|
||||
src: loadingState.response[index]
|
||||
.imageUrls.first,
|
||||
src: item.imageUrls.first,
|
||||
);
|
||||
}),
|
||||
),
|
||||
@@ -167,8 +165,7 @@ Widget searchArticlePanel(BuildContext context,
|
||||
maxLines: 2,
|
||||
TextSpan(
|
||||
children: [
|
||||
for (var i in loadingState
|
||||
.response[index].title) ...[
|
||||
for (var i in item.title) ...[
|
||||
TextSpan(
|
||||
text: i['text'],
|
||||
style: TextStyle(
|
||||
@@ -187,19 +184,15 @@ Widget searchArticlePanel(BuildContext context,
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
Utils.dateFormat(
|
||||
loadingState
|
||||
.response[index].pubTime,
|
||||
Utils.dateFormat(item.pubTime,
|
||||
formatType: 'detail'),
|
||||
style: textStyle),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'${loadingState.response[index].view}浏览',
|
||||
Text('${item.view}浏览',
|
||||
style: textStyle),
|
||||
Text(' • ', style: textStyle),
|
||||
Text(
|
||||
'${loadingState.response[index].reply}评论',
|
||||
Text('${item.reply}评论',
|
||||
style: textStyle),
|
||||
],
|
||||
),
|
||||
@@ -214,7 +207,7 @@ Widget searchArticlePanel(BuildContext context,
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: loadingState.response.length,
|
||||
childCount: loadingState.response!.length,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -8,10 +8,11 @@ import 'package:PiliPlus/common/widgets/network_img_layer.dart';
|
||||
|
||||
import '../../../utils/grid.dart';
|
||||
|
||||
Widget searchLivePanel(BuildContext context, ctr, LoadingState loadingState) {
|
||||
Widget searchLivePanel(
|
||||
BuildContext context, ctr, LoadingState<List<dynamic>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => loadingWidget,
|
||||
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||
Success() => loadingState.response?.isNotEmpty == true
|
||||
? GridView.builder(
|
||||
padding: EdgeInsets.only(
|
||||
left: StyleString.safeSpace,
|
||||
@@ -27,12 +28,12 @@ Widget searchLivePanel(BuildContext context, ctr, LoadingState loadingState) {
|
||||
childAspectRatio: StyleString.aspectRatio,
|
||||
mainAxisExtent: MediaQuery.textScalerOf(context).scale(80),
|
||||
),
|
||||
itemCount: loadingState.response.length,
|
||||
itemCount: loadingState.response!.length,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == loadingState.response.length - 1) {
|
||||
if (index == loadingState.response!.length - 1) {
|
||||
ctr.onLoadMore();
|
||||
}
|
||||
return LiveItem(liveItem: loadingState.response[index]);
|
||||
return LiveItem(liveItem: loadingState.response![index]);
|
||||
},
|
||||
)
|
||||
: errorWidget(
|
||||
|
||||
@@ -9,11 +9,12 @@ import 'package:PiliPlus/utils/utils.dart';
|
||||
|
||||
import '../../../utils/grid.dart';
|
||||
|
||||
Widget searchBangumiPanel(context, ctr, LoadingState loadingState) {
|
||||
Widget searchBangumiPanel(
|
||||
context, ctr, LoadingState<List<dynamic>?> loadingState) {
|
||||
late TextStyle style = TextStyle(fontSize: 13);
|
||||
return switch (loadingState) {
|
||||
Loading() => loadingWidget,
|
||||
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||
Success() => loadingState.response?.isNotEmpty == true
|
||||
? CustomScrollView(
|
||||
controller: ctr.scrollController,
|
||||
slivers: [
|
||||
@@ -28,10 +29,10 @@ Widget searchBangumiPanel(context, ctr, LoadingState loadingState) {
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
if (index == loadingState.response.length - 1) {
|
||||
if (index == loadingState.response!.length - 1) {
|
||||
ctr.onLoadMore();
|
||||
}
|
||||
var i = loadingState.response[index];
|
||||
var i = loadingState.response![index];
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Utils.viewBangumi(seasonId: i.seasonId);
|
||||
@@ -139,7 +140,7 @@ Widget searchBangumiPanel(context, ctr, LoadingState loadingState) {
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: loadingState.response.length,
|
||||
childCount: loadingState.response!.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -14,8 +14,10 @@ import 'package:PiliPlus/utils/utils.dart';
|
||||
|
||||
import '../../../utils/grid.dart';
|
||||
|
||||
Widget searchUserPanel(BuildContext context,
|
||||
SearchPanelController searchPanelCtr, LoadingState loadingState) {
|
||||
Widget searchUserPanel(
|
||||
BuildContext context,
|
||||
SearchPanelController searchPanelCtr,
|
||||
LoadingState<List<dynamic>?> loadingState) {
|
||||
TextStyle style = TextStyle(
|
||||
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize,
|
||||
color: Theme.of(context).colorScheme.outline);
|
||||
@@ -78,7 +80,7 @@ Widget searchUserPanel(BuildContext context,
|
||||
),
|
||||
switch (loadingState) {
|
||||
Loading() => errorWidget(),
|
||||
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||
Success() => loadingState.response?.isNotEmpty == true
|
||||
? SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context).padding.bottom + 80,
|
||||
@@ -90,10 +92,10 @@ Widget searchUserPanel(BuildContext context,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
if (index == loadingState.response.length - 1) {
|
||||
if (index == loadingState.response!.length - 1) {
|
||||
searchPanelCtr.onLoadMore();
|
||||
}
|
||||
var i = loadingState.response[index];
|
||||
var i = loadingState.response![index];
|
||||
String heroTag = Utils.makeHeroTag(i!.mid);
|
||||
return InkWell(
|
||||
onTap: () => Get.toNamed('/member?mid=${i.mid}',
|
||||
@@ -170,7 +172,7 @@ Widget searchUserPanel(BuildContext context,
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: loadingState.response.length,
|
||||
childCount: loadingState.response!.length,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -16,8 +16,10 @@ import 'package:intl/intl.dart';
|
||||
import '../../../common/constants.dart';
|
||||
import '../../../utils/grid.dart';
|
||||
|
||||
Widget searchVideoPanel(BuildContext context,
|
||||
SearchPanelController searchPanelCtr, LoadingState loadingState) {
|
||||
Widget searchVideoPanel(
|
||||
BuildContext context,
|
||||
SearchPanelController searchPanelCtr,
|
||||
LoadingState<List<dynamic>?> loadingState) {
|
||||
final controller = Get.put(VideoPanelController(), tag: searchPanelCtr.tag);
|
||||
return CustomScrollView(
|
||||
controller: searchPanelCtr.scrollController,
|
||||
@@ -90,7 +92,7 @@ Widget searchVideoPanel(BuildContext context,
|
||||
),
|
||||
switch (loadingState) {
|
||||
Loading() => errorWidget(),
|
||||
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||
Success() => loadingState.response?.isNotEmpty == true
|
||||
? SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context).padding.bottom + 80,
|
||||
@@ -103,15 +105,15 @@ Widget searchVideoPanel(BuildContext context,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
if (index == loadingState.response.length - 1) {
|
||||
if (index == loadingState.response!.length - 1) {
|
||||
searchPanelCtr.onLoadMore();
|
||||
}
|
||||
return VideoCardH(
|
||||
videoItem: loadingState.response[index],
|
||||
videoItem: loadingState.response![index],
|
||||
showPubdate: true,
|
||||
);
|
||||
},
|
||||
childCount: loadingState.response.length,
|
||||
childCount: loadingState.response!.length,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user