mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-31 08:08:19 +08:00
opt: search panel
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
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/search_panel/widgets/video_panel.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';
|
||||||
@@ -14,7 +15,6 @@ import 'widgets/article_panel.dart';
|
|||||||
import 'widgets/live_panel.dart';
|
import 'widgets/live_panel.dart';
|
||||||
import 'widgets/media_bangumi_panel.dart';
|
import 'widgets/media_bangumi_panel.dart';
|
||||||
import 'widgets/user_panel.dart';
|
import 'widgets/user_panel.dart';
|
||||||
import 'widgets/video_panel.dart';
|
|
||||||
|
|
||||||
class SearchPanel extends StatefulWidget {
|
class SearchPanel extends StatefulWidget {
|
||||||
final String? keyword;
|
final String? keyword;
|
||||||
@@ -112,9 +112,10 @@ class _SearchPanelState extends State<SearchPanel>
|
|||||||
} else {
|
} else {
|
||||||
switch (widget.searchType) {
|
switch (widget.searchType) {
|
||||||
case SearchType.video:
|
case SearchType.video:
|
||||||
return SearchVideoPanel(
|
return searchVideoPanel(
|
||||||
ctr: _searchPanelController,
|
context,
|
||||||
loadingState: loadingState,
|
_searchPanelController,
|
||||||
|
loadingState,
|
||||||
);
|
);
|
||||||
case SearchType.media_bangumi:
|
case SearchType.media_bangumi:
|
||||||
return searchBangumiPanel(
|
return searchBangumiPanel(
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:PiliPalaX/common/widgets/http_error.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/search/widgets/search_text.dart';
|
import 'package:PiliPalaX/pages/search/widgets/search_text.dart';
|
||||||
import 'package:PiliPalaX/pages/search_panel/controller.dart';
|
import 'package:PiliPalaX/pages/search_panel/controller.dart';
|
||||||
@@ -13,7 +14,7 @@ import 'package:PiliPalaX/utils/utils.dart';
|
|||||||
|
|
||||||
import '../../../utils/grid.dart';
|
import '../../../utils/grid.dart';
|
||||||
|
|
||||||
Widget searchArticlePanel(BuildContext context, searchPanelCtr, loadingState) {
|
Widget searchArticlePanel(context, searchPanelCtr, LoadingState loadingState) {
|
||||||
TextStyle textStyle = TextStyle(
|
TextStyle textStyle = TextStyle(
|
||||||
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize,
|
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize,
|
||||||
color: Theme.of(context).colorScheme.outline);
|
color: Theme.of(context).colorScheme.outline);
|
||||||
@@ -73,141 +74,151 @@ Widget searchArticlePanel(BuildContext context, searchPanelCtr, loadingState) {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
loadingState is Success
|
switch (loadingState) {
|
||||||
? SliverPadding(
|
Loading() => errorWidget(),
|
||||||
padding: EdgeInsets.only(
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
bottom: StyleString.safeSpace +
|
? SliverPadding(
|
||||||
MediaQuery.of(context).padding.bottom,
|
padding: EdgeInsets.only(
|
||||||
),
|
bottom: StyleString.safeSpace +
|
||||||
sliver: SliverGrid(
|
MediaQuery.of(context).padding.bottom,
|
||||||
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
|
||||||
mainAxisSpacing: StyleString.safeSpace,
|
|
||||||
crossAxisSpacing: StyleString.safeSpace,
|
|
||||||
maxCrossAxisExtent: Grid.maxRowWidth * 2,
|
|
||||||
childAspectRatio: StyleString.aspectRatio * 2.4,
|
|
||||||
mainAxisExtent: 0,
|
|
||||||
),
|
),
|
||||||
delegate: SliverChildBuilderDelegate(
|
sliver: SliverGrid(
|
||||||
(BuildContext context, int index) {
|
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
||||||
return InkWell(
|
mainAxisSpacing: StyleString.safeSpace,
|
||||||
onTap: () {
|
crossAxisSpacing: StyleString.safeSpace,
|
||||||
Get.toNamed('/htmlRender', parameters: {
|
maxCrossAxisExtent: Grid.maxRowWidth * 2,
|
||||||
'url':
|
childAspectRatio: StyleString.aspectRatio * 2.4,
|
||||||
'www.bilibili.com/read/cv${loadingState.response[index].id}',
|
mainAxisExtent: 0,
|
||||||
'title': loadingState.response[index].subTitle,
|
),
|
||||||
'id': 'cv${loadingState.response[index].id}',
|
delegate: SliverChildBuilderDelegate(
|
||||||
'dynamicType': 'read'
|
(BuildContext context, int index) {
|
||||||
});
|
return InkWell(
|
||||||
},
|
onTap: () {
|
||||||
child: Padding(
|
Get.toNamed('/htmlRender', parameters: {
|
||||||
padding: const EdgeInsets.symmetric(
|
'url':
|
||||||
horizontal: StyleString.safeSpace),
|
'www.bilibili.com/read/cv${loadingState.response[index].id}',
|
||||||
child: LayoutBuilder(
|
'title': loadingState.response[index].subTitle,
|
||||||
builder: (context, boxConstraints) {
|
'id': 'cv${loadingState.response[index].id}',
|
||||||
final double width = (boxConstraints.maxWidth -
|
'dynamicType': 'read'
|
||||||
StyleString.cardSpace *
|
});
|
||||||
6 /
|
},
|
||||||
MediaQuery.textScalerOf(context)
|
child: Padding(
|
||||||
.scale(1.0)) /
|
padding: const EdgeInsets.symmetric(
|
||||||
2;
|
horizontal: StyleString.safeSpace),
|
||||||
return Container(
|
child: LayoutBuilder(
|
||||||
constraints: const BoxConstraints(minHeight: 88),
|
builder: (context, boxConstraints) {
|
||||||
height: width / StyleString.aspectRatio,
|
final double width = (boxConstraints.maxWidth -
|
||||||
child: Row(
|
StyleString.cardSpace *
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
6 /
|
||||||
children: <Widget>[
|
MediaQuery.textScalerOf(context)
|
||||||
if (loadingState.response[index].imageUrls !=
|
.scale(1.0)) /
|
||||||
null &&
|
2;
|
||||||
loadingState
|
return Container(
|
||||||
.response[index].imageUrls.isNotEmpty)
|
constraints:
|
||||||
AspectRatio(
|
const BoxConstraints(minHeight: 88),
|
||||||
aspectRatio: StyleString.aspectRatio,
|
height: width / StyleString.aspectRatio,
|
||||||
child: LayoutBuilder(
|
child: Row(
|
||||||
builder: (context, boxConstraints) {
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
double maxWidth =
|
children: <Widget>[
|
||||||
boxConstraints.maxWidth;
|
if (loadingState
|
||||||
double maxHeight =
|
.response[index].imageUrls !=
|
||||||
boxConstraints.maxHeight;
|
null &&
|
||||||
return NetworkImgLayer(
|
loadingState.response[index].imageUrls
|
||||||
width: maxWidth,
|
.isNotEmpty)
|
||||||
height: maxHeight,
|
AspectRatio(
|
||||||
src: loadingState
|
aspectRatio: StyleString.aspectRatio,
|
||||||
.response[index].imageUrls.first,
|
child: LayoutBuilder(
|
||||||
);
|
builder: (context, boxConstraints) {
|
||||||
}),
|
double maxWidth =
|
||||||
),
|
boxConstraints.maxWidth;
|
||||||
Expanded(
|
double maxHeight =
|
||||||
child: Padding(
|
boxConstraints.maxHeight;
|
||||||
padding: const EdgeInsets.fromLTRB(
|
return NetworkImgLayer(
|
||||||
10, 2, 6, 0),
|
width: maxWidth,
|
||||||
child: Column(
|
height: maxHeight,
|
||||||
mainAxisSize: MainAxisSize.min,
|
src: loadingState.response[index]
|
||||||
crossAxisAlignment:
|
.imageUrls.first,
|
||||||
CrossAxisAlignment.start,
|
);
|
||||||
children: [
|
}),
|
||||||
RichText(
|
),
|
||||||
maxLines: 2,
|
Expanded(
|
||||||
text: TextSpan(
|
child: Padding(
|
||||||
children: [
|
padding: const EdgeInsets.fromLTRB(
|
||||||
for (var i in loadingState
|
10, 2, 6, 0),
|
||||||
.response[index].title) ...[
|
child: Column(
|
||||||
TextSpan(
|
mainAxisSize: MainAxisSize.min,
|
||||||
text: i['text'],
|
crossAxisAlignment:
|
||||||
style: TextStyle(
|
CrossAxisAlignment.start,
|
||||||
fontWeight:
|
children: [
|
||||||
FontWeight.w400,
|
RichText(
|
||||||
letterSpacing: 0.3,
|
maxLines: 2,
|
||||||
color: i['type'] == 'em'
|
text: TextSpan(
|
||||||
? Theme.of(context)
|
children: [
|
||||||
.colorScheme
|
for (var i in loadingState
|
||||||
.primary
|
.response[index]
|
||||||
: Theme.of(context)
|
.title) ...[
|
||||||
.colorScheme
|
TextSpan(
|
||||||
.onSurface,
|
text: i['text'],
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight:
|
||||||
|
FontWeight.w400,
|
||||||
|
letterSpacing: 0.3,
|
||||||
|
color: i['type'] == 'em'
|
||||||
|
? Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.primary
|
||||||
|
: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onSurface,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
]
|
||||||
]
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
Text(
|
||||||
|
Utils.dateFormat(
|
||||||
|
loadingState.response[index]
|
||||||
|
.pubTime,
|
||||||
|
formatType: 'detail'),
|
||||||
|
style: textStyle),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'${loadingState.response[index].view}浏览',
|
||||||
|
style: textStyle),
|
||||||
|
Text(' • ', style: textStyle),
|
||||||
|
Text(
|
||||||
|
'${loadingState.response[index].reply}评论',
|
||||||
|
style: textStyle),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
const Spacer(),
|
),
|
||||||
Text(
|
|
||||||
Utils.dateFormat(
|
|
||||||
loadingState
|
|
||||||
.response[index].pubTime,
|
|
||||||
formatType: 'detail'),
|
|
||||||
style: textStyle),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'${loadingState.response[index].view}浏览',
|
|
||||||
style: textStyle),
|
|
||||||
Text(' • ', style: textStyle),
|
|
||||||
Text(
|
|
||||||
'${loadingState.response[index].reply}评论',
|
|
||||||
style: textStyle),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
childCount: loadingState.response.length,
|
||||||
childCount: loadingState.response.length,
|
),
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
: HttpError(
|
||||||
|
callback: searchPanelCtr.onReload,
|
||||||
),
|
),
|
||||||
)
|
Error() => HttpError(
|
||||||
: HttpError(
|
errMsg: loadingState.errMsg,
|
||||||
errMsg: loadingState is Error ? loadingState.errMsg : '没有相关数据',
|
callback: searchPanelCtr.onReload,
|
||||||
callback: searchPanelCtr.onReload,
|
),
|
||||||
),
|
LoadingState() => throw UnimplementedError(),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,14 +75,11 @@ class LiveItem extends StatelessWidget {
|
|||||||
double maxHeight = boxConstraints.maxHeight;
|
double maxHeight = boxConstraints.maxHeight;
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
Hero(
|
NetworkImgLayer(
|
||||||
tag: heroTag,
|
src: liveItem.cover,
|
||||||
child: NetworkImgLayer(
|
type: 'emote',
|
||||||
src: liveItem.cover,
|
width: maxWidth,
|
||||||
type: 'emote',
|
height: maxHeight,
|
||||||
width: maxWidth,
|
|
||||||
height: maxHeight,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
left: 0,
|
left: 0,
|
||||||
|
|||||||
@@ -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:PiliPalaX/common/constants.dart';
|
import 'package:PiliPalaX/common/constants.dart';
|
||||||
@@ -8,135 +8,144 @@ import 'package:PiliPalaX/utils/utils.dart';
|
|||||||
|
|
||||||
import '../../../utils/grid.dart';
|
import '../../../utils/grid.dart';
|
||||||
|
|
||||||
Widget searchBangumiPanel(BuildContext context, ctr, loadingState) {
|
Widget searchBangumiPanel(context, ctr, LoadingState loadingState) {
|
||||||
TextStyle style =
|
TextStyle style =
|
||||||
TextStyle(fontSize: Theme.of(context).textTheme.labelMedium!.fontSize);
|
TextStyle(fontSize: Theme.of(context).textTheme.labelMedium!.fontSize);
|
||||||
return CustomScrollView(
|
return switch (loadingState) {
|
||||||
controller: ctr.scrollController,
|
Loading() => loadingWidget,
|
||||||
slivers: [
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
loadingState is Success
|
? CustomScrollView(
|
||||||
? SliverPadding(
|
controller: ctr.scrollController,
|
||||||
padding: EdgeInsets.only(
|
slivers: [
|
||||||
bottom: StyleString.safeSpace +
|
SliverPadding(
|
||||||
MediaQuery.of(context).padding.bottom,
|
padding: EdgeInsets.only(
|
||||||
),
|
bottom: StyleString.safeSpace +
|
||||||
sliver: SliverGrid(
|
MediaQuery.of(context).padding.bottom,
|
||||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
|
||||||
mainAxisSpacing: StyleString.safeSpace,
|
|
||||||
crossAxisSpacing: StyleString.safeSpace,
|
|
||||||
maxCrossAxisExtent: Grid.maxRowWidth * 2,
|
|
||||||
mainAxisExtent: 160,
|
|
||||||
),
|
),
|
||||||
delegate: SliverChildBuilderDelegate(
|
sliver: SliverGrid(
|
||||||
(BuildContext context, int index) {
|
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||||
var i = loadingState.response[index];
|
mainAxisSpacing: StyleString.safeSpace,
|
||||||
return InkWell(
|
crossAxisSpacing: StyleString.safeSpace,
|
||||||
onTap: () {
|
maxCrossAxisExtent: Grid.maxRowWidth * 2,
|
||||||
Utils.viewBangumi(seasonId: i.seasonId);
|
mainAxisExtent: 160,
|
||||||
},
|
),
|
||||||
child: Padding(
|
delegate: SliverChildBuilderDelegate(
|
||||||
padding: const EdgeInsets.symmetric(
|
(BuildContext context, int index) {
|
||||||
horizontal: StyleString.safeSpace,
|
var i = loadingState.response[index];
|
||||||
vertical: StyleString.cardSpace,
|
return InkWell(
|
||||||
),
|
onTap: () {
|
||||||
child: Row(
|
Utils.viewBangumi(seasonId: i.seasonId);
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
},
|
||||||
children: [
|
child: Padding(
|
||||||
Stack(
|
padding: const EdgeInsets.symmetric(
|
||||||
children: [
|
horizontal: StyleString.safeSpace,
|
||||||
NetworkImgLayer(
|
vertical: StyleString.cardSpace,
|
||||||
width: 111,
|
),
|
||||||
height: 148,
|
child: Row(
|
||||||
src: i.cover,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
),
|
children: [
|
||||||
PBadge(
|
Stack(
|
||||||
text: i.mediaType == 1 ? '番剧' : '国创',
|
|
||||||
top: 6.0,
|
|
||||||
right: 4.0,
|
|
||||||
bottom: null,
|
|
||||||
left: null,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(width: 10),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 4),
|
NetworkImgLayer(
|
||||||
RichText(
|
width: 111,
|
||||||
maxLines: 1,
|
height: 148,
|
||||||
overflow: TextOverflow.ellipsis,
|
src: i.cover,
|
||||||
text: TextSpan(
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onSurface),
|
|
||||||
children: [
|
|
||||||
for (var i in i.title) ...[
|
|
||||||
TextSpan(
|
|
||||||
text: i['text'],
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: MediaQuery.textScalerOf(
|
|
||||||
context)
|
|
||||||
.scale(Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.titleSmall!
|
|
||||||
.fontSize!),
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: i['type'] == 'em'
|
|
||||||
? Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.primary
|
|
||||||
: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onSurface,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
Text('评分:${i.mediaScore['score'].toString()}',
|
|
||||||
style: style),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Text(i.areas, style: style),
|
|
||||||
const SizedBox(width: 3),
|
|
||||||
const Text('·'),
|
|
||||||
const SizedBox(width: 3),
|
|
||||||
Text(
|
|
||||||
Utils.dateFormat(i.pubtime)
|
|
||||||
.toString(),
|
|
||||||
style: style),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Text(i.styles, style: style),
|
|
||||||
const SizedBox(width: 3),
|
|
||||||
const Text('·'),
|
|
||||||
const SizedBox(width: 3),
|
|
||||||
Text(i.indexShow, style: style),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
PBadge(
|
||||||
|
text: i.mediaType == 1 ? '番剧' : '国创',
|
||||||
|
top: 6.0,
|
||||||
|
right: 4.0,
|
||||||
|
bottom: null,
|
||||||
|
left: null,
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(width: 10),
|
||||||
],
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
RichText(
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
text: TextSpan(
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onSurface),
|
||||||
|
children: [
|
||||||
|
for (var i in i.title) ...[
|
||||||
|
TextSpan(
|
||||||
|
text: i['text'],
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize:
|
||||||
|
MediaQuery.textScalerOf(
|
||||||
|
context)
|
||||||
|
.scale(Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.titleSmall!
|
||||||
|
.fontSize!),
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: i['type'] == 'em'
|
||||||
|
? Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.primary
|
||||||
|
: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Text(
|
||||||
|
'评分:${i.mediaScore['score'].toString()}',
|
||||||
|
style: style),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Text(i.areas, style: style),
|
||||||
|
const SizedBox(width: 3),
|
||||||
|
const Text('·'),
|
||||||
|
const SizedBox(width: 3),
|
||||||
|
Text(
|
||||||
|
Utils.dateFormat(i.pubtime)
|
||||||
|
.toString(),
|
||||||
|
style: style),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Text(i.styles, style: style),
|
||||||
|
const SizedBox(width: 3),
|
||||||
|
const Text('·'),
|
||||||
|
const SizedBox(width: 3),
|
||||||
|
Text(i.indexShow, style: style),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
childCount: loadingState.response.length,
|
||||||
childCount: loadingState.response.length,
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
],
|
||||||
: HttpError(
|
)
|
||||||
errMsg: loadingState is Error ? loadingState.errMsg : '没有相关数据',
|
: errorWidget(
|
||||||
callback: ctr.onReload,
|
callback: ctr.onReload,
|
||||||
),
|
),
|
||||||
],
|
Error() => errorWidget(
|
||||||
);
|
errMsg: loadingState.errMsg,
|
||||||
|
callback: ctr.onReload,
|
||||||
|
),
|
||||||
|
LoadingState() => throw UnimplementedError(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:PiliPalaX/common/widgets/http_error.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/search/widgets/search_text.dart';
|
import 'package:PiliPalaX/pages/search/widgets/search_text.dart';
|
||||||
import 'package:PiliPalaX/pages/search_panel/controller.dart';
|
import 'package:PiliPalaX/pages/search_panel/controller.dart';
|
||||||
@@ -13,7 +14,7 @@ import 'package:PiliPalaX/utils/utils.dart';
|
|||||||
import '../../../common/constants.dart';
|
import '../../../common/constants.dart';
|
||||||
import '../../../utils/grid.dart';
|
import '../../../utils/grid.dart';
|
||||||
|
|
||||||
Widget searchUserPanel(BuildContext context, searchPanelCtr, loadingState) {
|
Widget searchUserPanel(context, searchPanelCtr, LoadingState loadingState) {
|
||||||
TextStyle style = TextStyle(
|
TextStyle style = TextStyle(
|
||||||
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize,
|
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize,
|
||||||
color: Theme.of(context).colorScheme.outline);
|
color: Theme.of(context).colorScheme.outline);
|
||||||
@@ -73,85 +74,89 @@ Widget searchUserPanel(BuildContext context, searchPanelCtr, loadingState) {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
loadingState is Success
|
switch (loadingState) {
|
||||||
? SliverPadding(
|
Loading() => errorWidget(),
|
||||||
padding: EdgeInsets.only(
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
bottom: StyleString.safeSpace +
|
? SliverPadding(
|
||||||
MediaQuery.of(context).padding.bottom,
|
padding: EdgeInsets.only(
|
||||||
),
|
bottom: StyleString.safeSpace +
|
||||||
sliver: SliverGrid(
|
MediaQuery.of(context).padding.bottom,
|
||||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
|
||||||
mainAxisSpacing: StyleString.cardSpace,
|
|
||||||
crossAxisSpacing: StyleString.safeSpace,
|
|
||||||
maxCrossAxisExtent: Grid.maxRowWidth * 2,
|
|
||||||
mainAxisExtent: 56,
|
|
||||||
),
|
),
|
||||||
delegate: SliverChildBuilderDelegate(
|
sliver: SliverGrid(
|
||||||
(BuildContext context, int index) {
|
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||||
var i = loadingState.response[index];
|
mainAxisSpacing: StyleString.cardSpace,
|
||||||
String heroTag = Utils.makeHeroTag(i!.mid);
|
crossAxisSpacing: StyleString.safeSpace,
|
||||||
return InkWell(
|
maxCrossAxisExtent: Grid.maxRowWidth * 2,
|
||||||
onTap: () => Get.toNamed('/member?mid=${i.mid}',
|
mainAxisExtent: 56,
|
||||||
arguments: {'heroTag': heroTag, 'face': i.upic}),
|
),
|
||||||
child: Row(
|
delegate: SliverChildBuilderDelegate(
|
||||||
children: [
|
(BuildContext context, int index) {
|
||||||
const SizedBox(width: 15),
|
var i = loadingState.response[index];
|
||||||
Hero(
|
String heroTag = Utils.makeHeroTag(i!.mid);
|
||||||
tag: heroTag,
|
return InkWell(
|
||||||
child: NetworkImgLayer(
|
onTap: () => Get.toNamed('/member?mid=${i.mid}',
|
||||||
|
arguments: {'heroTag': heroTag, 'face': i.upic}),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const SizedBox(width: 15),
|
||||||
|
NetworkImgLayer(
|
||||||
width: 42,
|
width: 42,
|
||||||
height: 42,
|
height: 42,
|
||||||
src: i.upic,
|
src: i.upic,
|
||||||
type: 'avatar',
|
type: 'avatar',
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(width: 10),
|
||||||
const SizedBox(width: 10),
|
Column(
|
||||||
Column(
|
mainAxisSize: MainAxisSize.max,
|
||||||
mainAxisSize: MainAxisSize.max,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
children: [
|
||||||
children: [
|
Row(
|
||||||
Row(
|
children: [
|
||||||
children: [
|
Text(
|
||||||
Text(
|
i!.uname,
|
||||||
i!.uname,
|
style: const TextStyle(
|
||||||
style: const TextStyle(
|
fontSize: 14,
|
||||||
fontSize: 14,
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(width: 6),
|
||||||
const SizedBox(width: 6),
|
Image.asset(
|
||||||
Image.asset(
|
'assets/images/lv/lv${i!.level}.png',
|
||||||
'assets/images/lv/lv${i!.level}.png',
|
height: 11,
|
||||||
height: 11,
|
semanticLabel: '等级${i.level}',
|
||||||
semanticLabel: '等级${i.level}',
|
),
|
||||||
),
|
],
|
||||||
],
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Text('粉丝:${i.fans} ', style: style),
|
|
||||||
Text(' 视频:${i.videos}', style: style)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
if (i.officialVerify['desc'] != '')
|
|
||||||
Text(
|
|
||||||
i.officialVerify['desc'],
|
|
||||||
style: style,
|
|
||||||
),
|
),
|
||||||
],
|
Row(
|
||||||
)
|
children: [
|
||||||
],
|
Text('粉丝:${i.fans} ', style: style),
|
||||||
),
|
Text(' 视频:${i.videos}', style: style)
|
||||||
);
|
],
|
||||||
},
|
),
|
||||||
childCount: loadingState.response.length,
|
if (i.officialVerify['desc'] != '')
|
||||||
|
Text(
|
||||||
|
i.officialVerify['desc'],
|
||||||
|
style: style,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
childCount: loadingState.response.length,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
: HttpError(
|
||||||
|
callback: searchPanelCtr.onReload,
|
||||||
),
|
),
|
||||||
)
|
Error() => HttpError(
|
||||||
: HttpError(
|
errMsg: loadingState.errMsg,
|
||||||
errMsg: loadingState is Error ? loadingState.errMsg : '没有相关数据',
|
callback: searchPanelCtr.onReload,
|
||||||
callback: searchPanelCtr.onReload,
|
),
|
||||||
)
|
LoadingState() => throw UnimplementedError(),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:PiliPalaX/common/widgets/http_error.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/search/widgets/search_text.dart';
|
import 'package:PiliPalaX/pages/search/widgets/search_text.dart';
|
||||||
import 'package:PiliPalaX/pages/video/detail/reply/view.dart'
|
import 'package:PiliPalaX/pages/video/detail/reply/view.dart'
|
||||||
@@ -14,87 +15,76 @@ import 'package:intl/intl.dart';
|
|||||||
import '../../../common/constants.dart';
|
import '../../../common/constants.dart';
|
||||||
import '../../../utils/grid.dart';
|
import '../../../utils/grid.dart';
|
||||||
|
|
||||||
class SearchVideoPanel extends StatelessWidget {
|
Widget searchVideoPanel(context, ctr, LoadingState loadingState) {
|
||||||
SearchVideoPanel({
|
final controller = Get.put(VideoPanelController());
|
||||||
required this.ctr,
|
return CustomScrollView(
|
||||||
required this.loadingState,
|
controller: ctr.scrollController,
|
||||||
super.key,
|
slivers: [
|
||||||
});
|
SliverPersistentHeader(
|
||||||
|
pinned: false,
|
||||||
final SearchPanelController ctr;
|
floating: true,
|
||||||
final dynamic loadingState;
|
delegate: MySliverPersistentHeaderDelegate(
|
||||||
|
child: Container(
|
||||||
final VideoPanelController controller = Get.put(VideoPanelController());
|
height: 34,
|
||||||
|
color: Theme.of(context).colorScheme.surface,
|
||||||
@override
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
Widget build(BuildContext context) {
|
child: Row(
|
||||||
return CustomScrollView(
|
children: [
|
||||||
controller: ctr.scrollController,
|
Expanded(
|
||||||
slivers: [
|
child: SingleChildScrollView(
|
||||||
SliverPersistentHeader(
|
scrollDirection: Axis.horizontal,
|
||||||
pinned: false,
|
child: Obx(
|
||||||
floating: true,
|
() => Wrap(
|
||||||
delegate: MySliverPersistentHeaderDelegate(
|
// spacing: ,
|
||||||
child: Container(
|
children: [
|
||||||
width: context.width,
|
for (var i in controller.filterList) ...[
|
||||||
height: 34,
|
CustomFilterChip(
|
||||||
color: Theme.of(context).colorScheme.surface,
|
label: i['label'],
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
type: i['type'],
|
||||||
child: Row(
|
selectedType: controller.selectedType.value,
|
||||||
children: [
|
callFn: (bool selected) async {
|
||||||
Expanded(
|
debugPrint('selected: $selected');
|
||||||
child: SingleChildScrollView(
|
controller.selectedType.value = i['type'];
|
||||||
scrollDirection: Axis.horizontal,
|
ctr.order.value =
|
||||||
child: Obx(
|
i['type'].toString().split('.').last;
|
||||||
() => Wrap(
|
SmartDialog.showLoading(msg: 'loading');
|
||||||
// spacing: ,
|
await ctr.onRefresh();
|
||||||
children: [
|
SmartDialog.dismiss();
|
||||||
for (var i in controller.filterList) ...[
|
},
|
||||||
CustomFilterChip(
|
),
|
||||||
label: i['label'],
|
]
|
||||||
type: i['type'],
|
],
|
||||||
selectedType: controller.selectedType.value,
|
|
||||||
callFn: (bool selected) async {
|
|
||||||
debugPrint('selected: $selected');
|
|
||||||
controller.selectedType.value = i['type'];
|
|
||||||
ctr.order.value =
|
|
||||||
i['type'].toString().split('.').last;
|
|
||||||
SmartDialog.showLoading(msg: 'loading');
|
|
||||||
await ctr.onRefresh();
|
|
||||||
SmartDialog.dismiss();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const VerticalDivider(indent: 7, endIndent: 8),
|
),
|
||||||
const SizedBox(width: 3),
|
const VerticalDivider(indent: 7, endIndent: 8),
|
||||||
SizedBox(
|
const SizedBox(width: 3),
|
||||||
width: 32,
|
SizedBox(
|
||||||
height: 32,
|
width: 32,
|
||||||
child: IconButton(
|
height: 32,
|
||||||
tooltip: '筛选',
|
child: IconButton(
|
||||||
style: ButtonStyle(
|
tooltip: '筛选',
|
||||||
padding: WidgetStateProperty.all(EdgeInsets.zero),
|
style: ButtonStyle(
|
||||||
),
|
padding: WidgetStateProperty.all(EdgeInsets.zero),
|
||||||
onPressed: () =>
|
),
|
||||||
controller.onShowFilterDialog(context, ctr),
|
onPressed: () =>
|
||||||
icon: Icon(
|
controller.onShowFilterDialog(context, ctr),
|
||||||
Icons.filter_list_outlined,
|
icon: Icon(
|
||||||
size: 18,
|
Icons.filter_list_outlined,
|
||||||
color: Theme.of(context).colorScheme.primary,
|
size: 18,
|
||||||
),
|
color: Theme.of(context).colorScheme.primary,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
loadingState is Success
|
),
|
||||||
|
switch (loadingState) {
|
||||||
|
Loading() => errorWidget(),
|
||||||
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
? SliverPadding(
|
? SliverPadding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
left: StyleString.safeSpace,
|
left: StyleString.safeSpace,
|
||||||
@@ -122,12 +112,16 @@ class SearchVideoPanel extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
: HttpError(
|
: HttpError(
|
||||||
errMsg: loadingState is Error ? loadingState.errMsg : '没有相关数据',
|
|
||||||
callback: ctr.onReload,
|
callback: ctr.onReload,
|
||||||
),
|
),
|
||||||
],
|
Error() => HttpError(
|
||||||
);
|
errMsg: loadingState.errMsg,
|
||||||
}
|
callback: ctr.onReload,
|
||||||
|
),
|
||||||
|
_ => throw UnimplementedError(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomFilterChip extends StatelessWidget {
|
class CustomFilterChip extends StatelessWidget {
|
||||||
|
|||||||
@@ -87,9 +87,7 @@ class _RelatedVideoPanelState extends State<RelatedVideoPanel>
|
|||||||
}
|
}
|
||||||
}, childCount: loadingState.response.length + 1),
|
}, childCount: loadingState.response.length + 1),
|
||||||
)
|
)
|
||||||
: HttpError(
|
: SliverToBoxAdapter(),
|
||||||
callback: _relatedController.onReload,
|
|
||||||
),
|
|
||||||
Error() => HttpError(
|
Error() => HttpError(
|
||||||
errMsg: loadingState.errMsg,
|
errMsg: loadingState.errMsg,
|
||||||
callback: _relatedController.onReload,
|
callback: _relatedController.onReload,
|
||||||
|
|||||||
Reference in New Issue
Block a user